1
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 package org.jomc.ant.test;
32
33 import org.apache.tools.ant.BuildException;
34 import org.apache.tools.ant.Project;
35 import org.jomc.ant.ClassProcessingException;
36 import org.jomc.ant.ValidateClasspathTask;
37 import org.jomc.ant.test.support.AntExecutionResult;
38 import static org.jomc.ant.test.support.Assert.assertException;
39 import static org.jomc.ant.test.support.Assert.assertExceptionMessage;
40 import static org.jomc.ant.test.support.Assert.assertMessageLogged;
41 import static org.jomc.ant.test.support.Assert.assertMessageNotLogged;
42 import static org.jomc.ant.test.support.Assert.assertNoException;
43 import org.junit.Test;
44
45
46
47
48
49
50
51 public class ValidateClasspathTaskTest extends ClassFileProcessorTaskTest
52 {
53
54
55 public ValidateClasspathTaskTest()
56 {
57 super();
58 }
59
60
61 @Override
62 public ValidateClasspathTask getJomcTask()
63 {
64 return (ValidateClasspathTask) super.getJomcTask();
65 }
66
67
68 @Override
69 protected ValidateClasspathTask newJomcTask()
70 {
71 return new ValidateClasspathTask();
72 }
73
74
75 @Override
76 protected String getBuildFileName()
77 {
78 return "validate-classpath-test.xml";
79 }
80
81 @Test
82 public final void testSpecificationNotFound() throws Exception
83 {
84 final AntExecutionResult r = this.executeTarget( "test-specification-not-found" );
85 assertNoException( r );
86 assertMessageLogged( r, "Specification 'DOES NOT EXIST' not found.", Project.MSG_WARN );
87 }
88
89 @Test
90 public final void testImplementationNotFound() throws Exception
91 {
92 final AntExecutionResult r = this.executeTarget( "test-implementation-not-found" );
93 assertNoException( r );
94 assertMessageLogged( r, "Implementation 'DOES NOT EXIST' not found.", Project.MSG_WARN );
95 }
96
97 @Test
98 public final void testModuleNotFound() throws Exception
99 {
100 final AntExecutionResult r = this.executeTarget( "test-module-not-found" );
101 assertNoException( r );
102 assertMessageLogged( r, "Module 'DOES NOT EXIST' not found.", Project.MSG_WARN );
103 }
104
105 @Test
106 public final void testClassProcessingDisabled() throws Exception
107 {
108 final AntExecutionResult r = this.executeTarget( "test-class-processing-disabled" );
109 assertNoException( r );
110 assertMessageLogged( r, "Class file processing disabled.", Project.MSG_INFO );
111 }
112
113 @Test
114 public final void testValidateAntTasks() throws Exception
115 {
116 final AntExecutionResult r = this.executeTarget( "test-validate-ant-tasks" );
117 assertNoException( r );
118 }
119
120 @Test
121 public final void testValidateAntTasksWithRedundantResources() throws Exception
122 {
123 final AntExecutionResult r = this.executeTarget( "test-validate-ant-tasks-with-redundant-resources" );
124 assertNoException( r );
125 }
126
127 @Test
128 public final void testValidateIllegalAntTasks() throws Exception
129 {
130 final AntExecutionResult r = this.executeTarget( "test-validate-illegal-ant-tasks" );
131 assertException( r, ClassProcessingException.class );
132 }
133
134 @Test
135 public final void testValidateOneSpecification() throws Exception
136 {
137 final AntExecutionResult r = this.executeTarget( "test-validate-one-specification" );
138 assertNoException( r );
139 assertMessageNotLogged( r, "Specification 'org.jomc.ant.test.JomcTask' not found." );
140 }
141
142 @Test
143 public final void testValidateOneIllegalSpecification() throws Exception
144 {
145 final AntExecutionResult r = this.executeTarget( "test-validate-one-illegal-specification" );
146 assertException( r, ClassProcessingException.class );
147 }
148
149 @Test
150 public final void testValidateOneImplementation() throws Exception
151 {
152 final AntExecutionResult r = this.executeTarget( "test-validate-one-implementation" );
153 assertNoException( r );
154 assertMessageNotLogged( r, "Implementation 'org.jomc.ant.test.JomcToolTask' not found." );
155 }
156
157 @Test
158 public final void testValidateOneIllegalImplementation() throws Exception
159 {
160 final AntExecutionResult r = this.executeTarget( "test-validate-one-illegal-implementation" );
161 assertException( r, ClassProcessingException.class );
162 }
163
164 @Test
165 public final void testValidateOneModule() throws Exception
166 {
167 final AntExecutionResult r = this.executeTarget( "test-validate-one-module" );
168 assertNoException( r );
169 assertMessageNotLogged( r, "Module 'JOMC Ant Tasks Tests' not found." );
170 }
171
172 @Test
173 public final void testValidateOneIllegalModule() throws Exception
174 {
175 final AntExecutionResult r = this.executeTarget( "test-validate-one-illegal-module" );
176 assertException( r, ClassProcessingException.class );
177 }
178
179 @Test
180 public final void testValidateAntTasksWithClasspathref() throws Exception
181 {
182 final AntExecutionResult r = this.executeTarget( "test-validate-ant-tasks-with-classpathref" );
183 assertNoException( r );
184 }
185
186 @Test
187 public final void testValidateAntTasksWithNestedClasspath() throws Exception
188 {
189 final AntExecutionResult r = this.executeTarget( "test-validate-ant-tasks-with-nested-classpath" );
190 assertNoException( r );
191 }
192
193 @Test
194 public final void testValidateAntTasksAllAttributes() throws Exception
195 {
196 final AntExecutionResult r = this.executeTarget( "test-validate-ant-tasks-all-attributes" );
197 assertNoException( r );
198 }
199
200 @Test
201 public final void testValidateAntTasksBrokenModel() throws Exception
202 {
203 final AntExecutionResult r = this.executeTarget( "test-validate-ant-tasks-broken-model" );
204 assertException( r, ClassProcessingException.class );
205 }
206
207 }