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 version 2.11.0 for camel-spring-redis
Date Mon, 20 Nov 2017 18:01:17 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 020e0c7  CAMEL-11869: Upgrade mockito-core to version 2.11.0 for camel-spring-redis
020e0c7 is described below

commit 020e0c7d92459585b37e72e5ba1e849903a955da
Author: aldettinger <aldettinger@gmail.com>
AuthorDate: Mon Nov 20 18:59:18 2017 +0100

    CAMEL-11869: Upgrade mockito-core to version 2.11.0 for camel-spring-redis
---
 components/camel-spring-redis/pom.xml              |  8 ++---
 .../camel/component/redis/RedisConnectionTest.java | 27 ++++++---------
 .../redis/RedisConsumerIntegrationTest.java        |  2 +-
 .../camel/component/redis/RedisConsumerTest.java   | 28 ++++++++--------
 .../camel/component/redis/RedisHashTest.java       | 30 ++++++++---------
 .../apache/camel/component/redis/RedisKeyTest.java | 29 ++++++++---------
 .../camel/component/redis/RedisListTest.java       | 26 +++++++--------
 .../redis/RedisProducerIntegrationTest.java        |  2 +-
 .../apache/camel/component/redis/RedisSetTest.java | 38 ++++++++++------------
 .../camel/component/redis/RedisSortedSetTest.java  | 30 ++++++++---------
 .../camel/component/redis/RedisStringTest.java     | 30 ++++++++---------
 .../camel/component/redis/RedisTestSupport.java    |  8 ++++-
 .../component/redis/RedisTransactionTest.java      | 16 ++++-----
 .../idempotent/RedisIdempotentRepositoryTest.java  | 22 ++++++++-----
 ...sStringIdempotentRepositoryIntegrationTest.java |  4 +--
 .../RedisStringIdempotentRepositoryTest.java       | 25 +++++++-------
 16 files changed, 158 insertions(+), 167 deletions(-)

diff --git a/components/camel-spring-redis/pom.xml b/components/camel-spring-redis/pom.xml
index 07768c65..fd0e54e 100755
--- a/components/camel-spring-redis/pom.xml
+++ b/components/camel-spring-redis/pom.xml
@@ -65,8 +65,9 @@
     <dependency>
       <groupId>org.mockito</groupId>
       <artifactId>mockito-core</artifactId>
+      <version>${mockito2-version}</version>
       <scope>test</scope>
-    </dependency>  
+    </dependency>
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-api</artifactId>
@@ -82,11 +83,6 @@
       <artifactId>log4j-slf4j-impl</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>commons-pool</groupId>
-      <artifactId>commons-pool</artifactId>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
 
 </project>
diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisConnectionTest.java
b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisConnectionTest.java
index ae41530..83db56f 100755
--- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisConnectionTest.java
+++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisConnectionTest.java
@@ -17,21 +17,22 @@
 package org.apache.camel.component.redis;
 
 import org.apache.camel.impl.JndiRegistry;
-import org.junit.Before;
 import org.junit.Test;
