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.ManageSourcesTask;
36 import org.jomc.ant.SourceProcessingException;
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 ManageSourcesTaskTest extends SourceFileProcessorTaskTest
52 {
53
54
55 public ManageSourcesTaskTest()
56 {
57 super();
58 }
59
60
61 @Override
62 public ManageSourcesTask getJomcTask()
63 {
64 return (ManageSourcesTask) super.getJomcTask();
65 }
66
67
68 @Override
69 protected ManageSourcesTask newJomcTask()
70 {
71 return new ManageSourcesTask();
72 }
73
74
75 @Override
76 protected String getBuildFileName()
77 {
78 return "manage-sources-test.xml";
79 }
80
81 @Test
82 public final void testMissingSourcesDirectory() throws Exception
83 {
84 final AntExecutionResult r = this.executeTarget( "test-missing-sources-directory" );
85 assertException( r, BuildException.class );
86 assertExceptionMessage( r, "Mandatory attribute 'sourcesDirectory' is missing a value." );
87 }
88
89 @Test
90 public final void testSpecificationNotFound() throws Exception
91 {
92 final AntExecutionResult r = this.executeTarget( "test-specification-not-found" );
93 assertNoException( r );
94 assertMessageLogged( r, "Specification 'DOES NOT EXIST' not found.", Project.MSG_WARN );
95 }
96
97 @Test
98 public final void testImplementationNotFound() throws Exception
99 {
100 final AntExecutionResult r = this.executeTarget( "test-implementation-not-found" );
101 assertNoException( r );
102 assertMessageLogged( r, "Implementation 'DOES NOT EXIST' not found.", Project.MSG_WARN );
103 }
104
105 @Test
106 public final void testModuleNotFound() throws Exception
107 {
108 final AntExecutionResult r = this.executeTarget( "test-module-not-found" );
109 assertNoException( r );
110 assertMessageLogged( r, "Module 'DOES NOT EXIST' not found.", Project.MSG_WARN );
111 }
112
113 @Test
114 public final void testSourceProcessingDisabled() throws Exception
115 {
116 final AntExecutionResult r = this.executeTarget( "test-source-processing-disabled" );
117 assertNoException( r );
118 assertMessageLogged( r, "Source file processing disabled.", Project.MSG_INFO );
119 }
120
121 @Test
122 public final void testManageAntTaskSources() throws Exception
123 {
124 final AntExecutionResult r = this.executeTarget( "test-manage-ant-task-sources" );
125 assertNoException( r );
126 assertMessageLogged( r, "Source file processing successful.", Project.MSG_INFO );
127 }
128
129 @Test
130 public final void testManageAntTaskSourcesWithRedundantResources() throws Exception
131 {
132 final AntExecutionResult r = this.executeTarget( "test-manage-ant-task-sources-with-redundant-resources" );
133 assertNoException( r );
134 assertMessageLogged( r, "Source file processing successful.", Project.MSG_INFO );
135 }
136
137 @Test
138 public final void testManageOneSpecification() throws Exception
139 {
140 final AntExecutionResult r = this.executeTarget( "test-manage-one-specification" );
141 assertNoException( r );
142 assertMessageNotLogged( r, "Specification 'org.jomc.ant.test.JomcTask' not found." );
143 }
144
145 @Test
146 public final void testManageOneImplementation() throws Exception
147 {
148 final AntExecutionResult r = this.executeTarget( "test-manage-one-implementation" );
149 assertNoException( r );
150 assertMessageNotLogged( r, "Implementation 'org.jomc.ant.test.JomcToolTask' not found." );
151 }
152
153 @Test
154 public final void testManageOneModule() throws Exception
155 {
156 final AntExecutionResult r = this.executeTarget( "test-manage-one-module" );
157 assertNoException( r );
158 assertMessageNotLogged( r, "Module 'JOMC Ant Tasks Tests' not found." );
159 }
160
161 @Test
162 public final void testManageAntTaskSourcesWithClasspathref() throws Exception
163 {
164 final AntExecutionResult r = this.executeTarget( "test-manage-ant-task-sources-with-classpathref" );
165 assertNoException( r );
166 assertMessageLogged( r, "Source file processing successful.", Project.MSG_INFO );
167 }
168
169 @Test
170 public final void testManageAntTaskSourcesWithNestedClasspath() throws Exception
171 {
172 final AntExecutionResult r = this.executeTarget( "test-manage-ant-task-sources-with-nested-classpath" );
173 assertNoException( r );
174 assertMessageLogged( r, "Source file processing successful.", Project.MSG_INFO );
175 }
176
177 @Test
178 public final void testManageAntTaskSourcesAllAttributes() throws Exception
179 {
180 final AntExecutionResult r = this.executeTarget( "test-manage-ant-task-sources-all-attributes" );
181 assertNoException( r );
182 assertMessageLogged( r, "Source file processing successful.", Project.MSG_INFO );
183 }
184
185 @Test
186 public final void testManageAntTaskSourcesBrokenModel() throws Exception
187 {
188 final AntExecutionResult r = this.executeTarget( "test-manage-ant-task-sources-broken-model" );
189 assertException( r, SourceProcessingException.class );
190 }
191
192 }