1 package org.apache.maven.j2ee;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 import junit.framework.TestCase;
58
59 /**
60 * Unit test for {@link ValidationStatusListener}.
61 *
62 * @author <a href="mailto:dion@multitask.com.au">dIon Gillard</a>
63 * @version $Id: ValidationStatusListenerTest.java 170200 2005-05-15 06:24:19Z brett $
64 */
65 public class ValidationStatusListenerTest extends TestCase
66 {
67 /** instance used for testing */
68 private ValidationStatusListener instance;
69
70 /**
71 * Creates a new instance of ValidationStatusListenerTest
72 * @param testName the name of the test
73 */
74 public ValidationStatusListenerTest(String testName)
75 {
76 super(testName);
77 }
78
79 /**
80 * test that the zero arg constructor works
81 * @throws Exception when there is an unexpected problem
82 */
83 public void testDefaultConstructor() throws Exception
84 {
85 instance = new ValidationStatusListener();
86 assertNotNull("Constructor hasn't returned a value", instance);
87 assertEquals("started property isn't false", false,
88 instance.isStarted());
89 assertEquals("error property isn't false", false, instance.isError());
90 assertEquals("warning property isn't false", false,
91 instance.isWarning());
92 assertEquals("ended property isn't false", false, instance.isEnded());
93 }
94
95 /**
96 * test that the listener handles validation started events correctly
97 * @throws Exception when there is an unexpected problem
98 */
99 public void testStarted() throws Exception
100 {
101 instance = new ValidationStatusListener();
102 instance.validationStarted(new ValidationEvent(this));
103 assertTrue("started property is not being set", instance.isStarted());
104 }
105
106 /**
107 * test that the listener handles validation error events correctly
108 * @throws Exception when there is an unexpected problem
109 */
110 public void testError() throws Exception
111 {
112 testStarted();
113 instance.validationError(new ValidationEvent(this));
114 assertTrue("error property is not being set", instance.isError());
115 }
116
117 /**
118 * test that the listener handles validation warning events correctly
119 * @throws Exception when there is an unexpected problem
120 */
121 public void testWarning() throws Exception
122 {
123 testStarted();
124 instance.validationWarning(new ValidationEvent(this));
125 assertTrue("warning property is not being set", instance.isWarning());
126 }
127
128 /**
129 * test that the listener handles validation ended events correctly
130 * @throws Exception when there is an unexpected problem
131 */
132 public void testEnded() throws Exception
133 {
134 testStarted();
135 instance.validationEnded(new ValidationEvent(this));
136 assertTrue("ended property is not being set", instance.isEnded());
137 }
138
139 }