-import org.springframework.data.redis.connection.RedisConnection;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.springframework.data.redis.core.RedisCallback;
 import org.springframework.data.redis.core.RedisTemplate;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+@RunWith(MockitoJUnitRunner.class)
 public class RedisConnectionTest extends RedisTestSupport {
 
-    private RedisTemplate redisTemplate;
-    private RedisConnection redisConnection;
+    @Mock
+    private RedisTemplate<String, String> redisTemplate;
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
@@ -40,16 +41,9 @@ public class RedisConnectionTest extends RedisTestSupport {
         return registry;
     }
 
-    @Before
-    public void setUp() throws Exception {
-        redisTemplate = mock(RedisTemplate.class);
-        redisConnection = mock(RedisConnection.class);
-        super.setUp();
-    }
-
     @Test
     public void shouldExecuteECHO() throws Exception {
-        when(redisTemplate.execute(any(RedisCallback.class))).thenReturn("value");
+        when(redisTemplate.execute(ArgumentMatchers.<RedisCallback<String>>any())).thenReturn("value");
 
         Object result = sendHeaders(
                 RedisConstants.COMMAND, "ECHO",
@@ -60,7 +54,7 @@ public class RedisConnectionTest extends RedisTestSupport {
 
     @Test
     public void shouldExecutePING() throws Exception {
-        when(redisTemplate.execute(any(RedisCallback.class))).thenReturn("PONG");
+        when(redisTemplate.execute(ArgumentMatchers.<RedisCallback<String>>any())).thenReturn("PONG");
 
         Object result = sendHeaders(RedisConstants.COMMAND, "PING");
 
@@ -71,10 +65,9 @@ public class RedisConnectionTest extends RedisTestSupport {
     public void shouldExecuteQUIT() throws Exception {
         sendHeaders(RedisConstants.COMMAND, "QUIT");
 
-        verify(redisTemplate).execute(any(RedisCallback.class));
+        verify(redisTemplate).execute(ArgumentMatchers.<RedisCallback<String>>any());
     }
 
-
     @Test
     public void shouldExecutePUBLISH() throws Exception {
         sendHeaders(
diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisConsumerIntegrationTest.java
b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisConsumerIntegrationTest.java
index 22df19a..03fd48f 100755
--- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisConsumerIntegrationTest.java
+++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisConsumerIntegrationTest.java
@@ -40,7 +40,7 @@ public class RedisConsumerIntegrationTest extends RedisTestSupport {
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry registry = super.createRegistry();
 
-        redisTemplate = new RedisTemplate();
+        redisTemplate = new RedisTemplate<>();
         redisTemplate.setConnectionFactory(CONNECTION_FACTORY);
         redisTemplate.afterPropertiesSet();
 
diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisConsumerTest.java
b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisConsumerTest.java
index 64aaa09..817bebd 100755
--- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisConsumerTest.java
+++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisConsumerTest.java
@@ -23,22 +23,33 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
+import org.mockito.ArgumentMatchers;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.springframework.data.redis.connection.DefaultMessage;
 import org.springframework.data.redis.connection.MessageListener;
 import org.springframework.data.redis.listener.ChannelTopic;
 import org.springframework.data.redis.listener.RedisMessageListenerContainer;
 import org.springframework.data.redis.listener.Topic;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.verify;
 
+@RunWith(MockitoJUnitRunner.class)
 public class RedisConsumerTest extends CamelTestSupport {
+
+    @Mock
     private RedisMessageListenerContainer listenerContainer;
 
+    @Captor
+    private ArgumentCaptor<Collection<ChannelTopic>> collectionCaptor;
+    @Captor
+    private ArgumentCaptor<MessageListener> messageListenerCaptor;
+
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry registry = super.createRegistry();
@@ -46,15 +57,8 @@ public class RedisConsumerTest extends CamelTestSupport {
         return registry;
     }
 
-    @Before
-    public void setUp() throws Exception {
-        listenerContainer = mock(RedisMessageListenerContainer.class);
-        super.setUp();
-    }
-
     @Test
     public void registerConsumerForTwoChannelTopics() throws Exception {
-        ArgumentCaptor<Collection> collectionCaptor = ArgumentCaptor.forClass(Collection.class);
         verify(listenerContainer).addMessageListener(any(MessageListener.class), collectionCaptor.capture());
 
         Collection<ChannelTopic> topics = collectionCaptor.getValue();
@@ -72,9 +76,7 @@ public class RedisConsumerTest extends CamelTestSupport {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMinimumMessageCount(2);
 
-        ArgumentCaptor<MessageListener> messageListenerCaptor = ArgumentCaptor
-                .forClass(MessageListener.class);
-        verify(listenerContainer).addMessageListener(messageListenerCaptor.capture(), any(Collection.class));
+        verify(listenerContainer).addMessageListener(messageListenerCaptor.capture(), ArgumentMatchers.<Collection<?
extends Topic>>any());
 
         MessageListener messageListener = messageListenerCaptor.getValue();
         messageListener.onMessage(new DefaultMessage(null, null), null);
diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisHashTest.java
b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisHashTest.java
index da60087..c3927e4 100755
--- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisHashTest.java
+++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisHashTest.java
@@ -25,38 +25,36 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.camel.impl.JndiRegistry;
-import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.springframework.data.redis.core.HashOperations;
 import org.springframework.data.redis.core.RedisTemplate;
 
-import static org.mockito.Matchers.anyCollection;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
+import static org.mockito.ArgumentMatchers.anyList;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+@RunWith(MockitoJUnitRunner.class)
 public class RedisHashTest extends RedisTestSupport {
-    private RedisTemplate redisTemplate;
-    private HashOperations hashOperations;
+
+    @Mock
+    private RedisTemplate<String, String> redisTemplate;
+    @Mock
+    private HashOperations<String, String, String> hashOperations;
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
-        when(redisTemplate.opsForHash()).thenReturn(hashOperations);
+        when(redisTemplate.<String, String>opsForHash()).thenReturn(hashOperations);
 
         JndiRegistry registry = super.createRegistry();
         registry.bind("redisTemplate", redisTemplate);
         return registry;
     }
 
-    @Before
-    public void setUp() throws Exception {
-        redisTemplate = mock(RedisTemplate.class);
-        hashOperations = mock(HashOperations.class);
-        super.setUp();
-    }
-
     @Test
     public void shouldExecuteHDEL() throws Exception {
         sendHeaders(
@@ -208,7 +206,7 @@ public class RedisHashTest extends RedisTestSupport {
     public void shouldExecuteHMGET() throws Exception {
         List<String> fields = new ArrayList<>();
         fields.add("field1");
-        when(hashOperations.multiGet(anyString(), anyCollection())).thenReturn(fields);
+        when(hashOperations.multiGet(anyString(), anyList())).thenReturn(fields);
 
         Object result = sendHeaders(
                 RedisConstants.COMMAND, "HMGET",
diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisKeyTest.java
b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisKeyTest.java
index 98e301f..653dbc4 100755
--- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisKeyTest.java
+++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisKeyTest.java
@@ -25,22 +25,27 @@ import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.impl.JndiRegistry;
-import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.springframework.data.redis.connection.DataType;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.query.SortQuery;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+@RunWith(MockitoJUnitRunner.class)
 public class RedisKeyTest extends RedisTestSupport {
-    private RedisTemplate redisTemplate;
+
+    @Mock
+    private RedisTemplate<String, Integer> redisTemplate;
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
@@ -49,12 +54,6 @@ public class RedisKeyTest extends RedisTestSupport {
         return registry;
     }
 
-    @Before
-    public void setUp() throws Exception {
-        redisTemplate = mock(RedisTemplate.class);
-        super.setUp();
-    }
-
     @Test
     public void shouldExecuteDEL() throws Exception {
         Collection<String> keys = new HashSet<>();
@@ -213,13 +212,13 @@ public class RedisKeyTest extends RedisTestSupport {
     public void shouldExecuteSORT() throws Exception {
         List<Integer> list = new ArrayList<>();
         list.add(5);
-        when(redisTemplate.sort(any(SortQuery.class))).thenReturn(list);
+        when(redisTemplate.sort(ArgumentMatchers.<SortQuery<String>>any())).thenReturn(list);
 
         Object result = sendHeaders(
                 RedisConstants.COMMAND, "SORT",
                 RedisConstants.KEY, "key");
 
-        verify(redisTemplate).sort(any(SortQuery.class));
+        verify(redisTemplate).sort(ArgumentMatchers.<SortQuery<String>>any());
         assertEquals(list, result);
     }
 
diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisListTest.java
b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisListTest.java
index 78bef4f..e3fe72e 100755
--- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisListTest.java
+++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisListTest.java
@@ -21,21 +21,26 @@ import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.impl.JndiRegistry;
-import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.springframework.data.redis.core.ListOperations;
 import org.springframework.data.redis.core.RedisTemplate;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+@RunWith(MockitoJUnitRunner.class)
 public class RedisListTest extends RedisTestSupport {
-    private RedisTemplate redisTemplate;
-    private ListOperations listOperations;
+
+    @Mock
+    private RedisTemplate<String, String> redisTemplate;
+    @Mock
+    private ListOperations<String, String> listOperations;
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
@@ -46,13 +51,6 @@ public class RedisListTest extends RedisTestSupport {
         return registry;
     }
 
-    @Before
-    public void setUp() throws Exception {
-        redisTemplate = mock(RedisTemplate.class);
-        listOperations = mock(ListOperations.class);
-        super.setUp();
-    }
-
     @Test
     public void shouldExecuteLPOP() throws Exception {
         when(listOperations.leftPop(anyString())).thenReturn("value");
diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisProducerIntegrationTest.java
b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisProducerIntegrationTest.java
index ea3f642..ec66419 100755
--- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisProducerIntegrationTest.java
+++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisProducerIntegrationTest.java
@@ -33,7 +33,7 @@ public class RedisProducerIntegrationTest extends RedisTestSupport {
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry registry = super.createRegistry();
-        redisTemplate = new RedisTemplate();
+        redisTemplate = new RedisTemplate<String, String>();
         redisTemplate.setConnectionFactory(CONNECTION_FACTORY);
         redisTemplate.afterPropertiesSet();
 
diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSetTest.java
b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSetTest.java
index 3323d0f..57a3ded 100755
--- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSetTest.java
+++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSetTest.java
@@ -20,21 +20,26 @@ import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.camel.impl.JndiRegistry;
-import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.SetOperations;
 
-import static org.mockito.Matchers.anyCollection;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anySet;
+import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+@RunWith(MockitoJUnitRunner.class)
 public class RedisSetTest extends RedisTestSupport {
-    private RedisTemplate redisTemplate;
-    private SetOperations setOperations;
+
+    @Mock
+    private RedisTemplate<String, String> redisTemplate;
+    @Mock
+    private SetOperations<String, String> setOperations;
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
@@ -45,16 +50,9 @@ public class RedisSetTest extends RedisTestSupport {
         return registry;
     }
 
-    @Before
-    public void setUp() throws Exception {
-        redisTemplate = mock(RedisTemplate.class);
-        setOperations = mock(SetOperations.class);
-        super.setUp();
-    }
-
     @Test
     public void shouldExecuteSADD() throws Exception {
-        when(setOperations.add(anyString(), anyObject())).thenReturn(null);
+        when(setOperations.add(anyString(), any())).thenReturn(null);
 
         Object result = sendHeaders(
                 RedisConstants.COMMAND, "SADD",
@@ -83,7 +81,7 @@ public class RedisSetTest extends RedisTestSupport {
         Set<String> difference = new HashSet<>();
         difference.add("a");
         difference.add("b");
-        when(setOperations.difference(anyString(), anyCollection())).thenReturn(difference);
+        when(setOperations.difference(anyString(), anySet())).thenReturn(difference);
 
         Set<String> keys = new HashSet<>();
         keys.add("key2");
@@ -116,7 +114,7 @@ public class RedisSetTest extends RedisTestSupport {
         Set<String> difference = new HashSet<>();
         difference.add("a");
         difference.add("b");
-        when(setOperations.intersect(anyString(), anyCollection())).thenReturn(difference);
+        when(setOperations.intersect(anyString(), anySet())).thenReturn(difference);
 
         Set<String> keys = new HashSet<>();
         keys.add("key2");
@@ -146,7 +144,7 @@ public class RedisSetTest extends RedisTestSupport {
 
     @Test
     public void shouldExecuteSISMEMBER() throws Exception {
-        when(setOperations.isMember(anyString(), anyObject())).thenReturn(true);
+        when(setOperations.isMember(anyString(), any())).thenReturn(true);
 
         Object result = sendHeaders(
                 RedisConstants.COMMAND, "SISMEMBER",
@@ -212,7 +210,7 @@ public class RedisSetTest extends RedisTestSupport {
 
     @Test
     public void shouldExecuteSREM() throws Exception {
-        when(setOperations.remove(anyString(), anyObject())).thenReturn(Long.valueOf(1));
+        when(setOperations.remove(anyString(), any())).thenReturn(Long.valueOf(1));
 
         Object result = sendHeaders(
                 RedisConstants.COMMAND, "SREM",
@@ -229,7 +227,7 @@ public class RedisSetTest extends RedisTestSupport {
         resultKeys.add("key2");
         resultKeys.add("key3");
 
-        when(setOperations.union(anyString(), anyCollection())).thenReturn(resultKeys);
+        when(setOperations.union(anyString(), anySet())).thenReturn(resultKeys);
 
         Set<String> keys = new HashSet<>();
         keys.add("key2");
diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSortedSetTest.java
b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSortedSetTest.java
index 01cb157..749b6f1 100755
--- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSortedSetTest.java
+++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSortedSetTest.java
@@ -20,22 +20,27 @@ import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.camel.impl.JndiRegistry;
-import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.ZSetOperations;
 
-import static org.mockito.Matchers.anyDouble;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyDouble;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+@RunWith(MockitoJUnitRunner.class)
 public class RedisSortedSetTest extends RedisTestSupport {
-    private RedisTemplate redisTemplate;
-    private ZSetOperations zSetOperations;
+
+    @Mock
+    private RedisTemplate<String, String> redisTemplate;
+    @Mock
+    private ZSetOperations<String, String> zSetOperations;
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
@@ -46,16 +51,9 @@ public class RedisSortedSetTest extends RedisTestSupport {
         return registry;
     }
 
-    @Before
-    public void setUp() throws Exception {
-        redisTemplate = mock(RedisTemplate.class);
-        zSetOperations = mock(ZSetOperations.class);
-        super.setUp();
-    }
-
     @Test
     public void shouldExecuteZADD() {
-        when(zSetOperations.add(anyString(), anyObject(), anyDouble())).thenReturn(false);
+        when(zSetOperations.add(anyString(), any(), anyDouble())).thenReturn(false);
 
         Object result = sendHeaders(
                 RedisConstants.COMMAND, "ZADD",
diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisStringTest.java
b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisStringTest.java
index 274fe31..0e4e5cf 100755
--- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisStringTest.java
+++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisStringTest.java
@@ -23,21 +23,24 @@ import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.impl.JndiRegistry;
-import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.springframework.data.redis.core.RedisCallback;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.ValueOperations;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+@RunWith(MockitoJUnitRunner.class)
 public class RedisStringTest extends RedisTestSupport {
-    private ValueOperations valueOperations;
+
+    @Mock
+    private ValueOperations<String, String> valueOperations;
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
@@ -48,13 +51,6 @@ public class RedisStringTest extends RedisTestSupport {
         return registry;
     }
 
-    @Before
-    public void setUp() throws Exception {
-        redisTemplate = mock(RedisTemplate.class);
-        valueOperations = mock(ValueOperations.class);
-        super.setUp();
-    }
-
     @Test
     public void shouldExecuteSET() throws Exception {
         sendHeaders(
@@ -123,20 +119,20 @@ public class RedisStringTest extends RedisTestSupport {
                 RedisConstants.OFFSET, "10",
                 RedisConstants.VALUE, "0");
 
-        verify(redisTemplate).execute(any(RedisCallback.class));
+        verify(redisTemplate).execute(ArgumentMatchers.<RedisCallback<String>>any());
     }
 
 
     @Test
     public void shouldExecuteGETBIT() throws Exception {
-        when(redisTemplate.execute(any(RedisCallback.class))).thenReturn(true);
+        when(redisTemplate.execute(ArgumentMatchers.<RedisCallback<Boolean>>any())).thenReturn(true);
 
         Object result = sendHeaders(
                 RedisConstants.COMMAND, "GETBIT",
                 RedisConstants.KEY, "key",
                 RedisConstants.OFFSET, "2");
 
-        verify(redisTemplate).execute(any(RedisCallback.class));
+        verify(redisTemplate).execute(ArgumentMatchers.<RedisCallback<String>>any());
         assertEquals(true, result);
     }
 
diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisTestSupport.java
b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisTestSupport.java
index 44b53e9..538e47b 100755
--- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisTestSupport.java
+++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisTestSupport.java
@@ -23,10 +23,16 @@ import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.springframework.data.redis.core.RedisTemplate;
 
+@RunWith(MockitoJUnitRunner.class)
 public class RedisTestSupport extends CamelTestSupport {
-    protected RedisTemplate redisTemplate;
+
+    @Mock
+    protected RedisTemplate<String, String> redisTemplate;
 
     @Produce(uri = "direct:start")
     protected ProducerTemplate template;
diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisTransactionTest.java
b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisTransactionTest.java
index 64b1039..16e8266 100755
--- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisTransactionTest.java
+++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisTransactionTest.java
@@ -20,15 +20,19 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.camel.impl.JndiRegistry;
-import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.springframework.data.redis.core.RedisTemplate;
 
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
+@RunWith(MockitoJUnitRunner.class)
 public class RedisTransactionTest extends RedisTestSupport {
-    private RedisTemplate redisTemplate;
+
+    @Mock
+    private RedisTemplate<String, ?> redisTemplate;
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
@@ -37,12 +41,6 @@ public class RedisTransactionTest extends RedisTestSupport {
         return registry;
     }
 
-    @Before
-    public void setUp() throws Exception {
-        redisTemplate = mock(RedisTemplate.class);
-        super.setUp();
-    }
-
     @Test
     public void shouldExecuteMULTI() throws Exception {
         sendHeaders(RedisConstants.COMMAND, "MULTI");
diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisIdempotentRepositoryTest.java
b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisIdempotentRepositoryTest.java
index 9c80e9a..c13963c 100755
--- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisIdempotentRepositoryTest.java
+++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisIdempotentRepositoryTest.java
@@ -18,31 +18,37 @@ package org.apache.camel.component.redis.processor.idempotent;
 
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.springframework.data.redis.connection.RedisConnection;
 import org.springframework.data.redis.connection.RedisConnectionFactory;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.SetOperations;
 
 import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+@RunWith(MockitoJUnitRunner.class)
 public class RedisIdempotentRepositoryTest {
+
     private static final String REPOSITORY = "testRepository";
     private static final String KEY = "KEY";
-    private RedisTemplate redisTemplate;
+
+    @Mock
+    private RedisTemplate<String, String> redisTemplate;
+    @Mock
     private RedisConnectionFactory redisConnectionFactory;
+    @Mock
     private RedisConnection redisConnection;
-    private SetOperations setOperations;
+    @Mock
+    private SetOperations<String, String> setOperations;
+
     private RedisIdempotentRepository idempotentRepository;
 
     @Before
     public void setUp() throws Exception {
-        redisTemplate = mock(RedisTemplate.class);
-        setOperations = mock(SetOperations.class);
-        redisConnection = mock(RedisConnection.class);
-        redisConnectionFactory = mock(RedisConnectionFactory.class);
         when(redisTemplate.opsForSet()).thenReturn(setOperations);
         when(redisTemplate.getConnectionFactory()).thenReturn(redisConnectionFactory);
         when(redisTemplate.getConnectionFactory().getConnection()).thenReturn(redisConnection);
@@ -66,7 +72,7 @@ public class RedisIdempotentRepositoryTest {
         idempotentRepository.remove(KEY);
         verify(setOperations).remove(REPOSITORY, KEY);
     }
-    
+
     @Test
     public void shouldClearRepository() {
         idempotentRepository.clear();
diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisStringIdempotentRepositoryIntegrationTest.java
b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisStringIdempotentRepositoryIntegrationTest.java
index 277bb51..ade80c0 100644
--- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisStringIdempotentRepositoryIntegrationTest.java
+++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisStringIdempotentRepositoryIntegrationTest.java
@@ -45,7 +45,7 @@ public class RedisStringIdempotentRepositoryIntegrationTest extends CamelTestSup
     private MockEndpoint mockResult;
 
     @Resource
-    private RedisTemplate redisTemplate;
+    private RedisTemplate<String, String> redisTemplate;
 
     static {
         CONNECTION_FACTORY.afterPropertiesSet();
@@ -54,7 +54,7 @@ public class RedisStringIdempotentRepositoryIntegrationTest extends CamelTestSup
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry registry = super.createRegistry();
-        redisTemplate = new RedisTemplate();
+        redisTemplate = new RedisTemplate<>();
         redisTemplate.setConnectionFactory(CONNECTION_FACTORY);
         redisTemplate.afterPropertiesSet();
 
diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisStringIdempotentRepositoryTest.java
b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisStringIdempotentRepositoryTest.java
index 81ae079..286b9e3 100644
--- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisStringIdempotentRepositoryTest.java
+++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisStringIdempotentRepositoryTest.java
@@ -20,6 +20,9 @@ import java.util.concurrent.TimeUnit;
 
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.springframework.data.redis.connection.RedisConnection;
 import org.springframework.data.redis.connection.RedisConnectionFactory;
 import org.springframework.data.redis.core.RedisOperations;
@@ -27,32 +30,32 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.ValueOperations;
 
 import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+@RunWith(MockitoJUnitRunner.class)
 public class RedisStringIdempotentRepositoryTest {
 
     private static final String REPOSITORY = "testRepository";
     private static final String KEY = "KEY";
-    private RedisTemplate redisTemplate;
+
+    @Mock
+    private RedisTemplate<String, String> redisTemplate;
+    @Mock
     private RedisConnectionFactory redisConnectionFactory;
+    @Mock
     private RedisConnection redisConnection;
-    private RedisOperations redisOperations;
-    private ValueOperations valueOperations;
+    @Mock
+    private RedisOperations<String, String> redisOperations;
+    @Mock
+    private ValueOperations<String, String> valueOperations;
+
     private RedisStringIdempotentRepository idempotentRepository;
 
     @Before
     public void setUp() throws Exception {
-        redisTemplate = mock(RedisTemplate.class);
-        valueOperations = mock(ValueOperations.class);
-        redisConnection = mock(RedisConnection.class);
-        redisOperations = mock(RedisOperations.class);
-        redisConnectionFactory = mock(RedisConnectionFactory.class);
         when(redisTemplate.opsForValue()).thenReturn(valueOperations);
-        when(redisTemplate.getConnectionFactory()).thenReturn(redisConnectionFactory);
         when(valueOperations.getOperations()).thenReturn(redisOperations);
-        when(redisTemplate.getConnectionFactory().getConnection()).thenReturn(redisConnection);
         idempotentRepository = new RedisStringIdempotentRepository(redisTemplate, REPOSITORY);
         idempotentRepository.setExpiry(1000L);
     }

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

Mime
View raw message