This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit ef7817874ebd0560832e6d68a232a9e2ec5ee453 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Thu Aug 1 11:27:53 2019 +0200 CAMEL-13801 - camel3 - Use @BindToRegistry wherever possible, Camel-Spring-Redis --- .../org/apache/camel/component/redis/RedisConnectionTest.java | 9 ++------- .../camel/component/redis/RedisConsumerIntegrationTest.java | 6 ++++-- .../java/org/apache/camel/component/redis/RedisConsumerTest.java | 9 ++------- .../test/java/org/apache/camel/component/redis/RedisGeoTest.java | 9 ++------- .../java/org/apache/camel/component/redis/RedisHashTest.java | 6 ++++-- .../test/java/org/apache/camel/component/redis/RedisKeyTest.java | 9 ++------- .../java/org/apache/camel/component/redis/RedisListTest.java | 6 ++++-- .../camel/component/redis/RedisProducerIntegrationTest.java | 6 ++++-- .../test/java/org/apache/camel/component/redis/RedisSetTest.java | 6 ++++-- .../org/apache/camel/component/redis/RedisSortedSetTest.java | 6 ++++-- .../java/org/apache/camel/component/redis/RedisStringTest.java | 6 ++++-- .../org/apache/camel/component/redis/RedisTransactionTest.java | 9 ++------- .../RedisStringIdempotentRepositoryIntegrationTest.java | 6 ++++-- 13 files changed, 42 insertions(+), 51 deletions(-) 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 8a617ed..7def53b 100644 --- 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 @@ -16,6 +16,7 @@ */ package org.apache.camel.component.redis; +import org.apache.camel.BindToRegistry; import org.apache.camel.impl.JndiRegistry; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,15 +33,9 @@ import static org.mockito.Mockito.when; public class RedisConnectionTest extends RedisTestSupport { @Mock + @BindToRegistry("redisTemplate") private RedisTemplate<String, String> redisTemplate; - @Override - protected JndiRegistry createRegistry() throws Exception { - JndiRegistry registry = super.createRegistry(); - registry.bind("redisTemplate", redisTemplate); - return registry; - } - @Test public void shouldExecuteECHO() throws Exception { when(redisTemplate.execute(ArgumentMatchers.<RedisCallback<String>>any())).thenReturn("value"); 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 f2d6f188..c2bc54d 100644 --- 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 @@ -19,6 +19,8 @@ package org.apache.camel.component.redis; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.impl.JndiRegistry; +import org.apache.camel.spi.Registry; +import org.apache.camel.support.SimpleRegistry; import org.junit.Ignore; import org.junit.Test; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; @@ -37,8 +39,8 @@ public class RedisConsumerIntegrationTest extends RedisTestSupport { } @Override - protected JndiRegistry createRegistry() throws Exception { - JndiRegistry registry = super.createRegistry(); + protected Registry createCamelRegistry() throws Exception { + Registry registry = new SimpleRegistry(); redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(CONNECTION_FACTORY); 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 dd27487..51a589c 100644 --- 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 @@ -19,6 +19,7 @@ package org.apache.camel.component.redis; import java.util.Collection; import java.util.Iterator; +import org.apache.camel.BindToRegistry; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.impl.JndiRegistry; import org.apache.camel.test.junit4.CamelTestSupport; @@ -40,6 +41,7 @@ import static org.mockito.Mockito.verify; public class RedisConsumerTest extends CamelTestSupport { @Mock + @BindToRegistry("listenerContainer") private RedisMessageListenerContainer listenerContainer; @Captor @@ -47,13 +49,6 @@ public class RedisConsumerTest extends CamelTestSupport { @Captor private ArgumentCaptor<MessageListener> messageListenerCaptor; - @Override - protected JndiRegistry createRegistry() throws Exception { - JndiRegistry registry = super.createRegistry(); - registry.bind("listenerContainer", listenerContainer); - return registry; - } - @Test public void registerConsumerForTwoChannelTopics() throws Exception { verify(listenerContainer).addMessageListener(any(MessageListener.class), collectionCaptor.capture()); diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisGeoTest.java b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisGeoTest.java index f66a156..3aa0f22 100755 --- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisGeoTest.java +++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisGeoTest.java @@ -16,6 +16,7 @@ */ package org.apache.camel.component.redis; +import org.apache.camel.BindToRegistry; import org.apache.camel.impl.JndiRegistry; import org.junit.Before; import org.junit.Test; @@ -38,6 +39,7 @@ import static org.mockito.Mockito.when; public class RedisGeoTest extends RedisTestSupport { @Mock + @BindToRegistry("redisTemplate") private RedisTemplate<String, String> redisTemplate; @Mock @@ -48,13 +50,6 @@ public class RedisGeoTest extends RedisTestSupport { when(redisTemplate.opsForGeo()).thenReturn(geoOperations); } - @Override - protected JndiRegistry createRegistry() throws Exception { - JndiRegistry registry = super.createRegistry(); - registry.bind("redisTemplate", redisTemplate); - return registry; - } - @Test public void shouldExecuteGEOADD() throws Exception { sendHeaders(RedisConstants.COMMAND, Command.GEOADD, RedisConstants.KEY, "Sicily", RedisConstants.LONGITUDE, 13.361389, RedisConstants.LATITUDE, 38.115556, 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 269c5eb..6456ed3 100644 --- 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,6 +25,8 @@ import java.util.Map; import java.util.Set; import org.apache.camel.impl.JndiRegistry; +import org.apache.camel.spi.Registry; +import org.apache.camel.support.SimpleRegistry; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -47,10 +49,10 @@ public class RedisHashTest extends RedisTestSupport { private HashOperations<String, String, String> hashOperations; @Override - protected JndiRegistry createRegistry() throws Exception { + protected Registry createCamelRegistry() throws Exception { when(redisTemplate.<String, String>opsForHash()).thenReturn(hashOperations); - JndiRegistry registry = super.createRegistry(); + Registry registry = new SimpleRegistry(); registry.bind("redisTemplate", redisTemplate); return registry; } 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 ef4f7eb..82c6fea 100644 --- 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 @@ -24,6 +24,7 @@ import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; +import org.apache.camel.BindToRegistry; import org.apache.camel.impl.JndiRegistry; import org.junit.Test; import org.junit.runner.RunWith; @@ -45,15 +46,9 @@ import static org.mockito.Mockito.when; public class RedisKeyTest extends RedisTestSupport { @Mock + @BindToRegistry("redisTemplate") private RedisTemplate<String, Integer> redisTemplate; - @Override - protected JndiRegistry createRegistry() throws Exception { - JndiRegistry registry = super.createRegistry(); - registry.bind("redisTemplate", redisTemplate); - return registry; - } - @Test public void shouldExecuteDEL() throws Exception { Collection<String> keys = new HashSet<>(); 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 9690605..b70791a 100644 --- 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,6 +21,8 @@ import java.util.List; import java.util.concurrent.TimeUnit; import org.apache.camel.impl.JndiRegistry; +import org.apache.camel.spi.Registry; +import org.apache.camel.support.SimpleRegistry; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -43,10 +45,10 @@ public class RedisListTest extends RedisTestSupport { private ListOperations<String, String> listOperations; @Override - protected JndiRegistry createRegistry() throws Exception { + protected Registry createCamelRegistry() throws Exception { when(redisTemplate.opsForList()).thenReturn(listOperations); - JndiRegistry registry = super.createRegistry(); + Registry registry = new SimpleRegistry(); registry.bind("redisTemplate", redisTemplate); return registry; } 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 5ee0c72..a34c1a6 100644 --- 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 @@ -17,6 +17,8 @@ package org.apache.camel.component.redis; import org.apache.camel.impl.JndiRegistry; +import org.apache.camel.spi.Registry; +import org.apache.camel.support.SimpleRegistry; import org.junit.Ignore; import org.junit.Test; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; @@ -31,8 +33,8 @@ public class RedisProducerIntegrationTest extends RedisTestSupport { } @Override - protected JndiRegistry createRegistry() throws Exception { - JndiRegistry registry = super.createRegistry(); + protected Registry createCamelRegistry() throws Exception { + Registry registry = new SimpleRegistry(); redisTemplate = new RedisTemplate<>(); 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 ad45535..eed4f8d 100644 --- 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,6 +20,8 @@ import java.util.HashSet; import java.util.Set; import org.apache.camel.impl.JndiRegistry; +import org.apache.camel.spi.Registry; +import org.apache.camel.support.SimpleRegistry; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -42,10 +44,10 @@ public class RedisSetTest extends RedisTestSupport { private SetOperations<String, String> setOperations; @Override - protected JndiRegistry createRegistry() throws Exception { + protected Registry createCamelRegistry() throws Exception { when(redisTemplate.opsForSet()).thenReturn(setOperations); - JndiRegistry registry = super.createRegistry(); + Registry registry = new SimpleRegistry(); registry.bind("redisTemplate", redisTemplate); return registry; } 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 43200dd..d00dbfd 100644 --- 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,6 +20,8 @@ import java.util.HashSet; import java.util.Set; import org.apache.camel.impl.JndiRegistry; +import org.apache.camel.spi.Registry; +import org.apache.camel.support.SimpleRegistry; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -43,10 +45,10 @@ public class RedisSortedSetTest extends RedisTestSupport { private ZSetOperations<String, String> zSetOperations; @Override - protected JndiRegistry createRegistry() throws Exception { + protected Registry createCamelRegistry() throws Exception { when(redisTemplate.opsForZSet()).thenReturn(zSetOperations); - JndiRegistry registry = super.createRegistry(); + Registry registry = new SimpleRegistry(); registry.bind("redisTemplate", redisTemplate); return registry; } 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 7022095..27aa7a0 100644 --- 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,6 +23,8 @@ import java.util.Map; import java.util.concurrent.TimeUnit; import org.apache.camel.impl.JndiRegistry; +import org.apache.camel.spi.Registry; +import org.apache.camel.support.SimpleRegistry; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; @@ -43,10 +45,10 @@ public class RedisStringTest extends RedisTestSupport { private ValueOperations<String, String> valueOperations; @Override - protected JndiRegistry createRegistry() throws Exception { + protected Registry createCamelRegistry() throws Exception { when(redisTemplate.opsForValue()).thenReturn(valueOperations); - JndiRegistry registry = super.createRegistry(); + Registry registry = new SimpleRegistry(); registry.bind("redisTemplate", redisTemplate); return registry; } 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 aecf492..26117f1 100644 --- 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 @@ -19,6 +19,7 @@ package org.apache.camel.component.redis; import java.util.ArrayList; import java.util.List; +import org.apache.camel.BindToRegistry; import org.apache.camel.impl.JndiRegistry; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,15 +33,9 @@ import static org.mockito.Mockito.verify; public class RedisTransactionTest extends RedisTestSupport { @Mock + @BindToRegistry("redisTemplate") private RedisTemplate<String, ?> redisTemplate; - @Override - protected JndiRegistry createRegistry() throws Exception { - JndiRegistry registry = super.createRegistry(); - registry.bind("redisTemplate", redisTemplate); - return registry; - } - @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/RedisStringIdempotentRepositoryIntegrationTest.java b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisStringIdempotentRepositoryIntegrationTest.java index 435c26c..c2562d2 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 @@ -25,6 +25,8 @@ import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.impl.JndiRegistry; +import org.apache.camel.spi.Registry; +import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Ignore; import org.junit.Test; @@ -52,8 +54,8 @@ public class RedisStringIdempotentRepositoryIntegrationTest extends CamelTestSup } @Override - protected JndiRegistry createRegistry() throws Exception { - JndiRegistry registry = super.createRegistry(); + protected Registry createCamelRegistry() throws Exception { + SimpleRegistry registry = new SimpleRegistry(); redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(CONNECTION_FACTORY); redisTemplate.afterPropertiesSet();