KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > savant > test > ArtifactTest


1 /*
2  * Copyright (c) 2003-2004, Inversoft, All Rights Reserved
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.savant.test;
8
9
10 import java.io.File JavaDoc;
11
12 import junit.framework.TestCase;
13
14 import com.inversoft.savant.Artifact;
15 import com.inversoft.savant.SavantException;
16
17
18 /**
19  * <p>
20  * This class is the TestCase for the artifact object.
21  * </p>
22  *
23  * @author Brian Pontarelli
24  */

25 public class ArtifactTest extends TestCase {
26
27     /**
28      * Constructs a new <code>ArtifactTest</code>.
29      */

30     public ArtifactTest(String JavaDoc name) {
31         super(name);
32     }
33
34
35     /**
36      * Tests that the artifact generates the file and dir correctly.
37      */

38     public void testArtifact() {
39         Artifact artifact = new Artifact();
40         artifact.setGroup("group_name");
41         artifact.setName("name");
42         artifact.setProjectname("project_name");
43         artifact.setType("type");
44         artifact.setVersion("vers");
45
46         assertEquals("group_name" + File.separator + "project_name",
47             artifact.getArtifactDir());
48         assertEquals("group_name" + File.separator + "project_name" + File.separator +
49             "name-vers.type", artifact.getArtifactFile());
50     }
51
52     /**
53      * Tests all the failure cases.
54      */

55     public void testFailure() {
56         Artifact artifact = new Artifact();
57         artifact.setGroup(null);
58         artifact.setName("name");
59         artifact.setProjectname("project_name");
60         artifact.setType("type");
61         artifact.setVersion("vers");
62
63         try {
64             artifact.validate();
65             fail("Should have failed");
66         } catch (SavantException e) {
67             // expected
68
}
69
70         artifact.setGroup("group_name");
71         artifact.setName(null);
72         artifact.setProjectname("project_name");
73         artifact.setType("type");
74         artifact.setVersion("vers");
75
76         try {
77             artifact.validate();
78             fail("Should have failed");
79         } catch (SavantException e) {
80             // expected
81
}
82
83         artifact.setGroup("group_name");
84         artifact.setName("name");
85         artifact.setProjectname(null);
86         artifact.setType("type");
87         artifact.setVersion("vers");
88
89         try {
90             artifact.validate();
91             fail("Should have failed");
92         } catch (SavantException e) {
93             // expected
94
}
95
96         artifact.setGroup("group_name");
97         artifact.setName("name");
98         artifact.setProjectname("project_name");
99         artifact.setType(null);
100         artifact.setVersion("vers");
101
102         try {
103             artifact.validate();
104             fail("Should have failed");
105         } catch (SavantException e) {
106             // expected
107
}
108
109         artifact.setGroup("group_name");
110         artifact.setName("name");
111         artifact.setProjectname("project_name");
112         artifact.setType("type");
113         artifact.setVersion(null);
114
115         try {
116             artifact.validate();
117         } catch (SavantException e) {
118             fail("Should not have failed");
119         }
120     }
121 }
Popular Tags