Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dadoonet committed Jul 23, 2018
1 parent 0a86ec2 commit 2fd37fb
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,95 +35,95 @@ public class FsMatchFilesTest extends AbstractFSCrawlerTestCase {

@Test
public void exclude_only() {
assertThat(isIndexable(false, "test.doc", new ArrayList<>(), Collections.singletonList("*.doc")), is(false));
assertThat(isIndexable(false, "test.xls", new ArrayList<>(), Collections.singletonList("*.doc")), is(true));
assertThat(isIndexable(false, "my.doc.xls", new ArrayList<>(), Collections.singletonList("*.doc")), is(true));
assertThat(isIndexable(false, "my.doc.xls", new ArrayList<>(), Arrays.asList("*.doc", "*.xls")), is(false));
assertThat(isIndexable(false, "my.doc.xls", new ArrayList<>(), Collections.singletonList("my.d?c*.xls")), is(false));
assertThat(isIndexable(false, "my.douc.xls", new ArrayList<>(), Collections.singletonList("my.d?c*.xls")), is(true));
assertThat(isIndexable(false, ".snapshots", new ArrayList<>(), Collections.singletonList(".snapshots")), is(false));
assertThat(isIndexable(false, "doc.doc", new ArrayList<>(), Arrays.asList("*.pdf", "*.xls", "*.doc")), is(false));
assertThat(isIndexable(false, "doc.ppt", new ArrayList<>(), Arrays.asList("*.pdf", "*.xls", "*.doc")), is(true));
assertThat(isIndexable(false, "/test.doc", new ArrayList<>(), Collections.singletonList("*/*.doc")), is(false));
assertThat(isIndexable(false, "/test.xls", new ArrayList<>(), Collections.singletonList("*/*.doc")), is(true));
assertThat(isIndexable(false, "/my.doc.xls", new ArrayList<>(), Collections.singletonList("*/*.doc")), is(true));
assertThat(isIndexable(false, "/my.doc.xls", new ArrayList<>(), Arrays.asList("*/*.doc", "*/*.xls")), is(false));
assertThat(isIndexable(false, "/my.doc.xls", new ArrayList<>(), Collections.singletonList("*/my.d?c*.xls")), is(false));
assertThat(isIndexable(false, "/my.douc.xls", new ArrayList<>(), Collections.singletonList("*/my.d?c*.xls")), is(true));
assertThat(isIndexable(false, "/.snapshots", new ArrayList<>(), Collections.singletonList("*/.snapshots")), is(false));
assertThat(isIndexable(false, "/doc.doc", new ArrayList<>(), Arrays.asList("*/*.pdf", "*/*.xls", "*/*.doc")), is(false));
assertThat(isIndexable(false, "/doc.ppt", new ArrayList<>(), Arrays.asList("*/*.pdf", "*/*.xls", "*/*.doc")), is(true));
}

@Test
public void include_only() {
assertThat(isIndexable(false, "test.doc", Collections.singletonList("*.doc"), new ArrayList<>()), is(true));
assertThat(isIndexable(false, "test.xls", Collections.singletonList("*.doc"), new ArrayList<>()), is(false));
assertThat(isIndexable(false, "my.doc.xls", Collections.singletonList("*.doc"), new ArrayList<>()), is(false));
assertThat(isIndexable(false, "my.doc.xls", Collections.singletonList("my.d?c*.xls"), new ArrayList<>()), is(true));
assertThat(isIndexable(false, "my.douc.xls", Collections.singletonList("my.d?c*.xls"), new ArrayList<>()), is(false));
assertThat(isIndexable(false, "doc.doc", Arrays.asList("*.pdf", "*.xls", "*.doc"), new ArrayList<>()), is(true));
assertThat(isIndexable(false, "doc.ppt", Arrays.asList("*.pdf", "*.xls", "*.doc"), new ArrayList<>()), is(false));
assertThat(isIndexable(false, "/test.doc", Collections.singletonList("*/*.doc"), new ArrayList<>()), is(true));
assertThat(isIndexable(false, "/test.xls", Collections.singletonList("*/*.doc"), new ArrayList<>()), is(false));
assertThat(isIndexable(false, "/my.doc.xls", Collections.singletonList("*/*.doc"), new ArrayList<>()), is(false));
assertThat(isIndexable(false, "/my.doc.xls", Collections.singletonList("*/my.d?c*.xls"), new ArrayList<>()), is(true));
assertThat(isIndexable(false, "/my.douc.xls", Collections.singletonList("*/my.d?c*.xls"), new ArrayList<>()), is(false));
assertThat(isIndexable(false, "/doc.doc", Arrays.asList("*/*.pdf", "*/*.xls", "*/*.doc"), new ArrayList<>()), is(true));
assertThat(isIndexable(false, "/doc.ppt", Arrays.asList("*/*.pdf", "*/*.xls", "*/*.doc"), new ArrayList<>()), is(false));
}

@Test
public void include_exclude() {
assertThat(isIndexable(false, "test.doc", Collections.singletonList("*.xls"), Collections.singletonList("*.doc")), is(false));
assertThat(isIndexable(false, "test.xls", Collections.singletonList("*.xls"), Collections.singletonList("*.doc")), is(true));
assertThat(isIndexable(false, "my.doc.xls", Collections.singletonList("*.xls"), Collections.singletonList("*.doc")), is(true));
assertThat(isIndexable(false, "my.doc.xls", Collections.singletonList("*.xls"), Collections.singletonList("my.d?c*.xls")), is(false));
assertThat(isIndexable(false, "my.douc.xls", Collections.singletonList("*.xls"), Collections.singletonList("my.d?c*.xls")), is(true));
assertThat(isIndexable(false, "/test.doc", Collections.singletonList("*/*.xls"), Collections.singletonList("*/*.doc")), is(false));
assertThat(isIndexable(false, "/test.xls", Collections.singletonList("*/*.xls"), Collections.singletonList("*/*.doc")), is(true));
assertThat(isIndexable(false, "/my.doc.xls", Collections.singletonList("*/*.xls"), Collections.singletonList("*/*.doc")), is(true));
assertThat(isIndexable(false, "/my.doc.xls", Collections.singletonList("*/*.xls"), Collections.singletonList("*/my.d?c*.xls")), is(false));
assertThat(isIndexable(false, "/my.douc.xls", Collections.singletonList("*/*.xls"), Collections.singletonList("*/my.d?c*.xls")), is(true));
}

@Test
public void default_ignored_file() {
assertThat(isIndexable(false, "~mydoc", new ArrayList<>(), DEFAULT_EXCLUDED), is(false));
assertThat(isIndexable(false, "~", new ArrayList<>(), DEFAULT_EXCLUDED), is(false));
assertThat(isIndexable(false, "adoc.doc", new ArrayList<>(), DEFAULT_EXCLUDED), is(true));
assertThat(isIndexable(false, "mydoc~", new ArrayList<>(), DEFAULT_EXCLUDED), is(true));
assertThat(isIndexable(false, "/~mydoc", new ArrayList<>(), DEFAULT_EXCLUDED), is(false));
assertThat(isIndexable(false, "/~", new ArrayList<>(), DEFAULT_EXCLUDED), is(false));
assertThat(isIndexable(false, "/adoc.doc", new ArrayList<>(), DEFAULT_EXCLUDED), is(true));
assertThat(isIndexable(false, "/mydoc~", new ArrayList<>(), DEFAULT_EXCLUDED), is(true));
}

@Test
public void case_sensitive() {
// Excludes
assertThat(isIndexable(false, "test.doc", new ArrayList<>(), Collections.singletonList("*.DOC")), is(false));
assertThat(isIndexable(false, "test.xls", new ArrayList<>(), Collections.singletonList("*.DOC")), is(true));
assertThat(isIndexable(false, "my.doc.xls", new ArrayList<>(), Collections.singletonList("*.DOC")), is(true));
assertThat(isIndexable(false, "my.doc.xls", new ArrayList<>(), Arrays.asList("*.DOC", "*.XLS")), is(false));
assertThat(isIndexable(false, "my.doc.xls", new ArrayList<>(), Collections.singletonList("MY.D?C*.XLS")), is(false));
assertThat(isIndexable(false, "my.douc.xls", new ArrayList<>(), Collections.singletonList("MY.d?C*.XLS")), is(true));
assertThat(isIndexable(false, ".snapshots", new ArrayList<>(), Collections.singletonList(".SNAPSHOTS")), is(false));
assertThat(isIndexable(false, "/test.doc", new ArrayList<>(), Collections.singletonList("*/*.DOC")), is(false));
assertThat(isIndexable(false, "/test.xls", new ArrayList<>(), Collections.singletonList("*/*.DOC")), is(true));
assertThat(isIndexable(false, "/my.doc.xls", new ArrayList<>(), Collections.singletonList("*/*.DOC")), is(true));
assertThat(isIndexable(false, "/my.doc.xls", new ArrayList<>(), Arrays.asList("*/*.DOC", "*/*.XLS")), is(false));
assertThat(isIndexable(false, "/my.doc.xls", new ArrayList<>(), Collections.singletonList("*/MY.D?C*.XLS")), is(false));
assertThat(isIndexable(false, "/my.douc.xls", new ArrayList<>(), Collections.singletonList("*/MY.d?C*.XLS")), is(true));
assertThat(isIndexable(false, "/.snapshots", new ArrayList<>(), Collections.singletonList("*/.SNAPSHOTS")), is(false));

// Includes
assertThat(isIndexable(false, "test.doc", Collections.singletonList("*.DOC"), new ArrayList<>()), is(true));
assertThat(isIndexable(false, "test.xls", Collections.singletonList("*.DOC"), new ArrayList<>()), is(false));
assertThat(isIndexable(false, "my.doc.xls", Collections.singletonList("*.DOC"), new ArrayList<>()), is(false));
assertThat(isIndexable(false, "my.doc.xls", Collections.singletonList("MY.D?C*.XLS"), new ArrayList<>()), is(true));
assertThat(isIndexable(false, "my.douc.xls", Collections.singletonList("MY.D?C*.XLS"), new ArrayList<>()), is(false));
assertThat(isIndexable(false, "/test.doc", Collections.singletonList("*/*.DOC"), new ArrayList<>()), is(true));
assertThat(isIndexable(false, "/test.xls", Collections.singletonList("*/*.DOC"), new ArrayList<>()), is(false));
assertThat(isIndexable(false, "/my.doc.xls", Collections.singletonList("*/*.DOC"), new ArrayList<>()), is(false));
assertThat(isIndexable(false, "/my.doc.xls", Collections.singletonList("*/MY.D?C*.XLS"), new ArrayList<>()), is(true));
assertThat(isIndexable(false, "/my.douc.xls", Collections.singletonList("*/MY.D?C*.XLS"), new ArrayList<>()), is(false));
}

@Test
public void directories() {
assertThat(isIndexable(true, "folderA", new ArrayList<>(), Collections.singletonList("folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "folderA/subfolderA", new ArrayList<>(), Collections.singletonList("folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "folderA/subfolderB", new ArrayList<>(), Collections.singletonList("folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "folderA/subfolderC", new ArrayList<>(), Collections.singletonList("folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "folderB", new ArrayList<>(), Collections.singletonList("folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "folderB/subfolderA", new ArrayList<>(), Collections.singletonList("folderB/subfolder*")), is(false));
assertThat(isIndexable(true, "folderB/subfolderB", new ArrayList<>(), Collections.singletonList("folderB/subfolder*")), is(false));
assertThat(isIndexable(true, "folderB/subfolderC", new ArrayList<>(), Collections.singletonList("folderB/subfolder*")), is(false));
assertThat(isIndexable(true, "folderC", new ArrayList<>(), Collections.singletonList("folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "folderC/subfolderA", new ArrayList<>(), Collections.singletonList("folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "folderC/subfolderB", new ArrayList<>(), Collections.singletonList("folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "folderC/subfolderC", new ArrayList<>(), Collections.singletonList("folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "subfolderA", new ArrayList<>(), Collections.singletonList("folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "subfolderB", new ArrayList<>(), Collections.singletonList("folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "subfolderC", new ArrayList<>(), Collections.singletonList("folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "folderA", new ArrayList<>(), Collections.singletonList("folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "folderA/subfolderA", new ArrayList<>(), Collections.singletonList("folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "folderA/subfolderB", new ArrayList<>(), Collections.singletonList("folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "folderA/subfolderC", new ArrayList<>(), Collections.singletonList("folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "folderB", new ArrayList<>(), Collections.singletonList("folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "folderB/subfolderA", new ArrayList<>(), Collections.singletonList("folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "folderB/subfolderB", new ArrayList<>(), Collections.singletonList("folderB/subfolderB")), is(false));
assertThat(isIndexable(true, "folderB/subfolderC", new ArrayList<>(), Collections.singletonList("folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "folderC", new ArrayList<>(), Collections.singletonList("folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "folderC/subfolderA", new ArrayList<>(), Collections.singletonList("folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "folderC/subfolderB", new ArrayList<>(), Collections.singletonList("folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "folderC/subfolderC", new ArrayList<>(), Collections.singletonList("folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "subfolderA", new ArrayList<>(), Collections.singletonList("folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "subfolderB", new ArrayList<>(), Collections.singletonList("folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "subfolderC", new ArrayList<>(), Collections.singletonList("folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "/folderA", new ArrayList<>(), Collections.singletonList("/folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "/folderA/subfolderA", new ArrayList<>(), Collections.singletonList("/folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "/folderA/subfolderB", new ArrayList<>(), Collections.singletonList("/folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "/folderA/subfolderC", new ArrayList<>(), Collections.singletonList("/folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "/folderB", new ArrayList<>(), Collections.singletonList("/folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "/folderB/subfolderA", new ArrayList<>(), Collections.singletonList("/folderB/subfolder*")), is(false));
assertThat(isIndexable(true, "/folderB/subfolderB", new ArrayList<>(), Collections.singletonList("/folderB/subfolder*")), is(false));
assertThat(isIndexable(true, "/folderB/subfolderC", new ArrayList<>(), Collections.singletonList("/folderB/subfolder*")), is(false));
assertThat(isIndexable(true, "/folderC", new ArrayList<>(), Collections.singletonList("/folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "/folderC/subfolderA", new ArrayList<>(), Collections.singletonList("/folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "/folderC/subfolderB", new ArrayList<>(), Collections.singletonList("/folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "/folderC/subfolderC", new ArrayList<>(), Collections.singletonList("/folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "/subfolderA", new ArrayList<>(), Collections.singletonList("/folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "/subfolderB", new ArrayList<>(), Collections.singletonList("/folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "/subfolderC", new ArrayList<>(), Collections.singletonList("/folderB/subfolder*")), is(true));
assertThat(isIndexable(true, "/folderA", new ArrayList<>(), Collections.singletonList("/folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "/folderA/subfolderA", new ArrayList<>(), Collections.singletonList("/folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "/folderA/subfolderB", new ArrayList<>(), Collections.singletonList("/folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "/folderA/subfolderC", new ArrayList<>(), Collections.singletonList("/folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "/folderB", new ArrayList<>(), Collections.singletonList("/folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "/folderB/subfolderA", new ArrayList<>(), Collections.singletonList("/folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "/folderB/subfolderB", new ArrayList<>(), Collections.singletonList("/folderB/subfolderB")), is(false));
assertThat(isIndexable(true, "/folderB/subfolderC", new ArrayList<>(), Collections.singletonList("/folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "/folderC", new ArrayList<>(), Collections.singletonList("/folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "/folderC/subfolderA", new ArrayList<>(), Collections.singletonList("/folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "/folderC/subfolderB", new ArrayList<>(), Collections.singletonList("/folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "/folderC/subfolderC", new ArrayList<>(), Collections.singletonList("/folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "/subfolderA", new ArrayList<>(), Collections.singletonList("/folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "/subfolderB", new ArrayList<>(), Collections.singletonList("/folderB/subfolderB")), is(true));
assertThat(isIndexable(true, "/subfolderC", new ArrayList<>(), Collections.singletonList("/folderB/subfolderB")), is(true));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void testWithSimplestJsonJobFile() throws IOException {
assertThat(settings.getFs(), notNullValue());
assertThat(settings.getFs().getChecksum(), nullValue());
assertThat(settings.getFs().getIncludes(), nullValue());
assertThat(settings.getFs().getExcludes(), contains("~*"));
assertThat(settings.getFs().getExcludes(), contains("*/~*"));
assertThat(settings.getFs().getIndexedChars(), nullValue());
assertThat(settings.getFs().getUpdateRate(), is(TimeValue.timeValueMinutes(15)));
assertThat(settings.getFs().getUrl(), is("/tmp/es"));
Expand Down

0 comments on commit 2fd37fb

Please sign in to comment.