aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-02-19 13:10:29 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-02-19 13:32:39 +0100
commit5b2ce72ec304284354e4786ac3afe6fb3dd24077 (patch)
tree5063d293d69f46f43e9d5c767f46bd6d0d1a8e44
parent4dcf22377c7823584f0d9d7dbb85641980245fd8 (diff)
downloadsonarqube-5b2ce72ec304284354e4786ac3afe6fb3dd24077.tar.gz
sonarqube-5b2ce72ec304284354e4786ac3afe6fb3dd24077.zip
Drop dependency xmlunit
Replaced by assertJ assertThat().isXmlEqualTo()
-rw-r--r--pom.xml5
-rw-r--r--server/sonar-server/pom.xml5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelXMLExporterTest.java15
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java10
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/QProfileBackuperMediumTest/expected-backup.xml2
-rw-r--r--sonar-plugin-api/pom.xml5
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/profiles/XMLProfileSerializerTest.java33
7 files changed, 11 insertions, 64 deletions
diff --git a/pom.xml b/pom.xml
index bc2cd9f0712..610e8028afc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -976,11 +976,6 @@
<version>1.9.2</version>
</dependency>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
<version>2.4.5</version>
diff --git a/server/sonar-server/pom.xml b/server/sonar-server/pom.xml
index bb1b64f3053..0f9315c3840 100644
--- a/server/sonar-server/pom.xml
+++ b/server/sonar-server/pom.xml
@@ -224,11 +224,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>com.tngtech.java</groupId>
<artifactId>junit-dataprovider</artifactId>
<scope>test</scope>
diff --git a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelXMLExporterTest.java b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelXMLExporterTest.java
index dce5f8bb9f5..017876ef1d3 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelXMLExporterTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelXMLExporterTest.java
@@ -23,17 +23,13 @@ import com.google.common.io.Resources;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;
-import org.apache.commons.lang.CharUtils;
import org.apache.commons.lang.SystemUtils;
-import org.custommonkey.xmlunit.Diff;
-import org.custommonkey.xmlunit.XMLUnit;
import org.junit.Test;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.server.debt.DebtRemediationFunction;
import static com.google.common.collect.Lists.newArrayList;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertTrue;
import static org.sonar.server.debt.DebtModelXMLExporter.RuleDebt;
public class DebtModelXMLExporterTest {
@@ -42,7 +38,7 @@ public class DebtModelXMLExporterTest {
@Test
public void export_empty() {
- assertThat(underTest.export(Collections.<RuleDebt>emptyList())).isEqualTo("<sqale/>" + SystemUtils.LINE_SEPARATOR);
+ assertThat(underTest.export(Collections.emptyList())).isEqualTo("<sqale/>" + SystemUtils.LINE_SEPARATOR);
}
@Test
@@ -52,7 +48,7 @@ public class DebtModelXMLExporterTest {
.setFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name()).setCoefficient("3d").setOffset("15min")
);
- assertSimilarXml(getFileContent("export_xml.xml"), underTest.export(rules));
+ assertThat(underTest.export(rules)).isXmlEqualTo(getFileContent("export_xml.xml"));
}
@Test
@@ -80,13 +76,6 @@ public class DebtModelXMLExporterTest {
);
}
- public static void assertSimilarXml(String expectedXml, String xml) throws Exception {
- XMLUnit.setIgnoreWhitespace(true);
- Diff diff = XMLUnit.compareXML(xml, expectedXml);
- String message = "Diff: " + diff.toString() + CharUtils.LF + "XML: " + xml;
- assertTrue(message, diff.similar());
- }
-
private static String getFileContent(String file) throws Exception {
return Resources.toString(Resources.getResource(DebtModelXMLExporterTest.class, "DebtModelXMLExporterTest/" + file), StandardCharsets.UTF_8);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java
index 1d460227b3f..5c9c7e51539 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java
@@ -25,8 +25,6 @@ import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.util.List;
import javax.xml.stream.XMLStreamException;
-import org.custommonkey.xmlunit.Diff;
-import org.custommonkey.xmlunit.XMLUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
@@ -134,12 +132,8 @@ public class QProfileBackuperMediumTest {
StringWriter output = new StringWriter();
tester.get(QProfileBackuper.class).backup(XOO_P1_KEY, output);
- XMLUnit.setIgnoreWhitespace(true);
- XMLUnit.setIgnoreComments(true);
- Diff diff = XMLUnit.compareXML(output.toString(),
- Resources.toString(getClass().getResource("QProfileBackuperMediumTest/expected-backup.xml"), StandardCharsets.UTF_8));
-
- assertThat(diff.identical()).as(diff.toString()).isTrue();
+ String expectedXml = Resources.toString(getClass().getResource("QProfileBackuperMediumTest/expected-backup.xml"), StandardCharsets.UTF_8);
+ assertThat(output.toString()).isXmlEqualTo(expectedXml);
}
@Test
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/QProfileBackuperMediumTest/expected-backup.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/QProfileBackuperMediumTest/expected-backup.xml
index 02ff3f84ddb..037019f9c5a 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/QProfileBackuperMediumTest/expected-backup.xml
+++ b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/QProfileBackuperMediumTest/expected-backup.xml
@@ -3,14 +3,12 @@
<name>P1</name>
<language>xoo</language>
<rules>
- <!-- blah comes first (sorted by repository) -->
<rule>
<repositoryKey>blah</repositoryKey>
<key>my-rule</key>
<priority>INFO</priority>
<parameters/>
</rule>
- <!-- x1 before x2 (sorted by key) -->
<rule>
<repositoryKey>xoo</repositoryKey>
<key>x1</key>
diff --git a/sonar-plugin-api/pom.xml b/sonar-plugin-api/pom.xml
index ee8f9a32bca..2a83f3319b0 100644
--- a/sonar-plugin-api/pom.xml
+++ b/sonar-plugin-api/pom.xml
@@ -172,11 +172,6 @@
<artifactId>sonar-testing-harness</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/XMLProfileSerializerTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/XMLProfileSerializerTest.java
index cd8da67c16d..95070b30a0f 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/XMLProfileSerializerTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/XMLProfileSerializerTest.java
@@ -19,22 +19,17 @@
*/
package org.sonar.api.profiles;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.CharUtils;
-import org.custommonkey.xmlunit.Diff;
-import org.custommonkey.xmlunit.XMLUnit;
import org.junit.Test;
import org.sonar.api.rules.ActiveRule;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RulePriority;
import org.xml.sax.SAXException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.io.Writer;
-
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
public class XMLProfileSerializerTest {
@@ -75,22 +70,8 @@ public class XMLProfileSerializerTest {
assertSimilarXml("exportRuleParameters.xml", writer.toString());
}
- public static void assertSimilarXml(String fileWithExpectedXml, String xml) throws IOException, SAXException {
- String pathToExpectedXml = "/org/sonar/api/profiles/XMLProfileSerializerTest/" + fileWithExpectedXml;
- InputStream stream = XMLProfileSerializerTest.class.getResourceAsStream(pathToExpectedXml);
- try {
- Diff diff = isSimilarXml(IOUtils.toString(stream), xml);
- String message = "Diff: " + diff.toString() + CharUtils.LF + "XML: " + xml;
- assertTrue(message, diff.similar());
-
- } finally {
- IOUtils.closeQuietly(stream);
- }
- }
-
- static Diff isSimilarXml(String expectedXml, String xml) throws IOException, SAXException {
- XMLUnit.setIgnoreWhitespace(true);
- Diff diff = XMLUnit.compareXML(xml, expectedXml);
- return diff;
+ private void assertSimilarXml(String fileWithExpectedXml, String xml) throws IOException, SAXException {
+ String pathToExpectedXml = "XMLProfileSerializerTest/" + fileWithExpectedXml;
+ assertThat(xml).isXmlEqualTo(IOUtils.toString(getClass().getResource(pathToExpectedXml)));
}
}