Fix pom content comparison to avoid line ending problems (#119)

This commit is contained in:
Guillaume Nodet 2021-10-06 09:29:32 +02:00 committed by GitHub
parent c27293d258
commit 26c555962d
2 changed files with 38 additions and 24 deletions

View File

@ -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 ) );
}
}

View File

@ -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 ) );
}
}