Tools { public static void assertSimilar(String expected, String real, char wildcard) throws ComparisonFailure { if (!isSimilar(expected, real, wildcard)) { throw new ComparisonFailure("Not matched", expected, real); } }  static String[] tokenizeArgs(String args); static String convertToHtml(String str); static String getFilename(String filePath); static String getDir(String filePath); static String ensureDir(String dir, String basedir); static String ensureFileDir(String file, String basedir); static String ensureDir(String outputDir); static String modifyUrl(final String url, Integer mods); static void openURL(String url); static ByteArrayOutputStream readAll(InputStream instream, long maxSize); static void readAndWrite(InputStream instream, long maxSize, OutputStream outstream); static int copyFile(File source, File target, boolean overwrite); static String joinRelativeUrl(String baseUrl, String url); static boolean isEmpty(String str); static long writeAll(OutputStream out, InputStream in); static String expandProperties(StringToStringMap values, String content, boolean leaveMissing); static String replaceHost(String endpoint, String host); static String getEndpointFromUrl(URL baseUrl); static String getContentTypeFromFilename(String fileName); static String getExtensionForContentType(String contentType); static String getFileContent(String path); static String getTitleProperty(String path); static String normalizeFileSeparators(String input); static void assertSimilar(String expected, String real, char wildcard); static boolean isSimilar(String expected, String real, char wildcard); static void main(String[] args); static File createTemporaryDirectory(); static void deleteDirectoryOnExit(final File directory); static boolean isPropertyExpansion(@Nullable String value); static String removePropertyExpansions(String definitionUrl, String definition); static final int COPY_BUFFER_SIZE; static final long READ_ALL; }
@Test public void onlyWildcardMatches() { Tools.assertSimilar("*", "abc", '*'); }
@Test public void exactMatches() { Tools.assertSimilar("abc", "abc", '*'); }
@Test public void wildCardInBeginningMatches() { Tools.assertSimilar("*abc", "abc", '*'); Tools.assertSimilar("*bc", "abc", '*'); }
@Test public void wildCardInMiddleMatches() { Tools.assertSimilar("a*c", "abc", '*'); }
@Test public void wildCardInEndMatches() { Tools.assertSimilar("abc*", "abc", '*'); Tools.assertSimilar("ab*", "abc", '*'); }
@Test public void wildCardInBeginningAndEndMatches() { Tools.assertSimilar("*abc*", "abc", '*'); Tools.assertSimilar("*bc*", "abc", '*'); Tools.assertSimilar("*ab*", "abc", '*'); Tools.assertSimilar("*b*", "abc", '*'); }
@Test(expected = ComparisonFailure.class) public void mixingUpOrderBetweenWildcardsDoesNotMatch() { Tools.assertSimilar("The*in*mainly*rain*Spain*stays*the*plain!", "The rain in Spain stays mainly in the plain!", '*'); }
@Test(expected = ComparisonFailure.class) public void differentCasingDoesNotMatch() { Tools.assertSimilar("heLLo", "HEllO", '*'); }