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
23 import org.apache.maven.model.Plugin;
24 import org.apache.maven.plugin.MojoExecution;
25 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
26 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
27 import org.apache.maven.project.MavenProject;
28 import org.codehaus.plexus.util.FileUtils;
29
30 import static org.assertj.core.api.Assertions.assertThat;
31
32
33
34
35 public class TestJavadocReportTest extends AbstractMojoTestCase {
36
37
38
39
40
41 public void testTestJavadoc() throws Exception {
42 File testPom =
43 new File(getBasedir(), "src/test/resources/unit/test-javadoc-test/test-javadoc-test-plugin-config.xml");
44 TestJavadocReport mojo = (TestJavadocReport) lookupMojo("test-javadoc", testPom);
45
46 Plugin p = new Plugin();
47 p.setGroupId("org.apache.maven.plugins");
48 p.setArtifactId("maven-javadoc-plugin");
49 MojoExecution mojoExecution = new MojoExecution(p, "test-javadoc", null);
50
51 setVariableValueToObject(mojo, "mojoExecution", mojoExecution);
52
53 MavenProject currentProject = new MavenProjectStub();
54 currentProject.setGroupId("GROUPID");
55 currentProject.setArtifactId("ARTIFACTID");
56
57 setVariableValueToObject(mojo, "session", newMavenSession(currentProject));
58
59 mojo.execute();
60
61 File generatedFile =
62 new File(getBasedir(), "target/test/unit/test-javadoc-test/target/site/testapidocs/maven/AppTest.html");
63 assertThat(generatedFile).exists();
64
65 File options = new File(getBasedir(), "target/test/unit/test-javadoc-test/target/site/testapidocs/options");
66 assertThat(FileUtils.fileRead(options)).contains("junit-3.8.1.jar");
67 }
68 }