camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aldettin...@apache.org
Subject [camel] branch master updated: CAMEL-11869: Upgrade mockito-core to 2.11.0 for camel-core, camel-dropbox, camel-jgroups and camel-quickfix
Date Thu, 02 Nov 2017 20:35:29 GMT
This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new a082a39  CAMEL-11869: Upgrade mockito-core to 2.11.0 for camel-core, camel-dropbox,
camel-jgroups and camel-quickfix
a082a39 is described below

commit a082a395bd9ec97083cc3dc4329a095c0b917bc4
Author: aldettinger <aldettinger@gmail.com>
AuthorDate: Thu Nov 2 21:17:47 2017 +0100

    CAMEL-11869: Upgrade mockito-core to 2.11.0 for camel-core, camel-dropbox, camel-jgroups
and camel-quickfix
---
 camel-core/pom.xml                                 |  1 +
 .../camel/builder/xml/XPathTransformTest.java      |  4 ++--
 .../builder/xml/XsltTestErrorListenerTest.java     |  6 +++---
 .../rest/RestProducerBindingProcessorTest.java     |  2 +-
 .../camel/processor/ThroughPutLoggerTest.java      |  2 +-
 components/camel-dropbox/pom.xml                   |  5 -----
 components/camel-jgroups/pom.xml                   |  1 +
 .../jgroups/CamelJGroupsReceiverTest.java          |  9 ++++----
 components/camel-quickfix/pom.xml                  |  8 +------
 .../component/quickfixj/QuickfixjConsumerTest.java | 13 +++++------
 .../component/quickfixj/QuickfixjProducerTest.java | 25 +++++++++++-----------
 11 files changed, 35 insertions(+), 41 deletions(-)

diff --git a/camel-core/pom.xml b/camel-core/pom.xml
index 3c1bf09..65a00cd 100644
--- a/camel-core/pom.xml
+++ b/camel-core/pom.xml
@@ -193,6 +193,7 @@
     <dependency>
       <groupId>org.mockito</groupId>
       <artifactId>mockito-core</artifactId>
+      <version>${mockito2-version}</version>
       <scope>test</scope>
     </dependency>
 
diff --git a/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformTest.java
b/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformTest.java
index 448532d..e4c9f89 100644
--- a/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformTest.java
+++ b/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformTest.java
@@ -26,12 +26,12 @@ import org.apache.camel.ContextTestSupport;
 import org.slf4j.Logger;
 
 import static org.hamcrest.Matchers.containsString;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.argThat;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+import static org.mockito.hamcrest.MockitoHamcrest.argThat;
 
 
 /**
diff --git a/camel-core/src/test/java/org/apache/camel/builder/xml/XsltTestErrorListenerTest.java
b/camel-core/src/test/java/org/apache/camel/builder/xml/XsltTestErrorListenerTest.java
index 6dcd27a..57aa8b5 100644
--- a/camel-core/src/test/java/org/apache/camel/builder/xml/XsltTestErrorListenerTest.java
+++ b/camel-core/src/test/java/org/apache/camel/builder/xml/XsltTestErrorListenerTest.java
@@ -21,7 +21,7 @@ import javax.xml.transform.ErrorListener;
 
 import junit.framework.TestCase;
 
-import static org.mockito.Matchers.anyObject;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
@@ -45,7 +45,7 @@ public class XsltTestErrorListenerTest extends TestCase {
         } catch (Exception ex) {
             // expected
         }
-        verify(errorListener, atLeastOnce()).error(anyObject());
-        verify(errorListener).fatalError(anyObject());
+        verify(errorListener, atLeastOnce()).error(any());
+        verify(errorListener).fatalError(any());
     }
 }
diff --git a/camel-core/src/test/java/org/apache/camel/component/rest/RestProducerBindingProcessorTest.java
b/camel-core/src/test/java/org/apache/camel/component/rest/RestProducerBindingProcessorTest.java
index fc7f12d..f39f4cd 100644
--- a/camel-core/src/test/java/org/apache/camel/component/rest/RestProducerBindingProcessorTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/rest/RestProducerBindingProcessorTest.java
@@ -33,7 +33,7 @@ import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
 import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.same;
+import static org.mockito.ArgumentMatchers.same;
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
diff --git a/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java
b/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java
index d9c814a..195fcbb 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java
@@ -24,10 +24,10 @@ import org.apache.camel.util.CamelLogger;
 import org.slf4j.Logger;
 
 import static org.hamcrest.Matchers.startsWith;
-import static org.mockito.Matchers.argThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+import static org.mockito.hamcrest.MockitoHamcrest.argThat;
 
 public class ThroughPutLoggerTest extends TestCase {
 
diff --git a/components/camel-dropbox/pom.xml b/components/camel-dropbox/pom.xml
index f0080fb..7f10ff2 100755
--- a/components/camel-dropbox/pom.xml
+++ b/components/camel-dropbox/pom.xml
@@ -95,11 +95,6 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.mockito</groupId>
-      <artifactId>mockito-core</artifactId>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
 
   <profiles>
diff --git a/components/camel-jgroups/pom.xml b/components/camel-jgroups/pom.xml
index 60b843f..c87e97f 100644
--- a/components/camel-jgroups/pom.xml
+++ b/components/camel-jgroups/pom.xml
@@ -56,6 +56,7 @@
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
+            <version>${mockito2-version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git a/components/camel-jgroups/src/test/java/org/apache/camel/component/jgroups/CamelJGroupsReceiverTest.java
b/components/camel-jgroups/src/test/java/org/apache/camel/component/jgroups/CamelJGroupsReceiverTest.java
index 8b6c761..1f69d36 100644
--- a/components/camel-jgroups/src/test/java/org/apache/camel/component/jgroups/CamelJGroupsReceiverTest.java
+++ b/components/camel-jgroups/src/test/java/org/apache/camel/component/jgroups/CamelJGroupsReceiverTest.java
@@ -16,15 +16,16 @@
  */
 package org.apache.camel.component.jgroups;
 
