RedisStoreTest: increase timeouts

This commit is contained in:
Artem Bilan
2015-12-14 12:02:18 -05:00
parent 69c98c4aad
commit ddcca027f1

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -50,20 +50,21 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
@Test @Test
@RedisAvailable @RedisAvailable
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testListInboundConfiguration() throws Exception{ public void testListInboundConfiguration() throws Exception {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest(); RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.prepareList(jcf); this.prepareList(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("list-inbound-adapter.xml", this.getClass()); ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("list-inbound-adapter.xml", this.getClass());
SourcePollingChannelAdapter spca = context.getBean("listAdapter", SourcePollingChannelAdapter.class); SourcePollingChannelAdapter spca = context.getBean("listAdapter", SourcePollingChannelAdapter.class);
spca.start(); spca.start();
QueueChannel redisChannel = context.getBean("redisChannel", QueueChannel.class); QueueChannel redisChannel = context.getBean("redisChannel", QueueChannel.class);
Message<Integer> message = (Message<Integer>) redisChannel.receive(1000); Message<Integer> message = (Message<Integer>) redisChannel.receive(10000);
assertNotNull(message); assertNotNull(message);
assertEquals(Integer.valueOf(13), message.getPayload()); assertEquals(Integer.valueOf(13), message.getPayload());
//poll again, should get the same stuff //poll again, should get the same stuff
message = (Message<Integer>) redisChannel.receive(1000); message = (Message<Integer>) redisChannel.receive(10000);
assertNotNull(message); assertNotNull(message);
assertEquals(Integer.valueOf(13), message.getPayload()); assertEquals(Integer.valueOf(13), message.getPayload());
this.deletePresidents(jcf); this.deletePresidents(jcf);
@@ -74,22 +75,24 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
@RedisAvailable @RedisAvailable
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// synchronization commit renames the list // synchronization commit renames the list
public void testListInboundConfigurationWithSynchronization() throws Exception{ public void testListInboundConfigurationWithSynchronization() throws Exception {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest(); RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
StringRedisTemplate template = this.createStringRedisTemplate(jcf); StringRedisTemplate template = this.createStringRedisTemplate(jcf);
template.delete("bar"); template.delete("bar");
this.prepareList(jcf); this.prepareList(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("list-inbound-adapter.xml", this.getClass()); ClassPathXmlApplicationContext context =
SourcePollingChannelAdapter spca = context.getBean("listAdapterWithSynchronization", SourcePollingChannelAdapter.class); new ClassPathXmlApplicationContext("list-inbound-adapter.xml", this.getClass());
SourcePollingChannelAdapter spca =
context.getBean("listAdapterWithSynchronization", SourcePollingChannelAdapter.class);
spca.start(); spca.start();
QueueChannel redisChannel = context.getBean("redisChannel", QueueChannel.class); QueueChannel redisChannel = context.getBean("redisChannel", QueueChannel.class);
Message<Integer> message = (Message<Integer>) redisChannel.receive(1000); Message<Integer> message = (Message<Integer>) redisChannel.receive(10000);
assertNotNull(message); assertNotNull(message);
assertEquals(Integer.valueOf(13), message.getPayload()); assertEquals(Integer.valueOf(13), message.getPayload());
//poll again, should get nothing since the collection was removed during synchronization //poll again, should get nothing since the collection was removed during synchronization
message = (Message<Integer>) redisChannel.receive(1000); message = (Message<Integer>) redisChannel.receive(100);
assertNull(message); assertNull(message);
assertEquals(Long.valueOf(13), template.boundListOps("bar").size()); assertEquals(Long.valueOf(13), template.boundListOps("bar").size());
template.delete("bar"); template.delete("bar");
@@ -101,7 +104,7 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
@Test @Test
@RedisAvailable @RedisAvailable
// synchronization rollback renames the list // synchronization rollback renames the list
public void testListInboundConfigurationWithSynchronizationAndRollback() throws Exception{ public void testListInboundConfigurationWithSynchronizationAndRollback() throws Exception {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest(); RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
StringRedisTemplate template = this.createStringRedisTemplate(jcf); StringRedisTemplate template = this.createStringRedisTemplate(jcf);
template.delete("baz"); template.delete("baz");
@@ -117,6 +120,7 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
latch.countDown(); latch.countDown();
throw new RuntimeException("Test Rollback"); throw new RuntimeException("Test Rollback");
} }
}); });
SourcePollingChannelAdapter spca = context.getBean("listAdapterWithSynchronizationAndRollback", SourcePollingChannelAdapter spca = context.getBean("listAdapterWithSynchronizationAndRollback",
SourcePollingChannelAdapter.class); SourcePollingChannelAdapter.class);
@@ -126,7 +130,7 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
while (n++ < 100 && template.keys("baz").size() == 0) { while (n++ < 100 && template.keys("baz").size() == 0) {
Thread.sleep(100); Thread.sleep(100);
} }
assertTrue("Rename didn't occcur", n < 100); assertTrue("Rename didn't occur", n < 100);
assertEquals(Long.valueOf(13), template.boundListOps("baz").size()); assertEquals(Long.valueOf(13), template.boundListOps("baz").size());
template.delete("baz"); template.delete("baz");
@@ -138,22 +142,24 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
@RedisAvailable @RedisAvailable
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// synchronization commit renames the list // synchronization commit renames the list
public void testListInboundConfigurationWithSynchronizationAndTemplate() throws Exception{ public void testListInboundConfigurationWithSynchronizationAndTemplate() throws Exception {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest(); RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
StringRedisTemplate template = this.createStringRedisTemplate(jcf); StringRedisTemplate template = this.createStringRedisTemplate(jcf);
template.delete("bar"); template.delete("bar");
this.prepareList(jcf); this.prepareList(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("list-inbound-adapter.xml", this.getClass()); ClassPathXmlApplicationContext context =
SourcePollingChannelAdapter spca = context.getBean("listAdapterWithSynchronizationAndRedisTemplate", SourcePollingChannelAdapter.class); new ClassPathXmlApplicationContext("list-inbound-adapter.xml", this.getClass());
SourcePollingChannelAdapter spca =
context.getBean("listAdapterWithSynchronizationAndRedisTemplate", SourcePollingChannelAdapter.class);
spca.start(); spca.start();
QueueChannel redisChannel = context.getBean("redisChannel", QueueChannel.class); QueueChannel redisChannel = context.getBean("redisChannel", QueueChannel.class);
Message<Integer> message = (Message<Integer>) redisChannel.receive(1000); Message<Integer> message = (Message<Integer>) redisChannel.receive(10000);
assertNotNull(message); assertNotNull(message);
assertEquals(Integer.valueOf(13), message.getPayload()); assertEquals(Integer.valueOf(13), message.getPayload());
//poll again, should get nothing since the collection was removed during synchronization //poll again, should get nothing since the collection was removed during synchronization
message = (Message<Integer>) redisChannel.receive(1000); message = (Message<Integer>) redisChannel.receive(100);
assertNull(message); assertNull(message);
assertEquals(Long.valueOf(13), template.boundListOps("bar").size()); assertEquals(Long.valueOf(13), template.boundListOps("bar").size());
template.delete("bar"); template.delete("bar");
@@ -168,7 +174,8 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
public void testZsetInboundAdapter() throws InterruptedException { public void testZsetInboundAdapter() throws InterruptedException {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest(); RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.prepareZset(jcf); this.prepareZset(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("zset-inbound-adapter.xml", this.getClass()); ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("zset-inbound-adapter.xml", this.getClass());
//No Score test //No Score test
SourcePollingChannelAdapter zsetAdapterNoScore = SourcePollingChannelAdapter zsetAdapterNoScore =
@@ -177,12 +184,12 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
QueueChannel redisChannel = context.getBean("redisChannel", QueueChannel.class); QueueChannel redisChannel = context.getBean("redisChannel", QueueChannel.class);
Message<RedisZSet<Object>> message = (Message<RedisZSet<Object>>) redisChannel.receive(2000); Message<RedisZSet<Object>> message = (Message<RedisZSet<Object>>) redisChannel.receive(10000);
assertNotNull(message); assertNotNull(message);
assertEquals(13, message.getPayload().size()); assertEquals(13, message.getPayload().size());
//poll again, should get the same stuff //poll again, should get the same stuff
message = (Message<RedisZSet<Object>>) redisChannel.receive(2000); message = (Message<RedisZSet<Object>>) redisChannel.receive(10000);
assertNotNull(message); assertNotNull(message);
assertEquals(13, message.getPayload().size()); assertEquals(13, message.getPayload().size());
@@ -194,12 +201,12 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
context.getBean("zsetAdapterWithScoreRange", SourcePollingChannelAdapter.class); context.getBean("zsetAdapterWithScoreRange", SourcePollingChannelAdapter.class);
zsetAdapterWithScoreRange.start(); zsetAdapterWithScoreRange.start();
message = (Message<RedisZSet<Object>>) redisChannel.receive(2000); message = (Message<RedisZSet<Object>>) redisChannel.receive(10000);
assertNotNull(message); assertNotNull(message);
assertEquals(11, message.getPayload().rangeByScore(18, 20).size()); assertEquals(11, message.getPayload().rangeByScore(18, 20).size());
//poll again, should get the same stuff //poll again, should get the same stuff
message = (Message<RedisZSet<Object>>) redisChannel.receive(2000); message = (Message<RedisZSet<Object>>) redisChannel.receive(10000);
assertNotNull(message); assertNotNull(message);
assertEquals(11, message.getPayload().rangeByScore(18, 20).size()); assertEquals(11, message.getPayload().rangeByScore(18, 20).size());
@@ -211,12 +218,12 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
context.getBean("zsetAdapterWithSingleScore", SourcePollingChannelAdapter.class); context.getBean("zsetAdapterWithSingleScore", SourcePollingChannelAdapter.class);
zsetAdapterWithSingleScore.start(); zsetAdapterWithSingleScore.start();
message = (Message<RedisZSet<Object>>) redisChannel.receive(2000); message = (Message<RedisZSet<Object>>) redisChannel.receive(10000);
assertNotNull(message); assertNotNull(message);
assertEquals(2, message.getPayload().rangeByScore(18, 18).size()); assertEquals(2, message.getPayload().rangeByScore(18, 18).size());
//poll again, should get the same stuff //poll again, should get the same stuff
message = (Message<RedisZSet<Object>>) redisChannel.receive(2000); message = (Message<RedisZSet<Object>>) redisChannel.receive(10000);
assertNotNull(message); assertNotNull(message);
assertEquals(2, message.getPayload().rangeByScore(18, 18).size()); assertEquals(2, message.getPayload().rangeByScore(18, 18).size());
@@ -231,24 +238,24 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
// get all 13 presidents // get all 13 presidents
zsetAdapterNoScore.start(); zsetAdapterNoScore.start();
message = (Message<RedisZSet<Object>>) redisChannel.receive(2000); message = (Message<RedisZSet<Object>>) redisChannel.receive(10000);
assertNotNull(message); assertNotNull(message);
assertEquals(13, message.getPayload().size()); assertEquals(13, message.getPayload().size());
zsetAdapterNoScore.stop(); zsetAdapterNoScore.stop();
// get only presidents for 18th century // get only presidents for 18th century
zsetAdapterWithSingleScoreAndSynchronization.start(); zsetAdapterWithSingleScoreAndSynchronization.start();
Message<Integer> sizeMessage = (Message<Integer>) otherRedisChannel.receive(2000); Message<Integer> sizeMessage = (Message<Integer>) otherRedisChannel.receive(10000);
assertNotNull(sizeMessage); assertNotNull(sizeMessage);
assertEquals(Integer.valueOf(2), sizeMessage.getPayload()); assertEquals(Integer.valueOf(2), sizeMessage.getPayload());
// ... however other elements are still available 13-2=11 // ... however other elements are still available 13-2=11
zsetAdapterNoScore.start(); zsetAdapterNoScore.start();
message = (Message<RedisZSet<Object>>) redisChannel.receive(2000); message = (Message<RedisZSet<Object>>) redisChannel.receive(10000);
assertNotNull(message); assertNotNull(message);
int n = 0; int n = 0;
while(n++ < 100 && message.getPayload().size() != 11) { while (n++ < 100 && message.getPayload().size() != 11) {
Thread.sleep(100); Thread.sleep(100);
} }
assertTrue(n < 100); assertTrue(n < 100);