View Javadoc

1   package org.apache.maven.plugin.javadoc;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.commons.lang.SystemUtils;
23  import org.apache.maven.plugin.MojoExecutionException;
24  import org.apache.maven.plugin.javadoc.ProxyServer.AuthAsyncProxyServlet;
25  import org.apache.maven.plugin.testing.AbstractMojoTestCase;
26  import org.apache.maven.settings.Proxy;
27  import org.apache.maven.settings.Settings;
28  import org.codehaus.plexus.util.FileUtils;
29  import org.codehaus.plexus.util.IOUtil;
30  import org.codehaus.plexus.util.ReaderFactory;
31  import org.codehaus.plexus.util.StringUtils;
32  
33  import java.io.*;
34  import java.util.HashMap;
35  import java.util.List;
36  import java.util.Map;
37  
38  /**
39   * Test {@link org.apache.maven.plugin.javadoc.JavadocReport} class.
40   *
41   * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
42   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
43   */
44  public class JavadocReportTest
45      extends AbstractMojoTestCase
46  {
47      private static final char LINE_SEPARATOR = ' ';
48  
49      /** flag to copy repo only one time */
50      private static boolean TEST_REPO_CREATED = false;
51  
52      private File unit;
53  
54      /** {@inheritDoc} */
55      protected void setUp()
56          throws Exception
57      {
58          super.setUp();
59  
60          unit = new File( getBasedir(), "src/test/resources/unit" );
61  
62          createTestRepo();
63      }
64  
65      /**
66       * Create test repository in target directory.
67       *
68       * @throws IOException if any
69       */
70      private void createTestRepo()
71          throws IOException
72      {
73          if ( TEST_REPO_CREATED )
74          {
75              return;
76          }
77  
78          File localRepo = new File( getBasedir(), "target/local-repo/" );
79          localRepo.mkdirs();
80  
81          // ----------------------------------------------------------------------
82          // UMLGraph
83          // ----------------------------------------------------------------------
84  
85          File sourceDir = new File( unit, "doclet-test/artifact-doclet" );
86          assertTrue( sourceDir.exists() );
87          FileUtils.copyDirectoryStructure( sourceDir, localRepo );
88  
89          // ----------------------------------------------------------------------
90          // UMLGraph-bis
91          // ----------------------------------------------------------------------
92  
93          sourceDir = new File( unit, "doclet-path-test/artifact-doclet" );
94          assertTrue( sourceDir.exists() );
95          FileUtils.copyDirectoryStructure( sourceDir, localRepo );
96  
97          // ----------------------------------------------------------------------
98          // commons-attributes-compiler
99          // http://www.tullmann.org/pat/taglets/
100         // ----------------------------------------------------------------------
101 
102         sourceDir = new File( unit, "taglet-test/artifact-taglet" );
103         assertTrue( sourceDir.exists() );
104         FileUtils.copyDirectoryStructure( sourceDir, localRepo );
105 
106         // ----------------------------------------------------------------------
107         // stylesheetfile-test
108         // ----------------------------------------------------------------------
109 
110         sourceDir = new File( unit, "stylesheetfile-test/artifact-stylesheetfile" );
111         assertTrue( sourceDir.exists() );
112         FileUtils.copyDirectoryStructure( sourceDir, localRepo );
113 
114         // ----------------------------------------------------------------------
115         // helpfile-test
116         // ----------------------------------------------------------------------
117 
118         sourceDir = new File( unit, "helpfile-test/artifact-helpfile" );
119         assertTrue( sourceDir.exists() );
120         FileUtils.copyDirectoryStructure( sourceDir, localRepo );
121 
122         // Remove SCM files
123         List<String> files =
124             FileUtils.getFileAndDirectoryNames( localRepo, FileUtils.getDefaultExcludesAsString(), null, true,
125                                                 true, true, true );
126         for ( String filename : files )
127         {
128             File file = new File( filename );
129 
130             if ( file.isDirectory() )
131             {
132                 FileUtils.deleteDirectory( file );
133             }
134             else
135             {
136                 file.delete();
137             }
138         }
139 
140         TEST_REPO_CREATED = true;
141     }
142 
143     /**
144      * Convenience method that reads the contents of the specified file object into a string with a
145      * <code>space</code> as line separator.
146      *
147      * @see #LINE_SEPARATOR
148      * @param file the file to be read
149      * @return a String object that contains the contents of the file
150      * @throws IOException if any
151      */
152     private static String readFile( File file )
153         throws IOException
154     {
155         String strTmp;
156         StringBuilder str = new StringBuilder( (int) file.length() );
157         BufferedReader in = new BufferedReader( new FileReader( file ) );
158 
159         try
160         {
161             while ( ( strTmp = in.readLine() ) != null )
162             {
163                 str.append( LINE_SEPARATOR );
164                 str.append( strTmp );
165             }
166         }
167         finally
168         {
169             in.close();
170         }
171 
172         return str.toString();
173     }
174 
175     /**
176      * Test when default configuration is provided for the plugin
177      *
178      * @throws Exception if any
179      */
180     public void testDefaultConfiguration()
181         throws Exception
182     {
183         File testPom = new File( unit, "default-configuration/default-configuration-plugin-config.xml" );
184         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
185         mojo.execute();
186 
187         // package level generated javadoc files
188         File apidocs = new File( getBasedir(), "target/test/unit/default-configuration/target/site/apidocs" );
189 
190         File generatedFile = new File( apidocs, "def/configuration/App.html" );
191         assertTrue( generatedFile.exists() );
192         assertTrue( FileUtils.fileRead( generatedFile, "UTF-8" ).contains( "/docs/api/java/lang/Object.html" ) );
193 
194         assertTrue( new File( apidocs, "def/configuration/AppSample.html" ).exists() );
195         assertTrue( new File( apidocs, "def/configuration/package-frame.html" ).exists() );
196         assertTrue( new File( apidocs, "def/configuration/package-summary.html" ).exists() );
197         assertTrue( new File( apidocs, "def/configuration/package-tree.html" ).exists() );
198         assertTrue( new File( apidocs, "def/configuration/package-use.html" ).exists() );
199 
200         // class level generated javadoc files
201         assertTrue( new File( apidocs, "def/configuration/class-use/App.html" ).exists() );
202         assertTrue( new File( apidocs, "def/configuration/class-use/AppSample.html" ).exists() );
203 
204         // project level generated javadoc files
205         assertTrue( new File( apidocs, "allclasses-frame.html" ).exists() );
206         assertTrue( new File( apidocs, "allclasses-noframe.html" ).exists() );
207         assertTrue( new File( apidocs, "constant-values.html" ).exists() );
208         assertTrue( new File( apidocs, "deprecated-list.html" ).exists() );
209         assertTrue( new File( apidocs, "help-doc.html" ).exists() );
210         assertTrue( new File( apidocs, "index-all.html" ).exists() );
211         assertTrue( new File( apidocs, "index.html" ).exists() );
212         assertTrue( new File( apidocs, "overview-tree.html" ).exists() );
213         assertTrue( new File( apidocs, "package-list" ).exists() );
214         assertTrue( new File( apidocs, "stylesheet.css" ).exists() );
215     }
216 
217     /**
218      * Method for testing the subpackages and excludePackageNames parameter
219      *
220      * @throws Exception if any
221      */
222     public void testSubpackages()
223         throws Exception
224     {
225         File testPom = new File( unit, "subpackages-test/subpackages-test-plugin-config.xml" );
226         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
227         mojo.execute();
228 
229         File apidocs = new File( getBasedir(), "target/test/unit/subpackages-test/target/site/apidocs" );
230 
231         // check the excluded packages
232         assertFalse( new File( apidocs, "subpackages/test/excluded" ).exists() );
233         assertFalse( new File( apidocs, "subpackages/test/included/exclude" ).exists() );
234 
235         // check if the classes in the specified subpackages were included
236         assertTrue( new File( apidocs, "subpackages/test/App.html" ).exists() );
237         assertTrue( new File( apidocs, "subpackages/test/AppSample.html" ).exists() );
238         assertTrue( new File( apidocs, "subpackages/test/included/IncludedApp.html" ).exists() );
239         assertTrue( new File( apidocs, "subpackages/test/included/IncludedAppSample.html" ).exists() );
240     }
241 
242     public void testIncludesExcludes()
243             throws Exception
244     {
245         File testPom = new File( unit, "file-include-exclude-test/file-include-exclude-plugin-config.xml" );
246         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
247         mojo.execute();
248 
249         File apidocs = new File( getBasedir(), "target/test/unit/file-include-exclude-test/target/site/apidocs" );
250 
251         // check if the classes in the specified subpackages were included
252         assertTrue( new File( apidocs, "subpackages/test/App.html" ).exists() );
253         assertTrue( new File( apidocs, "subpackages/test/AppSample.html" ).exists() );
254         assertTrue( new File( apidocs, "subpackages/test/included/IncludedApp.html" ).exists() );
255         assertTrue( new File( apidocs, "subpackages/test/included/IncludedAppSample.html" ).exists() );
256         assertFalse( new File( apidocs, "subpackages/test/PariahApp.html" ).exists() );
257     }
258 
259     /**
260      * Test the recursion and exclusion of the doc-files subdirectories.
261      *
262      * @throws Exception if any
263      */
264     public void testDocfiles()
265         throws Exception
266     {
267         File testPom = new File( unit, "docfiles-test/docfiles-test-plugin-config.xml" );
268         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
269         mojo.execute();
270 
271         File apidocs = new File( getBasedir(), "target/test/unit/docfiles-test/target/site/apidocs/" );
272 
273         // check if the doc-files subdirectories were copied
274         assertTrue( new File( apidocs, "doc-files" ).exists() );
275         assertTrue( new File( apidocs, "doc-files/included-dir1/sample-included1.gif" ).exists() );
276         assertTrue( new File( apidocs, "doc-files/included-dir2/sample-included2.gif" ).exists() );
277         assertFalse( new File( apidocs, "doc-files/excluded-dir1" ).exists() );
278         assertFalse( new File( apidocs, "doc-files/excluded-dir2" ).exists() );
279 
280         testPom = new File( unit, "docfiles-with-java-test/docfiles-with-java-test-plugin-config.xml" );
281         mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
282         mojo.execute();
283     }
284 
285     /**
286      * Test javadoc plugin using custom configuration. noindex, notree and nodeprecated parameters
287      * were set to true.
288      *
289      * @throws Exception if any
290      */
291     public void testCustomConfiguration()
292         throws Exception
293     {
294         File testPom = new File( unit, "custom-configuration/custom-configuration-plugin-config.xml" );
295         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
296         mojo.execute();
297 
298         File apidocs = new File( getBasedir(), "target/test/unit/custom-configuration/target/site/apidocs" );
299 
300         // check if there is a tree page generated (notree == true)
301         assertFalse( new File( apidocs, "overview-tree.html" ).exists() );
302         assertFalse( new File( apidocs, "custom/configuration/package-tree.html" ).exists() );
303 
304         // check if the main index page was generated (noindex == true)
305         assertFalse( new File( apidocs, "index-all.html" ).exists() );
306 
307         // check if the deprecated list and the deprecated api were generated (nodeprecated == true)
308         // @todo Fix: the class-use of the deprecated api is still created eventhough the deprecated api of that class
309         // is no longer generated
310         assertFalse( new File( apidocs, "deprecated-list.html" ).exists() );
311         assertFalse( new File( apidocs, "custom/configuration/App.html" ).exists() );
312 
313         // read the contents of the html files based on some of the parameter values
314         // author == false
315         String str = readFile( new File( apidocs, "custom/configuration/AppSample.html" ) );
316         assertFalse( str.toLowerCase().contains( "author" ) );
317 
318         // bottom
319         assertTrue( str.toUpperCase().contains( "SAMPLE BOTTOM CONTENT" ) );
320 
321         // offlineLinks
322         assertTrue( str.toLowerCase().contains( "href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/lang/string.html" ) );
323 
324         // header
325         assertTrue( str.toUpperCase().contains( "MAVEN JAVADOC PLUGIN TEST" ) );
326 
327         // footer
328         assertTrue( str.toUpperCase().contains( "MAVEN JAVADOC PLUGIN TEST FOOTER" ) );
329 
330         // nohelp == true
331         assertFalse( str.toUpperCase().contains( "/HELP-DOC.HTML" ) );
332 
333         // check the wildcard (*) package exclusions -- excludePackageNames parameter
334         assertTrue( new File( apidocs, "custom/configuration/exclude1/Exclude1App.html" ).exists() );
335         assertFalse( new File( apidocs, "custom/configuration/exclude1/subexclude/SubexcludeApp.html" ).exists() );
336         assertFalse( new File( apidocs, "custom/configuration/exclude2/Exclude2App.html" ).exists() );
337 
338         File options = new File( apidocs, "options" );
339         assertTrue( options.isFile() );
340         String contentOptions = null;
341         Reader reader = null;
342         try
343         {
344             reader = ReaderFactory.newPlatformReader( options );
345             contentOptions = IOUtil.toString( reader );
346         }
347         finally
348         {
349             IOUtil.close( reader );
350         }
351 
352         assertTrue( contentOptions != null );
353         assertTrue( contentOptions.contains( "-link" ) );
354         assertTrue( contentOptions.contains( "http://java.sun.com/j2se/" ) );
355     }
356 
357     /**
358      * Method to test the doclet artifact configuration
359      *
360      * @throws Exception if any
361      */
362     public void testDoclets()
363         throws Exception
364     {
365         // ----------------------------------------------------------------------
366         // doclet-test: check if the file generated by UmlGraph exists and if
367         // doclet path contains the UmlGraph artifact
368         // ----------------------------------------------------------------------
369 
370         File testPom = new File( unit, "doclet-test/doclet-test-plugin-config.xml" );
371         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
372         mojo.execute();
373 
374         File generatedFile = new File( getBasedir(), "target/test/unit/doclet-test/target/site/apidocs/graph.dot" );
375         assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
376 
377         File optionsFile = new File( mojo.getOutputDirectory(), "options" );
378         assertTrue( optionsFile.exists() );
379         String options = readFile( optionsFile );
380         assertTrue( options.contains( "/target/local-repo/umlgraph/UMLGraph/2.1/UMLGraph-2.1.jar" ) );
381 
382         // ----------------------------------------------------------------------
383         // doclet-path: check if the file generated by UmlGraph exists and if
384         // doclet path contains the twice UmlGraph artifacts
385         // ----------------------------------------------------------------------
386 
387         testPom = new File( unit, "doclet-path-test/doclet-path-test-plugin-config.xml" );
388         mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
389         mojo.execute();
390 
391         generatedFile = new File( getBasedir(), "target/test/unit/doclet-test/target/site/apidocs/graph.dot" );
392         assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
393 
394         optionsFile = new File( mojo.getOutputDirectory(), "options" );
395         assertTrue( optionsFile.exists() );
396         options = readFile( optionsFile );
397         assertTrue( options.contains( "/target/local-repo/umlgraph/UMLGraph/2.1/UMLGraph-2.1.jar" ) );
398         assertTrue( options.contains( "/target/local-repo/umlgraph/UMLGraph-bis/2.1/UMLGraph-bis-2.1.jar" ) );
399     }
400 
401     /**
402      * Method to test the aggregate parameter
403      *
404      * @throws Exception if any
405      */
406     public void testAggregate()
407         throws Exception
408     {
409         File testPom = new File( unit, "aggregate-test/aggregate-test-plugin-config.xml" );
410         JavadocReport mojo = (JavadocReport) lookupMojo( "aggregate", testPom );
411         mojo.execute();
412 
413         File apidocs = new File( getBasedir(), "target/test/unit/aggregate-test/target/site/apidocs/" );
414 
415         // check if project1 api files exist
416         assertTrue( new File( apidocs, "aggregate/test/project1/Project1App.html" ).exists() );
417         assertTrue( new File( apidocs, "aggregate/test/project1/Project1AppSample.html" ).exists() );
418         assertTrue( new File( apidocs, "aggregate/test/project1/Project1Sample.html" ).exists() );
419         assertTrue( new File( apidocs, "aggregate/test/project1/Project1Test.html" ).exists() );
420 
421         // check if project2 api files exist
422         assertTrue( new File( apidocs, "aggregate/test/project2/Project2App.html" ).exists() );
423         assertTrue( new File( apidocs, "aggregate/test/project2/Project2AppSample.html" ).exists() );
424         assertTrue( new File( apidocs, "aggregate/test/project2/Project2Sample.html" ).exists() );
425         assertTrue( new File( apidocs, "aggregate/test/project2/Project2Test.html" ).exists() );
426 
427     }
428 
429     /**
430      * Method to test when the path to the project sources has an apostrophe (')
431      *
432      * @throws Exception if any
433      */
434     public void testQuotedPath()
435         throws Exception
436     {
437         File testPom = new File( unit, "quotedpath'test/quotedpath-test-plugin-config.xml" );
438         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
439         mojo.execute();
440 
441         File apidocs = new File( getBasedir(), "target/test/unit/quotedpath'test/target/site/apidocs" );
442 
443         // package level generated javadoc files
444         assertTrue( new File( apidocs, "quotedpath/test/App.html" ).exists() );
445         assertTrue( new File( apidocs, "quotedpath/test/AppSample.html" ).exists() );
446 
447         // project level generated javadoc files
448         assertTrue( new File( apidocs, "index-all.html" ).exists() );
449         assertTrue( new File( apidocs, "index.html" ).exists() );
450         assertTrue( new File( apidocs, "overview-tree.html" ).exists() );
451         assertTrue( new File( apidocs, "package-list" ).exists() );
452         assertTrue( new File( apidocs, "stylesheet.css" ).exists() );
453     }
454 
455     /**
456      * @throws Exception if any
457      */
458     public void testExceptions()
459         throws Exception
460     {
461         try
462         {
463             File testPom = new File( unit, "default-configuration/exception-test-plugin-config.xml" );
464             JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
465             mojo.execute();
466 
467             fail( "Must throw exception." );
468         }
469         catch ( Exception e )
470         {
471             assertTrue( true );
472 
473             try
474             {
475                 FileUtils.deleteDirectory( new File( getBasedir(), "exception" ) );
476             }
477             catch ( IOException ie )
478             {
479                 // nop
480             }
481         }
482     }
483 
484     /**
485      * Method to test the taglet artifact configuration
486      *
487      * @throws Exception if any
488      */
489     public void testTaglets()
490         throws Exception
491     {
492         // ----------------------------------------------------------------------
493         // taglet-test: check if a taglet is used
494         // ----------------------------------------------------------------------
495 
496         File testPom = new File( unit, "taglet-test/taglet-test-plugin-config.xml" );
497         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
498         mojo.execute();
499 
500         File apidocs = new File( getBasedir(), "target/test/unit/taglet-test/target/site/apidocs" );
501 
502         assertTrue( new File( apidocs, "index.html" ).exists() );
503 
504         File appFile = new File( apidocs, "taglet/test/App.html" );
505         assertTrue( appFile.exists() );
506         String appString = readFile( appFile );
507         assertTrue( appString.contains( "<b>To Do:</b>" ) );
508     }
509 
510     /**
511      * Method to test the jdk5 javadoc
512      *
513      * @throws Exception if any
514      */
515     public void testJdk5()
516         throws Exception
517     {
518         if ( !SystemUtils.isJavaVersionAtLeast( 1.5f ) )
519         {
520             getContainer().getLogger().warn(
521                                              "JDK 5.0 or more is required to run javadoc for '"
522                                                  + getClass().getName() + "#" + getName() + "()'." );
523             return;
524         }
525 
526         File testPom = new File( unit, "jdk5-test/jdk5-test-plugin-config.xml" );
527         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
528         mojo.execute();
529 
530         File apidocs = new File( getBasedir(), "target/test/unit/jdk5-test/target/site/apidocs" );
531 
532         File index = new File( apidocs, "index.html" );
533         assertTrue( FileUtils.fileExists( index.getAbsolutePath() ) );
534 
535         File overviewSummary = new File( apidocs, "overview-summary.html" );
536         assertTrue( overviewSummary.exists() );
537         String content = readFile( overviewSummary );
538         assertTrue( content.contains( "<b>Test the package-info</b>" ) );
539 
540         File packageSummary = new File( apidocs, "jdk5/test/package-summary.html" );
541         assertTrue( packageSummary.exists() );
542         content = readFile( packageSummary );
543         assertTrue( content.contains( "<b>Test the package-info</b>" ) );
544     }
545 
546     /**
547      * Test to find the javadoc executable when <code>java.home</code> is not in the JDK_HOME. In this case, try to
548      * use the <code>JAVA_HOME</code> environment variable.
549      *
550      * @throws Exception if any
551      */
552     public void testToFindJavadoc()
553         throws Exception
554     {
555         String oldJreHome = System.getProperty( "java.home" );
556         System.setProperty( "java.home", "foo/bar" );
557 
558         File testPom = new File( unit, "javaHome-test/javaHome-test-plugin-config.xml" );
559         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
560         mojo.execute();
561 
562         System.setProperty( "java.home", oldJreHome );
563     }
564 
565     /**
566      * Test the javadoc resources.
567      *
568      * @throws Exception if any
569      */
570     public void testJavadocResources()
571         throws Exception
572     {
573         File testPom = new File( unit, "resources-test/resources-test-plugin-config.xml" );
574         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
575         mojo.execute();
576 
577         File apidocs = new File( getBasedir(), "target/test/unit/resources-test/target/site/apidocs/" );
578 
579         File app = new File( apidocs, "resources/test/App.html" );
580         assertTrue( app.exists() );
581         String content = readFile( app );
582         assertTrue( content.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\"/>" ) );
583         assertTrue( new File( apidocs, "resources/test/doc-files/maven-feather.png" ).exists() );
584 
585         File app2 = new File( apidocs, "resources/test2/App2.html" );
586         assertTrue( app2.exists() );
587         content = readFile( app2 );
588         assertTrue( content.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\"/>" ) );
589         assertFalse( new File( apidocs, "resources/test2/doc-files/maven-feather.png" ).exists() );
590 
591         // with excludes
592         testPom = new File( unit, "resources-with-excludes-test/resources-with-excludes-test-plugin-config.xml" );
593         mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
594         mojo.execute();
595 
596         apidocs = new File( getBasedir(), "target/test/unit/resources-with-excludes-test/target/site/apidocs" );
597 
598         app = new File( apidocs, "resources/test/App.html" );
599         assertTrue( app.exists() );
600         content = readFile( app );
601         assertTrue( content.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\"/>" ) );
602         assertFalse( new File( apidocs, "resources/test/doc-files/maven-feather.png" ).exists() );
603 
604         app2 = new File( apidocs, "resources/test2/App2.html" );
605         assertTrue( app2.exists() );
606         content = readFile( app2 );
607         assertTrue( content.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\"/>" ) );
608         assertTrue( new File( apidocs, "resources/test2/doc-files/maven-feather.png" ).exists() );
609     }
610 
611     /**
612      * Test the javadoc resources in the aggregation case.
613      *
614      * @throws Exception if any
615      */
616     public void testAggregateJavadocResources()
617         throws Exception
618     {
619         File testPom = new File( unit, "aggregate-resources-test/aggregate-resources-test-plugin-config.xml" );
620         JavadocReport mojo = (JavadocReport) lookupMojo( "aggregate", testPom );
621         mojo.execute();
622 
623         File apidocs = new File( getBasedir(), "target/test/unit/aggregate-resources-test/target/site/apidocs" );
624 
625         // Test overview
626         File overviewSummary = new File( apidocs, "overview-summary.html" );
627         assertTrue( overviewSummary.exists() );
628         String overview = readFile( overviewSummary ).toLowerCase();
629         assertTrue( overview.contains( "<a href=\"resources/test/package-summary.html\">resources.test</a>" ) );
630         assertTrue( overview.contains( ">blabla</" ) );
631         assertTrue( overview.contains( "<a href=\"resources/test2/package-summary.html\">resources.test2</a>" ) );
632         assertTrue( overview.contains( "<a href=\"resources2/test/package-summary.html\">resources2.test</a>" ) );
633         assertTrue( overview.contains( "<a href=\"resources2/test2/package-summary.html\">resources2.test2</a>" ) );
634 
635         // Test doc-files
636         File app = new File( apidocs, "resources/test/App.html" );
637         assertTrue( app.exists() );
638         overview = readFile( app );
639         assertTrue( overview.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\"/>" ) );
640         assertTrue( new File( apidocs, "resources/test/doc-files/maven-feather.png" ).exists() );
641     }
642 
643     /**
644      * Test the javadoc for a POM project.
645      *
646      * @throws Exception if any
647      */
648     public void testPom()
649         throws Exception
650     {
651         File testPom = new File( unit, "pom-test/pom-test-plugin-config.xml" );
652         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
653         mojo.execute();
654 
655         assertFalse( new File( getBasedir(), "target/test/unit/pom-test" ).exists() );
656     }
657 
658     /**
659      * Test the javadoc with tag.
660      *
661      * @throws Exception if any
662      */
663     public void testTag()
664         throws Exception
665     {
666         File testPom = new File( unit, "tag-test/tag-test-plugin-config.xml" );
667         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
668         mojo.execute();
669 
670         File app = new File( getBasedir(), "target/test/unit/tag-test/target/site/apidocs/tag/test/App.html" );
671         assertTrue( FileUtils.fileExists( app.getAbsolutePath() ) );
672         String readed = readFile( app );
673         assertTrue( readed.contains( ">To do something:</" ) );
674         assertTrue( readed.contains( ">Generator Class:</" ) );
675         assertTrue( readed.contains( ">Version:</" ) );
676         assertTrue( readed.toLowerCase().contains( "</dt>" + LINE_SEPARATOR + "  <dd>1.0</dd>" ) );
677     }
678 
679     /**
680      * Test newline in the header/footer parameter
681      *
682      * @throws Exception if any
683      */
684     public void testHeaderFooter()
685         throws Exception
686     {
687         File testPom = new File( unit, "header-footer-test/header-footer-test-plugin-config.xml" );
688         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
689         try
690         {
691             mojo.execute();
692         }
693         catch ( MojoExecutionException e )
694         {
695             assertTrue( "Doesnt handle correctly newline for header or footer parameter", false );
696         }
697 
698         assertTrue( true );
699     }
700 
701     /**
702      * Test newline in various string parameters
703      *
704      * @throws Exception if any
705      */
706     public void testNewline()
707         throws Exception
708     {
709         File testPom = new File( unit, "newline-test/newline-test-plugin-config.xml" );
710         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
711         try
712         {
713             mojo.execute();
714         }
715         catch ( MojoExecutionException e )
716         {
717             fail( "Doesn't handle correctly newline for string parameters. See options and packages files." );
718         }
719 
720         assertTrue( true );
721     }
722 
723     /**
724      * Method to test the jdk6 javadoc
725      *
726      * @throws Exception if any
727      */
728     public void testJdk6()
729         throws Exception
730     {
731         if ( !SystemUtils.isJavaVersionAtLeast( 1.6f ) )
732         {
733             getContainer().getLogger().warn(
734                                              "JDK 6.0 or more is required to run javadoc for '"
735                                                  + getClass().getName() + "#" + getName() + "()'." );
736             return;
737         }
738 
739         File testPom = new File( unit, "jdk6-test/jdk6-test-plugin-config.xml" );
740         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
741         mojo.execute();
742 
743         File apidocs = new File( getBasedir(), "target/test/unit/jdk6-test/target/site/apidocs" );
744 
745         assertTrue( new File( apidocs, "index.html" ).exists() );
746 
747         File overviewSummary = new File( apidocs, "overview-summary.html" );
748         assertTrue( overviewSummary.exists() );
749         String content = readFile( overviewSummary );
750         assertTrue( content.contains( "Top - Copyright &#169; All rights reserved." ) );
751         assertTrue( content.contains( "Header - Copyright &#169; All rights reserved." ) );
752         assertTrue( content.contains( "Footer - Copyright &#169; All rights reserved." ) );
753 
754         File packageSummary = new File( apidocs, "jdk6/test/package-summary.html" );
755         assertTrue( packageSummary.exists() );
756         content = readFile( packageSummary );
757         assertTrue( content.contains( "Top - Copyright &#169; All rights reserved." ) );
758         assertTrue( content.contains( "Header - Copyright &#169; All rights reserved." ) );
759         assertTrue( content.contains( "Footer - Copyright &#169; All rights reserved." ) );
760     }
761 
762     /**
763      * Method to test proxy support in the javadoc
764      *
765      * @throws Exception if any
766      */
767     public void testProxy()
768         throws Exception
769     {
770         Settings settings = new Settings();
771         Proxy proxy = new Proxy();
772 
773         // dummy proxy
774         proxy.setActive( true );
775         proxy.setHost( "127.0.0.1" );
776         proxy.setPort( 80 );
777         proxy.setProtocol( "http" );
778         proxy.setUsername( "toto" );
779         proxy.setPassword( "toto" );
780         proxy.setNonProxyHosts( "www.google.com|*.somewhere.com" );
781         settings.addProxy( proxy );
782 
783         File testPom = new File( getBasedir(), "src/test/resources/unit/proxy-test/proxy-test-plugin-config.xml" );
784         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
785         assertNotNull( mojo );
786         setVariableValueToObject( mojo, "settings", settings );
787         setVariableValueToObject( mojo, "remoteRepositories", mojo.project.getRemoteArtifactRepositories() );
788         mojo.execute();
789 
790         File commandLine = new File( getBasedir(), "target/test/unit/proxy-test/target/site/apidocs/javadoc." + ( SystemUtils.IS_OS_WINDOWS ? "bat" : "sh" ) );
791         assertTrue( FileUtils.fileExists( commandLine.getAbsolutePath() ) );
792         String readed = readFile( commandLine );
793         assertTrue( readed.contains( "-J-Dhttp.proxySet=true" ) );
794         assertTrue( readed.contains( "-J-Dhttp.proxyHost=127.0.0.1" ) );
795         assertTrue( readed.contains( "-J-Dhttp.proxyPort=80" ) );
796         assertTrue( readed.contains( "-J-Dhttp.proxyUser=\\\"toto\\\"" ) );
797         assertTrue( readed.contains( "-J-Dhttp.proxyPassword=\\\"toto\\\"" ) );
798         assertTrue( readed.contains( "-J-Dhttp.nonProxyHosts=\\\"www.google.com|*.somewhere.com\\\"" ) );
799 
800         File options = new File( getBasedir(), "target/test/unit/proxy-test/target/site/apidocs/options" );
801         assertTrue( FileUtils.fileExists( options.getAbsolutePath() ) );
802         String optionsContent = readFile( options );
803         // NO -link expected
804         assertFalse( optionsContent.contains( "-link" ) );
805 
806         // real proxy
807         ProxyServer proxyServer = null;
808         AuthAsyncProxyServlet proxyServlet = null;
809         try
810         {
811             proxyServlet = new AuthAsyncProxyServlet();
812             proxyServer = new ProxyServer( proxyServlet );
813             proxyServer.start();
814 
815             settings = new Settings();
816             proxy = new Proxy();
817             proxy.setActive( true );
818             proxy.setHost( proxyServer.getHostName() );
819             proxy.setPort( proxyServer.getPort() );
820             proxy.setProtocol( "http" );
821             settings.addProxy( proxy );
822 
823             mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
824             setVariableValueToObject( mojo, "settings", settings );
825             setVariableValueToObject( mojo, "remoteRepositories", mojo.project.getRemoteArtifactRepositories() );
826             mojo.execute();
827             readed = readFile( commandLine );
828             assertTrue( readed.contains( "-J-Dhttp.proxySet=true" ) );
829             assertTrue( readed.contains( "-J-Dhttp.proxyHost=" + proxyServer.getHostName() ) );
830             assertTrue( readed.contains( "-J-Dhttp.proxyPort=" + proxyServer.getPort() ) );
831 
832             optionsContent = readFile( options );
833             // -link expected
834 // TODO: This got disabled for now!
835 // This test fails since the last commit but I actually think it only ever worked by accident.
836 // It did rely on a commons-logging-1.0.4.pom which got resolved by a test which did run previously.
837 // But after updating to commons-logging.1.1.1 there is no pre-resolved artifact available in
838 // target/local-repo anymore, thus the javadoc link info cannot get built and the test fails
839 // I'll for now just disable this line of code, because the test as far as I can see _never_
840 // did go upstream. The remoteRepository list used is always empty!.
841 //
842 //            assertTrue( optionsContent.contains( "-link 'http://commons.apache.org/logging/apidocs'" ) );
843         }
844         finally
845         {
846             if ( proxyServer != null )
847             {
848                 proxyServer.stop();
849             }
850         }
851 
852         // auth proxy
853         Map<String, String> authentications = new HashMap<String, String>();
854         authentications.put( "foo", "bar" );
855         try
856         {
857             proxyServlet = new AuthAsyncProxyServlet( authentications );
858             proxyServer = new ProxyServer( proxyServlet );
859             proxyServer.start();
860 
861             settings = new Settings();
862             proxy = new Proxy();
863             proxy.setActive( true );
864             proxy.setHost( proxyServer.getHostName() );
865             proxy.setPort( proxyServer.getPort() );
866             proxy.setProtocol( "http" );
867             proxy.setUsername( "foo" );
868             proxy.setPassword( "bar" );
869             settings.addProxy( proxy );
870 
871             mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
872             setVariableValueToObject( mojo, "settings", settings );
873             setVariableValueToObject( mojo, "remoteRepositories", mojo.project.getRemoteArtifactRepositories() );
874             mojo.execute();
875             readed = readFile( commandLine );
876             assertTrue( readed.contains( "-J-Dhttp.proxySet=true" ) );
877             assertTrue( readed.contains( "-J-Dhttp.proxyHost=" + proxyServer.getHostName() ) );
878             assertTrue( readed.contains( "-J-Dhttp.proxyPort=" + proxyServer.getPort() ) );
879             assertTrue( readed.contains( "-J-Dhttp.proxyUser=\\\"foo\\\"" ) );
880             assertTrue( readed.contains( "-J-Dhttp.proxyPassword=\\\"bar\\\"" ) );
881 
882             optionsContent = readFile( options );
883             // -link expected
884 // see comment above (line 829)
885 //             assertTrue( optionsContent.contains( "-link 'http://commons.apache.org/logging/apidocs'" ) );
886         }
887         finally
888         {
889             if ( proxyServer != null )
890             {
891                 proxyServer.stop();
892             }
893         }
894     }
895 
896     /**
897      * Method to test error or conflict in Javadoc options and in standard doclet options.
898      *
899      * @throws Exception if any
900      */
901     public void testValidateOptions()
902         throws Exception
903     {
904         // encoding
905         File testPom = new File( unit, "validate-options-test/wrong-encoding-test-plugin-config.xml" );
906         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
907         try
908         {
909             mojo.execute();
910             assertTrue( "No wrong encoding catch", false );
911         }
912         catch ( MojoExecutionException e )
913         {
914             assertTrue( "No wrong encoding catch", e.getMessage().contains( "Unsupported option <encoding/>" ) );
915         }
916         testPom = new File( unit, "validate-options-test/wrong-docencoding-test-plugin-config.xml" );
917         mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
918         try
919         {
920             mojo.execute();
921             assertTrue( "No wrong docencoding catch", false );
922         }
923         catch ( MojoExecutionException e )
924         {
925             assertTrue( "No wrong docencoding catch", e.getMessage().contains( "Unsupported option <docencoding/>" ) );
926         }
927         testPom = new File( unit, "validate-options-test/wrong-charset-test-plugin-config.xml" );
928         mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
929         try
930         {
931             mojo.execute();
932             assertTrue( "No wrong charset catch", false );
933         }
934         catch ( MojoExecutionException e )
935         {
936             assertTrue( "No wrong charset catch", e.getMessage().contains( "Unsupported option <charset/>" ) );
937         }
938 
939         // locale
940         testPom = new File( unit, "validate-options-test/wrong-locale-test-plugin-config.xml" );
941         mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
942         try
943         {
944             mojo.execute();
945             assertTrue( "No wrong locale catch", false );
946         }
947         catch ( MojoExecutionException e )
948         {
949             assertTrue( "No wrong locale catch", e.getMessage().contains( "Unsupported option <locale/>" ) );
950         }
951         testPom = new File( unit, "validate-options-test/wrong-locale-with-variant-test-plugin-config.xml" );
952         mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
953         mojo.execute();
954         assertTrue( "No wrong locale catch", true );
955 
956         // conflict options
957         testPom = new File( unit, "validate-options-test/conflict-options-test-plugin-config.xml" );
958         mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
959         try
960         {
961             mojo.execute();
962             assertTrue( "No conflict catch", false );
963         }
964         catch ( MojoExecutionException e )
965         {
966             assertTrue( "No conflict catch", e.getMessage().contains( "Option <nohelp/> conflicts with <helpfile/>" ) );
967         }
968     }
969 
970     /**
971      * Method to test the <code>&lt;tagletArtifacts/&gt;</code> parameter.
972      *
973      * @throws Exception if any
974      */
975     public void testTagletArtifacts()
976         throws Exception
977     {
978         File testPom = new File( unit, "tagletArtifacts-test/tagletArtifacts-test-plugin-config.xml" );
979         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
980 
981         setVariableValueToObject( mojo, "remoteRepositories", mojo.project.getRemoteArtifactRepositories() );
982 
983         mojo.execute();
984 
985         File optionsFile = new File( mojo.getOutputDirectory(), "options" );
986         assertTrue( optionsFile.exists() );
987         String options = readFile( optionsFile );
988         // count -taglet
989         assertEquals( 20, StringUtils.countMatches( options, LINE_SEPARATOR + "-taglet" + LINE_SEPARATOR ) );
990         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoAggregatorTypeTaglet" ) );
991         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoComponentFieldTaglet" ) );
992         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoConfiguratorTypeTaglet" ) );
993         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoExecuteTypeTaglet" ) );
994         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoExecutionStrategyTypeTaglet" ) );
995         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoGoalTypeTaglet" ) );
996         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoInheritByDefaultTypeTaglet" ) );
997         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoInstantiationStrategyTypeTaglet" ) );
998         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoParameterFieldTaglet" ) );
999         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoPhaseTypeTaglet" ) );
1000         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoReadOnlyFieldTaglet" ) );
1001         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoRequiredFieldTaglet" ) );
1002         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoRequiresDependencyResolutionTypeTaglet" ) );
1003         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoRequiresDirectInvocationTypeTaglet" ) );
1004         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoRequiresOnLineTypeTaglet" ) );
1005         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoRequiresProjectTypeTaglet" ) );
1006         assertTrue( options.contains( "org.apache.maven.tools.plugin.javadoc.MojoRequiresReportsTypeTaglet" ) );
1007         assertTrue( options.contains( "org.codehaus.plexus.javadoc.PlexusConfigurationTaglet" ) );
1008         assertTrue( options.contains( "org.codehaus.plexus.javadoc.PlexusRequirementTaglet" ) );
1009         assertTrue( options.contains( "org.codehaus.plexus.javadoc.PlexusComponentTaglet" ) );
1010     }
1011 
1012     /**
1013      * Method to test the <code>&lt;stylesheetfile/&gt;</code> parameter.
1014      *
1015      * @throws Exception if any
1016      */
1017     public void testStylesheetfile()
1018         throws Exception
1019     {
1020         File testPom = new File( unit, "stylesheetfile-test/pom.xml" );
1021 
1022         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
1023         assertNotNull( mojo );
1024 
1025         setVariableValueToObject( mojo, "remoteRepositories", mojo.project.getRemoteArtifactRepositories() );
1026 
1027         File apidocs = new File( getBasedir(), "target/test/unit/stylesheetfile-test/target/site/apidocs" );
1028 
1029         File stylesheetfile = new File( apidocs, "stylesheet.css" );
1030         File options = new File( apidocs, "options" );
1031 
1032         // stylesheet == maven OR java
1033         setVariableValueToObject( mojo, "stylesheet", "javamaven" );
1034 
1035         try
1036         {
1037             mojo.execute();
1038             assertTrue( false );
1039         }
1040         catch ( Exception e )
1041         {
1042             assertTrue( true );
1043         }
1044 
1045         // stylesheet == java
1046         setVariableValueToObject( mojo, "stylesheet", "java" );
1047         mojo.execute();
1048 
1049         String content = readFile( stylesheetfile );
1050         assertTrue( content.contains( "/* Javadoc style sheet */" ) );
1051 
1052         String optionsContent = readFile( options );
1053         assertFalse( optionsContent.contains( "-stylesheetfile" ) );
1054 
1055         // stylesheet == maven
1056         setVariableValueToObject( mojo, "stylesheet", "maven" );
1057         mojo.execute();
1058 
1059         content = readFile( stylesheetfile );
1060         assertTrue( content.contains( "/* Javadoc style sheet */" )
1061             && content.contains( "Licensed to the Apache Software Foundation (ASF) under one" ) );
1062 
1063         optionsContent = readFile( options );
1064         assertTrue( optionsContent.contains( "-stylesheetfile" ) );
1065         assertTrue( optionsContent.contains( "'" + stylesheetfile.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
1066 
1067         // stylesheetfile defined as a project resource
1068         setVariableValueToObject( mojo, "stylesheet", null );
1069         setVariableValueToObject( mojo, "stylesheetfile", "com/mycompany/app/javadoc/css/stylesheet.css" );
1070         mojo.execute();
1071 
1072         content = readFile( stylesheetfile );
1073         assertTrue( content.contains( "/* Custom Javadoc style sheet in project */" ) );
1074 
1075         optionsContent = readFile( options );
1076         assertTrue( optionsContent.contains( "-stylesheetfile" ) );
1077         File stylesheetResource =
1078             new File( unit, "stylesheetfile-test/src/main/resources/com/mycompany/app/javadoc/css/stylesheet.css" );
1079         assertTrue( optionsContent.contains( "'" + stylesheetResource.getAbsolutePath().replaceAll( "\\\\", "/" )
1080             + "'" ) );
1081 
1082         // stylesheetfile defined in a javadoc plugin dependency
1083         setVariableValueToObject( mojo, "stylesheetfile", "com/mycompany/app/javadoc/css2/stylesheet.css" );
1084         mojo.execute();
1085 
1086         content = readFile( stylesheetfile );
1087         assertTrue( content.contains( "/* Custom Javadoc style sheet in artefact */" ) );
1088 
1089         optionsContent = readFile( options );
1090         assertTrue( optionsContent.contains( "-stylesheetfile" ) );
1091         assertTrue( optionsContent.contains( "'" + stylesheetfile.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
1092 
1093         // stylesheetfile defined as file
1094         File css =
1095             new File( unit, "stylesheetfile-test/src/main/resources/com/mycompany/app/javadoc/css3/stylesheet.css" );
1096         setVariableValueToObject( mojo, "stylesheetfile", css.getAbsolutePath() );
1097         mojo.execute();
1098 
1099         content = readFile( stylesheetfile );
1100         assertTrue( content.contains( "/* Custom Javadoc style sheet as file */" ) );
1101 
1102         optionsContent = readFile( options );
1103         assertTrue( optionsContent.contains( "-stylesheetfile" ) );
1104         stylesheetResource =
1105             new File( unit, "stylesheetfile-test/src/main/resources/com/mycompany/app/javadoc/css3/stylesheet.css" );
1106         assertTrue( optionsContent.contains( "'" + stylesheetResource.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
1107     }
1108 
1109     /**
1110      * Method to test the <code>&lt;helpfile/&gt;</code> parameter.
1111      *
1112      * @throws Exception if any
1113      */
1114     public void testHelpfile()
1115         throws Exception
1116     {
1117         File testPom = new File( unit, "helpfile-test/pom.xml" );
1118 
1119         JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
1120         assertNotNull( mojo );
1121 
1122         setVariableValueToObject( mojo, "remoteRepositories", mojo.project.getRemoteArtifactRepositories() );
1123 
1124         File apidocs = new File( getBasedir(), "target/test/unit/helpfile-test/target/site/apidocs" );
1125 
1126         File helpfile = new File( apidocs, "help-doc.html" );
1127         File options = new File( apidocs, "options" );
1128 
1129         // helpfile by default
1130         mojo.execute();
1131 
1132         String content = readFile( helpfile );
1133         assertTrue( content.contains( "<!-- Generated by javadoc" ) );
1134 
1135         String optionsContent = readFile( options );
1136         assertFalse( optionsContent.contains( "-helpfile" ) );
1137 
1138         // helpfile defined in a javadoc plugin dependency
1139         setVariableValueToObject( mojo, "helpfile", "com/mycompany/app/javadoc/helpfile/help-doc.html" );
1140         mojo.execute();
1141 
1142         content = readFile( helpfile );
1143         assertTrue( content.contains( "<!--  Help file from artefact -->" ) );
1144 
1145         optionsContent = readFile( options );
1146         assertTrue( optionsContent.contains( "-helpfile" ) );
1147         File help = new File( apidocs, "help-doc.html" );
1148         assertTrue( optionsContent.contains( "'" + help.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
1149 
1150         // helpfile defined as a project resource
1151         setVariableValueToObject( mojo, "helpfile", "com/mycompany/app/javadoc/helpfile2/help-doc.html" );
1152         mojo.execute();
1153 
1154         content = readFile( helpfile );
1155         assertTrue( content.contains( "<!--  Help file from file -->" ) );
1156 
1157         optionsContent = readFile( options );
1158         assertTrue( optionsContent.contains( "-helpfile" ) );
1159         help = new File( unit, "helpfile-test/src/main/resources/com/mycompany/app/javadoc/helpfile2/help-doc.html" );
1160         assertTrue( optionsContent.contains( "'" + help.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
1161 
1162         // helpfile defined as file
1163         help = new File( unit, "helpfile-test/src/main/resources/com/mycompany/app/javadoc/helpfile2/help-doc.html" );
1164         setVariableValueToObject( mojo, "helpfile", help.getAbsolutePath() );
1165         mojo.execute();
1166 
1167         content = readFile( helpfile );
1168         assertTrue( content.contains( "<!--  Help file from file -->" ) );
1169 
1170         optionsContent = readFile( options );
1171         assertTrue( optionsContent.contains( "-helpfile" ) );
1172         assertTrue( optionsContent.contains( "'" + help.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
1173     }
1174 }