use of org.apache.maven.plugins.javadoc.JavadocVersion in project maven-plugins by apache.
the class JavadocJarTest method testDefaultConfig.
/**
* Test when default configuration is provided
*
* @throws Exception if any
*/
public void testDefaultConfig() throws Exception {
File testPom = new File(getBasedir(), "src/test/resources/unit/javadocjar-default/javadocjar-default-plugin-config.xml");
JavadocJar mojo = lookupMojo(testPom);
mojo.execute();
// check if the javadoc jar file was generated
File generatedFile = new File(getBasedir(), "target/test/unit/javadocjar-default/target/javadocjar-default-javadoc.jar");
assertTrue(FileUtils.fileExists(generatedFile.getAbsolutePath()));
Set<String> set = new HashSet<>();
// validate contents of jar file
try (ZipFile jar = new ZipFile(generatedFile)) {
for (Enumeration<? extends ZipEntry> entries = jar.entries(); entries.hasMoreElements(); ) {
ZipEntry entry = entries.nextElement();
set.add(entry.getName());
}
}
assertTrue(set.contains("stylesheet.css"));
JavadocVersion javadocVersion = (JavadocVersion) getVariableValueFromObject(mojo, "javadocRuntimeVersion");
if (javadocVersion.compareTo(JavadocVersion.parse("1.7")) < 0) {
assertTrue(set.contains("resources/inherit.gif"));
} else if (javadocVersion.compareTo(JavadocVersion.parse("1.8")) < 0) {
assertTrue(set.contains("resources/background.gif"));
} else {
// JDK8 has no resources anymore
assertFalse(set.contains("resources"));
}
assertTrue(set.contains("javadocjar/def/package-use.html"));
assertTrue(set.contains("javadocjar/def/package-tree.html"));
assertTrue(set.contains("javadocjar/def/package-summary.html"));
assertTrue(set.contains("javadocjar/def/package-frame.html"));
assertTrue(set.contains("javadocjar/def/class-use/AppSample.html"));
assertTrue(set.contains("index.html"));
assertTrue(set.contains("javadocjar/def/App.html"));
assertTrue(set.contains("javadocjar/def/AppSample.html"));
assertTrue(set.contains("javadocjar/def/class-use/App.html"));
assertFalse(set.contains(AbstractJavadocMojo.ARGFILE_FILE_NAME));
assertFalse(set.contains(AbstractJavadocMojo.FILES_FILE_NAME));
assertFalse(set.contains(AbstractJavadocMojo.OPTIONS_FILE_NAME));
assertFalse(set.contains(AbstractJavadocMojo.PACKAGES_FILE_NAME));
// check if the javadoc files were created
generatedFile = new File(getBasedir(), "target/test/unit/javadocjar-default/target/site/apidocs/javadocjar/def/App.html");
assertTrue(FileUtils.fileExists(generatedFile.getAbsolutePath()));
generatedFile = new File(getBasedir(), "target/test/unit/javadocjar-default/target/site/apidocs/javadocjar/def/AppSample.html");
assertTrue(FileUtils.fileExists(generatedFile.getAbsolutePath()));
}
Aggregations