View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugins.javadoc;
20  
21  import javax.servlet.ServletException;
22  import javax.servlet.http.HttpServletRequest;
23  import javax.servlet.http.HttpServletResponse;
24  
25  import java.io.File;
26  import java.io.FileNotFoundException;
27  import java.io.IOException;
28  import java.io.OutputStream;
29  import java.net.SocketTimeoutException;
30  import java.net.URI;
31  import java.net.URL;
32  import java.nio.file.Path;
33  import java.nio.file.Paths;
34  import java.util.ArrayList;
35  import java.util.Collection;
36  import java.util.Collections;
37  import java.util.HashMap;
38  import java.util.List;
39  import java.util.Map;
40  import java.util.Set;
41  import java.util.regex.PatternSyntaxException;
42  
43  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
44  import org.apache.maven.plugins.javadoc.ProxyServer.AuthAsyncProxyServlet;
45  import org.apache.maven.settings.Proxy;
46  import org.apache.maven.settings.Settings;
47  import org.codehaus.plexus.PlexusTestCase;
48  import org.codehaus.plexus.util.FileUtils;
49  import org.eclipse.jetty.server.Request;
50  import org.eclipse.jetty.server.Server;
51  import org.eclipse.jetty.server.ServerConnector;
52  import org.eclipse.jetty.server.handler.AbstractHandler;
53  import org.eclipse.jetty.server.handler.MovedContextHandler;
54  import org.eclipse.jetty.util.ByteArrayISO8859Writer;
55  
56  import static org.assertj.core.api.Assertions.assertThat;
57  
58  /**
59   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
60   */
61  public class JavadocUtilTest extends PlexusTestCase {
62      /**
63       * Method to test the javadoc version parsing.
64       *
65       */
66      public void testParseJavadocVersion() {
67          String version = null;
68          try {
69              JavadocUtil.extractJavadocVersion(version);
70              fail("Not catch null");
71          } catch (IllegalArgumentException e) {
72              assertTrue(true);
73          }
74  
75          // Sun JDK 1.4
76          version = "java full version \"1.4.2_12-b03\"";
77          assertEquals("1.4.2", JavadocUtil.extractJavadocVersion(version));
78  
79          // Sun JDK 1.5
80          version = "java full version \"1.5.0_07-164\"";
81          assertEquals("1.5.0", JavadocUtil.extractJavadocVersion(version));
82  
83          // IBM JDK 1.4
84          version = "java full version \"J2RE 1.4.2 IBM Windows 32 build cn1420-20040626\"";
85          assertEquals("1.4.2", JavadocUtil.extractJavadocVersion(version));
86  
87          // IBM JDK 1.5
88          version = "javadoc version compl├Ęte de \"J2RE 1.5.0 IBM Windows 32 build pwi32pdev-20070426a\"";
89          assertEquals("1.5.0", JavadocUtil.extractJavadocVersion(version));
90  
91          // IBM JDK 1.5
92          version =
93                  "J2RE 1.5.0 IBM Windows 32 build pwi32devifx-20070323 (ifix 117674: SR4 + 116644 + 114941 + 116110 + 114881)";
94          assertEquals("1.5.0", JavadocUtil.extractJavadocVersion(version));
95  
96          // FreeBSD
97          version = "java full version \"diablo-1.5.0-b01\"";
98          assertEquals("1.5.0", JavadocUtil.extractJavadocVersion(version));
99  
100         // BEA
101         version = "java full version \"1.5.0_11-b03\"";
102         assertEquals("1.5.0", JavadocUtil.extractJavadocVersion(version));
103 
104         // Other tests
105         version = "java full version \"1.5.0_07-164\"" + System.getProperty("line.separator");
106         assertEquals("1.5.0", JavadocUtil.extractJavadocVersion(version));
107 
108         version = System.getProperty("line.separator") + "java full version \"1.5.0_07-164\"";
109         assertEquals("1.5.0", JavadocUtil.extractJavadocVersion(version));
110 
111         version = System.getProperty("line.separator") + "java full version \"1.5.0_07-164\""
112                 + System.getProperty("line.separator");
113         assertEquals("1.5.0", JavadocUtil.extractJavadocVersion(version));
114 
115         version = "java full" + System.getProperty("line.separator") + " version \"1.5.0_07-164\"";
116         assertEquals("1.5.0", JavadocUtil.extractJavadocVersion(version));
117 
118         version = "java full version \"1.99.123-b01\"";
119         assertEquals("1.99.123", JavadocUtil.extractJavadocVersion(version));
120 
121         version = "java full version \"1.5.0.07-164\"";
122         assertEquals("1.5.0", JavadocUtil.extractJavadocVersion(version));
123 
124         version = "java full version \"1.4\"";
125         assertEquals("1.4", JavadocUtil.extractJavadocVersion(version));
126 
127         version = "java full version \"1.A.B_07-164\"";
128         try {
129             JavadocUtil.extractJavadocVersion(version);
130             // does not fail since JEP 223 support addition
131             // assertTrue( "Not catch wrong pattern", false );
132         } catch (PatternSyntaxException e) {
133             assertTrue(true);
134         }
135 
136         version = "SCO-UNIX-J2SE-1.5.0_09*FCS-UW714-OSR6*_20061114";
137         assertEquals("1.5.0", JavadocUtil.extractJavadocVersion(version));
138 
139         // Java 9 EA
140         version = "java full version \"9-ea+113\"";
141         assertEquals("9", JavadocUtil.extractJavadocVersion(version));
142 
143         // Java 9 EA Jigsaw
144         version = "java full version \"9-ea+113-2016-04-14-161743.javare.4852.nc\"";
145         assertEquals("9", JavadocUtil.extractJavadocVersion(version));
146 
147         version = "java version \"9-ea\"";
148         assertEquals("9", JavadocUtil.extractJavadocVersion(version));
149 
150         // JEP 223 example for future versions
151         version = "java full version \"9+100\"";
152         assertEquals("9", JavadocUtil.extractJavadocVersion(version));
153 
154         version = "java full version \"9.0.1+20\"";
155         assertEquals("9.0.1", JavadocUtil.extractJavadocVersion(version));
156 
157         version = "java full version \"10+100\"";
158         assertEquals("10", JavadocUtil.extractJavadocVersion(version));
159 
160         version = "java full version \"10.0.1+20\"";
161         assertEquals("10.0.1", JavadocUtil.extractJavadocVersion(version));
162     }
163 
164     /**
165      * Method to test the javadoc memory parsing.
166      *
167      */
168     public void testParseJavadocMemory() {
169         String memory = null;
170         try {
171             JavadocUtil.parseJavadocMemory(memory);
172             fail("Not catch null");
173         } catch (IllegalArgumentException e) {
174             assertTrue(true);
175         }
176 
177         memory = "128";
178         assertEquals(JavadocUtil.parseJavadocMemory(memory), "128m");
179 
180         memory = "128k";
181         assertEquals(JavadocUtil.parseJavadocMemory(memory), "128k");
182         memory = "128kb";
183         assertEquals(JavadocUtil.parseJavadocMemory(memory), "128k");
184 
185         memory = "128m";
186         assertEquals(JavadocUtil.parseJavadocMemory(memory), "128m");
187         memory = "128mb";
188         assertEquals(JavadocUtil.parseJavadocMemory(memory), "128m");
189 
190         memory = "1g";
191         assertEquals(JavadocUtil.parseJavadocMemory(memory), "1024m");
192         memory = "1gb";
193         assertEquals(JavadocUtil.parseJavadocMemory(memory), "1024m");
194 
195         memory = "1t";
196         assertEquals(JavadocUtil.parseJavadocMemory(memory), "1048576m");
197         memory = "1tb";
198         assertEquals(JavadocUtil.parseJavadocMemory(memory), "1048576m");
199 
200         memory = System.getProperty("line.separator") + "128m";
201         assertEquals(JavadocUtil.parseJavadocMemory(memory), "128m");
202         memory = System.getProperty("line.separator") + "128m" + System.getProperty("line.separator");
203         assertEquals(JavadocUtil.parseJavadocMemory(memory), "128m");
204 
205         memory = "     128m";
206         assertEquals(JavadocUtil.parseJavadocMemory(memory), "128m");
207         memory = "     128m     ";
208         assertEquals(JavadocUtil.parseJavadocMemory(memory), "128m");
209 
210         memory = "1m28m";
211         try {
212             JavadocUtil.parseJavadocMemory(memory);
213             fail("Not catch wrong pattern");
214         } catch (IllegalArgumentException e) {
215             assertTrue(true);
216         }
217         memory = "ABC128m";
218         try {
219             JavadocUtil.parseJavadocMemory(memory);
220             fail("Not catch wrong pattern");
221         } catch (IllegalArgumentException e) {
222             assertTrue(true);
223         }
224     }
225 
226     /**
227      * Method to test the validate encoding parsing.
228      *
229      */
230     public void testValidateEncoding() {
231         assertFalse("Not catch null", JavadocUtil.validateEncoding(null));
232         assertTrue("UTF-8 not supported on this plateform", JavadocUtil.validateEncoding("UTF-8"));
233         assertTrue("ISO-8859-1 not supported on this plateform", JavadocUtil.validateEncoding("ISO-8859-1"));
234         assertFalse("latin is supported on this plateform???", JavadocUtil.validateEncoding("latin"));
235         assertFalse("WRONG is supported on this plateform???", JavadocUtil.validateEncoding("WRONG"));
236     }
237 
238     /**
239      * Method to test isValidPackageList()
240      *
241      * @throws Exception if any
242      */
243     public void testIsValidPackageList() throws Exception {
244         Settings settings = null;
245         Proxy proxy;
246 
247         URL url = null;
248         URL wrongUrl;
249         try {
250             JavadocUtil.isValidPackageList(url, settings, false);
251             fail();
252         } catch (IllegalArgumentException e) {
253             assertTrue(true);
254         }
255 
256         url = new File(getBasedir(), "/pom.xml").toURI().toURL();
257         assertTrue(JavadocUtil.isValidPackageList(url, settings, false));
258 
259         try {
260             assertFalse(JavadocUtil.isValidPackageList(url, settings, true));
261         } catch (IOException e) {
262             assertTrue(true);
263         }
264 
265         url = this.getClass()
266                 .getResource("/JavadocUtilTest-package-list.txt")
267                 .toURI()
268                 .toURL();
269         assertTrue(JavadocUtil.isValidPackageList(url, settings, true));
270 
271         url = new URL("http://maven.apache.org/plugins-archives/maven-javadoc-plugin-3.5.0/apidocs/package-list");
272         assertTrue(JavadocUtil.isValidPackageList(url, settings, true));
273 
274         wrongUrl = new URL("http://maven.apache.org/plugins/maven-javadoc-plugin/apidocs/package-list2");
275         try {
276             JavadocUtil.isValidPackageList(wrongUrl, settings, false);
277             fail();
278         } catch (IOException e) {
279             assertTrue(true);
280         }
281 
282         // real proxy
283         ProxyServer proxyServer = null;
284         AuthAsyncProxyServlet proxyServlet;
285         try {
286             proxyServlet = new AuthAsyncProxyServlet();
287             proxyServer = new ProxyServer(proxyServlet);
288             proxyServer.start();
289 
290             settings = new Settings();
291 
292             assertTrue(JavadocUtil.isValidPackageList(url, settings, true));
293 
294             try {
295                 JavadocUtil.isValidPackageList(wrongUrl, settings, false);
296                 fail();
297             } catch (IOException e) {
298                 assertTrue(true);
299             }
300         } finally {
301             if (proxyServer != null) {
302                 proxyServer.stop();
303             }
304         }
305 
306         Map<String, String> authentications = new HashMap<>();
307         authentications.put("foo", "bar");
308         // wrong auth
309         try {
310             proxyServlet = new AuthAsyncProxyServlet(authentications);
311             proxyServer = new ProxyServer(proxyServlet);
312             proxyServer.start();
313 
314             settings = new Settings();
315             proxy = new Proxy();
316             proxy.setActive(true);
317             proxy.setHost(proxyServer.getHostName());
318             proxy.setPort(proxyServer.getPort());
319             proxy.setProtocol("http");
320             settings.addProxy(proxy);
321 
322             JavadocUtil.isValidPackageList(url, settings, false);
323             fail();
324         } catch (FileNotFoundException e) {
325             assertTrue(true);
326         } finally {
327             proxyServer.stop();
328         }
329 
330         // auth proxy
331         try {
332             proxyServlet = new AuthAsyncProxyServlet(authentications);
333             proxyServer = new ProxyServer(proxyServlet);
334             proxyServer.start();
335 
336             settings = new Settings();
337             proxy = new Proxy();
338             proxy.setActive(true);
339             proxy.setHost(proxyServer.getHostName());
340             proxy.setPort(proxyServer.getPort());
341             proxy.setProtocol("http");
342             proxy.setUsername("foo");
343             proxy.setPassword("bar");
344             settings.addProxy(proxy);
345 
346             assertTrue(JavadocUtil.isValidPackageList(url, settings, true));
347 
348             try {
349                 JavadocUtil.isValidPackageList(wrongUrl, settings, false);
350                 fail();
351             } catch (IOException e) {
352                 assertTrue(true);
353             }
354         } finally {
355             proxyServer.stop();
356         }
357 
358         // timeout
359         try {
360             proxyServlet = new AuthAsyncProxyServlet(authentications, 3000); // more than 2000, see fetchURL
361             proxyServer = new ProxyServer(proxyServlet);
362             proxyServer.start();
363 
364             settings = new Settings();
365             proxy = new Proxy();
366             proxy.setActive(true);
367             proxy.setHost(proxyServer.getHostName());
368             proxy.setPort(proxyServer.getPort());
369             proxy.setProtocol("http");
370             proxy.setUsername("foo");
371             proxy.setPassword("bar");
372             settings.addProxy(proxy);
373 
374             JavadocUtil.isValidPackageList(url, settings, true);
375             fail();
376         } catch (SocketTimeoutException e) {
377             assertTrue(true);
378         } finally {
379             proxyServer.stop();
380         }
381 
382         // nonProxyHosts
383         try {
384             proxyServlet = new AuthAsyncProxyServlet(authentications);
385             proxyServer = new ProxyServer(proxyServlet);
386             proxyServer.start();
387 
388             settings = new Settings();
389             proxy = new Proxy();
390             proxy.setActive(true);
391             proxy.setHost(proxyServer.getHostName());
392             proxy.setPort(proxyServer.getPort());
393             proxy.setProtocol("http");
394             proxy.setUsername("foo");
395             proxy.setPassword("bar");
396             proxy.setNonProxyHosts("maven.apache.org");
397             settings.addProxy(proxy);
398 
399             assertTrue(JavadocUtil.isValidPackageList(url, settings, true));
400         } finally {
401             proxyServer.stop();
402         }
403     }
404 
405     public void testGetRedirectUrlNotHttp() throws Exception {
406         URL url = new URI("ftp://some.where").toURL();
407         assertEquals(
408                 url.toString(), JavadocUtil.getRedirectUrl(url, new Settings()).toString());
409 
410         url = new URI("file://some/where").toURL();
411         assertEquals(
412                 url.toString(), JavadocUtil.getRedirectUrl(url, new Settings()).toString());
413     }
414 
415     /**
416      * Tests a redirect from localhost:port1 to localhost:port2
417      */
418     public void testGetRedirectUrl() throws Exception {
419         Server server = null, redirectServer = null;
420         try {
421             redirectServer = new Server(0);
422             redirectServer.setHandler(new AbstractHandler() {
423                 @Override
424                 public void handle(
425                         String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
426                         throws IOException, ServletException {
427                     response.setStatus(HttpServletResponse.SC_OK);
428                     ByteArrayISO8859Writer writer = new ByteArrayISO8859Writer(100);
429                     writer.write("<html>Hello world</html>");
430                     writer.flush();
431                     response.setContentLength(writer.size());
432                     OutputStream out = response.getOutputStream();
433                     writer.writeTo(out);
434                     out.close();
435                     writer.close();
436                 }
437             });
438             redirectServer.start();
439 
440             server = new Server(0);
441             MovedContextHandler handler = new MovedContextHandler();
442             int redirectPort = ((ServerConnector) redirectServer.getConnectors()[0]).getLocalPort();
443             handler.setNewContextURL("http://localhost:" + redirectPort);
444             server.setHandler(handler);
445             server.start();
446 
447             URL url = new URI("http://localhost:"
448                             + ((ServerConnector) redirectServer.getConnectors()[0]).getLocalPort())
449                     .toURL();
450             URL redirectUrl = JavadocUtil.getRedirectUrl(url, new Settings());
451 
452             assertTrue(redirectUrl.toString().startsWith("http://localhost:" + redirectPort));
453         } finally {
454             stopSilently(server);
455             stopSilently(redirectServer);
456         }
457     }
458 
459     /**
460      * Tests that getRedirectUrl returns the same URL when there are no redirects.
461      */
462     public void testGetRedirectUrlWithNoRedirects() throws Exception {
463         Server server = null;
464         try {
465             server = new Server(0);
466             server.setHandler(new AbstractHandler() {
467                 @Override
468                 public void handle(
469                         String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
470                         throws IOException, ServletException {
471                     response.setStatus(HttpServletResponse.SC_OK);
472                     ByteArrayISO8859Writer writer = new ByteArrayISO8859Writer(100);
473                     writer.write("<html>Hello world</html>");
474                     writer.flush();
475                     response.setContentLength(writer.size());
476                     OutputStream out = response.getOutputStream();
477                     writer.writeTo(out);
478                     out.close();
479                     writer.close();
480                 }
481             });
482             server.start();
483 
484             URL url =
485                     new URI("http://localhost:" + ((ServerConnector) server.getConnectors()[0]).getLocalPort()).toURL();
486             URL redirectUrl = JavadocUtil.getRedirectUrl(url, new Settings());
487 
488             assertEquals(url.toURI(), redirectUrl.toURI());
489         } finally {
490             stopSilently(server);
491         }
492     }
493 
494     /**
495      * Tests that getRedirectUrl adds an Accept header in HTTP requests. Necessary because some sites like Cloudflare
496      * reject requests without an Accept header.
497      */
498     public void testGetRedirectUrlVerifyHeaders() throws Exception {
499         Server server = null;
500         try {
501             server = new Server(0);
502             server.setHandler(new AbstractHandler() {
503                 @Override
504                 public void handle(
505                         String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
506                         throws IOException, ServletException {
507 
508                     if (request.getHeader("Accept") == null) {
509                         response.setStatus(HttpServletResponse.SC_FORBIDDEN);
510                     } else {
511                         response.setStatus(HttpServletResponse.SC_OK);
512                     }
513                     response.getOutputStream().close();
514                 }
515             });
516             server.start();
517 
518             URL url =
519                     new URI("http://localhost:" + ((ServerConnector) server.getConnectors()[0]).getLocalPort()).toURL();
520             JavadocUtil.getRedirectUrl(url, new Settings());
521         } finally {
522             stopSilently(server);
523         }
524     }
525 
526     /**
527      * Method to test copyJavadocResources()
528      *
529      * @throws Exception if any
530      */
531     public void testCopyJavadocResources() throws Exception {
532         File input = new File(getBasedir(), "src/test/resources/unit/docfiles-test/docfiles/");
533         assertThat(input).exists();
534 
535         File output = new File(getBasedir(), "target/test/unit/docfiles-test/target/output");
536         if (output.exists()) {
537             FileUtils.deleteDirectory(output);
538         }
539         assertTrue(output.mkdirs());
540 
541         JavadocUtil.copyJavadocResources(output, input, null);
542 
543         assertThat(FileUtils.getFiles(output, null, null, false))
544                 .containsExactlyInAnyOrder(
545                         Paths.get("test", "doc-files", "excluded-dir1", "sample-excluded1.gif")
546                                 .toFile(),
547                         Paths.get("test", "doc-files", "excluded-dir2", "sample-excluded2.gif")
548                                 .toFile(),
549                         Paths.get("test", "doc-files", "included-dir1", "sample-included1.gif")
550                                 .toFile(),
551                         Paths.get("test", "doc-files", "included-dir2", "sample-included2.gif")
552                                 .toFile());
553 
554         assertThat(FileUtils.getDirectoryNames(new File(output, "test/doc-files"), null, null, false))
555                 .containsExactlyInAnyOrder("", "excluded-dir1", "excluded-dir2", "included-dir1", "included-dir2");
556 
557         input = new File(getBasedir(), "src/test/resources/unit/docfiles-test/docfiles/");
558         assertTrue(input.exists());
559 
560         output = new File(getBasedir(), "target/test/unit/docfiles-test/target/output");
561         if (output.exists()) {
562             FileUtils.deleteDirectory(output);
563         }
564         assertTrue(output.mkdirs());
565 
566         JavadocUtil.copyJavadocResources(output, input, "excluded-dir1:excluded-dir2");
567 
568         assertThat(FileUtils.getFiles(output, null, null, false))
569                 .containsExactlyInAnyOrder(
570                         Paths.get("test", "doc-files", "included-dir1", "sample-included1.gif")
571                                 .toFile(),
572                         Paths.get("test", "doc-files", "included-dir2", "sample-included2.gif")
573                                 .toFile());
574 
575         assertThat(FileUtils.getDirectoryNames(new File(output, "test/doc-files"), null, null, false))
576                 .containsExactlyInAnyOrder("", "included-dir1", "included-dir2");
577     }
578 
579     /**
580      * Method to test pruneDirs()
581      *
582      */
583     public void testPruneDirs() {
584         List<String> list = new ArrayList<>();
585         list.add(getBasedir() + "/target/classes");
586         list.add(getBasedir() + "/target/classes");
587         list.add(getBasedir() + "/target/classes");
588 
589         Set<Path> expected = Collections.singleton(Paths.get(getBasedir(), "target/classes"));
590 
591         MavenProjectStub project = new MavenProjectStub();
592         project.setFile(new File(getBasedir(), "pom.xml"));
593 
594         assertEquals(expected, JavadocUtil.pruneDirs(project, list));
595     }
596 
597     /**
598      * Method to test unifyPathSeparator()
599      *
600      */
601     public void testUnifyPathSeparator() {
602         assertNull(JavadocUtil.unifyPathSeparator(null));
603 
604         final String ps = File.pathSeparator;
605 
606         // Windows
607         String path1 = "C:\\maven-javadoc-plugin\\src\\main\\java";
608         String path2 = "C:\\maven-javadoc-plugin\\src\\main\\javadoc";
609         assertEquals(path1 + ps + path2, JavadocUtil.unifyPathSeparator(path1 + ";" + path2));
610         assertEquals(path1 + ps + path2, JavadocUtil.unifyPathSeparator(path1 + ":" + path2));
611 
612         path1 = "C:/maven-javadoc-plugin/src/main/java";
613         path2 = "C:/maven-javadoc-plugin/src/main/javadoc";
614         assertEquals(path1 + ps + path2, JavadocUtil.unifyPathSeparator(path1 + ";" + path2));
615         assertEquals(path1 + ps + path2, JavadocUtil.unifyPathSeparator(path1 + ":" + path2));
616         assertEquals(
617                 path1 + ps + path2 + ps + path1 + ps + path2,
618                 JavadocUtil.unifyPathSeparator(path1 + ";" + path2 + ";" + path1 + ":" + path2));
619 
620         // Unix
621         path1 = "/tmp/maven-javadoc-plugin/src/main/java";
622         path2 = "/tmp/maven-javadoc-plugin/src/main/javadoc";
623         assertEquals(path1 + ps + path2, JavadocUtil.unifyPathSeparator(path1 + ";" + path2));
624         assertEquals(path1 + ps + path2, JavadocUtil.unifyPathSeparator(path1 + ":" + path2));
625         assertEquals(
626                 path1 + ps + path2 + ps + path1 + ps + path2,
627                 JavadocUtil.unifyPathSeparator(path1 + ";" + path2 + ":" + path1 + ":" + path2));
628     }
629 
630     public void testGetIncludedFiles() {
631         File sourceDirectory = new File("target/it").getAbsoluteFile();
632         String[] fileList = new String[] {"Main.java"};
633         Collection<String> excludePackages = Collections.singleton("*.it");
634 
635         List<String> includedFiles = JavadocUtil.getIncludedFiles(sourceDirectory, fileList, excludePackages);
636 
637         assertThat(includedFiles.toArray(new String[0])).isEqualTo(fileList);
638     }
639 
640     private void stopSilently(Server server) {
641         try {
642             if (server != null) {
643                 server.stop();
644             }
645         } catch (Exception e) {
646             // ignored
647         }
648     }
649 }