Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump mockito-core from 1.9.0 to 3.11.2 #27

Merged
merged 5 commits into from Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Expand Up @@ -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
32 changes: 32 additions & 0 deletions mrm-maven-plugin/pom.xml
Expand Up @@ -140,4 +140,36 @@
</dependency>
</dependencies>

<profiles>
<profile>
<!-- run integration tests
to use this profile:
or run integration tests: mvn -Prun-its
-->
<id>run-its</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
<configuration>
<streamLogs>true</streamLogs>
<debug>false</debug>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
2 changes: 1 addition & 1 deletion mrm-maven-plugin/src/it/hostedrepo/pom.xml
Expand Up @@ -23,7 +23,7 @@
</execution>
</executions>
<configuration>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<localRepositoryPath>${project.build.directory}/local-repo-it</localRepositoryPath>
<projectsDirectory>src/it</projectsDirectory>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<settingsFile>src/it/settings.xml</settingsFile>
Expand Down
Expand Up @@ -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 );
Expand All @@ -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 )
{
Expand Down
Expand Up @@ -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;
Expand All @@ -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.<ArtifactRepository> emptyList(),
Collections.<ArtifactRepository> 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.<ArtifactRepository> 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.<ArtifactRepository> emptyList(),
Collections.<ArtifactRepository> 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.<ArtifactRepository> 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.<ArtifactRepository> emptyList(),
Collections.<ArtifactRepository> 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();
}

Expand Down
41 changes: 2 additions & 39 deletions pom.xml
Expand Up @@ -173,7 +173,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.0</version>
<version>3.11.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -251,6 +251,7 @@
<streamLogs>true</streamLogs>
<settingsFile>src/it/settings.xml</settingsFile>
<postBuildHookScript>verify</postBuildHookScript>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
</configuration>
</plugin>
<plugin>
Expand All @@ -267,42 +268,4 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<!-- run integration tests
to use this profile:
or run integration tests: mvn -Prun-its
Always run on travis
-->
<id>run-its</id>
<activation>
<property>
<name>env.CONTINUOUS_INTEGRATION</name>
</property>
</activation>
<build>
<defaultGoal>verify</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
<configuration>
<streamLogs>true</streamLogs>
<debug>false</debug>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>