diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6656BuildConsumer.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6656BuildConsumer.java index 6086e5c213..51634e016b 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6656BuildConsumer.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6656BuildConsumer.java @@ -23,7 +23,9 @@ import org.apache.maven.it.util.ResourceExtractor; import org.apache.maven.shared.utils.io.FileUtils; import java.io.File; +import java.io.IOException; import java.util.Arrays; +import java.util.Collections; /** * With the build-consumer the pom.xml will be adjusted during the process. @@ -71,21 +73,26 @@ public class MavenITmng6656BuildConsumer verifier.setAutoclean( false ); verifier.addCliOption( "-Dchangelist=MNG6656" ); - verifier.executeGoals( Arrays.asList( "install" ) ); + verifier.executeGoals( Collections.singletonList( "install" ) ); verifier.verifyErrorFreeLog(); - String content; - content = FileUtils.fileRead( new File( testDir, "expected/parent.pom") ); - verifier.assertArtifactContents( "org.sonatype.mavenbook.multi", "parent", "0.9-MNG6656-SNAPSHOT", "pom", content ); + assertTextEquals( new File( testDir, "expected/parent.pom"), + new File( verifier.getArtifactPath( "org.sonatype.mavenbook.multi", "parent", "0.9-MNG6656-SNAPSHOT", "pom" ) ) ); - content = FileUtils.fileRead( new File( testDir, "expected/simple-parent.pom") ); - verifier.assertArtifactContents( "org.sonatype.mavenbook.multi", "simple-parent", "0.9-MNG6656-SNAPSHOT", "pom", content ); + assertTextEquals( new File( testDir, "expected/simple-parent.pom"), + new File( verifier.getArtifactPath( "org.sonatype.mavenbook.multi", "simple-parent", "0.9-MNG6656-SNAPSHOT", "pom" ) ) ); - content = FileUtils.fileRead( new File( testDir, "expected/simple-weather.pom") ); - verifier.assertArtifactContents( "org.sonatype.mavenbook.multi", "simple-weather", "0.9-MNG6656-SNAPSHOT", "pom", content ); + assertTextEquals( new File( testDir, "expected/simple-weather.pom"), + new File( verifier.getArtifactPath( "org.sonatype.mavenbook.multi", "simple-weather", "0.9-MNG6656-SNAPSHOT", "pom" ) ) ); - content = FileUtils.fileRead( new File( testDir, "expected/simple-webapp.pom") ); - verifier.assertArtifactContents( "org.sonatype.mavenbook.multi", "simple-webapp", "0.9-MNG6656-SNAPSHOT", "pom", content ); + assertTextEquals( new File( testDir, "expected/simple-webapp.pom"), + new File( verifier.getArtifactPath( "org.sonatype.mavenbook.multi", "simple-webapp", "0.9-MNG6656-SNAPSHOT", "pom" ) ) ); + } + + static void assertTextEquals( File file1, File file2 ) + throws IOException + { + assertEquals( FileUtils.loadFile( file1 ), FileUtils.loadFile( file2 ) ); } } diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6957BuildConsumer.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6957BuildConsumer.java index 6486d45854..19eb1248ce 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6957BuildConsumer.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6957BuildConsumer.java @@ -23,7 +23,9 @@ import org.apache.maven.it.util.ResourceExtractor; import org.apache.maven.shared.utils.io.FileUtils; import java.io.File; +import java.io.IOException; import java.util.Arrays; +import java.util.Collections; /** * With the build-consumer the POM will be adjusted during the process. @@ -71,27 +73,32 @@ public class MavenITmng6957BuildConsumer verifier.setAutoclean( false ); verifier.addCliOption( "-Dchangelist=MNG6957" ); - verifier.executeGoals( Arrays.asList( "install" ) ); + verifier.executeGoals( Collections.singletonList( "install" ) ); verifier.verifyErrorFreeLog(); - String content; - content = FileUtils.fileRead( new File( testDir, "expected/parent.pom") ); - verifier.assertArtifactContents( "org.sonatype.mavenbook.multi", "parent", "0.9-MNG6957-SNAPSHOT", "pom", content ); + assertTextEquals( new File( testDir, "expected/parent.pom"), + new File( verifier.getArtifactPath( "org.sonatype.mavenbook.multi", "parent", "0.9-MNG6957-SNAPSHOT", "pom" ) ) ); - content = FileUtils.fileRead( new File( testDir, "expected/simple-parent.pom") ); - verifier.assertArtifactContents( "org.sonatype.mavenbook.multi", "simple-parent", "0.9-MNG6957-SNAPSHOT", "pom", content ); + assertTextEquals( new File( testDir, "expected/simple-parent.pom"), + new File( verifier.getArtifactPath( "org.sonatype.mavenbook.multi", "simple-parent", "0.9-MNG6957-SNAPSHOT", "pom" ) ) ); - content = FileUtils.fileRead( new File( testDir, "expected/simple-weather.pom") ); - verifier.assertArtifactContents( "org.sonatype.mavenbook.multi", "simple-weather", "0.9-MNG6957-SNAPSHOT", "pom", content ); + assertTextEquals( new File( testDir, "expected/simple-weather.pom"), + new File( verifier.getArtifactPath( "org.sonatype.mavenbook.multi", "simple-weather", "0.9-MNG6957-SNAPSHOT", "pom" ) ) ); - content = FileUtils.fileRead( new File( testDir, "expected/simple-webapp.pom") ); - verifier.assertArtifactContents( "org.sonatype.mavenbook.multi", "simple-webapp", "0.9-MNG6957-SNAPSHOT", "pom", content ); + assertTextEquals( new File( testDir, "expected/simple-webapp.pom"), + new File( verifier.getArtifactPath( "org.sonatype.mavenbook.multi", "simple-webapp", "0.9-MNG6957-SNAPSHOT", "pom" ) ) ); - content = FileUtils.fileRead( new File( testDir, "expected/simple-testutils.pom") ); - verifier.assertArtifactContents( "org.sonatype.mavenbook.multi", "simple-testutils", "0.9-MNG6957-SNAPSHOT", "pom", content ); + assertTextEquals( new File( testDir, "expected/simple-testutils.pom"), + new File( verifier.getArtifactPath( "org.sonatype.mavenbook.multi", "simple-testutils", "0.9-MNG6957-SNAPSHOT", "pom" ) ) ); - content = FileUtils.fileRead( new File( testDir, "expected/utils-parent.pom") ); - verifier.assertArtifactContents( "org.sonatype.mavenbook.multi", "utils-parent", "0.9-MNG6957-SNAPSHOT", "pom", content ); + assertTextEquals( new File( testDir, "expected/utils-parent.pom"), + new File( verifier.getArtifactPath( "org.sonatype.mavenbook.multi", "utils-parent", "0.9-MNG6957-SNAPSHOT", "pom" ) ) ); + } + + static void assertTextEquals( File file1, File file2 ) + throws IOException + { + assertEquals( FileUtils.loadFile( file1 ), FileUtils.loadFile( file2 ) ); } }