void testPostfixOnly() { GlobPatternMapper m = new GlobPatternMapper(); m.setFrom("*foo"); m.setTo("*plonk"); assertNull("Shouldn\'t match *foo", m.mapFileName("bar.baz")); String[] result = m.mapFileName("bar.foo"); assertNotNull("Should match *.foo", result); assertEquals("only one result for bar.foo", 1, result.length); assertEquals("bar.plonk", result[0]); // Try a silly case m.setTo("foo*"); result = m.mapFileName("bar.foo"); assertEquals("foobar.", result[0]); } public void testPrefixOnly() { GlobPatternMapper m = new GlobPatternMapper(); m.setFrom("foo*"); m.setTo("plonk*"); assertNull("Shouldn\'t match foo*", m.mapFileName("bar.baz")); String[] result = m.mapFileName("foo.bar"); assertNotNull("Should match foo*", result); assertEquals("only one result for foo.bar", 1, result.length); assertEquals("plonk.bar", result[0])
void testPrefixOnly() { GlobPatternMapper m = new GlobPatternMapper(); m.setFrom("foo*"); m.setTo("plonk*"); assertNull("Shouldn\'t match foo*", m.mapFileName("bar.baz")); String[] result = m.mapFileName("foo.bar"); assertNotNull("Should match foo*", result); assertEquals("only one result for foo.bar", 1, result.length); assertEquals("plonk.bar", result[0]); // Try a silly case m.setTo("*foo"); result = m.mapFileName("foo.bar"); assertEquals(".barfoo", result[0]); } public void testPreAndPostfix() { GlobPatternMapper m = new GlobPatternMapper(); m.setFrom("foo*bar"); m.setTo("plonk*pling"); assertNull("Shouldn\'t match foo*bar", m.mapFileName("bar.baz")); String[] result = m.mapFileName("foo.bar"); assertNotNull("Should match foo*bar", result); assertEquals("only one result for foo.bar", 1, result.length); assertEquals("plonk.pling", result[0])
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/util/GlobPatternMapperTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/util/GlobPatternMapperTest.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
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])
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0