mirror of https://github.com/apache/maven.git
[ MNG-6335] Update Mockito to 2.12.0
Also change scope to test
This commit is contained in:
parent
085ee9f275
commit
a03489b67d
|
@ -20,8 +20,7 @@ package org.apache.maven.toolchain;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.fail;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Matchers.anyString;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
@ -146,8 +145,7 @@ public class DefaultToolchainManagerPrivateTest
|
||||||
assertEquals( 2, toolchains.length );
|
assertEquals( 2, toolchains.length );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings( "unchecked" )
|
@Test
|
||||||
@Test( expected = MisconfiguredToolchainException.class )
|
|
||||||
public void testMisconfiguredToolchain()
|
public void testMisconfiguredToolchain()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -155,12 +153,11 @@ public class DefaultToolchainManagerPrivateTest
|
||||||
MavenSession session = mock( MavenSession.class );
|
MavenSession session = mock( MavenSession.class );
|
||||||
MavenExecutionRequest req = new DefaultMavenExecutionRequest();
|
MavenExecutionRequest req = new DefaultMavenExecutionRequest();
|
||||||
when( session.getRequest() ).thenReturn( req );
|
when( session.getRequest() ).thenReturn( req );
|
||||||
when(toolchainFactory_basicType.createDefaultToolchain()).thenThrow( MisconfiguredToolchainException.class );
|
|
||||||
|
|
||||||
// execute
|
// execute
|
||||||
toolchainManager.getToolchainsForType( "basic", session );
|
ToolchainPrivate[] basics = toolchainManager.getToolchainsForType("basic", session);
|
||||||
|
|
||||||
// verify
|
// verify
|
||||||
fail( "Should exit with a MisconfiguredToolchainException" );
|
assertEquals( 0, basics.length );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.maven.toolchain;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.mockito.Matchers.anyMap;
|
|
||||||
import static org.mockito.Matchers.isA;
|
import static org.mockito.Matchers.isA;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
@ -39,6 +38,7 @@ import org.apache.maven.toolchain.model.ToolchainModel;
|
||||||
import org.codehaus.plexus.logging.Logger;
|
import org.codehaus.plexus.logging.Logger;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.ArgumentMatchers;
|
||||||
import org.mockito.InjectMocks;
|
import org.mockito.InjectMocks;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
@ -142,7 +142,7 @@ public class DefaultToolchainManagerTest
|
||||||
executionRequest.setToolchains( toolchainModels );
|
executionRequest.setToolchains( toolchainModels );
|
||||||
when( session.getRequest() ).thenReturn( executionRequest );
|
when( session.getRequest() ).thenReturn( executionRequest );
|
||||||
ToolchainPrivate basicPrivate = mock( ToolchainPrivate.class );
|
ToolchainPrivate basicPrivate = mock( ToolchainPrivate.class );
|
||||||
when( basicPrivate.matchesRequirements( anyMap() ) ).thenReturn( false ).thenReturn( true );
|
when( basicPrivate.matchesRequirements( ArgumentMatchers.<String, String>anyMap() ) ).thenReturn( false ).thenReturn( true );
|
||||||
when( toolchainFactory_basicType.createToolchain( isA( ToolchainModel.class ) ) ).thenReturn( basicPrivate );
|
when( toolchainFactory_basicType.createToolchain( isA( ToolchainModel.class ) ) ).thenReturn( basicPrivate );
|
||||||
|
|
||||||
List<Toolchain> toolchains =
|
List<Toolchain> toolchains =
|
||||||
|
|
|
@ -21,8 +21,7 @@ package org.apache.maven.toolchain.building;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Matchers.anyMap;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -35,6 +34,7 @@ import org.apache.maven.toolchain.model.PersistedToolchains;
|
||||||
import org.apache.maven.toolchain.model.ToolchainModel;
|
import org.apache.maven.toolchain.model.ToolchainModel;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.ArgumentMatchers;
|
||||||
import org.mockito.InjectMocks;
|
import org.mockito.InjectMocks;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
@ -78,7 +78,7 @@ public class DefaultToolchainsBuilderTest
|
||||||
toolchain.setType( "TYPE" );
|
toolchain.setType( "TYPE" );
|
||||||
toolchain.addProvide( "key", "user_value" );
|
toolchain.addProvide( "key", "user_value" );
|
||||||
userResult.addToolchain( toolchain );
|
userResult.addToolchain( toolchain );
|
||||||
when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenReturn( userResult );
|
when( toolchainsReader.read( any( InputStream.class ), ArgumentMatchers.<String, Object>anyMap()) ).thenReturn( userResult );
|
||||||
|
|
||||||
ToolchainsBuildingResult result = toolchainBuilder.build( request );
|
ToolchainsBuildingResult result = toolchainBuilder.build( request );
|
||||||
assertNotNull( result.getEffectiveToolchains() );
|
assertNotNull( result.getEffectiveToolchains() );
|
||||||
|
@ -101,7 +101,7 @@ public class DefaultToolchainsBuilderTest
|
||||||
toolchain.setType( "TYPE" );
|
toolchain.setType( "TYPE" );
|
||||||
toolchain.addProvide( "key", "global_value" );
|
toolchain.addProvide( "key", "global_value" );
|
||||||
globalResult.addToolchain( toolchain );
|
globalResult.addToolchain( toolchain );
|
||||||
when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenReturn( globalResult );
|
when( toolchainsReader.read( any( InputStream.class ), ArgumentMatchers.<String, Object>anyMap()) ).thenReturn( globalResult );
|
||||||
|
|
||||||
ToolchainsBuildingResult result = toolchainBuilder.build( request );
|
ToolchainsBuildingResult result = toolchainBuilder.build( request );
|
||||||
assertNotNull( result.getEffectiveToolchains() );
|
assertNotNull( result.getEffectiveToolchains() );
|
||||||
|
@ -131,7 +131,7 @@ public class DefaultToolchainsBuilderTest
|
||||||
globalToolchain.setType( "TYPE" );
|
globalToolchain.setType( "TYPE" );
|
||||||
globalToolchain.addProvide( "key", "global_value" );
|
globalToolchain.addProvide( "key", "global_value" );
|
||||||
globalResult.addToolchain( globalToolchain );
|
globalResult.addToolchain( globalToolchain );
|
||||||
when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenReturn( globalResult ).thenReturn( userResult );
|
when( toolchainsReader.read( any( InputStream.class ), ArgumentMatchers.<String, Object>anyMap()) ).thenReturn( globalResult ).thenReturn( userResult );
|
||||||
|
|
||||||
ToolchainsBuildingResult result = toolchainBuilder.build( request );
|
ToolchainsBuildingResult result = toolchainBuilder.build( request );
|
||||||
assertNotNull( result.getEffectiveToolchains() );
|
assertNotNull( result.getEffectiveToolchains() );
|
||||||
|
@ -150,7 +150,7 @@ public class DefaultToolchainsBuilderTest
|
||||||
ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest();
|
ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest();
|
||||||
request.setGlobalToolchainsSource( new StringSource( "" ) );
|
request.setGlobalToolchainsSource( new StringSource( "" ) );
|
||||||
ToolchainsParseException parseException = new ToolchainsParseException( "MESSAGE", 4, 2 );
|
ToolchainsParseException parseException = new ToolchainsParseException( "MESSAGE", 4, 2 );
|
||||||
when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenThrow( parseException );
|
when( toolchainsReader.read( any( InputStream.class ), ArgumentMatchers.<String, Object>anyMap()) ).thenThrow( parseException );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -169,7 +169,7 @@ public class DefaultToolchainsBuilderTest
|
||||||
ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest();
|
ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest();
|
||||||
request.setGlobalToolchainsSource( new StringSource( "", "LOCATION" ) );
|
request.setGlobalToolchainsSource( new StringSource( "", "LOCATION" ) );
|
||||||
IOException ioException = new IOException( "MESSAGE" );
|
IOException ioException = new IOException( "MESSAGE" );
|
||||||
when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenThrow( ioException );
|
when( toolchainsReader.read( any( InputStream.class ), ArgumentMatchers.<String, Object>anyMap()) ).thenThrow( ioException );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -141,6 +141,7 @@ under the License.
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.fusesource.jansi</groupId>
|
<groupId>org.fusesource.jansi</groupId>
|
||||||
|
|
3
pom.xml
3
pom.xml
|
@ -53,7 +53,7 @@ under the License.
|
||||||
<commonsCliVersion>1.4</commonsCliVersion>
|
<commonsCliVersion>1.4</commonsCliVersion>
|
||||||
<commonsLangVersion>3.5</commonsLangVersion>
|
<commonsLangVersion>3.5</commonsLangVersion>
|
||||||
<junitVersion>4.12</junitVersion>
|
<junitVersion>4.12</junitVersion>
|
||||||
<mockitoVersion>1.10.19</mockitoVersion>
|
<mockitoVersion>2.12.0</mockitoVersion>
|
||||||
<plexusVersion>1.7.1</plexusVersion>
|
<plexusVersion>1.7.1</plexusVersion>
|
||||||
<plexusInterpolationVersion>1.24</plexusInterpolationVersion>
|
<plexusInterpolationVersion>1.24</plexusInterpolationVersion>
|
||||||
<plexusUtilsVersion>3.1.0</plexusUtilsVersion>
|
<plexusUtilsVersion>3.1.0</plexusUtilsVersion>
|
||||||
|
@ -405,6 +405,7 @@ under the License.
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<version>${mockitoVersion}</version>
|
<version>${mockitoVersion}</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<!--bootstrap-start-comment-->
|
<!--bootstrap-start-comment-->
|
||||||
|
|
Loading…
Reference in New Issue