You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2023/05/03 17:42:56 UTC
[maven-remote-resources-plugin] 01/01: [MRRESOURCES-131] Fix ITs for Maven 4
This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a commit to branch MRRESOURCES-131
in repository https://gitbox.apache.org/repos/asf/maven-remote-resources-plugin.git
commit cd541a04a7f844ec498a63443490fe891f81614a
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Wed May 3 19:39:42 2023 +0200
[MRRESOURCES-131] Fix ITs for Maven 4
---
pom.xml | 2 ++
src/it/resources/bad-dependency-poms/pom.xml | 5 +++-
.../resources/remote/it/IT_BadDependencyPoms.java | 32 ++++++---------------
.../remote/it/IT_GetDependencyProjects.java | 33 +++++++---------------
.../remote/it/support/BootstrapInstaller.java | 5 ++--
5 files changed, 27 insertions(+), 50 deletions(-)
diff --git a/pom.xml b/pom.xml
index d5e9098..a072605 100644
--- a/pom.xml
+++ b/pom.xml
@@ -378,6 +378,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>
diff --git a/src/it/resources/bad-dependency-poms/pom.xml b/src/it/resources/bad-dependency-poms/pom.xml
index 3628b20..6464de1 100644
--- a/src/it/resources/bad-dependency-poms/pom.xml
+++ b/src/it/resources/bad-dependency-poms/pom.xml
@@ -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>
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_BadDependencyPoms.java b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_BadDependencyPoms.java
index 39a098a..ccb0856 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_BadDependencyPoms.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_BadDependencyPoms.java
@@ -40,32 +40,18 @@ public class IT_BadDependencyPoms extends AbstractIT {
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"));
}
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GetDependencyProjects.java b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GetDependencyProjects.java
index 8d071be..e178a84 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GetDependencyProjects.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/it/IT_GetDependencyProjects.java
@@ -45,32 +45,19 @@ public class IT_GetDependencyProjects extends AbstractIT {
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"));
}
}
diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/it/support/BootstrapInstaller.java b/src/test/java/org/apache/maven/plugin/resources/remote/it/support/BootstrapInstaller.java
index 77808e8..e6ff751 100644
--- a/src/test/java/org/apache/maven/plugin/resources/remote/it/support/BootstrapInstaller.java
+++ b/src/test/java/org/apache/maven/plugin/resources/remote/it/support/BootstrapInstaller.java
@@ -35,10 +35,9 @@ public class BootstrapInstaller {
Verifier verifier = TestUtils.newVerifier(bootstrapDir);
- verifier.executeGoal("deploy");
-
+ verifier.addCliArgument("deploy");
+ verifier.execute();
verifier.verifyErrorFreeLog();
- verifier.resetStreams();
installed = true;
}