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.jomc.ant.JomcToolTask;
35 import org.jomc.ant.test.support.AntExecutionResult;
36 import static org.jomc.ant.test.support.Assert.assertException;
37 import static org.jomc.ant.test.support.Assert.assertExceptionMessage;
38 import org.junit.Test;
39 import static org.junit.Assert.assertNotNull;
40 import static org.junit.Assert.fail;
41
42
43
44
45
46
47
48 public class JomcToolTaskTest extends JomcModelTaskTest
49 {
50
51
52 public JomcToolTaskTest()
53 {
54 super();
55 }
56
57
58 @Override
59 public JomcToolTask getJomcTask()
60 {
61 return (JomcToolTask) super.getJomcTask();
62 }
63
64
65 @Override
66 protected JomcToolTask newJomcTask()
67 {
68 return new JomcToolTask();
69 }
70
71
72 @Override
73 protected String getBuildFileName()
74 {
75 return "jomc-tool-task-test.xml";
76 }
77
78 @Test
79 public final void testConfigureJomcTool() throws Exception
80 {
81 try
82 {
83 this.getJomcTask().configureJomcTool( null );
84 fail( "Expected 'NullPointerException' not thrown." );
85 }
86 catch ( final NullPointerException e )
87 {
88 assertNotNull( e.getMessage() );
89 System.out.println( e );
90 }
91 }
92
93 @Test
94 public final void testGetSpecification() throws Exception
95 {
96 try
97 {
98 this.getJomcTask().getSpecification( null );
99 fail( "Expected 'NullPointerException' not thrown." );
100 }
101 catch ( final NullPointerException e )
102 {
103 assertNotNull( e.getMessage() );
104 System.out.println( e );
105 }
106 }
107
108 @Test
109 public final void testGetImplementation() throws Exception
110 {
111 try
112 {
113 this.getJomcTask().getImplementation( null );
114 fail( "Expected 'NullPointerException' not thrown." );
115 }
116 catch ( final NullPointerException e )
117 {
118 assertNotNull( e.getMessage() );
119 System.out.println( e );
120 }
121 }
122
123 @Test
124 public final void testGetModule() throws Exception
125 {
126 try
127 {
128 this.getJomcTask().getModule( null );
129 fail( "Expected 'NullPointerException' not thrown." );
130 }
131 catch ( final NullPointerException e )
132 {
133 assertNotNull( e.getMessage() );
134 System.out.println( e );
135 }
136 }
137
138 @Test
139 public final void testVelocityPropertyMissingKey() throws Exception
140 {
141 final AntExecutionResult r = this.executeTarget( "test-velocity-property-missing-key" );
142 assertException( r, BuildException.class );
143 assertExceptionMessage( r, "Mandatory attribute 'key' is missing a value." );
144 }
145
146 @Test
147 public final void testVelocityPropertyResourceMissingLocation() throws Exception
148 {
149 final AntExecutionResult r = this.executeTarget( "test-velocity-property-resource-missing-location" );
150 assertException( r, BuildException.class );
151 assertExceptionMessage( r, "Mandatory attribute 'location' is missing a value." );
152 }
153
154 @Test
155 public final void testTemplateParameterMissingKey() throws Exception
156 {
157 final AntExecutionResult r = this.executeTarget( "test-template-parameter-missing-key" );
158 assertException( r, BuildException.class );
159 assertExceptionMessage( r, "Mandatory attribute 'key' is missing a value." );
160 }
161
162 @Test
163 public final void testTemplateParameterResourceMissingLocation() throws Exception
164 {
165 final AntExecutionResult r = this.executeTarget( "test-template-parameter-resource-missing-location" );
166 assertException( r, BuildException.class );
167 assertExceptionMessage( r, "Mandatory attribute 'location' is missing a value." );
168 }
169
170 @Test
171 public final void testInvalidMultipleLocaleElements() throws Exception
172 {
173 final AntExecutionResult r = this.executeTarget( "test-invalid-multiple-locale-elements" );
174 assertException( r, BuildException.class );
175 assertExceptionMessage( r, "Multiple nested 'locale' elements." );
176 }
177
178 }