File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/TarFileSetTest.java | File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/ZipFileSetTest.java | |||
Method name: void testAttributes()
|
Method name: void testAttributes()
|
|||
Number of AST nodes: 39 | Number of AST nodes: 39 | |||
1 | TarFileSet f = (TarFileSet)getInstance();↵ | 1 | ZipFileSet f = (ZipFileSet)getInstance();↵ | |
2 | //check that dir and src are incompatible↵ | 2 | //check that dir and src are incompatible↵ | |
3 | f.setSrc(new File("example.tar"));↵ | 3 | f.setSrc(new File("example.zip"));↵ | |
4 | try {↵ | 4 | try {↵ | |
5 | f.setDir(new File("examples"));↵ | 5 | f.setDir(new File("examples"));↵ | |
6 | fail("can add dir to "↵ | 6 | fail("can add dir to "↵ | |
7 | + f.getDataTypeName()↵ | 7 | + f.getDataTypeName()↵ | |
8 | + " when a src is already present");↵ | 8 | + " when a src is already present");↵ | |
9 | } catch (BuildException be) {↵ | 9 | } catch (BuildException be) {↵ | |
10 | assertEquals("Cannot set both dir and src attributes",be.getMessage());↵ | 10 | assertEquals("Cannot set both dir and src attributes",be.getMessage());↵ | |
11 | }↵ | 11 | }↵ | |
12 | f = (TarFileSet)getInstance();↵ | 12 | f = (ZipFileSet)getInstance();↵ | |
13 | //check that dir and src are incompatible↵ | 13 | //check that dir and src are incompatible↵ | |
14 | f.setDir(new File("examples"));↵ | 14 | f.setDir(new File("examples"));↵ | |
15 | try {↵ | 15 | try {↵ | |
16 | f.setSrc(new File("example.tar"));↵ | 16 | f.setSrc(new File("example.zip"));↵ | |
17 | fail("can add src to "↵ | 17 | fail("can add src to "↵ | |
18 | + f.getDataTypeName()↵ | 18 | + f.getDataTypeName()↵ | |
19 | + " when a dir is already present");↵ | 19 | + " when a dir is already present");↵ | |
20 | } catch (BuildException be) {↵ | 20 | } catch (BuildException be) {↵ | |
21 | assertEquals("Cannot set both dir and src attributes",be.getMessage());↵ | 21 | assertEquals("Cannot set both dir and src attributes",be.getMessage());↵ | |
22 | }↵ | 22 | }↵ | |
23 | //check that fullpath and prefix are incompatible↵ | 23 | //check that fullpath and prefix are incompatible↵ | |
24 | f = (TarFileSet)getInstance();↵ | 24 | f = (ZipFileSet)getInstance();↵ | |
25 | f.setSrc(new File("example.tar"));↵ | 25 | f.setSrc(new File("example.zip"));↵ | |
26 | f.setPrefix("/examples");↵ | 26 | f.setPrefix("/examples");↵ | |
27 | try {↵ | 27 | try {↵ | |
28 | f.setFullpath("/doc/manual/index.html");↵ | 28 | f.setFullpath("/doc/manual/index.html");↵ | |
29 | fail("Can add fullpath to "↵ | 29 | fail("Can add fullpath to "↵ | |
30 | + f.getDataTypeName()↵ | 30 | + f.getDataTypeName()↵ | |
31 | + " when a prefix is already present");↵ | 31 | + " when a prefix is already present");↵ | |
32 | } catch (BuildException be) {↵ | 32 | } catch (BuildException be) {↵ | |
33 | assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage());↵ | 33 | assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage());↵ | |
34 | }↵ | 34 | }↵ | |
35 | f = (TarFileSet)getInstance();↵ | 35 | f = (ZipFileSet)getInstance();↵ | |
36 | f.setSrc(new File("example.tar"));↵ | 36 | f.setSrc(new File("example.zip"));↵ | |
37 | f.setFullpath("/doc/manual/index.html");↵ | 37 | f.setFullpath("/doc/manual/index.html");↵ | |
38 | try {↵ | 38 | try {↵ | |
39 | f.setPrefix("/examples");↵ | 39 | f.setPrefix("/examples");↵ | |
40 | fail("Can add prefix to "↵ | 40 | fail("Can add prefix to "↵ | |
41 | + f.getDataTypeName()↵ | 41 | + f.getDataTypeName()↵ | |
42 | + " when a fullpath is already present");↵ | 42 | + " when a fullpath is already present");↵ | |
43 | } catch (BuildException be) {↵ | 43 | } catch (BuildException be) {↵ | |
44 | assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage());↵ | 44 | assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage());↵ | |
45 | }↵ | 45 | }↵ | |
46 | // check that reference tarfilesets cannot have specific attributes↵ | 46 | // check that reference zipfilesets cannot have specific attributes↵ | |
47 | f = (TarFileSet)getInstance();↵ | 47 | f = (ZipFileSet)getInstance();↵ | |
48 | f.setRefid(new Reference("test"));↵ | 48 | f.setRefid(new Reference("test"));↵ | |
49 | try {↵ | 49 | try {↵ | |
50 | f.setSrc(new File("example.tar"));↵ | 50 | f.setSrc(new File("example.zip"));↵ | |
51 | fail("Can add src to "↵ | 51 | fail("Can add src to "↵ | |
52 | + f.getDataTypeName()↵ | 52 | + f.getDataTypeName()↵ | |
53 | + " when a refid is already present");↵ | 53 | + " when a refid is already present");↵ | |
54 | } catch (BuildException be) {↵ | 54 | } catch (BuildException be) {↵ | |
55 | assertEquals("You must not specify more than one "↵ | 55 | assertEquals("You must not specify more than one "↵ | |
56 | + "attribute when using refid", be.getMessage());↵ | 56 | + "attribute when using refid", be.getMessage());↵ | |
57 | }↵ | 57 | }↵ | |
58 | // check that a reference tarfileset gets the same attributes as the original↵ | 58 | // check that a reference zipfileset gets the same attributes as the original↵ | |
59 | f = (TarFileSet)getInstance();↵ | 59 | f = (ZipFileSet)getInstance();↵ | |
60 | f.setSrc(new File("example.tar"));↵ | 60 | f.setSrc(new File("example.zip"));↵ | |
61 | f.setPrefix("/examples");↵ | 61 | f.setPrefix("/examples");↵ | |
62 | f.setFileMode("600");↵ | 62 | f.setFileMode("600");↵ | |
63 | f.setDirMode("530");↵ | 63 | f.setDirMode("530");↵ | |
64 | getProject().addReference("test",f);↵ | 64 | getProject().addReference("test",f);↵ | |
65 | TarFileSet zid=(TarFileSet)getInstance();↵ | 65 | ZipFileSet zid=(ZipFileSet)getInstance();↵ | |
66 | zid.setRefid(new Reference("test"));↵ | 66 | zid.setRefid(new Reference("test"));↵ | |
67 | assertTrue("src attribute copied by copy constructor",zid.getSrc(getProject()).equals(f.getSrc(getProject())));↵ | 67 | assertTrue("src attribute copied by copy constructor",zid.getSrc(getProject()).equals(f.getSrc(getProject())));↵ | |
68 | assertTrue("prefix attribute copied by copy constructor",f.getPrefix(getProject()).equals(zid.getPrefix(getProject())));↵ | 68 | assertTrue("prefix attribute copied by copy constructor",f.getPrefix(getProject()).equals(zid.getPrefix(getProject())));↵ | |
69 | assertTrue("file mode attribute copied by copy constructor",f.getFileMode(getProject())==zid.getFileMode(getProject()));↵ | 69 | assertTrue("file mode attribute copied by copy constructor",f.getFileMode(getProject())==zid.getFileMode(getProject()));↵ | |
70 | assertTrue("dir mode attribute copied by copy constructor",f.getDirMode(getProject())==zid.getDirMode(getProject())); | 70 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 6.5 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 417 |
Number of mapped statements | 39 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 320.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | TarFileSet f = (TarFileSet)getInstance(); |
| 1 | ZipFileSet f = (ZipFileSet)getInstance(); | ||||||||||||||||
2 | f.setSrc(new File("example.tar")); |
| 2 | f.setSrc(new File("example.zip")); | ||||||||||||||||
3 | try | 3 | try | |||||||||||||||||
4 | f.setDir(new File("examples")); |
| 4 | f.setDir(new File("examples")); | ||||||||||||||||
5 | fail("can add dir to " + f.getDataTypeName() + " when a src is already present"); |
| 5 | fail("can add dir to " + f.getDataTypeName() + " when a src is already present"); | ||||||||||||||||
6 | f = (TarFileSet)getInstance(); |
| 6 | f = (ZipFileSet)getInstance(); | ||||||||||||||||
7 | f.setDir(new File("examples")); |
| 7 | f.setDir(new File("examples")); | ||||||||||||||||
8 | try | 8 | try | |||||||||||||||||
9 | f.setSrc(new File("example.tar")); |
| 9 | f.setSrc(new File("example.zip")); | ||||||||||||||||
10 | fail("can add src to " + f.getDataTypeName() + " when a dir is already present"); |
| 10 | fail("can add src to " + f.getDataTypeName() + " when a dir is already present"); | ||||||||||||||||
11 | f = (TarFileSet)getInstance(); |
| 11 | f = (ZipFileSet)getInstance(); | ||||||||||||||||
12 | f.setSrc(new File("example.tar")); |
| 12 | f.setSrc(new File("example.zip")); | ||||||||||||||||
13 | f.setPrefix("/examples"); |
| 13 | f.setPrefix("/examples"); | ||||||||||||||||
14 | try | 14 | try | |||||||||||||||||
15 | f.setFullpath("/doc/manual/index.html"); |
| 15 | f.setFullpath("/doc/manual/index.html"); | ||||||||||||||||
16 | fail("Can add fullpath to " + f.getDataTypeName() + " when a prefix is already present"); |
| 16 | fail("Can add fullpath to " + f.getDataTypeName() + " when a prefix is already present"); | ||||||||||||||||
17 | f = (TarFileSet)getInstance(); |
| 17 | f = (ZipFileSet)getInstance(); | ||||||||||||||||
18 | f.setSrc(new File("example.tar")); |
| 18 | f.setSrc(new File("example.zip")); | ||||||||||||||||
19 | f.setFullpath("/doc/manual/index.html"); |
| 19 | f.setFullpath("/doc/manual/index.html"); | ||||||||||||||||
20 | try | 20 | try | |||||||||||||||||
21 | f.setPrefix("/examples"); |
| 21 | f.setPrefix("/examples"); | ||||||||||||||||
22 | fail("Can add prefix to " + f.getDataTypeName() + " when a fullpath is already present"); |
| 22 | fail("Can add prefix to " + f.getDataTypeName() + " when a fullpath is already present"); | ||||||||||||||||
23 | f = (TarFileSet)getInstance(); |
| 23 | f = (ZipFileSet)getInstance(); | ||||||||||||||||
24 | f.setRefid(new Reference("test")); |
| 24 | f.setRefid(new Reference("test")); | ||||||||||||||||
25 | try | 25 | try | |||||||||||||||||
26 | f.setSrc(new File("example.tar")); |
| 26 | f.setSrc(new File("example.zip")); | ||||||||||||||||
27 | fail("Can add src to " + f.getDataTypeName() + " when a refid is already present"); |
| 27 | fail("Can add src to " + f.getDataTypeName() + " when a refid is already present"); | ||||||||||||||||
28 | f = (TarFileSet)getInstance(); |
| 28 | f = (ZipFileSet)getInstance(); | ||||||||||||||||
29 | f.setSrc(new File("example.tar")); |
| 29 | f.setSrc(new File("example.zip")); | ||||||||||||||||
30 | f.setPrefix("/examples"); |
| 30 | f.setPrefix("/examples"); | ||||||||||||||||
31 | f.setFileMode("600"); |
| 31 | f.setFileMode("600"); | ||||||||||||||||
32 | f.setDirMode("530"); |
| 32 | f.setDirMode("530"); | ||||||||||||||||
33 | getProject().addReference("test", f); |
| 33 | getProject().addReference("test", f); | ||||||||||||||||
34 | TarFileSet zid = (TarFileSet)getInstance(); |
| 34 | ZipFileSet zid = (ZipFileSet)getInstance(); | ||||||||||||||||
35 | zid.setRefid(new Reference("test")); |
| 35 | zid.setRefid(new Reference("test")); | ||||||||||||||||
36 | assertTrue("src attribute copied by copy constructor", zid.getSrc(getProject()).equals(f.getSrc(getProject()))); |
| 36 | assertTrue("src attribute copied by copy constructor", zid.getSrc(getProject()).equals(f.getSrc(getProject()))); | ||||||||||||||||
37 | assertTrue("prefix attribute copied by copy constructor", f.getPrefix(getProject()).equals(zid.getPrefix(getProject()))); |
| 37 | assertTrue("prefix attribute copied by copy constructor", f.getPrefix(getProject()).equals(zid.getPrefix(getProject()))); | ||||||||||||||||
38 | assertTrue("file mode attribute copied by copy constructor", f.getFileMode(getProject()) == zid.getFileMode(getProject())); |
| 38 | assertTrue("file mode attribute copied by copy constructor", f.getFileMode(getProject()) == zid.getFileMode(getProject())); | ||||||||||||||||
39 | assertTrue("dir mode attribute copied by copy constructor", f.getDirMode(getProject()) == zid.getDirMode(getProject())); |
| 39 | assertTrue("dir mode attribute copied by copy constructor", f.getDirMode(getProject()) == zid.getDirMode(getProject())); |
Row | Violation |
---|