1 package org.apache.maven.model.converter.plugins;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import junit.framework.Assert;
23 import org.apache.maven.model.converter.ProjectConverterException;
24 import org.codehaus.plexus.util.xml.Xpp3Dom;
25
26 import java.io.IOException;
27
28
29
30
31
32 public class PCCJavadocTest
33 extends AbstractPCCTest
34 {
35 protected void setUp()
36 throws Exception
37 {
38 super.setUp();
39
40 pluginConfigurationConverter = new PCCJavadoc();
41 }
42
43 public void testBuildConfiguration()
44 {
45 try
46 {
47 projectProperties.load( getClassLoader().getResourceAsStream( "PCCJavadocTest1.properties" ) );
48
49 pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties );
50
51 String value = configuration.getChild( "additionalparam" ).getValue();
52 Assert.assertEquals( "check additionalparam value", "-J-showversion", value );
53
54 value = configuration.getChild( "author" ).getValue();
55 Assert.assertEquals( "check author value", "false", value );
56
57 value = configuration.getChild( "bottom" ).getValue();
58 Assert.assertEquals( "check bottom value", "Copyright", value );
59
60 value = configuration.getChild( "destDir" ).getValue();
61 Assert.assertEquals( "check destDir value", "apidocs", value );
62
63 value = configuration.getChild( "docencoding" ).getValue();
64 Assert.assertEquals( "check docencoding value", "UTF-8", value );
65
66 value = configuration.getChild( "doclet" ).getValue();
67 Assert.assertEquals( "check doclet value", "org.apache.MyDoclet", value );
68
69 value = configuration.getChild( "docletPath" ).getValue();
70 Assert.assertEquals( "check docletPath value", "/path/to/doclet", value );
71
72 value = configuration.getChild( "doctitle" ).getValue();
73 Assert.assertEquals( "check doctitle value", "The title", value );
74
75 value = configuration.getChild( "encoding" ).getValue();
76 Assert.assertEquals( "check encoding value", "ISO-8859-1", value );
77
78 value = configuration.getChild( "excludePackageNames" ).getValue();
79 Assert.assertEquals( "check excludePackageNames value", "org.apache.internal,org.apache.test", value );
80
81 value = configuration.getChild( "footer" ).getValue();
82 Assert.assertEquals( "check footer value", "The footer", value );
83
84 value = configuration.getChild( "header" ).getValue();
85 Assert.assertEquals( "check header value", "The header", value );
86
87 value = configuration.getChild( "isOffline" ).getValue();
88 Assert.assertEquals( "check isOffline value", "false", value );
89
90 Xpp3Dom links = configuration.getChild( "links" );
91 if ( links.getChildCount() == 2 )
92 {
93 Xpp3Dom tagOne = links.getChild( 0 );
94
95 value = tagOne.getValue();
96 Assert.assertEquals( "check links/link value", "http://java.sun.com/j2se/1.4/docs/api/", value );
97
98 Xpp3Dom tagTwo = links.getChild( 1 );
99
100 value = tagTwo.getValue();
101 Assert.assertEquals( "check links/link value", "http://java.sun.com/j2ee/sdk_1.3/techdocs/api/",
102 value );
103 }
104 else
105 {
106 Assert.fail( "Wrong number of link elements" );
107 }
108
109 value = configuration.getChild( "locale" ).getValue();
110 Assert.assertEquals( "check locale value", "en_US", value );
111
112 value = configuration.getChild( "maxmemory" ).getValue();
113 Assert.assertEquals( "check maxmemory value", "1024m", value );
114
115 value = configuration.getChild( "offlineLinks" ).getValue();
116 Assert.assertEquals( "check offlineLinks value", "/opt/java-apidoc/j2sdk1.4.2/docs/api/", value );
117
118 value = configuration.getChild( "overview" ).getValue();
119 Assert.assertEquals( "check overview value", "src/main/java/org/apache/overview.html", value );
120
121 value = configuration.getChild( "source" ).getValue();
122 Assert.assertEquals( "check source value", "1.3", value );
123
124 value = configuration.getChild( "stylesheetfile" ).getValue();
125 Assert.assertEquals( "check stylesheetfile value", "myStylesheet.css", value );
126
127 value = configuration.getChild( "subpackages" ).getValue();
128 Assert.assertEquals( "check subpackages value", "org.apache.maven", value );
129
130 value = configuration.getChild( "taglet" ).getValue();
131 Assert.assertEquals( "check taglet value", "org.apache.MyTaglet", value );
132
133 value = configuration.getChild( "tagletpath" ).getValue();
134 Assert.assertEquals( "check tagletpath value", "/path/to/taglet", value );
135
136 Xpp3Dom tags = configuration.getChild( "tags" );
137 if ( tags.getChildCount() == 2 )
138 {
139 Xpp3Dom tagOne = tags.getChild( 0 );
140
141 value = tagOne.getChild( "head" ).getValue();
142 Assert.assertEquals( "check tags/tag/head value", "To Do:", value );
143
144 value = tagOne.getChild( "name" ).getValue();
145 Assert.assertEquals( "check tags/tag/name value", "todo", value );
146
147 value = tagOne.getChild( "placement" ).getValue();
148 Assert.assertEquals( "check tags/tag/placement value", "a", value );
149
150 Xpp3Dom tagTwo = tags.getChild( 1 );
151
152 value = tagTwo.getChild( "head" ).getValue();
153 Assert.assertEquals( "check tags/tag/head value", "Task:", value );
154
155 value = tagTwo.getChild( "name" ).getValue();
156 Assert.assertEquals( "check tags/tag/name value", "task", value );
157
158 value = tagTwo.getChild( "placement" ).getValue();
159 Assert.assertEquals( "check tags/tag/placement value", "Xa", value );
160 }
161 else
162 {
163 Assert.fail( "Wrong number of tag elements" );
164 }
165
166 value = configuration.getChild( "use" ).getValue();
167 Assert.assertEquals( "check use value", "true", value );
168
169 value = configuration.getChild( "version" ).getValue();
170 Assert.assertEquals( "check version value", "true", value );
171
172 value = configuration.getChild( "windowtitle" ).getValue();
173 Assert.assertEquals( "check windowtitle value", "The title", value );
174 }
175 catch ( ProjectConverterException e )
176 {
177 Assert.fail( e.getMessage() );
178 }
179 catch ( IOException e )
180 {
181 Assert.fail( "Unable to find the requested resource." );
182 }
183 }
184
185 public void testBuildConfigurationShow1()
186 {
187 try
188 {
189 projectProperties.load( getClassLoader().getResourceAsStream( "PCCJavadocTest1.properties" ) );
190
191 pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties );
192
193 String value = configuration.getChild( "show" ).getValue();
194 Assert.assertEquals( "check show value", "package", value );
195 }
196 catch ( ProjectConverterException e )
197 {
198 Assert.fail( e.getMessage() );
199 }
200 catch ( IOException e )
201 {
202 Assert.fail( "Unable to find the requested resource." );
203 }
204 }
205
206 public void testBuildConfigurationShow2()
207 {
208 try
209 {
210 projectProperties.load( getClassLoader().getResourceAsStream( "PCCJavadocTest2.properties" ) );
211
212 pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties );
213
214 String value = configuration.getChild( "show" ).getValue();
215 Assert.assertEquals( "check show value", "private", value );
216 }
217 catch ( ProjectConverterException e )
218 {
219 Assert.fail( e.getMessage() );
220 }
221 catch ( IOException e )
222 {
223 Assert.fail( "Unable to find the requested resource." );
224 }
225 }
226
227 public void testBuildConfigurationShow3()
228 {
229 try
230 {
231 projectProperties.load( getClassLoader().getResourceAsStream( "PCCJavadocTest3.properties" ) );
232
233 pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties );
234
235 String value = configuration.getChild( "show" ).getValue();
236 Assert.assertEquals( "check show value", "public", value );
237 }
238 catch ( ProjectConverterException e )
239 {
240 Assert.fail( e.getMessage() );
241 }
242 catch ( IOException e )
243 {
244 Assert.fail( "Unable to find the requested resource." );
245 }
246 }
247 }