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