INT-3665: Remove Deprecations and Resolve Issues

https://jira.spring.io/browse/INT-3665

Fixes according Travis report

Introduce `...ExpressionString(String)` setter

Some further fixes and polishing

Address PR comments
This commit is contained in:
Artem Bilan
2015-08-13 16:10:36 -04:00
committed by Gary Russell
parent 84fdd98428
commit cf528c0b5d
81 changed files with 529 additions and 1168 deletions

View File

@@ -27,6 +27,7 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.data.gemfire.CacheFactoryBean;
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;
@@ -36,12 +37,14 @@ import com.gemstone.gemfire.cache.Region;
/**
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
* @since 2.1
*/
public class CacheListeningMessageProducerTests {
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
@Test
@SuppressWarnings("deprecation")
public void receiveNewValuePayloadForCreateEvent() throws Exception {
CacheFactoryBean cacheFactoryBean = new CacheFactoryBean();
Cache cache = cacheFactoryBean.getObject();
@@ -55,7 +58,7 @@ public class CacheListeningMessageProducerTests {
Region<String, String> region = regionFactoryBean.getObject();
QueueChannel channel = new QueueChannel();
CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region);
producer.setPayloadExpression("key + '=' + newValue");
producer.setPayloadExpression(PARSER.parseExpression("key + '=' + newValue"));
producer.setOutputChannel(channel);
producer.setBeanFactory(mock(BeanFactory.class));
producer.afterPropertiesSet();
@@ -68,7 +71,6 @@ public class CacheListeningMessageProducerTests {
}
@Test
@SuppressWarnings("deprecation")
public void receiveNewValuePayloadForUpdateEvent() throws Exception {
CacheFactoryBean cacheFactoryBean = new CacheFactoryBean();
Cache cache = cacheFactoryBean.getObject();
@@ -82,7 +84,7 @@ public class CacheListeningMessageProducerTests {
Region<String, String> region = regionFactoryBean.getObject();
QueueChannel channel = new QueueChannel();
CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region);
producer.setPayloadExpression("newValue");
producer.setPayloadExpression(PARSER.parseExpression("newValue"));
producer.setOutputChannel(channel);
producer.setBeanFactory(mock(BeanFactory.class));
producer.afterPropertiesSet();
@@ -99,7 +101,6 @@ public class CacheListeningMessageProducerTests {
}
@Test
@SuppressWarnings("deprecation")
public void receiveOldValuePayloadForDestroyEvent() throws Exception {
CacheFactoryBean cacheFactoryBean = new CacheFactoryBean();
Cache cache = cacheFactoryBean.getObject();
@@ -114,7 +115,7 @@ public class CacheListeningMessageProducerTests {
QueueChannel channel = new QueueChannel();
CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region);
producer.setSupportedEventTypes(EventType.DESTROYED);
producer.setPayloadExpression("oldValue");
producer.setPayloadExpression(PARSER.parseExpression("oldValue"));
producer.setOutputChannel(channel);
producer.setBeanFactory(mock(BeanFactory.class));
producer.afterPropertiesSet();
@@ -129,7 +130,6 @@ public class CacheListeningMessageProducerTests {
}
@Test
@SuppressWarnings("deprecation")
public void receiveOldValuePayloadForInvalidateEvent() throws Exception {
CacheFactoryBean cacheFactoryBean = new CacheFactoryBean();
Cache cache = cacheFactoryBean.getObject();
@@ -144,7 +144,7 @@ public class CacheListeningMessageProducerTests {
QueueChannel channel = new QueueChannel();
CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region);
producer.setSupportedEventTypes(EventType.INVALIDATED);
producer.setPayloadExpression("key + ' was ' + oldValue");
producer.setPayloadExpression(PARSER.parseExpression("key + ' was ' + oldValue"));
producer.setOutputChannel(channel);
producer.setBeanFactory(mock(BeanFactory.class));
producer.afterPropertiesSet();
@@ -164,4 +164,5 @@ public class CacheListeningMessageProducerTests {
attributesFactoryBean.afterPropertiesSet();
regionFactoryBean.setAttributes(attributesFactoryBean.getObject());
}
}

View File

@@ -16,16 +16,17 @@ package org.springframework.integration.gemfire.inbound;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessagingException;
import org.junit.Before;
import org.junit.Test;
import com.gemstone.gemfire.cache.Operation;
import com.gemstone.gemfire.cache.query.CqEvent;
import com.gemstone.gemfire.cache.query.CqQuery;
@@ -38,6 +39,8 @@ import com.gemstone.gemfire.cache.query.internal.CqQueryImpl;
*/
public class ContinuousQueryMessageProducerTests {
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
ContinuousQueryListenerContainer queryListenerContainer;
ContinuousQueryMessageProducer cqMessageProducer;
@@ -87,10 +90,9 @@ public class ContinuousQueryMessageProducerTests {
}
@Test
@SuppressWarnings("deprecation")
public void testPayloadExpression() {
CqEvent cqEvent = event(Operation.CREATE, "hello");
cqMessageProducer.setPayloadExpression("newValue.toUpperCase() + ', WORLD'");
cqMessageProducer.setPayloadExpression(PARSER.parseExpression("newValue.toUpperCase() + ', WORLD'"));
cqMessageProducer.afterPropertiesSet();
cqMessageProducer.onEvent(cqEvent);
@@ -100,7 +102,7 @@ public class ContinuousQueryMessageProducerTests {
CqEvent event(final Operation operation, final Object value) {
CqEvent event = new CqEvent() {
return new CqEvent() {
final CqQuery cq = new CqQueryImpl();
@@ -139,8 +141,6 @@ public class ContinuousQueryMessageProducerTests {
}
};
return event;
}
private static class CqMessageHandler implements MessageHandler {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2015 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. You may obtain a copy of the License at
@@ -24,6 +24,7 @@ import org.springframework.messaging.MessagingException;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.messaging.support.ErrorMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -36,7 +37,9 @@ import com.gemstone.gemfire.internal.cache.DistributedRegion;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@DirtiesContext
public class GemfireInboundChannelAdapterTests {
@Autowired
SubscribableChannel channel1;
@@ -58,8 +61,6 @@ public class GemfireInboundChannelAdapterTests {
@Autowired
DistributedRegion region3;
@Test
public void testGemfireInboundChannelAdapterWithExpression() {
@@ -96,23 +97,27 @@ public class GemfireInboundChannelAdapterTests {
region3.put("payload", "payload");
assertEquals(1, errorHandler.count);
}
static class ErrorHandler implements MessageHandler {
public int count = 0;
public void handleMessage(Message<?> message) throws MessagingException {
assertTrue(message instanceof ErrorMessage);
count++;
}
}
static class EventHandler implements MessageHandler {
public Object event = null;
public void handleMessage(Message<?> message) throws MessagingException {
event = message.getPayload();
}
}
}