diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index ebda63a4..ff612f71 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -51,4 +51,4 @@ jobs:
java-version: ${{ matrix.java }}
- name: Build with Maven
- run: mvn verify -e -B -V -P run-its
+ run: mvn clean verify -e -B -V -P run-its
diff --git a/mrm-maven-plugin/pom.xml b/mrm-maven-plugin/pom.xml
index f35b604e..23221e33 100644
--- a/mrm-maven-plugin/pom.xml
+++ b/mrm-maven-plugin/pom.xml
@@ -140,4 +140,36 @@
+
+
+
+ run-its
+
+
+
+ org.apache.maven.plugins
+ maven-invoker-plugin
+
+
+ integration-test
+
+ install
+ run
+
+
+ true
+ false
+ ${project.build.directory}/local-repo
+
+
+
+
+
+
+
+
+
diff --git a/mrm-maven-plugin/src/it/hostedrepo/pom.xml b/mrm-maven-plugin/src/it/hostedrepo/pom.xml
index 54c96580..fa71f768 100644
--- a/mrm-maven-plugin/src/it/hostedrepo/pom.xml
+++ b/mrm-maven-plugin/src/it/hostedrepo/pom.xml
@@ -23,7 +23,7 @@
- ${project.build.directory}/local-repo
+ ${project.build.directory}/local-repo-it
src/it
${project.build.directory}/it
src/it/settings.xml
diff --git a/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/maven/ProxyArtifactStore.java b/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/maven/ProxyArtifactStore.java
index 840b6b36..40f89b6f 100644
--- a/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/maven/ProxyArtifactStore.java
+++ b/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/maven/ProxyArtifactStore.java
@@ -318,7 +318,7 @@ public InputStream get( Artifact artifact )
try
{
artifactResolver.resolve( mavenArtifact, remoteRepositories, localRepository );
- final File file = mavenArtifact.getFile();
+ File file = mavenArtifact.getFile();
if ( file != null && file.isFile() )
{
addResolved( artifact );
@@ -328,8 +328,7 @@ public InputStream get( Artifact artifact )
}
catch ( org.apache.maven.artifact.resolver.ArtifactNotFoundException e )
{
- ArtifactNotFoundException anfe = new ArtifactNotFoundException( artifact, e );
- throw anfe;
+ throw new ArtifactNotFoundException( artifact, e );
}
catch ( ArtifactResolutionException e )
{
diff --git a/mrm-maven-plugin/src/test/java/org/codehaus/mojo/mrm/maven/ProxyArtifactStoreTest.java b/mrm-maven-plugin/src/test/java/org/codehaus/mojo/mrm/maven/ProxyArtifactStoreTest.java
index 92f306af..d81b4531 100644
--- a/mrm-maven-plugin/src/test/java/org/codehaus/mojo/mrm/maven/ProxyArtifactStoreTest.java
+++ b/mrm-maven-plugin/src/test/java/org/codehaus/mojo/mrm/maven/ProxyArtifactStoreTest.java
@@ -19,13 +19,16 @@
* under the License.
*/
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import java.io.IOException;
import java.util.Collections;
+import java.util.List;
import org.apache.maven.archetype.ArchetypeManager;
import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -34,59 +37,59 @@
import org.codehaus.mojo.mrm.api.maven.Artifact;
import org.codehaus.mojo.mrm.api.maven.ArtifactNotFoundException;
import org.junit.Test;
+import org.mockito.ArgumentMatchers;
public class ProxyArtifactStoreTest
{
- // Original code passed the original Exception by calling initCause( e ), which causes an IllegalStateException
- @Test( expected = ArtifactNotFoundException.class )
+ @Test(expected = ArtifactNotFoundException.class)
public void verifyArtifactNotFoundExceptionOnGet()
throws Exception
{
- ArtifactFactory artifactFactory = mock( ArtifactFactory.class );
- ArtifactResolver artifactResolver = mock( ArtifactResolver.class );
+ ArtifactFactory artifactFactory = mock(ArtifactFactory.class);
+ ArtifactResolver artifactResolver = mock(ArtifactResolver.class);
ProxyArtifactStore store =
- new ProxyArtifactStore( null, Collections. emptyList(),
- Collections. emptyList(), null, artifactFactory,
- artifactResolver, null ,null );
+ new ProxyArtifactStore(null, Collections.emptyList(),
+ Collections.emptyList(), null, artifactFactory,
+ artifactResolver, null ,null);
- doThrow( org.apache.maven.artifact.resolver.ArtifactNotFoundException.class ).when( artifactResolver ).resolve( any( org.apache.maven.artifact.Artifact.class ),
- eq( Collections. emptyList() ),
- any( ArtifactRepository.class ) );
+ doThrow(org.apache.maven.artifact.resolver.ArtifactNotFoundException.class)
+ .when(artifactResolver)
+ .resolve(isNull(), eq(Collections.emptyList()), any());
Artifact artifact = new Artifact( "localhost", "test", "1.0-SNAPSHOT", "pom" );
- store.get( artifact );
+ store.get(artifact);
}
- @Test( expected = IOException.class )
+ @Test(expected = RuntimeException.class)
public void verifyArtifactResolutionExceptionOnGet()
throws Exception
{
- ArtifactFactory artifactFactory = mock( ArtifactFactory.class );
- ArtifactResolver artifactResolver = mock( ArtifactResolver.class );
+ ArtifactFactory artifactFactory = mock(ArtifactFactory.class);
+ ArtifactResolver artifactResolver = mock(ArtifactResolver.class);
ProxyArtifactStore store =
- new ProxyArtifactStore( null, Collections. emptyList(),
- Collections. emptyList(), null, artifactFactory,
+ new ProxyArtifactStore( null, Collections.emptyList(),
+ Collections.emptyList(), null, artifactFactory,
artifactResolver, null, null );
- doThrow( IOException.class ).when( artifactResolver ).resolve( any( org.apache.maven.artifact.Artifact.class ),
- eq( Collections. emptyList() ),
- any( ArtifactRepository.class ) );
+ doThrow(RuntimeException.class)
+ .when(artifactResolver)
+ .resolve(isNull(), eq(Collections.emptyList()), any());
Artifact artifact = new Artifact( "localhost", "test", "1.0-SNAPSHOT", "pom" );
- store.get( artifact );
+ store.get(artifact);
}
-
- @Test( expected = IOException.class )
+
+ @Test(expected = RuntimeException.class)
public void verifyArchetypeCatalogNotFoundException()
- throws Exception
+ throws Exception
{
ArchetypeManager archetypeManager = mock( ArchetypeManager.class );
ProxyArtifactStore store =
- new ProxyArtifactStore( null, Collections. emptyList(),
- Collections. emptyList(), null, null, null, archetypeManager,
- null );
- doThrow( IOException.class ).when( archetypeManager ).getDefaultLocalCatalog();
+ new ProxyArtifactStore( null, Collections.emptyList(),
+ Collections.emptyList(), null, null, null, archetypeManager,
+ null );
+ doThrow(RuntimeException.class).when(archetypeManager).getDefaultLocalCatalog();
store.getArchetypeCatalog();
}
diff --git a/pom.xml b/pom.xml
index bc4c12e3..86294372 100644
--- a/pom.xml
+++ b/pom.xml
@@ -173,7 +173,7 @@
org.mockito
mockito-core
- 1.9.0
+ 3.11.2
test
@@ -251,6 +251,7 @@
true
src/it/settings.xml
verify
+ ${project.build.directory}/local-repo
@@ -267,42 +268,4 @@
-
-
-
-
- run-its
-
-
- env.CONTINUOUS_INTEGRATION
-
-
-
- verify
-
-
- maven-invoker-plugin
-
-
- integration-test
-
- install
- run
-
-
- true
- false
-
-
-
-
-
-
-
-
-