diff --git a/japicmp-testbase/japicmp-test-maven-plugin/pom.xml b/japicmp-testbase/japicmp-test-maven-plugin/pom.xml
index 1719fd0b9..04b0c2e9b 100644
--- a/japicmp-testbase/japicmp-test-maven-plugin/pom.xml
+++ b/japicmp-testbase/japicmp-test-maven-plugin/pom.xml
@@ -104,11 +104,9 @@
true
public
false
- false
-
+ false
true
- ${project.basedir}/src/main/resources/css/stylesheet.css
-
+ ${project.basedir}/src/main/resources/css/stylesheet.css
Test-Title
diff --git a/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/output/xml/XmlOutputGeneratorAccessModifierTest.java b/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/output/xml/XmlOutputGeneratorAccessModifierTest.java
index 99f2d6198..a233ed460 100644
--- a/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/output/xml/XmlOutputGeneratorAccessModifierTest.java
+++ b/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/output/xml/XmlOutputGeneratorAccessModifierTest.java
@@ -12,14 +12,14 @@
import java.io.File;
import java.io.IOException;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import static japicmp.test.util.Helper.replaceLastDotWith$;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
public class XmlOutputGeneratorAccessModifierTest {
private static Document documentPublic;
@@ -27,18 +27,16 @@ public class XmlOutputGeneratorAccessModifierTest {
@BeforeClass
public static void beforeClass() throws IOException {
- Path diffPublicXmlFilePath = Paths.get(System.getProperty("user.dir"), "target", "diff_public.xml");
Path diffPublicHtmlFilePath = Paths.get(System.getProperty("user.dir"), "target", "diff_public.html");
- Path diffPrivateXmlFilePath = Paths.get(System.getProperty("user.dir"), "target", "diff_private.xml");
Path diffPrivateHtmlFilePath = Paths.get(System.getProperty("user.dir"), "target", "diff_private.html");
List jApiClasses = Helper.compareTestV1WithTestV2(AccessModifier.PUBLIC);
- Helper.generateHtmlOutput(jApiClasses, diffPublicXmlFilePath.toString(), diffPublicHtmlFilePath.toString(), true, AccessModifier.PUBLIC);
+ Helper.generateHtmlOutput(jApiClasses, diffPublicHtmlFilePath.toString(), true, AccessModifier.PUBLIC);
jApiClasses = Helper.compareTestV1WithTestV2(AccessModifier.PRIVATE);
- Helper.generateHtmlOutput(jApiClasses, diffPrivateXmlFilePath.toString(), diffPrivateHtmlFilePath.toString(), true, AccessModifier.PRIVATE);
+ Helper.generateHtmlOutput(jApiClasses, diffPrivateHtmlFilePath.toString(), true, AccessModifier.PRIVATE);
File htmlFilePublic = diffPublicHtmlFilePath.toFile();
File htmlFilePrivate = diffPrivateHtmlFilePath.toFile();
- documentPublic = Jsoup.parse(htmlFilePublic, Charset.forName("UTF-8").toString());
- documentPrivate = Jsoup.parse(htmlFilePrivate, Charset.forName("UTF-8").toString());
+ documentPublic = Jsoup.parse(htmlFilePublic, StandardCharsets.UTF_8.toString());
+ documentPrivate = Jsoup.parse(htmlFilePrivate, StandardCharsets.UTF_8.toString());
}
@Test
diff --git a/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/output/xml/XmlOutputGeneratorClassTypeTest.java b/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/output/xml/XmlOutputGeneratorClassTypeTest.java
index 9fdfb239f..066327743 100644
--- a/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/output/xml/XmlOutputGeneratorClassTypeTest.java
+++ b/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/output/xml/XmlOutputGeneratorClassTypeTest.java
@@ -13,7 +13,7 @@
import java.io.File;
import java.io.IOException;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
@@ -31,9 +31,9 @@ public static void beforeClass() throws IOException {
Path diffPublicXmlPath = Paths.get(System.getProperty("user.dir"), "target", "diff_public.xml");
Path diffPublicHtmlPath = Paths.get(System.getProperty("user.dir"), "target", "diff_public.html");
List jApiClasses = Helper.compareTestV1WithTestV2(AccessModifier.PUBLIC);
- Helper.generateHtmlOutput(jApiClasses, diffPublicXmlPath.toString(), diffPublicHtmlPath.toString(), false, AccessModifier.PUBLIC);
+ Helper.generateHtmlOutput(jApiClasses, diffPublicHtmlPath.toString(), false, AccessModifier.PUBLIC);
File htmlFilePublic = Paths.get(System.getProperty("user.dir"), "target", "diff_public.html").toFile();
- documentPublic = Jsoup.parse(htmlFilePublic, Charset.forName("UTF-8").toString());
+ documentPublic = Jsoup.parse(htmlFilePublic, StandardCharsets.UTF_8.toString());
}
@Test
diff --git a/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/output/xml/XmlOutputGeneratorTest.java b/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/output/xml/XmlOutputGeneratorTest.java
index 391fea580..3aa424271 100644
--- a/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/output/xml/XmlOutputGeneratorTest.java
+++ b/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/output/xml/XmlOutputGeneratorTest.java
@@ -1,14 +1,13 @@
package japicmp.test.output.xml;
-import com.google.common.io.Files;
import japicmp.cmp.JarArchiveComparator;
import japicmp.cmp.JarArchiveComparatorOptions;
import japicmp.config.Options;
import japicmp.filter.JavadocLikePackageFilter;
import japicmp.model.JApiClass;
-import japicmp.output.xml.XmlOutput;
-import japicmp.output.xml.XmlOutputGenerator;
-import japicmp.output.xml.XmlOutputGeneratorOptions;
+import japicmp.output.html.HtmlOutput;
+import japicmp.output.html.HtmlOutputGenerator;
+import japicmp.output.html.HtmlOutputGeneratorOptions;
import japicmp.util.Optional;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
@@ -18,15 +17,16 @@
import java.io.File;
import java.io.IOException;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import static japicmp.test.output.xml.XmlHelper.getDivForClass;
import static japicmp.test.util.Helper.getArchive;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
public class XmlOutputGeneratorTest {
private static final String JAPICMP_TEST_SEMVER001 = "japicmp.test.semver001";
@@ -38,42 +38,39 @@ public class XmlOutputGeneratorTest {
@BeforeClass
public static void beforeClass() throws IOException {
- Path diffXmlFilePath = Paths.get(System.getProperty("user.dir"), "target", "diff.xml");
Path diffHtmlFilePath = Paths.get(System.getProperty("user.dir"), "target", "diff.html");
- Path diffOnlyModificationsXmlFilePath = Paths.get(System.getProperty("user.dir"), "target", "diff_onlyModifications.xml");
Path diffOnlyModificationsHtmlFilePath = Paths.get(System.getProperty("user.dir"), "target", "diff_onlyModifications.html");
JarArchiveComparatorOptions options = new JarArchiveComparatorOptions();
options.getFilters().getExcludes().add(new JavadocLikePackageFilter(JAPICMP_TEST_SEMVER001, false));
JarArchiveComparator jarArchiveComparator = new JarArchiveComparator(options);
jApiClasses = jarArchiveComparator.compare(getArchive("japicmp-test-v1.jar"), getArchive("japicmp-test-v2.jar"));
- generateHtmlOutput(diffXmlFilePath.toString(), diffHtmlFilePath.toString(), false);
- generateHtmlOutput(diffOnlyModificationsXmlFilePath.toString(), diffOnlyModificationsHtmlFilePath.toString(), true);
+ generateHtmlOutput(diffHtmlFilePath.toString(), false);
+ generateHtmlOutput(diffOnlyModificationsHtmlFilePath.toString(), true);
htmlFile = Paths.get(System.getProperty("user.dir"), "target", "diff.html").toFile();
- document = Jsoup.parse(htmlFile, Charset.forName("UTF-8").toString());
- documentOnlyModifications = Jsoup.parse(diffOnlyModificationsHtmlFilePath.toFile(), Charset.forName("UTF-8").toString());
+ document = Jsoup.parse(htmlFile, StandardCharsets.UTF_8.toString());
+ documentOnlyModifications = Jsoup.parse(diffOnlyModificationsHtmlFilePath.toFile(), StandardCharsets.UTF_8.toString());
}
- private static void generateHtmlOutput(String xmlOutpuFile, String htmlOutputFile, boolean outputOnlyModifications) {
+ private static void generateHtmlOutput( String htmlOutputFile, boolean outputOnlyModifications) throws IOException {
Options options = Options.newDefault();
- options.setXmlOutputFile(Optional.of(xmlOutpuFile));
options.setHtmlOutputFile(Optional.of(htmlOutputFile));
options.setOutputOnlyModifications(outputOnlyModifications);
- XmlOutputGeneratorOptions xmlOutputGeneratorOptions = new XmlOutputGeneratorOptions();
- xmlOutputGeneratorOptions.setTitle(TITLE);
- XmlOutputGenerator generator = new XmlOutputGenerator(jApiClasses, options, xmlOutputGeneratorOptions);
- XmlOutput xmlOutput = generator.generate();
- XmlOutputGenerator.writeToFiles(options, xmlOutput);
+ HtmlOutputGeneratorOptions htmlOutputGeneratorOptions = new HtmlOutputGeneratorOptions();
+ htmlOutputGeneratorOptions.setTitle(TITLE);
+ HtmlOutputGenerator generator = new HtmlOutputGenerator(jApiClasses, options, htmlOutputGeneratorOptions);
+ HtmlOutput htmlOutput = generator.generate();
+ Files.write(Paths.get(htmlOutputFile), htmlOutput.getHtml().getBytes(StandardCharsets.UTF_8));
}
@Test
- public void testMetaInformationTable() throws IOException {
+ public void testMetaInformationTable() {
assertThat(document.select("div.meta-information > table").isEmpty(), is(false));
assertThat(document.select("div.meta-information > table > tbody > tr").size(), is(10));
}
@Test
public void htmlFileNotContainsPackageSemver001() throws IOException {
- List lines = Files.readLines(htmlFile, Charset.forName("UTF-8"));
+ List lines = Files.readAllLines(htmlFile.toPath(), StandardCharsets.UTF_8);
boolean containsPackageName = false;
for (String line : lines) {
if (line.contains(JAPICMP_TEST_SEMVER001)) {
@@ -85,13 +82,13 @@ public void htmlFileNotContainsPackageSemver001() throws IOException {
}
@Test
- public void superclassAllChangesAddedWithSuperclass() throws IOException {
+ public void superclassAllChangesAddedWithSuperclass() {
Elements divSuperClass = getSuperClassDiv(document, "japicmp.test.Superclasses$AddedWithSuperclass");
assertThat(divSuperClass.select("table").isEmpty(), is(false));
}
@Test
- public void superclassOnlyModificationsAddedWithSuperclass() throws IOException {
+ public void superclassOnlyModificationsAddedWithSuperclass() {
Elements divSuperClass = getSuperClassDiv(documentOnlyModifications, "japicmp.test.Superclasses$AddedWithSuperclass");
assertThat(divSuperClass.select("table").isEmpty(), is(false));
}
@@ -104,49 +101,49 @@ private Elements getSuperClassDiv(Document document, String className) {
}
@Test
- public void superclassAllChangesAdded() throws IOException {
- Elements divSuperClass = getSuperClassDiv(document, "japicmp.test.Added");
+ public void superclassAllChangesAdded() {
+ Elements divSuperClass = getSuperClassDiv(document, "japicmp.test.Superclasses$AddedWithSuperclass");
assertThat(divSuperClass.select("table").isEmpty(), is(false));
}
@Test
- public void superclassOnlyModificationsAdded() throws IOException {
+ public void superclassOnlyModificationsAdded() {
Elements divSuperClass = getSuperClassDiv(documentOnlyModifications, "japicmp.test.Added");
assertThat(divSuperClass.select("table").isEmpty(), is(true));
}
@Test
- public void superclassAddedWithSuperclass() throws IOException {
+ public void superclassAddedWithSuperclass() {
Elements divSuperClass = getSuperClassDiv(document, "japicmp.test.Superclasses$AddedWithSuperclass");
assertThat(divSuperClass.select("table").isEmpty(), is(false));
}
@Test
- public void superclassAddedWithSuperclassOnlyModifications() throws IOException {
+ public void superclassAddedWithSuperclassOnlyModifications() {
Elements divSuperClass = getSuperClassDiv(documentOnlyModifications, "japicmp.test.Superclasses$AddedWithSuperclass");
assertThat(divSuperClass.select("table").isEmpty(), is(false));
}
@Test
- public void superclassRemovedWithSuperclass() throws IOException {
+ public void superclassRemovedWithSuperclass() {
Elements divSuperClass = getSuperClassDiv(document, "japicmp.test.Superclasses$RemovedWithSuperclass");
assertThat(divSuperClass.select("table").isEmpty(), is(false));
}
@Test
- public void superclassRemovedWithSuperclassOnlyModifications() throws IOException {
+ public void superclassRemovedWithSuperclassOnlyModifications() {
Elements divSuperClass = getSuperClassDiv(documentOnlyModifications, "japicmp.test.Superclasses$RemovedWithSuperclass");
assertThat(divSuperClass.select("table").isEmpty(), is(false));
}
@Test
- public void superclassNoSuperclassToSuperclass() throws IOException {
+ public void superclassNoSuperclassToSuperclass() {
Elements divSuperClass = getSuperClassDiv(document, "japicmp.test.Superclasses$NoSuperclassToSuperclass");
assertThat(divSuperClass.select("table").isEmpty(), is(false));
}
@Test
- public void superclassNoSuperclassToSuperclassOnlyModifications() throws IOException {
+ public void superclassNoSuperclassToSuperclassOnlyModifications() {
Elements divSuperClass = getSuperClassDiv(documentOnlyModifications, "japicmp.test.Superclasses$NoSuperclassToSuperclass");
assertThat(divSuperClass.select("table").isEmpty(), is(false));
}
diff --git a/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/util/Helper.java b/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/util/Helper.java
index c191f99fa..382ebe91e 100644
--- a/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/util/Helper.java
+++ b/japicmp-testbase/japicmp-test/src/test/java/japicmp/test/util/Helper.java
@@ -1,20 +1,14 @@
package japicmp.test.util;
-import japicmp.util.Optional;
import japicmp.cmp.JApiCmpArchive;
import japicmp.cmp.JarArchiveComparator;
import japicmp.cmp.JarArchiveComparatorOptions;
import japicmp.config.Options;
-import japicmp.model.AccessModifier;
-import japicmp.model.JApiAnnotation;
-import japicmp.model.JApiAnnotationElement;
-import japicmp.model.JApiClass;
-import japicmp.model.JApiField;
-import japicmp.model.JApiImplementedInterface;
-import japicmp.model.JApiMethod;
-import japicmp.output.xml.XmlOutput;
-import japicmp.output.xml.XmlOutputGenerator;
-import japicmp.output.xml.XmlOutputGeneratorOptions;
+import japicmp.model.*;
+import japicmp.output.html.HtmlOutput;
+import japicmp.output.html.HtmlOutputGenerator;
+import japicmp.output.html.HtmlOutputGeneratorOptions;
+import japicmp.util.Optional;
import org.hamcrest.CoreMatchers;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
@@ -22,6 +16,10 @@
import org.junit.Assert;
import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.List;
public class Helper {
@@ -164,17 +162,15 @@ public static List compareTestV1WithTestV2(AccessModifier accessModif
return jarArchiveComparator.compare(getArchive("japicmp-test-v1.jar"), getArchive("japicmp-test-v2.jar"));
}
- public static void generateHtmlOutput(List jApiClasses, String xmlOutputFile, String htmlOutputFile, boolean outputOnlyModifications, AccessModifier accessModifier) {
+ public static void generateHtmlOutput(List jApiClasses, String htmlOutputFile, boolean outputOnlyModifications, AccessModifier accessModifier) throws IOException {
Options options = Options.newDefault();
- options.setXmlOutputFile(Optional.of(xmlOutputFile));
options.setHtmlOutputFile(Optional.of(htmlOutputFile));
options.setOutputOnlyModifications(outputOnlyModifications);
options.setAccessModifier(Optional.of(accessModifier));
- XmlOutputGeneratorOptions xmlOutputGeneratorOptions = new XmlOutputGeneratorOptions();
- xmlOutputGeneratorOptions.setCreateSchemaFile(true);
- XmlOutputGenerator generator = new XmlOutputGenerator(jApiClasses, options, xmlOutputGeneratorOptions);
- XmlOutput xmlOutput = generator.generate();
- XmlOutputGenerator.writeToFiles(options, xmlOutput);
+ HtmlOutputGeneratorOptions htmlOutputGeneratorOptions = new HtmlOutputGeneratorOptions();
+ HtmlOutputGenerator generator = new HtmlOutputGenerator(jApiClasses, options, htmlOutputGeneratorOptions);
+ HtmlOutput htmlOutput = generator.generate();
+ Files.write(Paths.get(htmlOutputFile), htmlOutput.getHtml().getBytes(StandardCharsets.UTF_8));
}
public interface SimpleExceptionVerifier {