GlobMatcher implements Predicate<String> { @Override public boolean test(String toMatch) { return pattern.matcher(toMatch).matches(); } GlobMatcher(String globPattern); @Override boolean test(String toMatch);  }
@Test public void testQuestionMark() { GlobMatcher matcher = new GlobMatcher("?oo"); assertTrue(matcher.test("foo")); assertTrue(matcher.test("boo")); assertFalse(matcher.test("waterloo")); }
@Test public void testStar() { GlobMatcher matcher = new GlobMatcher("*ue"); assertTrue(matcher.test("rue")); assertTrue(matcher.test("blue")); assertFalse(matcher.test("bluer")); }
@Test public void testMixed() { GlobMatcher matcher = new GlobMatcher("java.?ang.*"); assertTrue(matcher.test("java.lang.String")); assertTrue(matcher.test("java.lang.Integer")); assertTrue(matcher.test("java.lang.reflect.Method")); assertFalse(matcher.test("java.util.List")); }
@Test public void testEscaping() { GlobMatcher dotMatcher = new GlobMatcher("."); assertTrue(dotMatcher.test(".")); assertFalse(dotMatcher.test("a")); GlobMatcher dotStarMatcher = new GlobMatcher(".*"); assertTrue(dotStarMatcher.test(".abcd")); assertFalse(dotStarMatcher.test("abcd")); }