1 package org.apache.maven.plugins.javadoc;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import static org.mockito.Mockito.mock;
22 import static org.mockito.Mockito.spy;
23 import static org.mockito.Mockito.when;
24
25 import java.io.File;
26 import java.io.IOException;
27 import java.net.HttpURLConnection;
28 import java.net.URL;
29 import java.nio.charset.Charset;
30 import java.nio.charset.StandardCharsets;
31 import java.nio.file.Files;
32 import java.util.HashMap;
33 import java.util.List;
34 import java.util.Map;
35
36 import org.apache.maven.execution.MavenSession;
37 import org.apache.maven.model.Plugin;
38 import org.apache.maven.plugin.LegacySupport;
39 import org.apache.maven.plugin.MojoExecution;
40 import org.apache.maven.plugin.MojoExecutionException;
41 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
42 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
43 import org.apache.maven.plugins.javadoc.ProxyServer.AuthAsyncProxyServlet;
44 import org.apache.maven.project.MavenProject;
45 import org.apache.maven.project.ProjectBuildingRequest;
46 import org.apache.maven.repository.internal.MavenRepositorySystemSession;
47 import org.apache.maven.settings.Proxy;
48 import org.apache.maven.settings.Settings;
49 import org.codehaus.plexus.languages.java.version.JavaVersion;
50 import org.codehaus.plexus.util.FileUtils;
51 import org.codehaus.plexus.util.StringUtils;
52 import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
53
54
55
56
57
58
59
60 public class JavadocReportTest
61 extends AbstractMojoTestCase
62 {
63 private static final char LINE_SEPARATOR = ' ';
64
65
66 private static boolean TEST_REPO_CREATED = false;
67
68 private File unit;
69
70 private File localRepo;
71
72
73 @Override
74 protected void setUp()
75 throws Exception
76 {
77 super.setUp();
78
79 unit = new File( getBasedir(), "src/test/resources/unit" );
80
81 localRepo = new File( getBasedir(), "target/local-repo/" );
82
83 createTestRepo();
84 }
85
86
87 private JavadocReport lookupMojo( File testPom )
88 throws Exception
89 {
90 JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
91
92 MojoExecution mojoExec = new MojoExecution( new Plugin(), "javadoc", null );
93
94 setVariableValueToObject( mojo, "mojo", mojoExec );
95
96 MavenProject currentProject = new MavenProjectStub();
97 currentProject.setGroupId( "GROUPID" );
98 currentProject.setArtifactId( "ARTIFACTID" );
99
100 setVariableValueToObject( mojo, "session", newMavenSession( currentProject ) );
101
102 return mojo;
103 }
104
105
106
107
108
109
110 private void createTestRepo()
111 throws IOException
112 {
113 if ( TEST_REPO_CREATED )
114 {
115 return;
116 }
117
118 localRepo.mkdirs();
119
120
121
122
123
124 File sourceDir = new File( unit, "doclet-test/artifact-doclet" );
125 assertTrue( sourceDir.exists() );
126 FileUtils.copyDirectoryStructure( sourceDir, localRepo );
127
128
129
130
131
132 sourceDir = new File( unit, "doclet-path-test/artifact-doclet" );
133 assertTrue( sourceDir.exists() );
134 FileUtils.copyDirectoryStructure( sourceDir, localRepo );
135
136
137
138
139
140
141 sourceDir = new File( unit, "taglet-test/artifact-taglet" );
142 assertTrue( sourceDir.exists() );
143 FileUtils.copyDirectoryStructure( sourceDir, localRepo );
144
145
146
147
148
149 sourceDir = new File( unit, "stylesheetfile-test/artifact-stylesheetfile" );
150 assertTrue( sourceDir.exists() );
151 FileUtils.copyDirectoryStructure( sourceDir, localRepo );
152
153
154
155
156
157 sourceDir = new File( unit, "helpfile-test/artifact-helpfile" );
158 assertTrue( sourceDir.exists() );
159 FileUtils.copyDirectoryStructure( sourceDir, localRepo );
160
161
162 List<String> files =
163 FileUtils.getFileAndDirectoryNames( localRepo, FileUtils.getDefaultExcludesAsString(), null, true,
164 true, true, true );
165 for ( String filename : files )
166 {
167 File file = new File( filename );
168
169 if ( file.isDirectory() )
170 {
171 FileUtils.deleteDirectory( file );
172 }
173 else
174 {
175 file.delete();
176 }
177 }
178
179 TEST_REPO_CREATED = true;
180 }
181
182
183
184
185
186
187
188
189
190
191 private static String readFile( File file )
192 throws IOException
193 {
194 return readFile( file, StandardCharsets.UTF_8 );
195 }
196
197
198
199
200
201
202
203
204
205
206
207 private static String readFile( File file, Charset cs )
208 throws IOException
209 {
210 StringBuilder str = new StringBuilder( (int) file.length() );
211
212 for ( String strTmp : Files.readAllLines( file.toPath(), cs ) )
213 {
214 str.append( LINE_SEPARATOR);
215 str.append( strTmp );
216 }
217
218 return str.toString();
219 }
220
221
222
223
224
225
226 public void testDefaultConfiguration()
227 throws Exception
228 {
229 File testPom = new File( unit, "default-configuration/default-configuration-plugin-config.xml" );
230 JavadocReport mojo = lookupMojo( testPom );
231 mojo.execute();
232
233
234 File apidocs = new File( getBasedir(), "target/test/unit/default-configuration/target/site/apidocs" );
235
236 File generatedFile = new File( apidocs, "def/configuration/App.html" );
237 assertTrue( generatedFile.exists() );
238
239
240
241 String url = mojo.getDefaultJavadocApiLink().getUrl();
242 HttpURLConnection connection = (HttpURLConnection) new URL( url ).openConnection();
243 connection.setRequestMethod( "HEAD" );
244 if ( connection.getResponseCode() == 200 )
245 {
246 assertTrue( FileUtils.fileRead( generatedFile, "UTF-8" ).contains( "/docs/api/java/lang/Object.html" ) );
247 }
248
249 assertTrue( new File( apidocs, "def/configuration/AppSample.html" ).exists() );
250 assertTrue( new File( apidocs, "def/configuration/package-summary.html" ).exists() );
251 assertTrue( new File( apidocs, "def/configuration/package-tree.html" ).exists() );
252 assertTrue( new File( apidocs, "def/configuration/package-use.html" ).exists() );
253
254
255 if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore( "11" ) )
256 {
257 assertTrue( new File( apidocs, "def/configuration/package-frame.html" ).exists() );
258 assertTrue( new File( apidocs, "allclasses-frame.html" ).exists() );
259 assertTrue( new File( apidocs, "allclasses-noframe.html" ).exists() );
260 }
261
262
263 assertTrue( new File( apidocs, "def/configuration/class-use/App.html" ).exists() );
264 assertTrue( new File( apidocs, "def/configuration/class-use/AppSample.html" ).exists() );
265
266
267 assertTrue( new File( apidocs, "constant-values.html" ).exists() );
268 assertTrue( new File( apidocs, "deprecated-list.html" ).exists() );
269 assertTrue( new File( apidocs, "help-doc.html" ).exists() );
270 assertTrue( new File( apidocs, "index-all.html" ).exists() );
271 assertTrue( new File( apidocs, "index.html" ).exists() );
272 assertTrue( new File( apidocs, "overview-tree.html" ).exists() );
273 assertTrue( new File( apidocs, "stylesheet.css" ).exists() );
274
275 if ( JavaVersion.JAVA_VERSION.isAtLeast( "10" ) )
276 {
277 assertTrue( new File( apidocs, "element-list" ).exists() );
278 }
279 else
280 {
281 assertTrue( new File( apidocs, "package-list" ).exists() );
282 }
283 }
284
285
286
287
288
289
290 public void testSubpackages()
291 throws Exception
292 {
293 File testPom = new File( unit, "subpackages-test/subpackages-test-plugin-config.xml" );
294 JavadocReport mojo = lookupMojo( testPom );
295 mojo.execute();
296
297 File apidocs = new File( getBasedir(), "target/test/unit/subpackages-test/target/site/apidocs" );
298
299
300 assertFalse( new File( apidocs, "subpackages/test/excluded" ).exists() );
301 assertFalse( new File( apidocs, "subpackages/test/included/exclude" ).exists() );
302
303
304 assertTrue( new File( apidocs, "subpackages/test/App.html" ).exists() );
305 assertTrue( new File( apidocs, "subpackages/test/AppSample.html" ).exists() );
306 assertTrue( new File( apidocs, "subpackages/test/included/IncludedApp.html" ).exists() );
307 assertTrue( new File( apidocs, "subpackages/test/included/IncludedAppSample.html" ).exists() );
308 }
309
310 public void testIncludesExcludes()
311 throws Exception
312 {
313 File testPom = new File( unit, "file-include-exclude-test/file-include-exclude-plugin-config.xml" );
314 JavadocReport mojo = lookupMojo( testPom );
315 mojo.execute();
316
317 File apidocs = new File( getBasedir(), "target/test/unit/file-include-exclude-test/target/site/apidocs" );
318
319
320 assertTrue( new File( apidocs, "subpackages/test/App.html" ).exists() );
321 assertTrue( new File( apidocs, "subpackages/test/AppSample.html" ).exists() );
322 assertTrue( new File( apidocs, "subpackages/test/included/IncludedApp.html" ).exists() );
323 assertTrue( new File( apidocs, "subpackages/test/included/IncludedAppSample.html" ).exists() );
324 assertFalse( new File( apidocs, "subpackages/test/PariahApp.html" ).exists() );
325 }
326
327
328
329
330
331
332 public void testDocfiles()
333 throws Exception
334 {
335
336
337 if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "9" ) )
338 {
339 return;
340 }
341
342 File testPom = new File( unit, "docfiles-test/docfiles-test-plugin-config.xml" );
343 JavadocReport mojo = lookupMojo( testPom );
344 mojo.execute();
345
346 File apidocs = new File( getBasedir(), "target/test/unit/docfiles-test/target/site/apidocs/" );
347
348
349 assertTrue( new File( apidocs, "docfiles/test/doc-files" ).exists() );
350 assertTrue( new File( apidocs, "docfiles/test/doc-files/included-dir1/sample-included1.gif" ).exists() );
351 assertTrue( new File( apidocs, "docfiles/test/doc-files/included-dir2/sample-included2.gif" ).exists() );
352 assertFalse( new File( apidocs, "docfiles/test/doc-files/excluded-dir1" ).exists() );
353 assertFalse( new File( apidocs, "docfiles/test/doc-files/excluded-dir2" ).exists() );
354
355 testPom = new File( unit, "docfiles-with-java-test/docfiles-with-java-test-plugin-config.xml" );
356 mojo = lookupMojo( testPom );
357 mojo.execute();
358 }
359
360
361
362
363
364
365
366 public void testCustomConfiguration()
367 throws Exception
368 {
369 File testPom = new File( unit, "custom-configuration/custom-configuration-plugin-config.xml" );
370 JavadocReport mojo = lookupMojo( testPom );
371 mojo.execute();
372
373 File apidocs = new File( getBasedir(), "target/test/unit/custom-configuration/target/site/apidocs" );
374
375
376 assertFalse( new File( apidocs, "overview-tree.html" ).exists() );
377 assertFalse( new File( apidocs, "custom/configuration/package-tree.html" ).exists() );
378
379
380 assertFalse( new File( apidocs, "index-all.html" ).exists() );
381
382
383
384
385 assertFalse( new File( apidocs, "deprecated-list.html" ).exists() );
386 assertFalse( new File( apidocs, "custom/configuration/App.html" ).exists() );
387
388
389
390 String str = readFile( new File( apidocs, "custom/configuration/AppSample.html" ) );
391 assertFalse( str.toLowerCase().contains( "author" ) );
392
393
394 assertTrue( str.toUpperCase().contains( "SAMPLE BOTTOM CONTENT" ) );
395
396
397 if ( JavaVersion.JAVA_VERSION.isBefore( "11.0.2" ) )
398 {
399 assertTrue( str.toLowerCase().contains( "href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/lang/string.html" ) );
400 }
401 else
402 {
403 assertTrue( str.toLowerCase().contains( "href=\"http://java.sun.com/j2se/1.4.2/docs/api/java.base/java/lang/string.html" ) );
404 }
405
406
407 assertTrue( str.toUpperCase().contains( "MAVEN JAVADOC PLUGIN TEST" ) );
408
409
410 assertTrue( str.toUpperCase().contains( "MAVEN JAVADOC PLUGIN TEST FOOTER" ) );
411
412
413 assertFalse( str.toUpperCase().contains( "/HELP-DOC.HTML" ) );
414
415
416 assertTrue( new File( apidocs, "custom/configuration/exclude1/Exclude1App.html" ).exists() );
417 assertFalse( new File( apidocs, "custom/configuration/exclude1/subexclude/SubexcludeApp.html" ).exists() );
418 assertFalse( new File( apidocs, "custom/configuration/exclude2/Exclude2App.html" ).exists() );
419
420 File options = new File( apidocs, "options" );
421 assertTrue( options.isFile() );
422
423 String contentOptions = FileUtils.fileRead( options );
424
425 assertNotNull( contentOptions );
426 assertTrue( contentOptions.contains( "-link" ) );
427 assertTrue( contentOptions.contains( "http://java.sun.com/j2se/" ) );
428 }
429
430
431
432
433
434
435 public void testDoclets()
436 throws Exception
437 {
438
439
440
441
442
443 File testPom = new File( unit, "doclet-test/doclet-test-plugin-config.xml" );
444 JavadocReport mojo = lookupMojo( testPom );
445
446 MavenSession session = spy( newMavenSession( mojo.project ) );
447 ProjectBuildingRequest buildingRequest = mock( ProjectBuildingRequest.class );
448 when( buildingRequest.getRemoteRepositories() ).thenReturn( mojo.project.getRemoteArtifactRepositories() );
449 when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest );
450 MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
451 repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepo ) );
452 when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession );
453 when( session.getRepositorySession() ).thenReturn( repositorySession );
454 LegacySupport legacySupport = lookup( LegacySupport.class );
455 legacySupport.setSession( session );
456
457 setVariableValueToObject( mojo, "session", session );
458
459 mojo.execute();
460
461 File generatedFile = new File( getBasedir(), "target/test/unit/doclet-test/target/site/apidocs/graph.dot" );
462 assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
463
464 File optionsFile = new File( mojo.getOutputDirectory(), "options" );
465 assertTrue( optionsFile.exists() );
466 String options = readFile( optionsFile );
467 assertTrue( options.contains( "/target/local-repo/umlgraph/UMLGraph/2.1/UMLGraph-2.1.jar" ) );
468
469
470
471
472
473
474 testPom = new File( unit, "doclet-path-test/doclet-path-test-plugin-config.xml" );
475 mojo = lookupMojo( testPom );
476 setVariableValueToObject( mojo, "session", session );
477 mojo.execute();
478
479 generatedFile = new File( getBasedir(), "target/test/unit/doclet-test/target/site/apidocs/graph.dot" );
480 assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
481
482 optionsFile = new File( mojo.getOutputDirectory(), "options" );
483 assertTrue( optionsFile.exists() );
484 options = readFile( optionsFile );
485 assertTrue( options.contains( "/target/local-repo/umlgraph/UMLGraph/2.1/UMLGraph-2.1.jar" ) );
486 assertTrue( options.contains( "/target/local-repo/umlgraph/UMLGraph-bis/2.1/UMLGraph-bis-2.1.jar" ) );
487 }
488
489
490
491
492
493
494
495
496 public void testQuotedPath()
497 throws Exception
498 {
499 File testPom = new File( unit, "quotedpath'test/quotedpath-test-plugin-config.xml" );
500 JavadocReport mojo = lookupMojo( testPom );
501 mojo.execute();
502
503 File apidocs = new File( getBasedir(), "target/test/unit/quotedpath'test/target/site/apidocs" );
504
505
506 assertTrue( new File( apidocs, "quotedpath/test/App.html" ).exists() );
507 assertTrue( new File( apidocs, "quotedpath/test/AppSample.html" ).exists() );
508
509
510 assertTrue( new File( apidocs, "index-all.html" ).exists() );
511 assertTrue( new File( apidocs, "index.html" ).exists() );
512 assertTrue( new File( apidocs, "overview-tree.html" ).exists() );
513 assertTrue( new File( apidocs, "stylesheet.css" ).exists() );
514
515 if ( JavaVersion.JAVA_VERSION.isBefore( "10" ) )
516 {
517 assertTrue( new File( apidocs, "package-list" ).exists() );
518 }
519 else
520 {
521 assertTrue( new File( apidocs, "element-list" ).exists() );
522 }
523 }
524
525
526
527
528
529
530 public void testOptionsUmlautEncoding()
531 throws Exception
532 {
533 File testPom = new File(unit, "optionsumlautencoding-test/optionsumlautencoding-test-plugin-config.xml" );
534 JavadocReport mojo = lookupMojo( testPom );
535 mojo.execute();
536
537 File optionsFile = new File( mojo.getOutputDirectory(), "options" );
538 assertTrue( optionsFile.exists() );
539
540
541 String content;
542 if ( JavaVersion.JAVA_VERSION.isAtLeast( "9" ) )
543 {
544 content = readFile( optionsFile, StandardCharsets.UTF_8 );
545 }
546 else
547 {
548 content = readFile( optionsFile, Charset.defaultCharset() );
549 }
550 assertTrue( content.contains( "Options Umlaut Encoding ö ä ü ß" ) );
551
552 File apidocs = new File( getBasedir(), "target/test/unit/optionsumlautencoding-test/target/site/apidocs" );
553
554
555 assertTrue( new File( apidocs, "optionsumlautencoding/test/App.html" ).exists() );
556 assertTrue( new File( apidocs, "optionsumlautencoding/test/AppSample.html" ).exists() );
557
558
559 assertTrue( new File( apidocs, "index-all.html" ).exists() );
560 assertTrue( new File( apidocs, "index.html" ).exists() );
561 assertTrue( new File( apidocs, "overview-tree.html" ).exists() );
562 assertTrue( new File( apidocs, "stylesheet.css" ).exists() );
563
564 if ( JavaVersion.JAVA_VERSION.isBefore( "10" ) )
565 {
566 assertTrue( new File( apidocs, "package-list" ).exists() );
567 }
568 else
569 {
570 assertTrue( new File( apidocs, "element-list" ).exists() );
571 }
572 }
573
574
575
576
577 public void testExceptions()
578 throws Exception
579 {
580 try
581 {
582 File testPom = new File( unit, "default-configuration/exception-test-plugin-config.xml" );
583 JavadocReport mojo = lookupMojo( testPom );
584 mojo.execute();
585
586 fail( "Must throw exception." );
587 }
588 catch ( Exception e )
589 {
590 assertTrue( true );
591
592 try
593 {
594 FileUtils.deleteDirectory( new File( getBasedir(), "exception" ) );
595 }
596 catch ( IOException ie )
597 {
598
599 }
600 }
601 }
602
603
604
605
606
607
608 public void testTaglets()
609 throws Exception
610 {
611
612
613
614
615
616
617
618 if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "10" ) )
619 {
620 return;
621 }
622
623 File testPom = new File( unit, "taglet-test/taglet-test-plugin-config.xml" );
624 JavadocReport mojo = lookupMojo( testPom );
625
626 MavenSession session = spy( newMavenSession( mojo.project ) );
627 ProjectBuildingRequest buildingRequest = mock( ProjectBuildingRequest.class );
628 when( buildingRequest.getRemoteRepositories() ).thenReturn( mojo.project.getRemoteArtifactRepositories() );
629 when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest );
630 MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
631 repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepo ) );
632 when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession );
633 when( session.getRepositorySession() ).thenReturn( repositorySession );
634 LegacySupport legacySupport = lookup( LegacySupport.class );
635 legacySupport.setSession( session );
636
637 setVariableValueToObject( mojo, "session", session );
638
639 mojo.execute();
640
641 File apidocs = new File( getBasedir(), "target/test/unit/taglet-test/target/site/apidocs" );
642
643 assertTrue( new File( apidocs, "index.html" ).exists() );
644
645 File appFile = new File( apidocs, "taglet/test/App.html" );
646 assertTrue( appFile.exists() );
647 String appString = readFile( appFile );
648 assertTrue( appString.contains( "<b>To Do:</b>" ) );
649 }
650
651
652
653
654
655
656 public void testJdk5()
657 throws Exception
658 {
659
660
661 if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "9" ) )
662 {
663 return;
664 }
665
666 File testPom = new File( unit, "jdk5-test/jdk5-test-plugin-config.xml" );
667 JavadocReport mojo = lookupMojo( testPom );
668 mojo.execute();
669
670 File apidocs = new File( getBasedir(), "target/test/unit/jdk5-test/target/site/apidocs" );
671
672 File index = new File( apidocs, "index.html" );
673 assertTrue( FileUtils.fileExists( index.getAbsolutePath() ) );
674
675 File overviewSummary = new File( apidocs, "overview-summary.html" );
676 assertTrue( overviewSummary.exists() );
677 String content = readFile( overviewSummary );
678 assertTrue( content.contains( "<b>Test the package-info</b>" ) );
679
680 File packageSummary = new File( apidocs, "jdk5/test/package-summary.html" );
681 assertTrue( packageSummary.exists() );
682 content = readFile( packageSummary );
683 assertTrue( content.contains( "<b>Test the package-info</b>" ) );
684 }
685
686
687
688
689
690
691
692 public void testToFindJavadoc()
693 throws Exception
694 {
695 String oldJreHome = System.getProperty( "java.home" );
696 System.setProperty( "java.home", "foo/bar" );
697
698 File testPom = new File( unit, "javaHome-test/javaHome-test-plugin-config.xml" );
699 JavadocReport mojo = lookupMojo( testPom );
700 mojo.execute();
701
702 System.setProperty( "java.home", oldJreHome );
703 }
704
705
706
707
708
709
710 public void testJavadocResources()
711 throws Exception
712 {
713 File testPom = new File( unit, "resources-test/resources-test-plugin-config.xml" );
714 JavadocReport mojo = lookupMojo( testPom );
715 mojo.execute();
716
717 File apidocs = new File( getBasedir(), "target/test/unit/resources-test/target/site/apidocs/" );
718
719 File app = new File( apidocs, "resources/test/App.html" );
720 assertTrue( app.exists() );
721 String content = readFile( app );
722 assertTrue( content.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\">" ) );
723 assertTrue( new File( apidocs, "resources/test/doc-files/maven-feather.png" ).exists() );
724
725 File app2 = new File( apidocs, "resources/test2/App2.html" );
726 assertTrue( app2.exists() );
727 content = readFile( app2 );
728 assertTrue( content.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\">" ) );
729 assertFalse( new File( apidocs, "resources/test2/doc-files/maven-feather.png" ).exists() );
730
731
732 testPom = new File( unit, "resources-with-excludes-test/resources-with-excludes-test-plugin-config.xml" );
733 mojo = lookupMojo( testPom );
734 mojo.execute();
735
736 apidocs = new File( getBasedir(), "target/test/unit/resources-with-excludes-test/target/site/apidocs" );
737
738 app = new File( apidocs, "resources/test/App.html" );
739 assertTrue( app.exists() );
740 content = readFile( app );
741 assertTrue( content.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\">" ) );
742
743 JavaVersion javadocVersion = (JavaVersion) getVariableValueFromObject( mojo, "javadocRuntimeVersion" );
744 if( javadocVersion.isAtLeast( "1.8" ) && javadocVersion.isBefore( "13" ) )
745 {
746
747 assertTrue( "Javadoc runtime version: " + javadocVersion
748 + "\nThis bug appeared in JDK8 and was planned to be fixed in JDK9, see JDK-8032205",
749 new File( apidocs, "resources/test/doc-files/maven-feather.png" ).exists() );
750 }
751 else
752 {
753 assertFalse( new File( apidocs, "resources/test/doc-files/maven-feather.png" ).exists() );
754 }
755 assertTrue( new File( apidocs, "resources/test2/doc-files/maven-feather.png" ).exists() );
756
757 app2 = new File( apidocs, "resources/test2/App2.html" );
758 assertTrue( app2.exists() );
759 content = readFile( app2 );
760 assertTrue( content.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\">" ) );
761 assertTrue( new File( apidocs, "resources/test2/doc-files/maven-feather.png" ).exists() );
762 }
763
764
765
766
767
768
769 public void testPom()
770 throws Exception
771 {
772 File testPom = new File( unit, "pom-test/pom-test-plugin-config.xml" );
773 JavadocReport mojo = lookupMojo( testPom );
774 mojo.execute();
775
776 assertFalse( new File( getBasedir(), "target/test/unit/pom-test/target/site" ).exists() );
777 }
778
779
780
781
782
783
784 public void testTag()
785 throws Exception
786 {
787 File testPom = new File( unit, "tag-test/tag-test-plugin-config.xml" );
788 JavadocReport mojo = lookupMojo( testPom );
789 mojo.execute();
790
791 File app = new File( getBasedir(), "target/test/unit/tag-test/target/site/apidocs/tag/test/App.html" );
792 assertTrue( FileUtils.fileExists( app.getAbsolutePath() ) );
793 String readed = readFile( app );
794 assertTrue( readed.contains( ">To do something:</" ) );
795 assertTrue( readed.contains( ">Generator Class:</" ) );
796
797
798
799 if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore( "11" ) )
800 {
801 assertTrue( readed.contains( ">Version:</" ) );
802 assertTrue( readed.toLowerCase().contains( "</dt>" + LINE_SEPARATOR + " <dd>1.0</dd>" )
803 || readed.toLowerCase().contains( "</dt>" + LINE_SEPARATOR + "<dd>1.0</dd>" ) );
804 }
805 }
806
807
808
809
810
811
812 public void testHeaderFooter()
813 throws Exception
814 {
815 File testPom = new File( unit, "header-footer-test/header-footer-test-plugin-config.xml" );
816 JavadocReport mojo = lookupMojo( testPom );
817 try
818 {
819 mojo.execute();
820 }
821 catch ( MojoExecutionException e )
822 {
823 fail( "Doesnt handle correctly newline for header or footer parameter" );
824 }
825
826 assertTrue( true );
827 }
828
829
830
831
832
833
834 public void testNewline()
835 throws Exception
836 {
837 File testPom = new File( unit, "newline-test/newline-test-plugin-config.xml" );
838 JavadocReport mojo = lookupMojo( testPom );
839 try
840 {
841 mojo.execute();
842 }
843 catch ( MojoExecutionException e )
844 {
845 fail( "Doesn't handle correctly newline for string parameters. See options and packages files." );
846 }
847
848 assertTrue( true );
849 }
850
851
852
853
854
855
856 public void testJdk6()
857 throws Exception
858 {
859
860
861 if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "12" ) )
862 {
863 return;
864 }
865
866 File testPom = new File( unit, "jdk6-test/jdk6-test-plugin-config.xml" );
867 JavadocReport mojo = lookupMojo( testPom );
868 mojo.execute();
869
870 File apidocs = new File( getBasedir(), "target/test/unit/jdk6-test/target/site/apidocs" );
871 assertTrue( new File( apidocs, "index.html" ).exists() );
872
873 File overview;
874 if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore( "11" ) )
875 {
876 overview = new File( apidocs, "overview-summary.html" );
877 }
878 else
879 {
880 overview = new File( apidocs, "index.html" );
881 }
882
883 assertTrue( overview.exists() );
884 String content = readFile( overview );
885 assertTrue( content.contains( "Top - Copyright © All rights reserved." ) );
886 assertTrue( content.contains( "Header - Copyright © All rights reserved." ) );
887 assertTrue( content.contains( "Footer - Copyright © All rights reserved." ) );
888
889 File packageSummary = new File( apidocs, "jdk6/test/package-summary.html" );
890 assertTrue( packageSummary.exists() );
891 content = readFile( packageSummary );
892 assertTrue( content.contains( "Top - Copyright © All rights reserved." ) );
893 assertTrue( content.contains( "Header - Copyright © All rights reserved." ) );
894 assertTrue( content.contains( "Footer - Copyright © All rights reserved." ) );
895 }
896
897
898
899
900
901
902 public void testProxy()
903 throws Exception
904 {
905 Settings settings = new Settings();
906 Proxy proxy = new Proxy();
907
908
909 proxy.setActive( true );
910 proxy.setHost( "127.0.0.1" );
911 proxy.setPort( 80 );
912 proxy.setProtocol( "http" );
913 proxy.setUsername( "toto" );
914 proxy.setPassword( "toto" );
915 proxy.setNonProxyHosts( "www.google.com|*.somewhere.com" );
916 settings.addProxy( proxy );
917
918 File testPom = new File( getBasedir(), "src/test/resources/unit/proxy-test/proxy-test-plugin-config.xml" );
919 JavadocReport mojo = lookupMojo( testPom );
920
921 MavenSession session = spy( newMavenSession( mojo.project ) );
922 ProjectBuildingRequest buildingRequest = mock( ProjectBuildingRequest.class );
923 when( buildingRequest.getRemoteRepositories() ).thenReturn( mojo.project.getRemoteArtifactRepositories() );
924 when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest );
925 MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
926 repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepo ) );
927 when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession );
928 when( session.getRepositorySession() ).thenReturn( repositorySession );
929 LegacySupport legacySupport = lookup( LegacySupport.class );
930 legacySupport.setSession( session );
931
932 setVariableValueToObject( mojo, "settings", settings );
933 setVariableValueToObject( mojo, "session", session );
934 mojo.execute();
935
936 File commandLine = new File( getBasedir(), "target/test/unit/proxy-test/target/site/apidocs/javadoc." + ( SystemUtils.IS_OS_WINDOWS ? "bat" : "sh" ) );
937 assertTrue( FileUtils.fileExists( commandLine.getAbsolutePath() ) );
938 String readed = readFile( commandLine );
939 assertTrue( readed.contains( "-J-Dhttp.proxyHost=127.0.0.1" ) );
940 assertTrue( readed.contains( "-J-Dhttp.proxyPort=80" ) );
941 assertTrue( readed.contains( "-J-Dhttp.nonProxyHosts=\\\"www.google.com^|*.somewhere.com\\\"" ) );
942
943 File options = new File( getBasedir(), "target/test/unit/proxy-test/target/site/apidocs/options" );
944 assertTrue( FileUtils.fileExists( options.getAbsolutePath() ) );
945 String optionsContent = readFile( options );
946
947 assertFalse( optionsContent.contains( "-link" ) );
948
949
950 ProxyServer proxyServer = null;
951 AuthAsyncProxyServlet proxyServlet;
952 try
953 {
954 proxyServlet = new AuthAsyncProxyServlet();
955 proxyServer = new ProxyServer( proxyServlet );
956 proxyServer.start();
957
958 settings = new Settings();
959 proxy = new Proxy();
960 proxy.setActive( true );
961 proxy.setHost( proxyServer.getHostName() );
962 proxy.setPort( proxyServer.getPort() );
963 proxy.setProtocol( "http" );
964 settings.addProxy( proxy );
965
966 mojo = lookupMojo( testPom );
967 setVariableValueToObject( mojo, "settings", settings );
968 setVariableValueToObject( mojo, "session", session );
969 mojo.execute();
970 readed = readFile( commandLine );
971 assertTrue( readed.contains( "-J-Dhttp.proxyHost=" + proxyServer.getHostName() ) );
972 assertTrue( readed.contains( "-J-Dhttp.proxyPort=" + proxyServer.getPort() ) );
973
974 optionsContent = readFile( options );
975
976
977
978
979
980
981
982
983
984
985 }
986 finally
987 {
988 if ( proxyServer != null )
989 {
990 proxyServer.stop();
991 }
992 }
993
994
995 Map<String, String> authentications = new HashMap<>();
996 authentications.put( "foo", "bar" );
997 try
998 {
999 proxyServlet = new AuthAsyncProxyServlet( authentications );
1000 proxyServer = new ProxyServer( proxyServlet );
1001 proxyServer.start();
1002
1003 settings = new Settings();
1004 proxy = new Proxy();
1005 proxy.setActive( true );
1006 proxy.setHost( proxyServer.getHostName() );
1007 proxy.setPort( proxyServer.getPort() );
1008 proxy.setProtocol( "http" );
1009 proxy.setUsername( "foo" );
1010 proxy.setPassword( "bar" );
1011 settings.addProxy( proxy );
1012
1013 mojo = lookupMojo( testPom );
1014 setVariableValueToObject( mojo, "settings", settings );
1015 setVariableValueToObject( mojo, "session", session );
1016 mojo.execute();
1017 readed = readFile( commandLine );
1018 assertTrue( readed.contains( "-J-Dhttp.proxyHost=" + proxyServer.getHostName() ) );
1019 assertTrue( readed.contains( "-J-Dhttp.proxyPort=" + proxyServer.getPort() ) );
1020
1021 optionsContent = readFile( options );
1022
1023
1024
1025 }
1026 finally
1027 {
1028 if ( proxyServer != null )
1029 {
1030 proxyServer.stop();
1031 }
1032 }
1033 }
1034
1035
1036
1037
1038
1039
1040 public void testValidateOptions()
1041 throws Exception
1042 {
1043
1044 File testPom = new File( unit, "validate-options-test/wrong-encoding-test-plugin-config.xml" );
1045 JavadocReport mojo = lookupMojo( testPom );
1046 try
1047 {
1048 mojo.execute();
1049 fail( "No wrong encoding catch" );
1050 }
1051 catch ( MojoExecutionException e )
1052 {
1053 assertTrue( "No wrong encoding catch", e.getMessage().contains( "Unsupported option <encoding/>" ) );
1054 }
1055 testPom = new File( unit, "validate-options-test/wrong-docencoding-test-plugin-config.xml" );
1056 mojo = lookupMojo( testPom );
1057 try
1058 {
1059 mojo.execute();
1060 fail( "No wrong docencoding catch" );
1061 }
1062 catch ( MojoExecutionException e )
1063 {
1064 assertTrue( "No wrong docencoding catch", e.getMessage().contains( "Unsupported option <docencoding/>" ) );
1065 }
1066 testPom = new File( unit, "validate-options-test/wrong-charset-test-plugin-config.xml" );
1067 mojo = lookupMojo( testPom );
1068 try
1069 {
1070 mojo.execute();
1071 fail( "No wrong charset catch" );
1072 }
1073 catch ( MojoExecutionException e )
1074 {
1075 assertTrue( "No wrong charset catch", e.getMessage().contains( "Unsupported option <charset/>" ) );
1076 }
1077
1078
1079 testPom = new File( unit, "validate-options-test/wrong-locale-test-plugin-config.xml" );
1080 mojo = lookupMojo( testPom );
1081 try
1082 {
1083 mojo.execute();
1084 fail( "No wrong locale catch" );
1085 }
1086 catch ( MojoExecutionException e )
1087 {
1088 assertTrue( "No wrong locale catch", e.getMessage().contains( "Unsupported option <locale/>" ) );
1089 }
1090 testPom = new File( unit, "validate-options-test/wrong-locale-with-variant-test-plugin-config.xml" );
1091 mojo = lookupMojo( testPom );
1092 mojo.execute();
1093 assertTrue( "No wrong locale catch", true );
1094
1095
1096 testPom = new File( unit, "validate-options-test/conflict-options-test-plugin-config.xml" );
1097 mojo = lookupMojo( testPom );
1098 try
1099 {
1100 mojo.execute();
1101 fail( "No conflict catch" );
1102 }
1103 catch ( MojoExecutionException e )
1104 {
1105 assertTrue( "No conflict catch", e.getMessage().contains( "Option <nohelp/> conflicts with <helpfile/>" ) );
1106 }
1107 }
1108
1109
1110
1111
1112
1113
1114 public void testTagletArtifacts()
1115 throws Exception
1116 {
1117
1118
1119 if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "10" ) )
1120 {
1121 return;
1122 }
1123
1124 File testPom = new File( unit, "tagletArtifacts-test/tagletArtifacts-test-plugin-config.xml" );
1125 JavadocReport mojo = lookupMojo( testPom );
1126
1127 MavenSession session = spy( newMavenSession( mojo.project ) );
1128 ProjectBuildingRequest buildingRequest = mock( ProjectBuildingRequest.class );
1129 when( buildingRequest.getRemoteRepositories() ).thenReturn( mojo.project.getRemoteArtifactRepositories() );
1130 when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest );
1131 MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
1132 repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepo ) );
1133 when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession );
1134 when( session.getRepositorySession() ).thenReturn( repositorySession );
1135 LegacySupport legacySupport = lookup( LegacySupport.class );
1136 legacySupport.setSession( session );
1137 setVariableValueToObject( mojo, "session", session );
1138
1139 mojo.execute();
1140
1141 File optionsFile = new File( mojo.getOutputDirectory(), "options" );
1142 assertTrue( optionsFile.exists() );
1143 String options = readFile( optionsFile );
1144
1145 assertEquals( 20, StringUtils.countMatches( options, LINE_SEPARATOR + "-taglet" + LINE_SEPARATOR ) );
1146 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoAggregatorTypeTaglet" ) );
1147 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoComponentFieldTaglet" ) );
1148 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoConfiguratorTypeTaglet" ) );
1149 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoExecuteTypeTaglet" ) );
1150 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoExecutionStrategyTypeTaglet" ) );
1151 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoGoalTypeTaglet" ) );
1152 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoInheritByDefaultTypeTaglet" ) );
1153 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoInstantiationStrategyTypeTaglet" ) );
1154 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoParameterFieldTaglet" ) );
1155 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoPhaseTypeTaglet" ) );
1156 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoReadOnlyFieldTaglet" ) );
1157 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoRequiredFieldTaglet" ) );
1158 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoRequiresDependencyResolutionTypeTaglet" ) );
1159 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoRequiresDirectInvocationTypeTaglet" ) );
1160 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoRequiresOnLineTypeTaglet" ) );
1161 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoRequiresProjectTypeTaglet" ) );
1162 assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoRequiresReportsTypeTaglet" ) );
1163 assertTrue( options.contains( "org.codehaus.plexus.javadoc.PlexusConfigurationTaglet" ) );
1164 assertTrue( options.contains( "org.codehaus.plexus.javadoc.PlexusRequirementTaglet" ) );
1165 assertTrue( options.contains( "org.codehaus.plexus.javadoc.PlexusComponentTaglet" ) );
1166 }
1167
1168
1169
1170
1171
1172
1173 public void testStylesheetfile()
1174 throws Exception
1175 {
1176 File testPom = new File( unit, "stylesheetfile-test/pom.xml" );
1177
1178 JavadocReport mojo = lookupMojo( testPom );
1179 assertNotNull( mojo );
1180
1181 MavenSession session = spy( newMavenSession( mojo.project ) );
1182 ProjectBuildingRequest buildingRequest = mock( ProjectBuildingRequest.class );
1183 when( buildingRequest.getRemoteRepositories() ).thenReturn( mojo.project.getRemoteArtifactRepositories() );
1184 when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest );
1185 MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
1186 repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepo ) );
1187 when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession );
1188 when( session.getRepositorySession() ).thenReturn( repositorySession );
1189 LegacySupport legacySupport = lookup( LegacySupport.class );
1190 legacySupport.setSession( session );
1191 setVariableValueToObject( mojo, "session", session );
1192
1193 File apidocs = new File( getBasedir(), "target/test/unit/stylesheetfile-test/target/site/apidocs" );
1194
1195 File stylesheetfile = new File( apidocs, "stylesheet.css" );
1196 File options = new File( apidocs, "options" );
1197
1198
1199 setVariableValueToObject( mojo, "stylesheet", "javamaven" );
1200
1201 try
1202 {
1203 mojo.execute();
1204 fail();
1205 }
1206 catch ( Exception e )
1207 {
1208 assertTrue( true );
1209 }
1210
1211
1212 setVariableValueToObject( mojo, "stylesheet", "java" );
1213 mojo.execute();
1214
1215 String content = readFile( stylesheetfile );
1216 if ( JavaVersion.JAVA_VERSION.isAtLeast( "10" ) )
1217 {
1218 assertTrue( content.contains( "/* " + LINE_SEPARATOR
1219 + " * Javadoc style sheet" + LINE_SEPARATOR
1220 + " */" ) );
1221 }
1222 else
1223 {
1224 assertTrue( content.contains( "/* Javadoc style sheet */" ) );
1225 }
1226
1227 String optionsContent = readFile( options );
1228 assertFalse( optionsContent.contains( "-stylesheetfile" ) );
1229
1230
1231 setVariableValueToObject( mojo, "stylesheet", "maven" );
1232 mojo.execute();
1233
1234 content = readFile( stylesheetfile );
1235 assertTrue( content.contains( "/* Javadoc style sheet */" )
1236 && content.contains( "Licensed to the Apache Software Foundation (ASF) under one" ) );
1237
1238 optionsContent = readFile( options );
1239 assertTrue( optionsContent.contains( "-stylesheetfile" ) );
1240 assertTrue( optionsContent.contains( "'" + stylesheetfile.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
1241
1242
1243 setVariableValueToObject( mojo, "stylesheet", null );
1244 setVariableValueToObject( mojo, "stylesheetfile", "com/mycompany/app/javadoc/css/stylesheet.css" );
1245 mojo.execute();
1246
1247 content = readFile( stylesheetfile );
1248 assertTrue( content.contains( "/* Custom Javadoc style sheet in project */" ) );
1249
1250 optionsContent = readFile( options );
1251 assertTrue( optionsContent.contains( "-stylesheetfile" ) );
1252 File stylesheetResource =
1253 new File( unit, "stylesheetfile-test/src/main/resources/com/mycompany/app/javadoc/css/stylesheet.css" );
1254 assertTrue( optionsContent.contains( "'" + stylesheetResource.getAbsolutePath().replaceAll( "\\\\", "/" )
1255 + "'" ) );
1256
1257
1258 setVariableValueToObject( mojo, "stylesheetfile", "com/mycompany/app/javadoc/css2/stylesheet.css" );
1259 mojo.execute();
1260
1261 content = readFile( stylesheetfile );
1262 assertTrue( content.contains( "/* Custom Javadoc style sheet in artefact */" ) );
1263
1264 optionsContent = readFile( options );
1265 assertTrue( optionsContent.contains( "-stylesheetfile" ) );
1266 assertTrue( optionsContent.contains( "'" + stylesheetfile.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
1267
1268
1269 File css =
1270 new File( unit, "stylesheetfile-test/src/main/resources/com/mycompany/app/javadoc/css3/stylesheet.css" );
1271 setVariableValueToObject( mojo, "stylesheetfile", css.getAbsolutePath() );
1272 mojo.execute();
1273
1274 content = readFile( stylesheetfile );
1275 assertTrue( content.contains( "/* Custom Javadoc style sheet as file */" ) );
1276
1277 optionsContent = readFile( options );
1278 assertTrue( optionsContent.contains( "-stylesheetfile" ) );
1279 stylesheetResource =
1280 new File( unit, "stylesheetfile-test/src/main/resources/com/mycompany/app/javadoc/css3/stylesheet.css" );
1281 assertTrue( optionsContent.contains( "'" + stylesheetResource.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
1282 }
1283
1284
1285
1286
1287
1288
1289 public void testHelpfile()
1290 throws Exception
1291 {
1292 File testPom = new File( unit, "helpfile-test/pom.xml" );
1293
1294 JavadocReport mojo = lookupMojo( testPom );
1295 assertNotNull( mojo );
1296
1297 MavenSession session = spy( newMavenSession( mojo.project ) );
1298 ProjectBuildingRequest buildingRequest = mock( ProjectBuildingRequest.class );
1299 when( buildingRequest.getRemoteRepositories() ).thenReturn( mojo.project.getRemoteArtifactRepositories() );
1300 when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest );
1301 MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
1302 repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepo ) );
1303 when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession );
1304 when( session.getRepositorySession() ).thenReturn( repositorySession );
1305 LegacySupport legacySupport = lookup( LegacySupport.class );
1306 legacySupport.setSession( session );
1307 setVariableValueToObject( mojo, "session", session );
1308
1309 File apidocs = new File( getBasedir(), "target/test/unit/helpfile-test/target/site/apidocs" );
1310
1311 File helpfile = new File( apidocs, "help-doc.html" );
1312 File options = new File( apidocs, "options" );
1313
1314
1315 mojo.execute();
1316
1317 String content = readFile( helpfile );
1318 assertTrue( content.contains( "<!-- Generated by javadoc" ) );
1319
1320 String optionsContent = readFile( options );
1321 assertFalse( optionsContent.contains( "-helpfile" ) );
1322
1323
1324 setVariableValueToObject( mojo, "helpfile", "com/mycompany/app/javadoc/helpfile/help-doc.html" );
1325
1326 setVariableValueToObject( mojo, "session", session );
1327
1328 mojo.execute();
1329
1330 content = readFile( helpfile );
1331 assertTrue( content.contains( "<!-- Help file from artefact -->" ) );
1332
1333 optionsContent = readFile( options );
1334 assertTrue( optionsContent.contains( "-helpfile" ) );
1335 File help = new File( apidocs, "help-doc.html" );
1336 assertTrue( optionsContent.contains( "'" + help.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
1337
1338
1339 setVariableValueToObject( mojo, "helpfile", "com/mycompany/app/javadoc/helpfile2/help-doc.html" );
1340 mojo.execute();
1341
1342 content = readFile( helpfile );
1343 assertTrue( content.contains( "<!-- Help file from file -->" ) );
1344
1345 optionsContent = readFile( options );
1346 assertTrue( optionsContent.contains( "-helpfile" ) );
1347 help = new File( unit, "helpfile-test/src/main/resources/com/mycompany/app/javadoc/helpfile2/help-doc.html" );
1348 assertTrue( optionsContent.contains( "'" + help.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
1349
1350
1351 help = new File( unit, "helpfile-test/src/main/resources/com/mycompany/app/javadoc/helpfile2/help-doc.html" );
1352 setVariableValueToObject( mojo, "helpfile", help.getAbsolutePath() );
1353 mojo.execute();
1354
1355 content = readFile( helpfile );
1356 assertTrue( content.contains( "<!-- Help file from file -->" ) );
1357
1358 optionsContent = readFile( options );
1359 assertTrue( optionsContent.contains( "-helpfile" ) );
1360 assertTrue( optionsContent.contains( "'" + help.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
1361 }
1362 }