Created
December 15, 2020 09:41
-
-
Save ClausPolanka/8653bfa141f243320a4f23c3ac063dc8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FileSystemStopwordsTest { | |
private static final String STOPWORDS_FILE_PATH = "stopwords.txt"; | |
private TestFileSystemStopwords stopwordsFile = new TestFileSystemStopwords(STOPWORDS_FILE_PATH); | |
private Stopwords fileSystemStopwords = new FileSystemStopwords(STOPWORDS_FILE_PATH); | |
@Test | |
public void stopwordsReturnsStopwordsFromFile() { | |
stopwordsFile.addStopword("stopword"); | |
Collection<String> words = fileSystemStopwords.stopwords(); | |
assertThat("stopwords", words.size(), is(1)); | |
} | |
@Test | |
public void stopwordsReturnsEmptyStopwordsIfFilePathIsWrong() { | |
FileSystemStopwords stopwords = new FileSystemStopwords(STOPWORDS_FILE_PATH + "invalid"); | |
Collection<String> words = stopwords.stopwords(); | |
assertThat("stopwords", words.size(), is(0)); | |
} | |
@Test | |
public void stopwordsReturnsEmptyStopwordsIfFileIsLocked() { | |
stopwordsFile.addStopword("stopword"); | |
stopwordsFile.lockFile(); | |
Collection<String> words = fileSystemStopwords.stopwords(); | |
assertThat("stopwords", words.size(), is(0)); | |
} | |
@After | |
public void cleanup() { | |
stopwordsFile.reset(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment