From 57eae58ee50e70b7b54078e07ba470ef8ed7c882 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 4 Mar 2018 12:24:44 +0000 Subject: [PATCH] use xmlunit for xml diffs in unit tests git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1825810 13f79535-47bb-0310-9956-ffa450edef68 --- .classpath | 1 + build.gradle | 1 + build.xml | 5 +++ gradle/wrapper/gradle-wrapper.jar | Bin 54212 -> 54212 bytes sonar/pom.xml | 7 ++++ .../poi/xddf/usermodel/TestXDDFColor.java | 37 +++++++++++------- 6 files changed, 37 insertions(+), 14 deletions(-) diff --git a/.classpath b/.classpath index 7098e32766..944cd2142b 100644 --- a/.classpath +++ b/.classpath @@ -35,6 +35,7 @@ + diff --git a/build.gradle b/build.gradle index 5811fe43bc..1ec30a7441 100644 --- a/build.gradle +++ b/build.gradle @@ -206,6 +206,7 @@ project('ooxml') { testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:2.13.0' + testCompile 'org.xmlunit:xmlunit-core:2.5.1' testCompile project(path: ':main', configuration: 'tests') testCompile 'org.openjdk.jmh:jmh-core:1.19' testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.19' diff --git a/build.xml b/build.xml index 670585b736..57d13c3ed9 100644 --- a/build.xml +++ b/build.xml @@ -164,6 +164,8 @@ under the License. + + @@ -325,6 +327,7 @@ under the License. + @@ -632,6 +635,7 @@ under the License. + @@ -667,6 +671,7 @@ under the License. + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 219c335356cc4a39e1c7cd3fa5261637d4893930..feef4e75785b9342f1ed3be2f04e798330bfe58a 100644 GIT binary patch delta 26 gcmX@IocYLd<_)ojn5z;}HYXes5d<+NmtXb;0G^l&QUCw| delta 26 gcmX@IocYLd<_)ojnBQjEZB95OA_!tkF2C#x0H*B>00000 diff --git a/sonar/pom.xml b/sonar/pom.xml index 1022d2107b..50a1b3fb05 100644 --- a/sonar/pom.xml +++ b/sonar/pom.xml @@ -65,6 +65,7 @@ 2.6.0 4.12 + 2.5.1 2.13.0 3.0.1 3.0.1 @@ -137,6 +138,12 @@ ${junit.version} test + + org.xmlunit + xmlunit-core + ${xmlunit.version} + test + org.mockito mockito-core diff --git a/src/ooxml/testcases/org/apache/poi/xddf/usermodel/TestXDDFColor.java b/src/ooxml/testcases/org/apache/poi/xddf/usermodel/TestXDDFColor.java index 989313ae19..156133ad62 100644 --- a/src/ooxml/testcases/org/apache/poi/xddf/usermodel/TestXDDFColor.java +++ b/src/ooxml/testcases/org/apache/poi/xddf/usermodel/TestXDDFColor.java @@ -18,6 +18,7 @@ package org.apache.poi.xddf.usermodel; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import java.io.IOException; @@ -31,26 +32,34 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTSystemColor; import org.openxmlformats.schemas.drawingml.x2006.main.STPresetColorVal; import org.openxmlformats.schemas.drawingml.x2006.main.STSchemeColorVal; import org.openxmlformats.schemas.drawingml.x2006.main.STSystemColorVal; +import org.xmlunit.builder.DiffBuilder; +import org.xmlunit.builder.Input; +import org.xmlunit.diff.Diff; public class TestXDDFColor { private static final String XMLNS = "xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"/>"; @Test public void testSchemeColor() throws IOException { - XMLSlideShow ppt = new XMLSlideShow(); - XSLFTheme theme = ppt.createSlide().getTheme(); - - XDDFColor color = XDDFColor.forColorContainer(getThemeColor(theme, STSchemeColorVal.ACCENT_2)); - // accent2 in theme1.xml is - assertEquals(" + Diff d1 = DiffBuilder.compare(Input.fromString("