1 | public class TarFileSetTest extends AbstractFileSetTest {↵ | | 1 | public class ZipFileSetTest extends AbstractFileSetTest {↵
|
|
2 | public TarFileSetTest(String name) {↵ | | 2 | public ZipFileSetTest(String name) {↵
|
3 | super(name);↵ | | 3 | super(name);↵
|
4 | }↵ | | 4 | }↵
|
|
5 | protected AbstractFileSet getInstance() {↵ | | 5 | protected AbstractFileSet getInstance() {↵
|
6 | return new TarFileSet();↵ | | 6 | return new ZipFileSet();↵
|
7 | }↵ | | 7 | }↵
|
8 | public final void testAttributes() {↵ | | 8 | public final void testAttributes() {↵
|
9 | TarFileSet f = (TarFileSet)getInstance();↵ | | 9 | ZipFileSet f = (ZipFileSet)getInstance();↵
|
10 | //check that dir and src are incompatible↵ | | 10 | //check that dir and src are incompatible↵
|
11 | f.setSrc(new File("example.tar"));↵ | | 11 | f.setSrc(new File("example.zip"));↵
|
12 | try {↵ | | 12 | try {↵
|
13 | f.setDir(new File("examples"));↵ | | 13 | f.setDir(new File("examples"));↵
|
14 | fail("can add dir to "↵ | | 14 | fail("can add dir to "↵
|
15 | + f.getDataTypeName()↵ | | 15 | + f.getDataTypeName()↵
|
16 | + " when a src is already present");↵ | | 16 | + " when a src is already present");↵
|
17 | } catch (BuildException be) {↵ | | 17 | } catch (BuildException be) {↵
|
18 | assertEquals("Cannot set both dir and src attributes",be.getMessage());↵ | | 18 | assertEquals("Cannot set both dir and src attributes",be.getMessage());↵
|
19 | }↵ | | 19 | }↵
|
20 | f = (TarFileSet)getInstance();↵ | | 20 | f = (ZipFileSet)getInstance();↵
|
21 | //check that dir and src are incompatible↵ | | 21 | //check that dir and src are incompatible↵
|
22 | f.setDir(new File("examples"));↵ | | 22 | f.setDir(new File("examples"));↵
|
23 | try {↵ | | 23 | try {↵
|
24 | f.setSrc(new File("example.tar"));↵ | | 24 | f.setSrc(new File("example.zip"));↵
|
25 | fail("can add src to "↵ | | 25 | fail("can add src to "↵
|
26 | + f.getDataTypeName()↵ | | 26 | + f.getDataTypeName()↵
|
27 | + " when a dir is already present");↵ | | 27 | + " when a dir is already present");↵
|
28 | } catch (BuildException be) {↵ | | 28 | } catch (BuildException be) {↵
|
29 | assertEquals("Cannot set both dir and src attributes",be.getMessage());↵ | | 29 | assertEquals("Cannot set both dir and src attributes",be.getMessage());↵
|
30 | }↵ | | 30 | }↵
|
31 | //check that fullpath and prefix are incompatible↵ | | 31 | //check that fullpath and prefix are incompatible↵
|
32 | f = (TarFileSet)getInstance();↵ | | 32 | f = (ZipFileSet)getInstance();↵
|
33 | f.setSrc(new File("example.tar"));↵ | | 33 | f.setSrc(new File("example.zip"));↵
|
34 | f.setPrefix("/examples");↵ | | 34 | f.setPrefix("/examples");↵
|
35 | try {↵ | | 35 | try {↵
|
36 | f.setFullpath("/doc/manual/index.html");↵ | | 36 | f.setFullpath("/doc/manual/index.html");↵
|
37 | fail("Can add fullpath to "↵ | | 37 | fail("Can add fullpath to "↵
|
38 | + f.getDataTypeName()↵ | | 38 | + f.getDataTypeName()↵
|
39 | + " when a prefix is already present");↵ | | 39 | + " when a prefix is already present");↵
|
40 | } catch (BuildException be) {↵ | | 40 | } catch (BuildException be) {↵
|
41 | assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage());↵ | | 41 | assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage());↵
|
42 | }↵ | | 42 | }↵
|
43 | f = (TarFileSet)getInstance();↵ | | 43 | f = (ZipFileSet)getInstance();↵
|
44 | f.setSrc(new File("example.tar"));↵ | | 44 | f.setSrc(new File("example.zip"));↵
|
45 | f.setFullpath("/doc/manual/index.html");↵ | | 45 | f.setFullpath("/doc/manual/index.html");↵
|
46 | try {↵ | | 46 | try {↵
|
47 | f.setPrefix("/examples");↵ | | 47 | f.setPrefix("/examples");↵
|
48 | fail("Can add prefix to "↵ | | 48 | fail("Can add prefix to "↵
|
49 | + f.getDataTypeName()↵ | | 49 | + f.getDataTypeName()↵
|
50 | + " when a fullpath is already present");↵ | | 50 | + " when a fullpath is already present");↵
|
51 | } catch (BuildException be) {↵ | | 51 | } catch (BuildException be) {↵
|
52 | assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage());↵ | | 52 | assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage());↵
|
53 | }↵ | | 53 | }↵
|
54 | // check that reference tarfilesets cannot have specific attributes↵ | | 54 | // check that reference zipfilesets cannot have specific attributes↵
|
55 | f = (TarFileSet)getInstance();↵ | | 55 | f = (ZipFileSet)getInstance();↵
|
56 | f.setRefid(new Reference("test"));↵ | | 56 | f.setRefid(new Reference("test"));↵
|
57 | try {↵ | | 57 | try {↵
|
58 | f.setSrc(new File("example.tar"));↵ | | 58 | f.setSrc(new File("example.zip"));↵
|
59 | fail("Can add src to "↵ | | 59 | fail("Can add src to "↵
|
60 | + f.getDataTypeName()↵ | | 60 | + f.getDataTypeName()↵
|
61 | + " when a refid is already present");↵ | | 61 | + " when a refid is already present");↵
|
62 | } catch (BuildException be) {↵ | | 62 | } catch (BuildException be) {↵
|
63 | assertEquals("You must not specify more than one "↵ | | 63 | assertEquals("You must not specify more than one "↵
|
64 | + "attribute when using refid", be.getMessage());↵ | | 64 | + "attribute when using refid", be.getMessage());↵
|
65 | }↵ | | 65 | }↵
|
66 | // check that a reference tarfileset gets the same attributes as the original↵ | | 66 | // check that a reference zipfileset gets the same attributes as the original↵
|
67 | f = (TarFileSet)getInstance();↵ | | 67 | f = (ZipFileSet)getInstance();↵
|
68 | f.setSrc(new File("example.tar"));↵ | | 68 | f.setSrc(new File("example.zip"));↵
|
69 | f.setPrefix("/examples");↵ | | 69 | f.setPrefix("/examples");↵
|
70 | f.setFileMode("600");↵ | | 70 | f.setFileMode("600");↵
|
71 | f.setDirMode("530");↵ | | 71 | f.setDirMode("530");↵
|
72 | getProject().addReference("test",f);↵ | | 72 | getProject().addReference("test",f);↵
|
73 | TarFileSet zid=(TarFileSet)getInstance();↵ | | 73 | ZipFileSet zid=(ZipFileSet)getInstance();↵
|
74 | zid.setRefid(new Reference("test"));↵ | | 74 | zid.setRefid(new Reference("test"));↵
|
75 | assertTrue("src attribute copied by copy constructor",zid.getSrc(getProject()).equals(f.getSrc(getProject())));↵ | | 75 | assertTrue("src attribute copied by copy constructor",zid.getSrc(getProject()).equals(f.getSrc(getProject())));↵
|
76 | assertTrue("prefix attribute copied by copy constructor",f.getPrefix(getProject()).equals(zid.getPrefix(getProject())));↵ | | 76 | assertTrue("prefix attribute copied by copy constructor",f.getPrefix(getProject()).equals(zid.getPrefix(getProject())));↵
|
77 | assertTrue("file mode attribute copied by copy constructor",f.getFileMode(getProject())==zid.getFileMode(getProject()));↵ | | 77 | assertTrue("file mode attribute copied by copy constructor",f.getFileMode(getProject())==zid.getFileMode(getProject()));↵
|
78 | assertTrue("dir mode attribute copied by copy constructor",f.getDirMode(getProject())==zid.getDirMode(getProject()));↵ | | 78 | assertTrue("dir mode attribute copied by copy constructor",f.getDirMode(getProject())==zid.getDirMode(getProject()));↵
|
79 | | | 79 |
|