Skip to content

Commit

Permalink
Bump mockito-core from 1.9.0 to 3.11.2 (#27)
Browse files Browse the repository at this point in the history
* Bump mockito-core from 1.9.0 to 3.11.2

Bumps [mockito-core](https://github.com/mockito/mockito) from 1.9.0 to 3.11.2.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v1.9.0...v3.11.2)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix mockito upgrade

Signed-off-by: Olivier Lamy <olamy@apache.org>

* force clean

Signed-off-by: Olivier Lamy <olamy@apache.org>

* force local repo path

Signed-off-by: Olivier Lamy <olamy@apache.org>

* there is absolutely no need to run invoker plugin for something else than the maven plugin module

Signed-off-by: Olivier Lamy <olamy@apache.org>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Olivier Lamy <olamy@apache.org>
  • Loading branch information
dependabot[bot] and olamy authored Aug 18, 2021
1 parent fe19cf7 commit 36a5a99
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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>

0 comments on commit 36a5a99

Please sign in to comment.