]> source.dussan.org Git - archiva.git/commitdiff
Switching to new xmlunit version
authorMartin Stockhammer <martin_s@apache.org>
Wed, 29 Jan 2020 22:03:00 +0000 (23:03 +0100)
committerMartin Stockhammer <martin_s@apache.org>
Wed, 29 Jan 2020 22:03:00 +0000 (23:03 +0100)
15 files changed:
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
archiva-modules/archiva-base/archiva-proxy/pom.xml
archiva-modules/archiva-base/archiva-test-utils/pom.xml
archiva-modules/archiva-maven/archiva-maven-proxy/pom.xml
archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java
archiva-modules/archiva-maven/archiva-maven-repository/pom.xml
archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java
archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriterTest.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
archiva-modules/archiva-web/archiva-rss/pom.xml
archiva-modules/archiva-web/archiva-webdav/pom.xml
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java
pom.xml

index eea06dfda884cbb18741f3f0bdba80b8809b3c5b..599130f8ad91c71ba84cd0e8a6bb7755c976aeac 100644 (file)
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>xmlunit</groupId>
-      <artifactId>xmlunit</artifactId>
+      <groupId>org.xmlunit</groupId>
+      <artifactId>xmlunit-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.xmlunit</groupId>
+      <artifactId>xmlunit-assertj</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
index 156f137cd471796b900e0fa993f1bd34c2fba60e..76b6ce72db048fc87073a49080dc68d651dfa59a 100644 (file)
@@ -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 =
             "<expected><versions><version>2.2</version>" + "<version>2.3</version></versions></expected>";
 
-        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 = "<expected><versions><version>2.0.3-SNAPSHOT</version>"
             + "<version>2.0.4-SNAPSHOT</version></versions></expected>";
 
-        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 );
     }
 }
index 453b90becf56c3a593e28430d6f081068287be09..3af6a44b3f99dafbe014844d6d7c239724f48053 100644 (file)
@@ -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 = "<expected><versions><version>2.3-SNAPSHOT</version></versions></expected>";
-
-        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 =
             "<expected><versions><version>2.2</version>" + "<version>2.3</version></versions></expected>";
 
-        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 );
     }
index af604519d1c84aefa5ea7bcb9d17d57b61bd6f4d..f3edcd0ba81733d905ae9f7aa861d3fd6f6691df 100644 (file)
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>xmlunit</groupId>
-      <artifactId>xmlunit</artifactId>
+      <groupId>org.xmlunit</groupId>
+      <artifactId>xmlunit-core</artifactId>
       <scope>test</scope>
     </dependency>
 
index 48625be154fbd975f0c1635a9311d531cc6faa48..7f74abdfaad68db40cb8df5a3dbc1299bbe5e2b6 100644 (file)
@@ -38,8 +38,8 @@
       <artifactId>spring-test</artifactId>
     </dependency>
     <dependency>
-      <groupId>xmlunit</groupId>
-      <artifactId>xmlunit</artifactId>
+      <groupId>org.xmlunit</groupId>
+      <artifactId>xmlunit-core</artifactId>
       <scope>compile</scope>
     </dependency>
     <dependency>
index 9c4599f2bb42aae89bc0333bd3cdba0722ee26f5..657cd0f476494cbacda51fb14f8720e304f3646f 100644 (file)
     </dependency>
 
     <!-- Test scope -->
+    <dependency>
+      <groupId>org.xmlunit</groupId>
+      <artifactId>xmlunit-core</artifactId>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>org.easymock</groupId>
       <artifactId>easymock</artifactId>
index 9a4934269a80ca2a98de328faf62eb65da2c0c89..f12a966d0b9652041bb1dd3adbc5231f28e9a761 100644 (file)
@@ -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 );
         }
 
index dac8aff5b3788db81c13ba7ace36cdd9684bcffb..94d7e7f9a124ca25f169f56d4569602828d38a01 100644 (file)
 
 
     <!-- Test scope -->
+    <dependency>
+      <groupId>org.xmlunit</groupId>
+      <artifactId>xmlunit-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.xmlunit</groupId>
+      <artifactId>xmlunit-assertj</artifactId>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>org.easymock</groupId>
       <artifactId>easymock</artifactId>
index e39a3dc69e0af756345fdf7588b63595c6dca807..b9b09db20cfd60fd3f4510c7394de4f834edfc95 100644 (file)
@@ -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 );
         }
index 304adf2efcb6f43ea8183e5372da3e3c9d7fa6b0..55936edd33f5bb0fcc8d40855670f5651826f938 100644 (file)
@@ -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();
     }
 }
index 7136293c44ca6a90e2ed49b86d4281135926d936..4c9252b9098797c7e50bc5e60022e4a32cfbb06f 100644 (file)
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>xmlunit</groupId>
-      <artifactId>xmlunit</artifactId>
+      <groupId>org.xmlunit</groupId>
+      <artifactId>xmlunit-core</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
index 64a25140c463efd6abb631561c088e8bbde1cd2d..7d9ab0387a0175ca3160b9d2b053665467cafb1f 100644 (file)
@@ -57,8 +57,8 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>xmlunit</groupId>
-      <artifactId>xmlunit</artifactId>
+      <groupId>org.xmlunit</groupId>
+      <artifactId>xmlunit-core</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
index c10f9a0330323116dcd8a30b52bde2090d989b1b..d13367243109e42195045805f7e6168ef5c93ff1 100644 (file)
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>xmlunit</groupId>
-      <artifactId>xmlunit</artifactId>
+      <groupId>org.xmlunit</groupId>
+      <artifactId>xmlunit-core</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
index 47c5d7ebfca7c9cd75d6e8a041540de976ea26d1..65fc4c61ac2d7b5e9d42bebedd4755b18033d400 100644 (file)
@@ -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 e14ff08875aac06e408c32a1c1d39874b64d9bfe..f726f9b57cb91f6bd81e44196901aec586e28270 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -61,6 +61,8 @@
     <commons-fileupload.version>1.4</commons-fileupload.version>
     <commons-lang.version>3.9</commons-lang.version>
 
+    <xmlunit.version>2.6.3</xmlunit.version>
+
     <maven3x.version>3.5.4</maven3x.version>
     <maven.resolver.version>1.1.1</maven.resolver.version>
     <maven.indexer.version>6.0.1-SNAPSHOT</maven.indexer.version>
 
 
       <dependency>
-        <groupId>xmlunit</groupId>
-        <artifactId>xmlunit</artifactId>
-        <version>1.0</version>
+        <groupId>org.xmlunit</groupId>
+        <artifactId>xmlunit-core</artifactId>
+        <version>${xmlunit.version}</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.xmlunit</groupId>
+        <artifactId>xmlunit-assertj</artifactId>
+        <version>${xmlunit.version}</version>
+        <scope>test</scope>
       </dependency>
+
       <dependency>
         <groupId>joda-time</groupId>
         <artifactId>joda-time</artifactId>