1 | void testPostfixOnly() {↵ | | 1 | void testPrefixOnly() {↵
|
2 | GlobPatternMapper m = new GlobPatternMapper();↵ | | 2 | GlobPatternMapper m = new GlobPatternMapper();↵
|
3 | m.setFrom("*foo");↵ | | 3 | m.setFrom("foo*");↵
|
4 | m.setTo("*plonk");↵ | | 4 | m.setTo("plonk*");↵
|
5 | assertNull("Shouldn\'t match *foo", m.mapFileName("bar.baz"));↵ | | 5 | assertNull("Shouldn\'t match foo*", m.mapFileName("bar.baz"));↵
|
6 | String[] result = m.mapFileName("bar.foo");↵ | | 6 | String[] result = m.mapFileName("foo.bar");↵
|
7 | assertNotNull("Should match *.foo", result);↵ | | 7 | assertNotNull("Should match foo*", result);↵
|
8 | assertEquals("only one result for bar.foo", 1, result.length);↵ | | 8 | assertEquals("only one result for foo.bar", 1, result.length);↵
|
9 | assertEquals("bar.plonk", result[0]);↵ | | 9 | assertEquals("plonk.bar", result[0]);↵
|
|
10 | // Try a silly case↵ | | 10 | // Try a silly case↵
|
11 | m.setTo("foo*");↵ | | 11 | m.setTo("*foo");↵
|
12 | result = m.mapFileName("bar.foo");↵ | | 12 | result = m.mapFileName("foo.bar");↵
|
13 | assertEquals("foobar.", result[0]);↵ | | 13 | assertEquals(".barfoo", result[0]);↵
|
14 | }↵ | | 14 | }↵
|
|
15 | public void testPrefixOnly() {↵ | | 15 | public void testPreAndPostfix() {↵
|
16 | GlobPatternMapper m = new GlobPatternMapper();↵ | | 16 | GlobPatternMapper m = new GlobPatternMapper();↵
|
17 | m.setFrom("foo*");↵ | | 17 | m.setFrom("foo*bar");↵
|
18 | m.setTo("plonk*");↵ | | 18 | m.setTo("plonk*pling");↵
|
19 | assertNull("Shouldn\'t match foo*", m.mapFileName("bar.baz"));↵ | | 19 | assertNull("Shouldn\'t match foo*bar", m.mapFileName("bar.baz"));↵
|
20 | String[] result = m.mapFileName("foo.bar");↵ | | 20 | String[] result = m.mapFileName("foo.bar");↵
|
21 | assertNotNull("Should match foo*", result);↵ | | 21 | assertNotNull("Should match foo*bar", result);↵
|
22 | assertEquals("only one result for foo.bar", 1, result.length);↵ | | 22 | assertEquals("only one result for foo.bar", 1, result.length);↵
|
23 | assertEquals("plonk.bar", result[0]) | | 23 | assertEquals("plonk.pling", result[0])
|