From 0327666ca70d7bd583a49dacd98981dd8d13f8e3 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Sat, 14 Nov 2015 16:51:01 -0500 Subject: [PATCH] Fix RedisMessageGroupStore Tests: clean up DB https://build.spring.io/browse/INT-B41-JOB1-493 --- .../store/AbstractKeyValueMessageStore.java | 6 +-- .../store/RedisMessageGroupStoreTests.java | 7 +-- .../redis/store/RedisMessageStoreTests.java | 51 ++++++++++++------- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractKeyValueMessageStore.java b/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractKeyValueMessageStore.java index e147e487b5..d25c40a678 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractKeyValueMessageStore.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractKeyValueMessageStore.java @@ -37,7 +37,7 @@ import org.springframework.util.Assert; * @author Gary Russell * @since 2.1 */ -public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupStore implements MessageStore{ +public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupStore implements MessageStore { protected static final String MESSAGE_KEY_PREFIX = "MESSAGE_"; @@ -342,8 +342,8 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS private SimpleMessageGroup normalizeSimpleMessageGroup(SimpleMessageGroup messageGroup){ SimpleMessageGroup normalizedGroup = new SimpleMessageGroup(messageGroup.getGroupId()); for (Message message : messageGroup.getMessages()) { - Message normailizedMessage = normalizeMessage(message); - normalizedGroup.add(normailizedMessage); + Message normalizedMessage = normalizeMessage(message); + normalizedGroup.add(normalizedMessage); } return normalizedGroup; } diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisMessageGroupStoreTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisMessageGroupStoreTests.java index a22d0a81c7..b8c4e20bfa 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisMessageGroupStoreTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisMessageGroupStoreTests.java @@ -29,6 +29,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import junit.framework.AssertionFailedError; import org.junit.After; import org.junit.Before; import org.junit.Ignore; @@ -49,8 +50,6 @@ import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.support.GenericMessage; -import junit.framework.AssertionFailedError; - /** * @author Oleg Zhurakousky * @author Artem Bilan @@ -63,9 +62,7 @@ public class RedisMessageGroupStoreTests extends RedisAvailableTests { @After public void setUpTearDown() { StringRedisTemplate template = createStringRedisTemplate(getConnectionFactoryForTest()); - template.delete("MESSAGE_GROUP_1"); - template.delete("MESSAGE_GROUP_2"); - template.delete("MESSAGE_GROUP_3"); + template.delete(template.keys("MESSAGE_GROUP_*")); } @Test diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisMessageStoreTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisMessageStoreTests.java index 0e7a82ed6c..69427477d6 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisMessageStoreTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisMessageStoreTests.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.redis.store; import static org.junit.Assert.assertEquals; @@ -98,7 +99,7 @@ public class RedisMessageStoreTests extends RedisAvailableTests { assertEquals("Barak Obama", storedMessage.getPayload().getName()); } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) @RedisAvailable public void testAddNonSerializableObjectMessage(){ RedisConnectionFactory jcf = this.getConnectionFactoryForTest(); @@ -120,6 +121,7 @@ public class RedisMessageStoreTests extends RedisAvailableTests { assertNotNull(retrievedMessage); assertEquals("Hello Redis", retrievedMessage.getPayload()); } + @SuppressWarnings("unchecked") @Test @RedisAvailable @@ -173,31 +175,42 @@ public class RedisMessageStoreTests extends RedisAvailableTests { messageStore.removeMessagesFromGroup(groupId, messages); MessageGroup group = messageStore.getMessageGroup(groupId); assertEquals(0, group.size()); + messageStore.removeMessageGroup("X"); } @SuppressWarnings("serial") - public static class Person implements Serializable{ + public static class Person implements Serializable { + private Address address; - public Address getAddress() { - return address; - } - public void setAddress(Address address) { - this.address = address; - } - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } + private String name; + public Person(Address address, String name){ this.address = address; this.name = name; } + + public Address getAddress() { + return address; + } + + public void setAddress(Address address) { + this.address = address; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } + @SuppressWarnings("serial") - public static class Address implements Serializable{ + public static class Address implements Serializable { + private String address; public String getAddress() { @@ -207,9 +220,11 @@ public class RedisMessageStoreTests extends RedisAvailableTests { public void setAddress(String address) { this.address = address; } - } - - public static class Foo{ } + + public static class Foo { + + } + }