Skip to content

Commit

Permalink
[MRRESOURCES-131] Fix ITs for Maven 4
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed May 6, 2023
1 parent d830cbe commit f8fe3ea
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 50 deletions.
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ under the License.
</plugin>
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<!-- TODO remove with next parent -->
<version>3.5.1</version>
<executions>
<execution>
<id>install-descriptor</id>
Expand Down
5 changes: 4 additions & 1 deletion src/it/resources/bad-dependency-poms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ under the License.
<repositories>
<repository>
<id>test</id>
<url>file:///${it.dir}/repo</url>
<url>file:///${project.build.testOutputDirectory}/bad-dependency-poms/repo</url>
<releases>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</repository>
</repositories>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,18 @@ public void test() throws IOException, URISyntaxException, VerificationException

Verifier verifier = TestUtils.newVerifier(dir);
verifier.deleteArtifacts("test");
verifier.getSystemProperties().setProperty("it.dir", dir.getAbsolutePath());

try {
verifier.executeGoal("generate-resources");
} catch (VerificationException e) {
verifier.resetStreams();
verifier.addCliArgument("generate-resources");
verifier.execute();

// We will get an exception from harness in case
// of execution failure (return code non zero).
// This is the case if we have missing artifacts
// as in this test case.
// This means we can't test the created file which will never
// contain the appropriate data we wan't to check for.
// So the only reliable way is to check the log output
// from maven which will print out message according to
// the missing artifacts.
verifier.verifyTextInLog(
"[WARNING] Invalid project model for artifact [test:missing:0.1]. It will be ignored by the remote resources Mojo.");
verifier.verifyTextInLog(
"[WARNING] Invalid project model for artifact [test:invalid:0.1]. It will be ignored by the remote resources Mojo");

File output = new File(dir, "log.txt");
String content = FileUtils.fileRead(output);
File output = new File(dir, "target/maven-shared-archive-resources/DEPENDENCIES");
String content = FileUtils.fileRead(output);

assertTrue(content.contains(
"mvn install:install-file -DgroupId=test -DartifactId=pom -Dversion=0.2 -Dpackaging=jar"));
assertTrue(content.contains(
"mvn install:install-file -DgroupId=test -DartifactId=missing -Dversion=0.1 -Dpackaging=jar"));
assertTrue(content.contains(
"mvn install:install-file -DgroupId=test -DartifactId=invalid -Dversion=0.1 -Dpackaging=jar"));
}
assertTrue(content.contains("Dependency Id: test:pom:0.2"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,19 @@ public void test() throws IOException, URISyntaxException, VerificationException
verifier.execute();
verifier.verifyErrorFreeLog();

verifier = TestUtils.newVerifier(new File(dir, "project"));
File projectDir = new File(dir, "project");
verifier = TestUtils.newVerifier(projectDir);

verifier.deleteArtifacts("org.apache.maven.plugin.rresource.it.gdp");

try {
verifier.addCliArgument("generate-resources");
verifier.execute();
} catch (VerificationException e) {
// We will get an exception from harness in case
// of execution failure (return code non zero).
// This is the case if we have missing artifacts
// as in this test case.
// This means we can't test the created file which will never
// contain the appropriate data we wan't to check for.
// So the only reliable way is to check the log output
// from maven which will print out message according to
// the missing artifacts.
File output = new File(verifier.getBasedir(), "log.txt");
String content = FileUtils.fileRead(output);
verifier.addCliArgument("generate-resources");
verifier.execute();
verifier.verifyErrorFreeLog();

File output = new File(projectDir, "target/maven-shared-archive-resources/DEPENDENCIES");
String content = FileUtils.fileRead(output);

assertTrue(
content.contains(
"mvn install:install-file -DgroupId=org.apache.maven.plugin.rresource.it.gdp -DartifactId=release -Dversion=1.0 -Dpackaging=jar"));
assertTrue(
content.contains(
"mvn install:install-file -DgroupId=org.apache.maven.plugin.rresource.it.gdp -DartifactId=snapshot -Dversion=1.0-SNAPSHOT -Dpackaging=jar"));
}
assertTrue(content.contains("Dependency Id: org.apache.maven.plugin.rresource.it.gdp:release:1.0"));
assertTrue(content.contains("Dependency Id: org.apache.maven.plugin.rresource.it.gdp:snapshot:1.0-SNAPSHOT"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ public static void install() throws IOException, URISyntaxException, Verificatio

Verifier verifier = TestUtils.newVerifier(bootstrapDir);

verifier.executeGoal("deploy");

verifier.addCliArgument("deploy");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.resetStreams();

installed = true;
}
Expand Down

0 comments on commit f8fe3ea

Please sign in to comment.