maven/0003-Revert-MNG-6335-Update-Mockito-to-2.12.0.patch

206 lines
10 KiB
Diff
Raw Normal View History

2019-04-13 15:03:06 +00:00
From e3b125fab7973d647288b9039fc897438b27c203 Mon Sep 17 00:00:00 2001
2018-03-15 13:12:15 +00:00
From: Michael Simacek <msimacek@redhat.com>
Date: Tue, 13 Mar 2018 11:49:16 +0100
2019-04-13 15:03:06 +00:00
Subject: [PATCH 3/4] Revert "[ MNG-6335] Update Mockito to 2.12.0"
2018-03-15 13:12:15 +00:00
This reverts commit a03489b67d04a4b014ff5d1c151b331a39bf100b.
---
2018-06-28 14:42:23 +00:00
.../DefaultToolchainManagerPrivateTest.java | 15 +++++++++------
.../toolchain/DefaultToolchainManagerTest.java | 4 ++--
.../building/DefaultToolchainsBuilderTest.java | 14 +++++++-------
maven-embedder/pom.xml | 1 -
2019-04-13 15:03:06 +00:00
.../java/org/apache/maven/cli/MavenCliTest.java | 6 +++---
2018-06-28 14:42:23 +00:00
pom.xml | 2 +-
2019-04-13 15:03:06 +00:00
6 files changed, 22 insertions(+), 20 deletions(-)
2018-03-15 13:12:15 +00:00
diff --git a/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivateTest.java b/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivateTest.java
2019-04-13 15:03:06 +00:00
index c93756463..1e4844154 100644
2018-03-15 13:12:15 +00:00
--- a/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivateTest.java
+++ b/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivateTest.java
2019-04-13 15:03:06 +00:00
@@ -20,7 +20,8 @@
2018-03-15 13:12:15 +00:00
*/
import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.anyString;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
2019-04-13 15:03:06 +00:00
@@ -144,8 +145,9 @@ public void testToolchainsForConfiguredType()
2018-03-15 13:12:15 +00:00
verify( logger, never() ).error( anyString() );
assertEquals( 2, toolchains.length );
}
-
- @Test
+
+ @SuppressWarnings( "unchecked" )
+ @Test( expected = MisconfiguredToolchainException.class )
public void testMisconfiguredToolchain()
throws Exception
{
2019-04-13 15:03:06 +00:00
@@ -153,11 +155,12 @@ public void testMisconfiguredToolchain()
2018-03-15 13:12:15 +00:00
MavenSession session = mock( MavenSession.class );
MavenExecutionRequest req = new DefaultMavenExecutionRequest();
when( session.getRequest() ).thenReturn( req );
+ when(toolchainFactory_basicType.createDefaultToolchain()).thenThrow( MisconfiguredToolchainException.class );
// execute
- ToolchainPrivate[] basics = toolchainManager.getToolchainsForType("basic", session);
-
+ toolchainManager.getToolchainsForType( "basic", session );
+
// verify
- assertEquals( 0, basics.length );
+ fail( "Should exit with a MisconfiguredToolchainException" );
}
}
diff --git a/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerTest.java b/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerTest.java
2019-04-13 15:03:06 +00:00
index 84444c08e..6e85c4246 100644
2018-03-15 13:12:15 +00:00
--- a/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerTest.java
+++ b/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerTest.java
2019-04-13 15:03:06 +00:00
@@ -20,6 +20,7 @@
2018-03-15 13:12:15 +00:00
*/
import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.anyMap;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
2019-04-13 15:03:06 +00:00
@@ -38,7 +39,6 @@
2018-03-15 13:12:15 +00:00
import org.codehaus.plexus.logging.Logger;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
2019-04-13 15:03:06 +00:00
@@ -142,7 +142,7 @@ public void testRequirements()
2018-03-15 13:12:15 +00:00
executionRequest.setToolchains( toolchainModels );
when( session.getRequest() ).thenReturn( executionRequest );
ToolchainPrivate basicPrivate = mock( ToolchainPrivate.class );
- when( basicPrivate.matchesRequirements( ArgumentMatchers.<String, String>anyMap() ) ).thenReturn( false ).thenReturn( true );
+ when( basicPrivate.matchesRequirements( anyMap() ) ).thenReturn( false ).thenReturn( true );
when( toolchainFactory_basicType.createToolchain( isA( ToolchainModel.class ) ) ).thenReturn( basicPrivate );
List<Toolchain> toolchains =
diff --git a/maven-core/src/test/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilderTest.java b/maven-core/src/test/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilderTest.java
2019-04-13 15:03:06 +00:00
index fc530df5a..80fca0942 100644
2018-03-15 13:12:15 +00:00
--- a/maven-core/src/test/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilderTest.java
+++ b/maven-core/src/test/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilderTest.java
2019-04-13 15:03:06 +00:00
@@ -21,7 +21,8 @@
2018-03-15 13:12:15 +00:00
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyMap;
import static org.mockito.Mockito.when;
import java.io.IOException;
2019-04-13 15:03:06 +00:00
@@ -34,7 +35,6 @@
2018-03-15 13:12:15 +00:00
import org.apache.maven.toolchain.model.ToolchainModel;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
2019-04-13 15:03:06 +00:00
@@ -78,7 +78,7 @@ public void testBuildRequestWithUserToolchains()
2018-03-15 13:12:15 +00:00
toolchain.setType( "TYPE" );
toolchain.addProvide( "key", "user_value" );
userResult.addToolchain( toolchain );
- when( toolchainsReader.read( any( InputStream.class ), ArgumentMatchers.<String, Object>anyMap()) ).thenReturn( userResult );
+ when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenReturn( userResult );
ToolchainsBuildingResult result = toolchainBuilder.build( request );
assertNotNull( result.getEffectiveToolchains() );
2019-04-13 15:03:06 +00:00
@@ -101,7 +101,7 @@ public void testBuildRequestWithGlobalToolchains()
2018-03-15 13:12:15 +00:00
toolchain.setType( "TYPE" );
toolchain.addProvide( "key", "global_value" );
globalResult.addToolchain( toolchain );
- when( toolchainsReader.read( any( InputStream.class ), ArgumentMatchers.<String, Object>anyMap()) ).thenReturn( globalResult );
+ when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenReturn( globalResult );
ToolchainsBuildingResult result = toolchainBuilder.build( request );
assertNotNull( result.getEffectiveToolchains() );
2019-04-13 15:03:06 +00:00
@@ -131,7 +131,7 @@ public void testBuildRequestWithBothToolchains()
2018-03-15 13:12:15 +00:00
globalToolchain.setType( "TYPE" );
globalToolchain.addProvide( "key", "global_value" );
globalResult.addToolchain( globalToolchain );
- when( toolchainsReader.read( any( InputStream.class ), ArgumentMatchers.<String, Object>anyMap()) ).thenReturn( globalResult ).thenReturn( userResult );
+ when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenReturn( globalResult ).thenReturn( userResult );
ToolchainsBuildingResult result = toolchainBuilder.build( request );
assertNotNull( result.getEffectiveToolchains() );
2019-04-13 15:03:06 +00:00
@@ -150,7 +150,7 @@ public void testStrictToolchainsParseException() throws Exception
2018-03-15 13:12:15 +00:00
ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest();
request.setGlobalToolchainsSource( new StringSource( "" ) );
ToolchainsParseException parseException = new ToolchainsParseException( "MESSAGE", 4, 2 );
- when( toolchainsReader.read( any( InputStream.class ), ArgumentMatchers.<String, Object>anyMap()) ).thenThrow( parseException );
+ when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenThrow( parseException );
try
{
2019-04-13 15:03:06 +00:00
@@ -169,7 +169,7 @@ public void testIOException() throws Exception
2018-03-15 13:12:15 +00:00
ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest();
request.setGlobalToolchainsSource( new StringSource( "", "LOCATION" ) );
IOException ioException = new IOException( "MESSAGE" );
- when( toolchainsReader.read( any( InputStream.class ), ArgumentMatchers.<String, Object>anyMap()) ).thenThrow( ioException );
+ when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenThrow( ioException );
try
{
diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml
2019-04-13 15:03:06 +00:00
index e32819196..3320d6c99 100644
2018-03-15 13:12:15 +00:00
--- a/maven-embedder/pom.xml
+++ b/maven-embedder/pom.xml
2019-04-13 15:03:06 +00:00
@@ -137,7 +137,6 @@ under the License.
2018-03-15 13:12:15 +00:00
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>
2019-04-13 15:03:06 +00:00
diff --git a/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java b/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
index 5f4c5b69a..88810d936 100644
--- a/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
+++ b/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
@@ -24,7 +24,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
-import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.isA;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -327,8 +327,8 @@ protected void customizeContainer(PlexusContainer container) {
customizedMavenCli.toolchains(cliRequest);
InOrder orderdEventSpyDispatcherMock = inOrder(eventSpyDispatcherMock);
- orderdEventSpyDispatcherMock.verify(eventSpyDispatcherMock, times(1)).onEvent(any(ToolchainsBuildingRequest.class));
- orderdEventSpyDispatcherMock.verify(eventSpyDispatcherMock, times(1)).onEvent(any(ToolchainsBuildingResult.class));
+ orderdEventSpyDispatcherMock.verify(eventSpyDispatcherMock, times(1)).onEvent(isA(ToolchainsBuildingRequest.class));
+ orderdEventSpyDispatcherMock.verify(eventSpyDispatcherMock, times(1)).onEvent(isA(ToolchainsBuildingResult.class));
}
}
2018-03-15 13:12:15 +00:00
diff --git a/pom.xml b/pom.xml
2019-04-13 15:03:06 +00:00
index 237cdc39e..84fc037bc 100644
2018-03-15 13:12:15 +00:00
--- a/pom.xml
+++ b/pom.xml
@@ -53,7 +53,7 @@ under the License.
<commonsCliVersion>1.4</commonsCliVersion>
2019-04-13 15:03:06 +00:00
<commonsLangVersion>3.8.1</commonsLangVersion>
2018-03-15 13:12:15 +00:00
<junitVersion>4.12</junitVersion>
2019-04-13 15:03:06 +00:00
- <mockitoVersion>2.21.0</mockitoVersion>
2018-03-15 13:12:15 +00:00
+ <mockitoVersion>1.10.19</mockitoVersion>
<plexusVersion>1.7.1</plexusVersion>
2019-04-13 15:03:06 +00:00
<plexusInterpolationVersion>1.25</plexusInterpolationVersion>
<plexusUtilsVersion>3.2.0</plexusUtilsVersion>
2018-03-15 13:12:15 +00:00
--
2019-04-13 15:03:06 +00:00
2.20.1
2018-03-15 13:12:15 +00:00