SimplePatternMatcher { public boolean wildcardMatch(String text, String pattern) { String[] cards = pattern.split("\\*"); int idx = 0; for (String card : cards) { idx = text.indexOf(card, idx); if(idx == -1) return false; } return true; }  boolean wildcardMatch(String text, String pattern);  }
@Test public void positive() throws Exception { String text = "java/lang/StringBuffer.class"; String pattern = "*Str*Bu*er*class"; assertTrue(matcher.wildcardMatch(text, pattern)); }
@Test public void negative() throws Exception { String text = "java/lang/StringBuffer.class"; String pattern = "*Str*Bx*er*class"; assertFalse(matcher.wildcardMatch(text, pattern)); }
@Test public void emptyPattern() throws Exception { String text = "java/lang/StringBuffer.class"; String pattern = ""; assertTrue(matcher.wildcardMatch(text, pattern)); }
@Test public void emptyText() throws Exception { String text = ""; String pattern = "*Str*Bx*er*class"; assertFalse(matcher.wildcardMatch(text, pattern)); }