KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.Date JavaDoc;
11
12 import junit.framework.TestCase;
13
14 import com.inversoft.savant.Artifact;
15 import com.inversoft.savant.ArtifactGroup;
16 import com.inversoft.savant.SavantException;
17
18
19 /**
20  * <p>
21  * This class is the test case for ArtifactGroup class.
22  * </p>
23  *
24  * @author Brian Pontarelli
25  */

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

31     public ArtifactGroupTest(String JavaDoc name) {
32         super(name);
33     }
34
35
36     /**
37      * Tests that the artifact group works correctly.
38      */

39     public void testArtifactGroup() {
40         ArtifactGroup group = new ArtifactGroup();
41
42         Artifact a = new Artifact();
43         group.addArtifact(a);
44         assertEquals(1, group.getArtifacts().size());
45         assertEquals(a, group.getArtifacts().get(0));
46
47         ArtifactGroup group2 = new ArtifactGroup();
48         group.addArtifactGroup(group2);
49         assertEquals(1, group.getArtifactGroups().size());
50         assertEquals(group2, group.getArtifactGroups().get(0));
51
52         group.setExpireminutes(3);
53         group.addArtifact(a);
54         assertEquals(3, a.getExpireminutes());
55         assertNull(a.getExpiretime());
56
57         group.setExpiretime(new Date JavaDoc());
58         group.addArtifact(a);
59         assertNotNull(a.getExpiretime());
60     }
61
62     /**
63      * Tests that the artifact group fails properly.
64      */

65     public void testFailure() {
66         ArtifactGroup group = new ArtifactGroup();
67
68         try {
69             group.validate();
70             fail("Should have failed");
71         } catch (SavantException e) {
72             // Expected
73
}
74     }
75 }
Popular Tags