-import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.jgroups.Message;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import static org.mockito.BDDMockito.*;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.mockito.BDDMockito.willThrow;
 
 @RunWith(MockitoJUnitRunner.class)
 public class CamelJGroupsReceiverTest {
@@ -45,7 +46,7 @@ public class CamelJGroupsReceiverTest {
     @Test(expected = JGroupsException.class)
     public void shouldHandleProcessingException() throws Exception {
         // Given
-        willThrow(Exception.class).given(processor).process(any(Exchange.class));
+        willThrow(Exception.class).given(processor).process(ArgumentMatchers.isNull());
         Message message = new Message(null, "someMessage");
         message.setSrc(null);
         // When
diff --git a/components/camel-quickfix/pom.xml b/components/camel-quickfix/pom.xml
index 85ef184..e1da14b 100644
--- a/components/camel-quickfix/pom.xml
+++ b/components/camel-quickfix/pom.xml
@@ -83,14 +83,8 @@
     <dependency>
       <groupId>org.mockito</groupId>
       <artifactId>mockito-core</artifactId>
+      <version>${mockito2-version}</version>
       <scope>test</scope>
-      <exclusions>
-        <!-- exclude hamcrest as we use the version from junit dependency -->
-        <exclusion>
-          <groupId>org.hamcrest</groupId>
-          <artifactId>hamcrest-core</artifactId>
-        </exclusion>
-      </exclusions>
     </dependency>
   </dependencies>
 
diff --git a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConsumerTest.java
b/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConsumerTest.java
index 1c7e28e..fbe23ee 100644
--- a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConsumerTest.java
+++ b/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConsumerTest.java
@@ -23,7 +23,6 @@ import org.hamcrest.CoreMatchers;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.Matchers;
 import org.mockito.Mockito;
 import quickfix.FixVersions;
 import quickfix.Message;
@@ -33,6 +32,8 @@ import quickfix.field.BeginString;
 import quickfix.field.SenderCompID;
 import quickfix.field.TargetCompID;
 
+import static org.mockito.ArgumentMatchers.isA;
+
 public class QuickfixjConsumerTest {
     private Exchange mockExchange;
     private Processor mockProcessor;
@@ -52,7 +53,7 @@ public class QuickfixjConsumerTest {
         inboundFixMessage.getHeader().setString(TargetCompID.FIELD, "TARGET");
         Mockito.when(mockCamelMessage.getBody(quickfix.Message.class)).thenReturn(inboundFixMessage);
         
-        mockProcessor = Mockito.mock(Processor.class);        
+        mockProcessor = Mockito.mock(Processor.class);
         mockEndpoint = Mockito.mock(QuickfixjEndpoint.class);
         Mockito.when(mockEndpoint.createExchange(ExchangePattern.InOnly)).thenReturn(mockExchange);
 
     }
@@ -76,7 +77,7 @@ public class QuickfixjConsumerTest {
         consumer.onExchange(mockExchange);
         
         // Second message should be processed
-        Mockito.verify(mockProcessor).process(Matchers.isA(Exchange.class));
+        Mockito.verify(mockProcessor).process(isA(Exchange.class));
     }
     
     @Test
@@ -115,7 +116,7 @@ public class QuickfixjConsumerTest {
         // Simulate a message from the FIX engine
         consumer.onExchange(mockExchange);
 
-        Mockito.verify(mockExchange).setException(Matchers.isA(IllegalStateException.class));
+        Mockito.verify(mockExchange).setException(isA(IllegalStateException.class));
     }
 
     @Test
@@ -127,7 +128,7 @@ public class QuickfixjConsumerTest {
 
         QuickfixjConsumer consumer = Mockito.spy(new QuickfixjConsumer(mockEndpoint, mockProcessor));
         Mockito.doReturn(mockSession).when(consumer).getSession(mockSessionId);
-        Mockito.doReturn(true).when(mockSession).send(Matchers.isA(Message.class));
+        Mockito.doReturn(true).when(mockSession).send(isA(Message.class));
 
         Mockito.when(mockExchange.getPattern()).thenReturn(ExchangePattern.InOut);
         Mockito.when(mockExchange.hasOut()).thenReturn(true);
@@ -140,7 +141,7 @@ public class QuickfixjConsumerTest {
         consumer.start();
 
         consumer.onExchange(mockExchange);
-        Mockito.verify(mockExchange, Mockito.never()).setException(Matchers.isA(Exception.class));
+        Mockito.verify(mockExchange, Mockito.never()).setException(isA(Exception.class));
         Mockito.verify(mockSession).send(outboundFixMessage);
     }
 }
diff --git a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjProducerTest.java
b/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjProducerTest.java
index be6f341..f649863 100644
--- a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjProducerTest.java
+++ b/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjProducerTest.java
@@ -25,7 +25,6 @@ import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.Matchers;
 import org.mockito.Mockito;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
@@ -42,6 +41,8 @@ import quickfix.field.SenderCompID;
 import quickfix.field.TargetCompID;
 import quickfix.fix42.Email;
 
+import static org.mockito.ArgumentMatchers.isA;
+
 public class QuickfixjProducerTest {
     private Exchange mockExchange;
     private QuickfixjEndpoint mockEndpoint;
@@ -83,21 +84,21 @@ public class QuickfixjProducerTest {
     public void setExceptionOnExchange() throws Exception {
         Session mockSession = Mockito.spy(TestSupport.createSession(sessionID));
         Mockito.doReturn(mockSession).when(producer).getSession(MessageUtils.getSessionID(inboundFixMessage));
-        Mockito.doThrow(new TestException()).when(mockSession).send(Matchers.isA(Message.class));
+        Mockito.doThrow(new TestException()).when(mockSession).send(isA(Message.class));
 
         producer.process(mockExchange);
-        Mockito.verify(mockExchange).setException(Matchers.isA(TestException.class));
+        Mockito.verify(mockExchange).setException(isA(TestException.class));
     }
     
     @Test
     public void processInOnlyExchangeSuccess() throws Exception {
         Session mockSession = Mockito.spy(TestSupport.createSession(sessionID));
         Mockito.doReturn(mockSession).when(producer).getSession(MessageUtils.getSessionID(inboundFixMessage));
-        Mockito.doReturn(true).when(mockSession).send(Matchers.isA(Message.class));
+        Mockito.doReturn(true).when(mockSession).send(isA(Message.class));
         
         producer.process(mockExchange);
         
-        Mockito.verify(mockExchange, Mockito.never()).setException(Matchers.isA(IllegalStateException.class));
+        Mockito.verify(mockExchange, Mockito.never()).setException(isA(IllegalStateException.class));
         Mockito.verify(mockSession).send(inboundFixMessage);
     }
     
@@ -105,12 +106,12 @@ public class QuickfixjProducerTest {
     public void processInOnlyExchangeSendUnsuccessful() throws Exception {
         Session mockSession = Mockito.spy(TestSupport.createSession(sessionID));
         Mockito.doReturn(mockSession).when(producer).getSession(MessageUtils.getSessionID(inboundFixMessage));
-        Mockito.doReturn(false).when(mockSession).send(Matchers.isA(Message.class));
+        Mockito.doReturn(false).when(mockSession).send(isA(Message.class));
 
         producer.process(mockExchange);
         
         Mockito.verify(mockSession).send(inboundFixMessage);
-        Mockito.verify(mockExchange).setException(Matchers.isA(CannotSendException.class));
+        Mockito.verify(mockExchange).setException(isA(CannotSendException.class));
     }    
 
     @Test
@@ -147,11 +148,11 @@ public class QuickfixjProducerTest {
                 }, 10);
                 return true;
             }            
-        }).when(mockSession).send(Matchers.isA(Message.class));
+        }).when(mockSession).send(isA(Message.class));
 
         producer.process(mockExchange);
         
-        Mockito.verify(mockExchange, Mockito.never()).setException(Matchers.isA(IllegalStateException.class));
+        Mockito.verify(mockExchange, Mockito.never()).setException(isA(IllegalStateException.class));
         Mockito.verify(mockSession).send(inboundFixMessage);
         Mockito.verify(mockOutboundCamelMessage).getHeaders();
         Mockito.verify(mockOutboundCamelMessage).setBody(outboundFixMessage);
@@ -190,12 +191,12 @@ public class QuickfixjProducerTest {
                 }, 10);
                 return false;
             }            
-        }).when(mockSession).send(Matchers.isA(Message.class));
+        }).when(mockSession).send(isA(Message.class));
 
         producer.process(mockExchange);
         
-        Mockito.verify(mockOutboundCamelMessage, Mockito.never()).setBody(Matchers.isA(Message.class));
+        Mockito.verify(mockOutboundCamelMessage, Mockito.never()).setBody(isA(Message.class));
         Mockito.verify(mockSession).send(inboundFixMessage);
-        Mockito.verify(mockExchange).setException(Matchers.isA(CannotSendException.class));
+        Mockito.verify(mockExchange).setException(isA(CannotSendException.class));
     }    
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@camel.apache.org" <commits@camel.apache.org>'].

Mime
View raw message