01: package org.andromda.core.common;
02:
03: import junit.framework.TestCase;
04:
05: /**
06: * JUnit tests for {@link org.andromda.common.PathMatcher}
07: *
08: * @author Chad Brandon
09: */
10: public class PathMatcherTest extends TestCase {
11: public void testWildcardMatch() {
12: String path = "org/andromda/some/file/Test.java";
13: assertTrue(PathMatcher.wildcardMatch(path, "**/*.java"));
14: assertFalse(PathMatcher.wildcardMatch(path, "*.java"));
15: assertTrue(PathMatcher.wildcardMatch(path, "*/*/*/*/*.java"));
16: assertFalse(PathMatcher.wildcardMatch(path, "*/*/*.java"));
17: assertTrue(PathMatcher.wildcardMatch(path, "**/*Test.java"));
18: assertTrue(PathMatcher.wildcardMatch(path, "**/*Tes*.java"));
19: assertFalse(PathMatcher.wildcardMatch(path,
20: "**/*TestFile*.java"));
21: assertFalse(PathMatcher.wildcardMatch(path, "**/.java"));
22: assertTrue(PathMatcher.wildcardMatch(path, "org/andromda/**/*"));
23:
24: path = "Test.java";
25: assertTrue(PathMatcher.wildcardMatch(path, "*.java"));
26: assertTrue(PathMatcher.wildcardMatch(path, "**/*.java"));
27: assertTrue(PathMatcher.wildcardMatch(path, "**/*"));
28:
29: assertTrue(PathMatcher.wildcardMatch(path, "*.java"));
30: assertTrue(PathMatcher.wildcardMatch(path, "**.java"));
31: assertTrue(PathMatcher.wildcardMatch(path, "**/*"));
32: assertFalse(PathMatcher.wildcardMatch(path, "***/*.java"));
33:
34: path = "org/Test.java";
35: assertFalse(PathMatcher.wildcardMatch(path, "*.java"));
36: assertTrue(PathMatcher.wildcardMatch(path, "**/*"));
37: }
38: }
|