Fix compatibility with latest Spring Data Geode
* Some configs and code style polishing in the Gemfire module tests and in the `DefaultHeaderChannelRegistry`
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:gfe="http://www.springframework.org/schema/gemfire"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:int-gfe="http://www.springframework.org/schema/integration/gemfire"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/gemfire
|
||||
http://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire.xsd
|
||||
http://www.springframework.org/schema/gemfire
|
||||
http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -28,8 +28,8 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.data.gemfire.CacheFactoryBean;
|
||||
import org.springframework.data.gemfire.GenericRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.RegionAttributesFactoryBean;
|
||||
import org.springframework.data.gemfire.RegionFactoryBean;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -38,6 +38,7 @@ import org.springframework.messaging.Message;
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class CacheListeningMessageProducerTests {
|
||||
@@ -46,7 +47,7 @@ public class CacheListeningMessageProducerTests {
|
||||
|
||||
private static CacheFactoryBean cacheFactoryBean;
|
||||
|
||||
private static RegionFactoryBean<String, String> regionFactoryBean;
|
||||
private static GenericRegionFactoryBean<String, String> regionFactoryBean;
|
||||
|
||||
private static Region<String, String> region;
|
||||
|
||||
@@ -54,9 +55,7 @@ public class CacheListeningMessageProducerTests {
|
||||
public static void setup() throws Exception {
|
||||
cacheFactoryBean = new CacheFactoryBean();
|
||||
|
||||
regionFactoryBean = new RegionFactoryBean<String, String>() {
|
||||
|
||||
};
|
||||
regionFactoryBean = new GenericRegionFactoryBean<>();
|
||||
regionFactoryBean.setName("test.receiveNewValuePayloadForCreateEvent");
|
||||
regionFactoryBean.setCache(cacheFactoryBean.getObject());
|
||||
setRegionAttributes(regionFactoryBean);
|
||||
@@ -72,7 +71,7 @@ public class CacheListeningMessageProducerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void receiveNewValuePayloadForCreateEvent() throws Exception {
|
||||
public void receiveNewValuePayloadForCreateEvent() {
|
||||
QueueChannel channel = new QueueChannel();
|
||||
CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region);
|
||||
producer.setPayloadExpression(PARSER.parseExpression("key + '=' + newValue"));
|
||||
@@ -91,7 +90,7 @@ public class CacheListeningMessageProducerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void receiveNewValuePayloadForUpdateEvent() throws Exception {
|
||||
public void receiveNewValuePayloadForUpdateEvent() {
|
||||
QueueChannel channel = new QueueChannel();
|
||||
CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region);
|
||||
producer.setPayloadExpression(PARSER.parseExpression("newValue"));
|
||||
@@ -114,7 +113,7 @@ public class CacheListeningMessageProducerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void receiveOldValuePayloadForDestroyEvent() throws Exception {
|
||||
public void receiveOldValuePayloadForDestroyEvent() {
|
||||
QueueChannel channel = new QueueChannel();
|
||||
CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region);
|
||||
producer.setSupportedEventTypes(EventType.DESTROYED);
|
||||
@@ -136,7 +135,7 @@ public class CacheListeningMessageProducerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void receiveOldValuePayloadForInvalidateEvent() throws Exception {
|
||||
public void receiveOldValuePayloadForInvalidateEvent() {
|
||||
QueueChannel channel = new QueueChannel();
|
||||
CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region);
|
||||
producer.setSupportedEventTypes(EventType.INVALIDATED);
|
||||
@@ -158,7 +157,9 @@ public class CacheListeningMessageProducerTests {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void setRegionAttributes(RegionFactoryBean<String, String> regionFactoryBean) throws Exception {
|
||||
private static void setRegionAttributes(GenericRegionFactoryBean<String, String> regionFactoryBean)
|
||||
throws Exception {
|
||||
|
||||
RegionAttributesFactoryBean attributesFactoryBean = new RegionAttributesFactoryBean();
|
||||
attributesFactoryBean.afterPropertiesSet();
|
||||
regionFactoryBean.setAttributes(attributesFactoryBean.getObject());
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<gfe:cache id="gemfire-cache-2" use-bean-factory-locator="false"/>
|
||||
<gfe:cache id="gemfire-cache-2"/>
|
||||
|
||||
<gfe:local-region id="region1" cache-ref="gemfire-cache-2"/>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
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">
|
||||
|
||||
<gfe:cache use-bean-factory-locator="false"/>
|
||||
<gfe:cache/>
|
||||
|
||||
<gfe:replicated-region id="region1"/>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -33,7 +33,7 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.data.gemfire.CacheFactoryBean;
|
||||
import org.springframework.data.gemfire.RegionFactoryBean;
|
||||
import org.springframework.data.gemfire.GenericRegionFactoryBean;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
@@ -48,6 +48,7 @@ import org.springframework.messaging.support.GenericMessage;
|
||||
* @author David Turanski
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class GemfireMessageStoreTests {
|
||||
@@ -57,7 +58,7 @@ public class GemfireMessageStoreTests {
|
||||
private static Region<Object, Object> region;
|
||||
|
||||
@Test
|
||||
public void addAndGetMessage() throws Exception {
|
||||
public void addAndGetMessage() {
|
||||
GemfireMessageStore store = new GemfireMessageStore(region);
|
||||
Message<?> message = MessageBuilder.withPayload("test").build();
|
||||
store.addMessage(message);
|
||||
@@ -67,9 +68,7 @@ public class GemfireMessageStoreTests {
|
||||
|
||||
@Test
|
||||
public void testRegionConstructor() throws Exception {
|
||||
RegionFactoryBean<Object, Object> region = new RegionFactoryBean<Object, Object>() {
|
||||
|
||||
};
|
||||
GenericRegionFactoryBean<Object, Object> region = new GenericRegionFactoryBean<>();
|
||||
region.setName("someRegion");
|
||||
region.setCache(cacheFactoryBean.getObject());
|
||||
region.afterPropertiesSet();
|
||||
@@ -81,10 +80,10 @@ public class GemfireMessageStoreTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithMessageHistory() throws Exception {
|
||||
public void testWithMessageHistory() {
|
||||
GemfireMessageStore store = new GemfireMessageStore(region);
|
||||
|
||||
Message<?> message = new GenericMessage<String>("Hello");
|
||||
Message<?> message = new GenericMessage<>("Hello");
|
||||
DirectChannel fooChannel = new DirectChannel();
|
||||
fooChannel.setBeanName("fooChannel");
|
||||
DirectChannel barChannel = new DirectChannel();
|
||||
@@ -103,11 +102,11 @@ public class GemfireMessageStoreTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddAndRemoveMessagesFromMessageGroup() throws Exception {
|
||||
public void testAddAndRemoveMessagesFromMessageGroup() {
|
||||
GemfireMessageStore messageStore = new GemfireMessageStore(region);
|
||||
|
||||
String groupId = "X";
|
||||
List<Message<?>> messages = new ArrayList<Message<?>>();
|
||||
List<Message<?>> messages = new ArrayList<>();
|
||||
for (int i = 0; i < 25; i++) {
|
||||
Message<String> message = MessageBuilder.withPayload("foo").setCorrelationId(groupId).build();
|
||||
messageStore.addMessagesToGroup(groupId, message);
|
||||
@@ -121,11 +120,11 @@ public class GemfireMessageStoreTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddAndRemoveMessagesFromMessageGroupWithPrefix() throws Exception {
|
||||
public void testAddAndRemoveMessagesFromMessageGroupWithPrefix() {
|
||||
GemfireMessageStore messageStore = new GemfireMessageStore(region, "foo_");
|
||||
|
||||
String groupId = "X";
|
||||
List<Message<?>> messages = new ArrayList<Message<?>>();
|
||||
List<Message<?>> messages = new ArrayList<>();
|
||||
for (int i = 0; i < 25; i++) {
|
||||
Message<String> message = MessageBuilder.withPayload("foo").setCorrelationId(groupId).build();
|
||||
messageStore.addMessagesToGroup(groupId, message);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
http://www.springframework.org/schema/geode http://www.springframework.org/schema/gemfire/spring-geode.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
|
||||
|
||||
<gfe:cache use-bean-factory-locator="false"/>
|
||||
<gfe:cache/>
|
||||
|
||||
<bean id="lockRegistry" class="org.springframework.integration.gemfire.util.GemfireLockRegistry">
|
||||
<constructor-arg ref="gemfireCache"/>
|
||||
|
||||
Reference in New Issue
Block a user