diff --git a/build.gradle b/build.gradle index c1e07142dc..2ba779e782 100644 --- a/build.gradle +++ b/build.gradle @@ -108,7 +108,6 @@ subprojects { subproject -> jackson2Version = '2.9.5' javaxActivationVersion = '1.1.1' javaxMailVersion = '1.6.1' - jedisVersion = '2.9.0' jmsApiVersion = '2.0.1' jpa21ApiVersion = '1.0.0.Final' jpaApiVersion = '2.1.1' @@ -120,6 +119,7 @@ subprojects { subproject -> junitPlatformVersion = '1.1.1' jythonVersion = '2.5.3' kryoShadedVersion = '3.0.3' + lettuceVersion = '5.0.3.RELEASE' log4jVersion = '2.11.0' micrometerVersion = '1.0.3' mockitoVersion = '2.18.0' @@ -364,7 +364,7 @@ project('spring-integration-file') { testCompile project(":spring-integration-gemfire") testCompile project(":spring-integration-jdbc") testCompile "com.h2database:h2:$h2Version" - testCompile "redis.clients:jedis:$jedisVersion" + testCompile "io.lettuce:lettuce-core:$lettuceVersion" testCompile "io.projectreactor:reactor-test:$reactorVersion" } } @@ -542,7 +542,7 @@ project('spring-integration-redis') { compile project(":spring-integration-core") compile ("org.springframework.data:spring-data-redis:$springDataRedisVersion") - testCompile "redis.clients:jedis:$jedisVersion" + testCompile "io.lettuce:lettuce-core:$lettuceVersion" } } @@ -642,7 +642,7 @@ project('spring-integration-twitter') { compile("javax.activation:activation:$javaxActivationVersion", optional) testCompile project(":spring-integration-redis") testCompile project(":spring-integration-redis").sourceSets.test.output - testCompile "redis.clients:jedis:$jedisVersion" + testCompile "io.lettuce:lettuce-core:$lettuceVersion" } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/leader/LockRegistryLeaderInitiator.java b/spring-integration-core/src/main/java/org/springframework/integration/support/leader/LockRegistryLeaderInitiator.java index 9e4a169209..609b161c65 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/leader/LockRegistryLeaderInitiator.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/leader/LockRegistryLeaderInitiator.java @@ -386,8 +386,8 @@ public class LockRegistryLeaderInitiator implements SmartLifecycle, DisposableBe this.lock.unlock(); } catch (Exception e1) { - logger.debug("Could not unlock - treat as broken. " + - "Revoking " + (isRunning() ? " and retrying..." : "..."), e); + logger.debug("Could not unlock - treat as broken: " + this.context + + ". Revoking " + (isRunning() ? " and retrying..." : "..."), e); } // The lock was broken and we are no longer leader diff --git a/spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisLockRegistry.java b/spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisLockRegistry.java index b9940a91bf..c192b090b0 100644 --- a/spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisLockRegistry.java +++ b/spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisLockRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,8 @@ import java.util.Iterator; import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; @@ -31,6 +33,7 @@ import java.util.concurrent.locks.ReentrantLock; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.DisposableBean; import org.springframework.dao.CannotAcquireLockException; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.StringRedisTemplate; @@ -38,7 +41,9 @@ import org.springframework.data.redis.core.script.DefaultRedisScript; import org.springframework.data.redis.core.script.RedisScript; import org.springframework.integration.support.locks.ExpirableLockRegistry; import org.springframework.integration.support.locks.LockRegistry; +import org.springframework.scheduling.concurrent.CustomizableThreadFactory; import org.springframework.util.Assert; +import org.springframework.util.ReflectionUtils; /** * Implementation of {@link LockRegistry} providing a distributed lock using Redis. @@ -68,11 +73,13 @@ import org.springframework.util.Assert; * @since 4.0 * */ -public final class RedisLockRegistry implements ExpirableLockRegistry { +public final class RedisLockRegistry implements ExpirableLockRegistry, DisposableBean { private static final Log logger = LogFactory.getLog(RedisLockRegistry.class); - private static final long DEFAULT_EXPIRE_AFTER = 60000; + private static final long DEFAULT_EXPIRE_AFTER = 60000L; + + public static final long DEFAULT_DELETE_TIMEOUT = 10000L; private static final String OBTAIN_LOCK_SCRIPT = "local lockClientId = redis.call('GET', KEYS[1])\n" + @@ -85,6 +92,27 @@ public final class RedisLockRegistry implements ExpirableLockRegistry { "end\n" + "return false"; + + /** + * An {@link ExecutorService} to call {@link StringRedisTemplate#delete(Object)} in + * the separate thread when the current one is interrupted. + */ + private ExecutorService executorService = + Executors.newCachedThreadPool(new CustomizableThreadFactory("redis-lock-registry-")); + + /** + * Flag to denote whether the {@link ExecutorService} was provided via the setter and + * thus should not be shutdown when {@link #destroy()} is called + */ + private boolean executorServiceExplicitlySet; + + /** + * Time in milliseconds to wait for the {@link StringRedisTemplate#delete(Object)} in + * the background thread. + */ + private long deleteTimeoutMillis = DEFAULT_DELETE_TIMEOUT; + + private final Map locks = new ConcurrentHashMap<>(); private final String clientId = UUID.randomUUID().toString(); @@ -141,6 +169,13 @@ public final class RedisLockRegistry implements ExpirableLockRegistry { } } + @Override + public void destroy() { + if (!this.executorServiceExplicitlySet) { + this.executorService.shutdown(); + } + } + private final class RedisLock implements Lock { private final String lockKey; @@ -172,11 +207,11 @@ public final class RedisLockRegistry implements ExpirableLockRegistry { break; } catch (InterruptedException e) { - /* - * This method must be uninterruptible so catch and ignore - * interrupts and only break out of the while loop when - * we get the lock. - */ + /* + * This method must be uninterruptible so catch and ignore + * interrupts and only break out of the while loop when + * we get the lock. + */ } catch (Exception e) { this.localLock.unlock(); @@ -263,11 +298,23 @@ public final class RedisLockRegistry implements ExpirableLockRegistry { return; } try { - RedisLockRegistry.this.redisTemplate.delete(this.lockKey); + + if (Thread.currentThread().isInterrupted()) { + RedisLockRegistry.this.executorService.submit(() -> + RedisLockRegistry.this.redisTemplate.delete(this.lockKey)) + .get(RedisLockRegistry.this.deleteTimeoutMillis, TimeUnit.MILLISECONDS); + } + else { + RedisLockRegistry.this.redisTemplate.delete(this.lockKey); + } + if (logger.isDebugEnabled()) { logger.debug("Released lock; " + this); } } + catch (Exception e) { + ReflectionUtils.rethrowRuntimeException(e); + } finally { this.localLock.unlock(); } diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisChannelParserTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisChannelParserTests-context.xml index 8b268d02d6..74a8ed225b 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisChannelParserTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisChannelParserTests-context.xml @@ -2,16 +2,17 @@ + http://www.springframework.org/schema/integration/redis http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> + + - - - - redisSerializer = TestUtils.getPropertyValue(redisChannel, "serializer", RedisSerializer.class); - assertEquals(connectionFactory, context.getBean("redisConnectionFactory")); - assertEquals(redisSerializer, context.getBean("redisSerializer")); + assertEquals(connectionFactory, this.context.getBean("redisConnectionFactory")); + assertEquals(redisSerializer, this.context.getBean("redisSerializer")); assertEquals("si.test.topic.parser", TestUtils.getPropertyValue(redisChannel, "topicName")); assertEquals(Integer.MAX_VALUE, TestUtils.getPropertyValue( - TestUtils.getPropertyValue(redisChannel, "dispatcher"), "maxSubscribers", Integer.class).intValue()); - redisChannel = context.getBean("redisChannelWithSubLimit", SubscribableChannel.class); - assertEquals(1, TestUtils.getPropertyValue(redisChannel, "dispatcher.maxSubscribers", Integer.class).intValue()); - Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); - assertSame(mbf, TestUtils.getPropertyValue(redisChannel, "messageBuilderFactory")); - context.close(); + TestUtils.getPropertyValue(this.redisChannel, "dispatcher"), "maxSubscribers", Integer.class).intValue()); + + assertEquals(1, + TestUtils.getPropertyValue(this.redisChannelWithSubLimit, "dispatcher.maxSubscribers", Integer.class).intValue()); + Object mbf = this.context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); + assertSame(mbf, TestUtils.getPropertyValue(this.redisChannelWithSubLimit, "messageBuilderFactory")); } @Test @RedisAvailable public void testPubSubChannelUsage() throws Exception { - ClassPathXmlApplicationContext context = - new ClassPathXmlApplicationContext("RedisChannelParserTests-context.xml", this.getClass()); - SubscribableChannel redisChannel = context.getBean("redisChannel", SubscribableChannel.class); - - this.awaitContainerSubscribed(TestUtils.getPropertyValue(redisChannel, "container", + this.awaitContainerSubscribed(TestUtils.getPropertyValue(this.redisChannel, "container", RedisMessageListenerContainer.class)); - final Message m = new GenericMessage("Hello Redis"); + final Message m = new GenericMessage<>("Hello Redis"); final CountDownLatch latch = new CountDownLatch(1); - redisChannel.subscribe(message -> { + this.redisChannel.subscribe(message -> { assertEquals(m.getPayload(), message.getPayload()); latch.countDown(); }); - redisChannel.send(m); - assertTrue(latch.await(5, TimeUnit.SECONDS)); - context.close(); + this.redisChannel.send(m); + + assertTrue(latch.await(10, TimeUnit.SECONDS)); } } diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests-context.xml index b562c99d90..ae0346e2be 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests-context.xml @@ -1,39 +1,41 @@ + http://www.springframework.org/schema/integration/redis http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> + + + id="adapter" topics="foo" topic-patterns="f*, b*" channel="receiveChannel" error-channel="testErrorChannel" + message-converter="testConverter" + serializer="serializer" + task-executor="executor"/> - - - + + + - + - - - - - + + class="org.springframework.integration.redis.config.RedisInboundChannelAdapterParserTests$TestMessageConverter"/> + id="autoChannel" topics="foo1, bar1" error-channel="testErrorChannel" + message-converter="testConverter" auto-startup="false"/> diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests.java index af8fd60183..51ac019858 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests.java @@ -111,6 +111,7 @@ public class RedisInboundChannelAdapterParserTests extends RedisAvailableTests { assertThat(receive.getPayload(), Matchers.isOneOf("Hello Redis from foo", "Hello Redis from bar")); } + adapter.stop(); } @Test diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests-context.xml index c2bf271837..2ce914f1aa 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests-context.xml @@ -1,11 +1,16 @@ + http://www.springframework.org/schema/integration/redis http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> + + @@ -25,19 +30,15 @@ - + - - - - - + diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests.java index af78bd24e4..899db78692 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests.java @@ -22,6 +22,8 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import org.hamcrest.Matchers; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -65,6 +67,21 @@ public class RedisOutboundChannelAdapterParserTests extends RedisAvailableTests @Autowired private RedisInboundChannelAdapter fooInbound; + @Autowired + private RedisInboundChannelAdapter barInbound; + + @Before + public void setup() { + this.fooInbound.start(); + this.barInbound.start(); + } + + @After + public void tearDown() { + this.fooInbound.stop(); + this.barInbound.stop(); + } + @Test @RedisAvailable public void validateConfiguration() { @@ -94,16 +111,16 @@ public class RedisOutboundChannelAdapterParserTests extends RedisAvailableTests MessageChannel sendChannel = context.getBean("sendChannel", MessageChannel.class); this.awaitContainerSubscribed(TestUtils.getPropertyValue(fooInbound, "container", RedisMessageListenerContainer.class)); - sendChannel.send(new GenericMessage("Hello Redis")); + sendChannel.send(new GenericMessage<>("Hello Redis")); QueueChannel receiveChannel = context.getBean("receiveChannel", QueueChannel.class); - Message message = receiveChannel.receive(5000); + Message message = receiveChannel.receive(10000); assertNotNull(message); assertEquals("Hello Redis", message.getPayload()); sendChannel = context.getBean("sendChannel", MessageChannel.class); sendChannel.send(MessageBuilder.withPayload("Hello Redis").setHeader("topic", "bar").build()); receiveChannel = context.getBean("barChannel", QueueChannel.class); - message = receiveChannel.receive(5000); + message = receiveChannel.receive(10000); assertNotNull(message); assertEquals("Hello Redis", message.getPayload()); } @@ -111,12 +128,12 @@ public class RedisOutboundChannelAdapterParserTests extends RedisAvailableTests @Test //INT-2275 @RedisAvailable public void testOutboundChannelAdapterWithinChain() throws Exception { - MessageChannel sendChannel = context.getBean("redisOutboudChain", MessageChannel.class); + MessageChannel sendChannel = context.getBean("redisOutboundChain", MessageChannel.class); this.awaitContainerSubscribed(TestUtils.getPropertyValue(fooInbound, "container", RedisMessageListenerContainer.class)); - sendChannel.send(new GenericMessage("Hello Redis from chain")); + sendChannel.send(new GenericMessage<>("Hello Redis from chain")); QueueChannel receiveChannel = context.getBean("receiveChannel", QueueChannel.class); - Message message = receiveChannel.receive(5000); + Message message = receiveChannel.receive(10000); assertNotNull(message); assertEquals("Hello Redis from chain", message.getPayload()); } diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueGatewayIntegrationTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueGatewayIntegrationTests-context.xml index 7d8084acbf..ae3418d047 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueGatewayIntegrationTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueGatewayIntegrationTests-context.xml @@ -3,15 +3,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration" xmlns:int-redis="http://www.springframework.org/schema/integration/redis" + xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd + http://www.springframework.org/schema/integration/redis http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> - http://www.springframework.org/schema/integration/redis http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd"> - - - - + diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueGatewayIntegrationTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueGatewayIntegrationTests.java index ffdf95292f..369d3b2197 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueGatewayIntegrationTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueGatewayIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -68,15 +70,22 @@ public class RedisQueueGatewayIntegrationTests extends RedisAvailableTests { @Autowired private RedisQueueOutboundGateway outboundGateway; + @Before public void setup() { RedisConnectionFactory jcf = getConnectionFactoryForTest(); jcf.getConnection().del(this.queueName); + this.inboundGateway.start(); + } + + @After + public void tearDown() { + this.inboundGateway.stop(); } @Test @RedisAvailable - public void testRequestWithReply() throws Exception { - this.sendChannel.send(new GenericMessage(1)); + public void testRequestWithReply() { + this.sendChannel.send(new GenericMessage<>(1)); Message receive = this.outputChannel.receive(10000); assertNotNull(receive); assertEquals(2, receive.getPayload()); @@ -84,45 +93,47 @@ public class RedisQueueGatewayIntegrationTests extends RedisAvailableTests { @Test @RedisAvailable - public void testInboundGatewayStop() throws Exception { - Long receiveTimeout = TestUtils.getPropertyValue(this.inboundGateway, "receiveTimeout", Long.class); - this.inboundGateway.setReceiveTimeout(1); + public void testInboundGatewayStop() { + Integer receiveTimeout = TestUtils.getPropertyValue(this.outboundGateway, "receiveTimeout", Integer.class); + this.outboundGateway.setReceiveTimeout(1); this.inboundGateway.stop(); try { - this.sendChannel.send(new GenericMessage("test1")); + this.sendChannel.send(new GenericMessage<>("test1")); } catch (Exception e) { assertTrue(e.getMessage().contains("No reply produced")); } finally { - this.inboundGateway.setReceiveTimeout(receiveTimeout); - this.inboundGateway.start(); + this.outboundGateway.setReceiveTimeout(receiveTimeout); } } @Test @RedisAvailable - public void testNullSerializer() throws Exception { + public void testNullSerializer() { + Integer receiveTimeout = TestUtils.getPropertyValue(this.outboundGateway, "receiveTimeout", Integer.class); + this.outboundGateway.setReceiveTimeout(1); this.inboundGateway.setSerializer(null); try { - this.sendChannel.send(new GenericMessage("test1")); + this.sendChannel.send(new GenericMessage<>("test1")); } catch (Exception e) { assertTrue(e.getMessage().contains("No reply produced")); } finally { this.inboundGateway.setSerializer(new StringRedisSerializer()); + this.outboundGateway.setReceiveTimeout(receiveTimeout); } } @Test @RedisAvailable - public void testRequestReplyWithMessage() throws Exception { + public void testRequestReplyWithMessage() { this.inboundGateway.setSerializer(new JdkSerializationRedisSerializer()); this.inboundGateway.setExtractPayload(false); this.outboundGateway.setSerializer(new JdkSerializationRedisSerializer()); this.outboundGateway.setExtractPayload(false); - this.sendChannel.send(new GenericMessage(2)); + this.sendChannel.send(new GenericMessage<>(2)); Message receive = this.outputChannel.receive(10000); assertNotNull(receive); assertEquals(3, receive.getPayload()); diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundChannelAdapterParserTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundChannelAdapterParserTests-context.xml index 1d82b8173a..bfb2af3959 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundChannelAdapterParserTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundChannelAdapterParserTests-context.xml @@ -9,10 +9,8 @@ http://www.springframework.org/schema/integration/redis http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"> - - + + diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundGatewayParserTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundGatewayParserTests-context.xml index e05534c007..c627fd939c 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundGatewayParserTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundGatewayParserTests-context.xml @@ -35,9 +35,7 @@ - - + @@ -47,6 +45,7 @@ diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundChannelAdapterParserTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundChannelAdapterParserTests-context.xml index 749ca20573..312e1898cc 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundChannelAdapterParserTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundChannelAdapterParserTests-context.xml @@ -7,9 +7,8 @@ http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/integration/redis http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd"> - - + + diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundGatewayParserTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundGatewayParserTests-context.xml index 6b6324d791..2a17b1fbb1 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundGatewayParserTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundGatewayParserTests-context.xml @@ -40,8 +40,7 @@ - - + diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/inbound-template-cf-fail.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/inbound-template-cf-fail.xml index 5f9c66d68c..db6341d6e6 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/inbound-template-cf-fail.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/inbound-template-cf-fail.xml @@ -1,12 +1,16 @@ + http://www.springframework.org/schema/integration/redis http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> + - - - - diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpointTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpointTests-context.xml index 474973e073..f2e2d46d1a 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpointTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpointTests-context.xml @@ -3,25 +3,23 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration" xmlns:int-redis="http://www.springframework.org/schema/integration/redis" - xmlns:task="http://www.springframework.org/schema/task" + xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/integration/redis http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd - http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"> + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> - - - + + channel="fromChannel" + expect-message="true" + serializer="testSerializer"/> @@ -31,11 +29,12 @@ + channel="symmetricalRedisChannel" + serializer=""/> - + diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpointTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpointTests.java index 05cc42effa..674f5ec5a6 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpointTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpointTests.java @@ -279,7 +279,7 @@ public class RedisQueueMessageDrivenEndpointTests extends RedisAvailableTests { @Test @RedisAvailable - @Ignore("JedisConnectionFactory doesn't support proper 'destroy()' and allows to create new fresh Redis connection") + @Ignore("LettuceConnectionFactory doesn't support proper reinitialization after 'destroy()'") public void testInt3196Recovery() throws Exception { String queueName = "test.si.Int3196Recovery"; QueueChannel channel = new QueueChannel(); diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/list-inbound-adapter.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/list-inbound-adapter.xml index ed95e1bf9f..cbd51235c3 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/list-inbound-adapter.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/list-inbound-adapter.xml @@ -1,11 +1,16 @@ + http://www.springframework.org/schema/integration/redis http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> + + - - - - diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/zset-inbound-adapter.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/zset-inbound-adapter.xml index 075af8fee3..5e2f736065 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/zset-inbound-adapter.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/zset-inbound-adapter.xml @@ -1,11 +1,16 @@ + http://www.springframework.org/schema/integration/redis http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> + + - + - + - + - + @@ -60,11 +65,6 @@ - - - - diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/leader/RedisLockRegistryLeaderInitiatorTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/leader/RedisLockRegistryLeaderInitiatorTests.java index 9f2ccb3414..65182de0ea 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/leader/RedisLockRegistryLeaderInitiatorTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/leader/RedisLockRegistryLeaderInitiatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2016-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.junit.Rule; import org.junit.Test; import org.springframework.integration.leader.Context; @@ -34,6 +35,7 @@ import org.springframework.integration.redis.rules.RedisAvailable; import org.springframework.integration.redis.rules.RedisAvailableTests; import org.springframework.integration.redis.util.RedisLockRegistry; import org.springframework.integration.support.leader.LockRegistryLeaderInitiator; +import org.springframework.integration.test.rule.Log4j2LevelAdjuster; /** * @author Artem Bilan @@ -44,16 +46,22 @@ import org.springframework.integration.support.leader.LockRegistryLeaderInitiato */ public class RedisLockRegistryLeaderInitiatorTests extends RedisAvailableTests { + @Rule + public Log4j2LevelAdjuster adjuster = + Log4j2LevelAdjuster.trace() + .categories(true, "org.springframework.data.redis"); + @Test @RedisAvailable public void testDistributedLeaderElection() throws Exception { + RedisLockRegistry registry = new RedisLockRegistry(getConnectionFactoryForTest(), "LeaderInitiator"); + registry.expireUnusedOlderThan(-1); CountDownLatch granted = new CountDownLatch(1); CountingPublisher countingPublisher = new CountingPublisher(granted); List initiators = new ArrayList<>(); for (int i = 0; i < 2; i++) { - RedisLockRegistry registry = new RedisLockRegistry(getConnectionFactoryForTest(), "LeaderInitiator"); LockRegistryLeaderInitiator initiator = - new LockRegistryLeaderInitiator(registry, new DefaultCandidate("foo", "bar")); + new LockRegistryLeaderInitiator(registry, new DefaultCandidate("foo:" + i, "bar")); initiator.setLeaderEventPublisher(countingPublisher); initiators.add(initiator); } diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisOutboundGatewayTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisOutboundGatewayTests-context.xml index ebbac31aeb..106c06790a 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisOutboundGatewayTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisOutboundGatewayTests-context.xml @@ -3,12 +3,17 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration" xmlns:int-redis="http://www.springframework.org/schema/integration/redis" + xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/integration/redis - http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd"> + http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> + + @@ -48,12 +53,6 @@ - - - - - diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisOutboundGatewayTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisOutboundGatewayTests.java index e451cde4fc..209d6f8803 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisOutboundGatewayTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisOutboundGatewayTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,16 +40,19 @@ import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.PollableChannel; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Artem Bilan * @author Gary Russell + * * @since 4.0 */ @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) +@DirtiesContext public class RedisOutboundGatewayTests extends RedisAvailableTests { @Autowired @@ -131,7 +134,7 @@ public class RedisOutboundGatewayTests extends RedisAvailableTests { .setHeader(RedisHeaders.COMMAND, "SET").build()); Message receive = this.replyChannel.receive(1000); assertNotNull(receive); - assertTrue(Arrays.equals("OK".getBytes(), (byte[]) receive.getPayload())); + assertEquals("OK", receive.getPayload()); this.getCommandChannel.send(MessageBuilder.withPayload("foo").build()); receive = this.replyChannel.receive(1000); diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisQueueOutboundChannelAdapterTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisQueueOutboundChannelAdapterTests-context.xml index 3b6baee12b..c3866f7d4a 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisQueueOutboundChannelAdapterTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisQueueOutboundChannelAdapterTests-context.xml @@ -3,14 +3,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration" xmlns:int-redis="http://www.springframework.org/schema/integration/redis" + xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd - http://www.springframework.org/schema/integration/redis http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd"> + http://www.springframework.org/schema/integration/redis http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> - - - + + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> + + @@ -56,8 +57,4 @@ map-key-expression="headers['baz']" collection-type="PROPERTIES"/> - - - - diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableRule.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableRule.java index 474e9b870b..cc83a238cb 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableRule.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableRule.java @@ -24,8 +24,11 @@ import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.Statement; import org.springframework.data.redis.connection.RedisStandaloneConfiguration; -import org.springframework.data.redis.connection.jedis.JedisClientConfiguration; -import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; +import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration; +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; + +import io.lettuce.core.ClientOptions; +import io.lettuce.core.SocketOptions; /** * @author Oleg Zhurakousky @@ -36,67 +39,50 @@ public final class RedisAvailableRule implements MethodRule { public static final int REDIS_PORT = 6379; - static ThreadLocal connectionFactoryResource = new ThreadLocal(); + public static LettuceConnectionFactory connectionFactory; + + protected static void setupConnectionFactory() { + RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(); + redisStandaloneConfiguration.setPort(REDIS_PORT); + + LettuceClientConfiguration clientConfiguration = LettuceClientConfiguration.builder() + .clientOptions( + ClientOptions.builder() + .socketOptions( + SocketOptions.builder() + .connectTimeout(Duration.ofMillis(10000)) + .build()) + .build()) + .commandTimeout(Duration.ofSeconds(10000)) + .build(); + + connectionFactory = new LettuceConnectionFactory(redisStandaloneConfiguration, clientConfiguration); + connectionFactory.afterPropertiesSet(); + } + + + public static void cleanUpConnectionFactoryIfAny() { + if (connectionFactory != null) { + connectionFactory.destroy(); + } + } + public Statement apply(final Statement base, final FrameworkMethod method, Object target) { RedisAvailable redisAvailable = method.getAnnotation(RedisAvailable.class); if (redisAvailable != null) { - JedisConnectionFactory connectionFactory = null; - try { - RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(); - redisStandaloneConfiguration.setPort(REDIS_PORT); - - JedisClientConfiguration clientConfiguration = JedisClientConfiguration.builder() - .connectTimeout(Duration.ofSeconds(20)) - .readTimeout(Duration.ofSeconds(20)) - .build(); - - connectionFactory = new JedisConnectionFactory(redisStandaloneConfiguration, clientConfiguration); - connectionFactory.afterPropertiesSet(); - connectionFactory.getConnection(); - connectionFactoryResource.set(connectionFactory); - } - catch (Exception e) { - if (connectionFactory != null) { - connectionFactory.destroy(); + if (connectionFactory != null) { + try { + connectionFactory.getConnection(); } - return new Statement() { + catch (Exception e) { + Assume.assumeTrue("Skipping test due to Redis not being available on port: " + REDIS_PORT + ": " + e, false); - @Override - public void evaluate() throws Throwable { - Assume.assumeTrue("Skipping test due to Redis not being available on port: " + REDIS_PORT, false); - } - }; - - } - - return new Statement() { - - @Override - public void evaluate() throws Throwable { - try { - base.evaluate(); - } - finally { - JedisConnectionFactory connectionFactory = connectionFactoryResource.get(); - connectionFactoryResource.remove(); - if (connectionFactory != null) { - connectionFactory.destroy(); - } - } } - - }; + } } - return new Statement() { - - @Override - public void evaluate() throws Throwable { - base.evaluate(); - } - - }; + return base; } } diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableTests.java index 6851a5fce2..47ba819583 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,8 @@ package org.springframework.integration.redis.rules; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Rule; import org.springframework.data.redis.connection.RedisConnection; @@ -38,26 +40,27 @@ import org.springframework.messaging.Message; * @author Artem Bilan * */ -public class RedisAvailableTests { +public abstract class RedisAvailableTests { @Rule public RedisAvailableRule redisAvailableRule = new RedisAvailableRule(); - private RedisConnectionFactory connectionFactory; + @BeforeClass + public static void setupConnectionFactory() { + RedisAvailableRule.setupConnectionFactory(); + } + + @AfterClass + public static void cleanUpConnectionFactoryIfAny() { + RedisAvailableRule.cleanUpConnectionFactoryIfAny(); + } protected RedisConnectionFactory getConnectionFactoryForTest() { - if (this.connectionFactory != null) { - return this.connectionFactory; - } - RedisConnectionFactory connectionFactory = RedisAvailableRule.connectionFactoryResource.get(); - this.connectionFactory = connectionFactory; - return connectionFactory; + return RedisAvailableRule.connectionFactory; } protected void awaitContainerSubscribed(RedisMessageListenerContainer container) throws Exception { awaitContainerSubscribedNoWait(container); - // wait another second because of race condition - Thread.sleep(1000); } private void awaitContainerSubscribedNoWait(RedisMessageListenerContainer container) throws InterruptedException { @@ -66,7 +69,7 @@ public class RedisAvailableTests { int n = 0; while (n++ < 300 && (connection = - TestUtils.getPropertyValue(container, "subscriptionTask.connection", RedisConnection .class)) == null) { + TestUtils.getPropertyValue(container, "subscriptionTask.connection", RedisConnection.class)) == null) { Thread.sleep(100); } assertNotNull("RedisMessageListenerContainer Failed to Connect", connection); diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/DelayerHandlerRescheduleIntegrationTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/DelayerHandlerRescheduleIntegrationTests-context.xml index 853c495964..134c253837 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/DelayerHandlerRescheduleIntegrationTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/DelayerHandlerRescheduleIntegrationTests-context.xml @@ -6,11 +6,7 @@ http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd"> - - - - - + diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/DelayerHandlerRescheduleIntegrationTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/DelayerHandlerRescheduleIntegrationTests.java index 16951e88a3..e51a62e8d5 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/DelayerHandlerRescheduleIntegrationTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/DelayerHandlerRescheduleIntegrationTests.java @@ -37,7 +37,6 @@ import org.springframework.integration.redis.rules.RedisAvailableTests; import org.springframework.integration.store.MessageGroup; import org.springframework.integration.store.MessageGroupStore; import org.springframework.integration.support.MessageBuilder; -import org.springframework.integration.test.rule.Log4j2LevelAdjuster; import org.springframework.integration.test.support.LongRunningIntegrationTest; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; @@ -57,11 +56,6 @@ public class DelayerHandlerRescheduleIntegrationTests extends RedisAvailableTest @Rule public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest(); - @Rule - public Log4j2LevelAdjuster adjuster = - Log4j2LevelAdjuster.trace() - .categories(true, "org.springframework.data.redis"); - @Test @RedisAvailable public void testDelayerHandlerRescheduleWithRedisMessageStore() throws Exception { diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisChannelMessageStoreTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisChannelMessageStoreTests-context.xml index 721e95c44c..96284c98f3 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisChannelMessageStoreTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisChannelMessageStoreTests-context.xml @@ -1,16 +1,17 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:int="http://www.springframework.org/schema/integration" + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> + + - - - - - + @@ -22,11 +23,7 @@ - - - - - + diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisChannelMessageStoreTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisChannelMessageStoreTests.java index fd5a83b273..b61e3b69bb 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisChannelMessageStoreTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisChannelMessageStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,16 +36,20 @@ import org.springframework.integration.support.MutableMessageBuilder; import org.springframework.messaging.Message; import org.springframework.messaging.PollableChannel; import org.springframework.messaging.support.GenericMessage; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Gary Russell + * @author Artem Bilan + * * @since 4.0 * */ @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) +@DirtiesContext public class RedisChannelMessageStoreTests extends RedisAvailableTests { @Autowired diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/redis-aggregator-config.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/redis-aggregator-config.xml index 612e43ef4e..d1c2eb0e37 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/redis-aggregator-config.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/redis-aggregator-config.xml @@ -1,8 +1,8 @@ @@ -12,11 +12,7 @@ - - - - - + diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/util/AggregatorWithRedisLocksTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/util/AggregatorWithRedisLocksTests-context.xml index d568b79e74..ad3582ce22 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/util/AggregatorWithRedisLocksTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/util/AggregatorWithRedisLocksTests-context.xml @@ -1,9 +1,14 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:int="http://www.springframework.org/schema/integration" + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> + + - - - - - - + @@ -28,7 +28,7 @@ expire-groups-upon-completion="true" lock-registry="redisLockRegistry2" /> - + diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/util/RedisLockRegistryTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/util/RedisLockRegistryTests.java index 6c79c52325..709db1d5fc 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/util/RedisLockRegistryTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/util/RedisLockRegistryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,6 @@ import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.integration.redis.rules.RedisAvailable; import org.springframework.integration.redis.rules.RedisAvailableTests; -import org.springframework.integration.test.rule.Log4j2LevelAdjuster; import org.springframework.integration.test.util.TestUtils; /** @@ -55,6 +54,7 @@ import org.springframework.integration.test.util.TestUtils; * @author Konstantin Yakimov * @author Artem Bilan * @author Vedran Pavic + * * @since 4.0 * */ @@ -66,11 +66,6 @@ public class RedisLockRegistryTests extends RedisAvailableTests { private final String registryKey2 = UUID.randomUUID().toString(); - @Rule - public Log4j2LevelAdjuster adjuster = - Log4j2LevelAdjuster.trace() - .categories("org.springframework.data.redis"); - @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceWithRedisTests-context.xml b/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceWithRedisTests-context.xml index 1f0cd01112..6ea4b3e3e6 100644 --- a/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceWithRedisTests-context.xml +++ b/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceWithRedisTests-context.xml @@ -17,20 +17,17 @@ + query="springintegration" + twitter-template="twitterTemplate" + channel="inbound_twitter" + metadata-store="redisMetadataStore" + auto-startup="false"> - - - - - +