From: Martin Stockhammer Date: Wed, 29 Jan 2020 22:03:00 +0000 (+0100) Subject: Switching to new xmlunit version X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=712867584d864d3f7c0ba66ed549342c23b958c3;p=archiva.git Switching to new xmlunit version --- diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml index eea06dfda..599130f8a 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml @@ -145,8 +145,13 @@ test - xmlunit - xmlunit + org.xmlunit + xmlunit-core + test + + + org.xmlunit + xmlunit-assertj test diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java index 156f137cd..76b6ce72d 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java @@ -30,11 +30,11 @@ import org.apache.archiva.repository.RepositoryContentFactory; import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.metadata.audit.RepositoryListener; import org.apache.archiva.repository.metadata.base.MetadataTools; -import org.custommonkey.xmlunit.XMLAssert; import org.easymock.EasyMock; import org.junit.Before; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; +import org.xmlunit.assertj.XmlAssert; import javax.inject.Inject; import java.nio.charset.Charset; @@ -179,12 +179,18 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest String expectedVersions = "2.2" + "2.3"; - XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/release", metadataXml ); - XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/latest", metadataXml ); - System.out.println(metadataXml); - XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions, - "//metadata/versioning/versions/version", metadataXml ); - XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml ); + XmlAssert.assertThat( metadataXml ).valueByXPath( "//metadata/versioning/release" ).isEqualTo( "2.3" ); + // XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/release", metadataXml ); + XmlAssert.assertThat( metadataXml ).valueByXPath( "//metadata/versioning/latest" ).isEqualTo( "2.3" ); + // XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/latest", metadataXml ); + XmlAssert.assertThat( metadataXml ).nodesByXPath( "//metadata/versioning/versions/version" ).hasSize( 2 ); + XmlAssert.assertThat( metadataXml ).valueByXPath( "//metadata/versioning/versions/version[1]" ).isEqualTo( "2.2" ); + XmlAssert.assertThat( metadataXml ).valueByXPath( "//metadata/versioning/versions/version[2]" ).isEqualTo( "2.3" ); + + // XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions, + // "//metadata/versioning/versions/version", metadataXml ); + XmlAssert.assertThat( metadataXml ).valueByXPath( "//metadata/versioning/lastUpdated" ).isEqualTo( "20070315032817" ); + // XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml ); } @Test @@ -377,9 +383,14 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest String expectedVersions = "2.0.3-SNAPSHOT" + "2.0.4-SNAPSHOT"; - XMLAssert.assertXpathEvaluatesTo( "2.0.4-SNAPSHOT", "//metadata/versioning/latest", metadataXml ); - XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions, - "//metadata/versioning/versions/version", metadataXml ); - XMLAssert.assertXpathEvaluatesTo( "20070427033345", "//metadata/versioning/lastUpdated", metadataXml ); + XmlAssert.assertThat( metadataXml ).valueByXPath( "//metadata/versioning/latest" ).isEqualTo( "2.0.4-SNAPSHOT" ); + // XMLAssert.assertXpathEvaluatesTo( "2.0.4-SNAPSHOT", "//metadata/versioning/latest", metadataXml ); + XmlAssert.assertThat( metadataXml ).nodesByXPath( "//metadata/versioning/versions/version" ).hasSize( 2 ); + XmlAssert.assertThat( metadataXml ).valueByXPath( "//metadata/versioning/versions/version[1]" ).isEqualTo( "2.0.3-SNAPSHOT" ); + XmlAssert.assertThat( metadataXml ).valueByXPath( "//metadata/versioning/versions/version[2]" ).isEqualTo( "2.0.4-SNAPSHOT" ); + // XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions, + // "//metadata/versioning/versions/version", metadataXml ); + XmlAssert.assertThat( metadataXml ).valueByXPath( "//metadata/versioning/lastUpdated" ).isEqualTo( "20070427033345" ); + // XMLAssert.assertXpathEvaluatesTo( "20070427033345", "//metadata/versioning/lastUpdated", metadataXml ); } } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java index 453b90bec..3af6a44b3 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java @@ -30,7 +30,6 @@ import org.apache.archiva.metadata.model.MetadataFacet; import org.apache.archiva.repository.base.ArchivaRepositoryRegistry; import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.features.ArtifactCleanupFeature; -import org.custommonkey.xmlunit.XMLAssert; import org.easymock.EasyMock; import org.junit.After; import org.junit.Before; @@ -39,6 +38,7 @@ import org.mockito.ArgumentCaptor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.test.context.ContextConfiguration; +import org.xmlunit.assertj.XmlAssert; import java.io.IOException; import java.nio.charset.Charset; @@ -421,12 +421,9 @@ public class RepositoryPurgeConsumerTest String metadataXml = org.apache.archiva.common.utils.FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() ); - String expectedVersions = "2.3-SNAPSHOT"; - - XMLAssert.assertXpathEvaluatesTo( "2.3-SNAPSHOT", "//metadata/versioning/latest", metadataXml ); - XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions, - "//metadata/versioning/versions/version", metadataXml ); - XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml ); + XmlAssert.assertThat( metadataXml ).valueByXPath( "//metadata/versioning/latest" ).isEqualTo( "2.3-SNAPSHOT" ); + XmlAssert.assertThat( metadataXml ).valueByXPath( "//metadata/versioning/versions/version" ).isEqualTo( "2.3-SNAPSHOT" ); + XmlAssert.assertThat(metadataXml).valueByXPath("//metadata/versioning/lastUpdated").isEqualTo ( "20070315032817" ); removeRepoFromConfiguration( "retention-count", repoConfiguration ); } @@ -492,10 +489,16 @@ public class RepositoryPurgeConsumerTest String expectedVersions = "2.2" + "2.3"; - XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/latest", metadataXml ); - XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions, - "//metadata/versioning/versions/version", metadataXml ); - XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml ); + XmlAssert.assertThat( metadataXml ).valueByXPath( "//metadata/versioning/latest" ).isEqualTo( "2.3" ); + // XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/latest", metadataXml ); + XmlAssert.assertThat( metadataXml ).nodesByXPath( "//metadata/versioning/versions/version" ).hasSize( 2 ); + XmlAssert.assertThat( metadataXml ).valueByXPath( "//metadata/versioning/versions/version[1]" ).isEqualTo( "2.2" ); + XmlAssert.assertThat( metadataXml ).valueByXPath( "//metadata/versioning/versions/version[2]" ).isEqualTo( "2.3" ); + // XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions, + // "//metadata/versioning/versions/version", metadataXml ); + + XmlAssert.assertThat( metadataXml ).valueByXPath( "//metadata/versioning/lastUpdated" ).isEqualTo( "20070315032817" ); + //XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml ); removeRepoFromConfiguration( "days-old", repoConfiguration ); } diff --git a/archiva-modules/archiva-base/archiva-proxy/pom.xml b/archiva-modules/archiva-base/archiva-proxy/pom.xml index af604519d..f3edcd0ba 100644 --- a/archiva-modules/archiva-base/archiva-proxy/pom.xml +++ b/archiva-modules/archiva-base/archiva-proxy/pom.xml @@ -107,8 +107,8 @@ test - xmlunit - xmlunit + org.xmlunit + xmlunit-core test diff --git a/archiva-modules/archiva-base/archiva-test-utils/pom.xml b/archiva-modules/archiva-base/archiva-test-utils/pom.xml index 48625be15..7f74abdfa 100644 --- a/archiva-modules/archiva-base/archiva-test-utils/pom.xml +++ b/archiva-modules/archiva-base/archiva-test-utils/pom.xml @@ -38,8 +38,8 @@ spring-test - xmlunit - xmlunit + org.xmlunit + xmlunit-core compile diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/pom.xml b/archiva-modules/archiva-maven/archiva-maven-proxy/pom.xml index 9c4599f2b..657cd0f47 100644 --- a/archiva-modules/archiva-maven/archiva-maven-proxy/pom.xml +++ b/archiva-modules/archiva-maven/archiva-maven-proxy/pom.xml @@ -78,6 +78,11 @@ + + org.xmlunit + xmlunit-core + test + org.easymock easymock diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java index 9a4934269..f12a966d0 100644 --- a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java @@ -39,10 +39,13 @@ import org.apache.archiva.repository.storage.FilesystemStorage; import org.apache.archiva.repository.storage.StorageAsset; import org.apache.commons.lang3.StringUtils; import org.apache.maven.wagon.TransferFailedException; -import org.custommonkey.xmlunit.DetailedDiff; -import org.custommonkey.xmlunit.Diff; import org.easymock.EasyMock; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xmlunit.builder.DiffBuilder; +import org.xmlunit.diff.Diff; +import org.xmlunit.diff.Difference; import javax.inject.Inject; import javax.inject.Named; @@ -1098,9 +1101,13 @@ public class MetadataTransferTest ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( actualFileAsset ); RepositoryMetadataWriter.write( metadata, actualContents ); - DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadataXml, actualContents.toString() ) ); - if ( !detailedDiff.similar() ) + Diff detailedDiff = DiffBuilder.compare( expectedMetadataXml).withTest( actualContents.toString() ).checkForSimilar().build(); + if ( detailedDiff.hasDifferences() ) { + for ( Difference diff : detailedDiff.getDifferences() ) + { + System.out.println( diff ); + } assertEquals( expectedMetadataXml, actualContents ); } diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/pom.xml b/archiva-modules/archiva-maven/archiva-maven-repository/pom.xml index dac8aff5b..94d7e7f9a 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/pom.xml +++ b/archiva-modules/archiva-maven/archiva-maven-repository/pom.xml @@ -151,6 +151,16 @@ + + org.xmlunit + xmlunit-core + test + + + org.xmlunit + xmlunit-assertj + test + org.easymock easymock diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java index e39a3dc69..b9b09db20 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java @@ -37,11 +37,12 @@ import org.apache.archiva.repository.metadata.base.MetadataTools; import org.apache.archiva.repository.maven2.MavenManagedRepository; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; -import org.custommonkey.xmlunit.DetailedDiff; -import org.custommonkey.xmlunit.Diff; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import org.xml.sax.SAXException; +import org.xmlunit.builder.DiffBuilder; +import org.xmlunit.diff.Diff; +import org.xmlunit.diff.Difference; import javax.inject.Inject; import javax.inject.Named; @@ -397,9 +398,12 @@ public class MetadataToolsTest Path metadataFile = Paths.get( repository.getRepoRoot(), tools.toPath( reference ) ); String actualMetadata = org.apache.archiva.common.utils.FileUtils.readFileToString( metadataFile, Charset.defaultCharset() ); - DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) ); - if ( !detailedDiff.similar() ) + Diff detailedDiff = DiffBuilder.compare( expectedMetadata ).withTest( actualMetadata ).checkForSimilar().build(); + if ( detailedDiff.hasDifferences() ) { + for ( Difference diff : detailedDiff.getDifferences() ) { + System.out.println( diff ); + } // If it isn't similar, dump the difference. assertEquals( expectedMetadata, actualMetadata ); } @@ -412,9 +416,12 @@ public class MetadataToolsTest Path metadataFile = Paths.get( repository.getRepoRoot(), tools.toPath( reference ) ); String actualMetadata = org.apache.archiva.common.utils.FileUtils.readFileToString( metadataFile, Charset.defaultCharset() ); - DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) ); - if ( !detailedDiff.similar() ) + Diff detailedDiff = DiffBuilder.compare( expectedMetadata ).withTest( actualMetadata ).checkForSimilar().build(); + if ( detailedDiff.hasDifferences() ) { + for ( Difference diff : detailedDiff.getDifferences() ) { + System.out.println( diff ); + } // If it isn't similar, dump the difference. assertEquals( expectedMetadata, actualMetadata ); } diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriterTest.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriterTest.java index 304adf2ef..55936edd3 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriterTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriterTest.java @@ -23,7 +23,6 @@ import junit.framework.TestCase; import org.apache.archiva.model.ArchivaRepositoryMetadata; import org.apache.archiva.repository.metadata.base.RepositoryMetadataWriter; import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; -import org.custommonkey.xmlunit.XMLAssert; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,6 +31,8 @@ import java.nio.charset.Charset; import java.nio.file.Path; import java.nio.file.Paths; +import org.xmlunit.assertj.XmlAssert; + /** * RepositoryMetadataWriterTest */ @@ -61,6 +62,6 @@ public class RepositoryMetadataWriterTest StringWriter actual = new StringWriter(); RepositoryMetadataWriter.write( metadata, actual ); - XMLAssert.assertXMLEqual( "XML Contents", expectedContent, actual.toString() ); + XmlAssert.assertThat( actual.toString() ).and( expectedContent ).areIdentical(); } } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml index 7136293c4..4c9252b90 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml @@ -238,8 +238,8 @@ test - xmlunit - xmlunit + org.xmlunit + xmlunit-core test diff --git a/archiva-modules/archiva-web/archiva-rss/pom.xml b/archiva-modules/archiva-web/archiva-rss/pom.xml index 64a25140c..7d9ab0387 100644 --- a/archiva-modules/archiva-web/archiva-rss/pom.xml +++ b/archiva-modules/archiva-web/archiva-rss/pom.xml @@ -57,8 +57,8 @@ test - xmlunit - xmlunit + org.xmlunit + xmlunit-core test diff --git a/archiva-modules/archiva-web/archiva-webdav/pom.xml b/archiva-modules/archiva-web/archiva-webdav/pom.xml index c10f9a033..d13367243 100644 --- a/archiva-modules/archiva-web/archiva-webdav/pom.xml +++ b/archiva-modules/archiva-web/archiva-webdav/pom.xml @@ -188,8 +188,8 @@ test - xmlunit - xmlunit + org.xmlunit + xmlunit-core test diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java index 47c5d7ebf..65fc4c61a 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java @@ -25,9 +25,10 @@ import com.gargoylesoftware.htmlunit.WebResponse; import org.apache.archiva.common.utils.FileUtils; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; -import org.custommonkey.xmlunit.DetailedDiff; -import org.custommonkey.xmlunit.Diff; import org.junit.Before; +import org.xmlunit.builder.DiffBuilder; +import org.xmlunit.diff.Diff; +import org.xmlunit.diff.Difference; import java.nio.file.Paths; @@ -44,9 +45,12 @@ public abstract class AbstractRepositoryServletProxiedMetadataTestCase protected void assertExpectedMetadata( String expectedMetadata, String actualMetadata ) throws Exception { - DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) ); - if ( !detailedDiff.similar() ) + Diff detailedDiff = DiffBuilder.compare( expectedMetadata ).withTest( actualMetadata ).checkForSimilar().build(); + if ( detailedDiff.hasDifferences() ) { + for ( Difference diff : detailedDiff.getDifferences() ) { + System.out.println( diff ); + } // If it isn't similar, dump the difference. assertEquals( expectedMetadata, actualMetadata ); } diff --git a/pom.xml b/pom.xml index e14ff0887..f726f9b57 100644 --- a/pom.xml +++ b/pom.xml @@ -61,6 +61,8 @@ 1.4 3.9 + 2.6.3 + 3.5.4 1.1.1 6.0.1-SNAPSHOT @@ -1493,10 +1495,18 @@ - xmlunit - xmlunit - 1.0 + org.xmlunit + xmlunit-core + ${xmlunit.version} + test + + + org.xmlunit + xmlunit-assertj + ${xmlunit.version} + test + joda-time joda-time