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