Skip to content

Instantly share code, notes, and snippets.

@ClausPolanka
Created December 15, 2020 09:41
Show Gist options
  • Save ClausPolanka/8653bfa141f243320a4f23c3ac063dc8 to your computer and use it in GitHub Desktop.
Save ClausPolanka/8653bfa141f243320a4f23c3ac063dc8 to your computer and use it in GitHub Desktop.
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