INT-2220 polished Gemfire tests
This commit is contained in:
committed by
Mark Fisher
parent
68875ca435
commit
72593f9ee9
@@ -37,6 +37,7 @@ import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.SimpleMessageGroup;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
|
||||
@@ -90,10 +91,15 @@ public class GemfireGroupStoreTests {
|
||||
|
||||
messageGroup = store.addMessageToGroup(messageGroup.getGroupId(), new GenericMessage<String>("1"));
|
||||
messageGroup = store.getMessageGroup(1);
|
||||
|
||||
assertEquals(1, messageGroup.size());
|
||||
Thread.sleep(1); //since it adds to a local region some times CREATED_DATE ends up to be the same
|
||||
// Unrealistic in a real scenario
|
||||
|
||||
messageGroup = store.addMessageToGroup(messageGroup.getGroupId(), message);
|
||||
messageGroup = store.getMessageGroup(1);
|
||||
|
||||
assertEquals(2, messageGroup.size());
|
||||
Thread.sleep(1);
|
||||
|
||||
messageGroup = store.addMessageToGroup(messageGroup.getGroupId(), new GenericMessage<String>("3"));
|
||||
messageGroup = store.getMessageGroup(1);
|
||||
assertEquals(3, messageGroup.size());
|
||||
@@ -323,6 +329,7 @@ public class GemfireGroupStoreTests {
|
||||
@After
|
||||
public void cleanup(){
|
||||
this.cache.close();
|
||||
Assert.isTrue(this.cache.isClosed(), "Cache did not close after close() call");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,10 +16,13 @@
|
||||
|
||||
package org.springframework.integration.gemfire.store;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.gemfire.CacheFactoryBean;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
|
||||
@@ -31,12 +34,11 @@ import static org.junit.Assert.assertEquals;
|
||||
*/
|
||||
public class GemfireMessageStoreTests {
|
||||
|
||||
private Cache cache;
|
||||
|
||||
@Test
|
||||
public void addAndGetMessage() throws Exception {
|
||||
CacheFactoryBean cacheFactoryBean = new CacheFactoryBean();
|
||||
cacheFactoryBean.afterPropertiesSet();
|
||||
Cache cache = (Cache)cacheFactoryBean.getObject();
|
||||
GemfireMessageStore store = new GemfireMessageStore(cache);
|
||||
GemfireMessageStore store = new GemfireMessageStore(this.cache);
|
||||
store.afterPropertiesSet();
|
||||
|
||||
Message<?> message = MessageBuilder.withPayload("test").build();
|
||||
@@ -45,4 +47,16 @@ public class GemfireMessageStoreTests {
|
||||
assertEquals(message, retrieved);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void init() throws Exception{
|
||||
CacheFactoryBean cacheFactoryBean = new CacheFactoryBean();
|
||||
cacheFactoryBean.afterPropertiesSet();
|
||||
this.cache = (Cache)cacheFactoryBean.getObject();
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanup(){
|
||||
this.cache.close();
|
||||
Assert.isTrue(this.cache.isClosed(), "Cache did not close after close() call");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user