INT-937, INT-87 Message History (work in progress)

This commit is contained in:
Mark Fisher
2010-02-19 04:24:51 +00:00
parent a41c862558
commit 746b046b24
27 changed files with 183 additions and 144 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -80,7 +80,7 @@ public class AggregatorParserTests {
CorrelationStrategy correlationStrategy = (CorrelationStrategy) context.getBean("correlationStrategy");
MessageChannel outputChannel = (MessageChannel) context.getBean("outputChannel");
MessageChannel discardChannel = (MessageChannel) context.getBean("discardChannel");
Object consumer = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
Object consumer = TestUtils.getPropertyValue(endpoint, "handler");
Assert.assertEquals(MethodInvokingAggregator.class, consumer.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(consumer);
Method expectedMethod = TestAggregatorBean.class.getMethod("createSingleMessageFromGroup", List.class);
@@ -141,8 +141,8 @@ public class AggregatorParserTests {
MessageChannel input = (MessageChannel) context.getBean("aggregatorWithPojoCompletionStrategyInput");
EventDrivenConsumer endpoint =
(EventDrivenConsumer) context.getBean("aggregatorWithPojoCompletionStrategy");
CompletionStrategy completionStrategy = (CompletionStrategy) new DirectFieldAccessor(
new DirectFieldAccessor(endpoint).getPropertyValue("handler")).getPropertyValue("completionStrategy");
CompletionStrategy completionStrategy = TestUtils.getPropertyValue(endpoint,
"handler.completionStrategy", CompletionStrategy.class);
Assert.assertTrue(completionStrategy instanceof CompletionStrategyAdapter);
DirectFieldAccessor completionStrategyAccessor = new DirectFieldAccessor(completionStrategy);
MethodInvoker invoker = (MethodInvoker) completionStrategyAccessor.getPropertyValue("invoker");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -27,7 +27,6 @@ import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.aggregator.CorrelationStrategy;
@@ -38,6 +37,7 @@ import org.springframework.integration.core.Message;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.message.MessageBuilder;
import org.springframework.integration.test.util.TestUtils;
/**
* @author Marius Bogoevici
@@ -79,7 +79,7 @@ public class ResequencerParserTests {
@Test
public void testDefaultResequencerProperties() {
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("defaultResequencer");
Resequencer resequencer = (Resequencer) new DirectFieldAccessor(endpoint).getPropertyValue("handler");
Resequencer resequencer = TestUtils.getPropertyValue(endpoint, "handler", Resequencer.class);
assertNull(getPropertyValue(resequencer, "outputChannel"));
assertNull(getPropertyValue(resequencer, "discardChannel"));
assertEquals("The ResequencerEndpoint is not set with the appropriate timeout value",
@@ -101,7 +101,7 @@ public class ResequencerParserTests {
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("completelyDefinedResequencer");
MessageChannel outputChannel = (MessageChannel) context.getBean("outputChannel");
MessageChannel discardChannel = (MessageChannel) context.getBean("discardChannel");
Resequencer resequencer = (Resequencer) new DirectFieldAccessor(endpoint).getPropertyValue("handler");
Resequencer resequencer = TestUtils.getPropertyValue(endpoint, "handler", Resequencer.class);
assertEquals("The ResequencerEndpoint is not injected with the appropriate output channel",
outputChannel, getPropertyValue(resequencer, "outputChannel"));
assertEquals("The ResequencerEndpoint is not injected with the appropriate discard channel",
@@ -123,7 +123,7 @@ public class ResequencerParserTests {
@Test
public void testCorrelationStrategyRefOnly() throws Exception {
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("resequencerWithCorrelationStrategyRefOnly");
Resequencer resequencer = (Resequencer) new DirectFieldAccessor(endpoint).getPropertyValue("handler");
Resequencer resequencer = TestUtils.getPropertyValue(endpoint, "handler", Resequencer.class);
assertEquals("The ResequencerEndpoint is not configured with the appropriate CorrelationStrategy",
context.getBean("testCorrelationStrategy"), getPropertyValue(resequencer, "correlationStrategy"));
}
@@ -131,7 +131,7 @@ public class ResequencerParserTests {
@Test
public void testCorrelationStrategyRefAndMethod() throws Exception {
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("resequencerWithCorrelationStrategyRefAndMethod");
Resequencer resequencer = (Resequencer) new DirectFieldAccessor(endpoint).getPropertyValue("handler");
Resequencer resequencer = TestUtils.getPropertyValue(endpoint, "handler", Resequencer.class);
Object correlationStrategy = getPropertyValue(resequencer, "correlationStrategy");
assertEquals("The ResequencerEndpoint is not configured with a CorrelationStrategy adapter",
CorrelationStrategyAdapter.class, correlationStrategy.getClass());

View File

@@ -39,6 +39,7 @@ import org.springframework.integration.aggregator.SequenceSizeCompletionStrategy
import org.springframework.integration.channel.BeanFactoryChannelResolver;
import org.springframework.integration.channel.ChannelResolver;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.test.util.TestUtils;
/**
* @author Marius Bogoevici
@@ -127,7 +128,7 @@ public class AggregatorAnnotationTests {
private AbstractMessageAggregator getAggregator(ApplicationContext context, final String endpointName) {
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean(
endpointName + ".aggregatingMethod.aggregator");
return (AbstractMessageAggregator) new DirectFieldAccessor(endpoint).getPropertyValue("handler");
return TestUtils.getPropertyValue(endpoint, "handler", AbstractMessageAggregator.class);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -27,6 +27,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.core.Ordered;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.handler.DelayHandler;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -46,7 +47,7 @@ public class DelayerParserTests {
public void defaultScheduler() {
Object endpoint = context.getBean("delayerWithDefaultScheduler");
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
Object handler = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
Object handler = TestUtils.getPropertyValue(endpoint, "handler");
assertEquals(DelayHandler.class, handler.getClass());
DelayHandler delayHandler = (DelayHandler) handler;
assertEquals(99, delayHandler.getOrder());
@@ -65,7 +66,7 @@ public class DelayerParserTests {
public void customScheduler() {
Object endpoint = context.getBean("delayerWithCustomScheduler");
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
Object handler = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
Object handler = TestUtils.getPropertyValue(endpoint, "handler");
assertEquals(DelayHandler.class, handler.getClass());
DelayHandler delayHandler = (DelayHandler) handler;
assertEquals(Ordered.LOWEST_PRECEDENCE, delayHandler.getOrder());

View File

@@ -26,6 +26,7 @@ import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.handler.MethodInvokingMessageHandler;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -43,23 +44,21 @@ public class MethodInvokingOutboundChannelAdapterParserTests {
@Test
public void checkConfig() {
Object adapter = context.getBean("adapter");
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
Object handler = adapterAccessor.getPropertyValue("handler");
Object handler = TestUtils.getPropertyValue(adapter, "handler");
assertEquals(MethodInvokingMessageHandler.class, handler.getClass());
DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
assertEquals(99, handlerAccessor.getPropertyValue("order"));
assertEquals(Boolean.FALSE, adapterAccessor.getPropertyValue("autoStartup"));
assertEquals(Boolean.FALSE, TestUtils.getPropertyValue(adapter, "autoStartup"));
}
@Test
public void checkConfigWithInnerBeanAndPoller() {
Object adapter = context.getBean("adapterB");
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
Object handler = adapterAccessor.getPropertyValue("handler");
Object handler = TestUtils.getPropertyValue(adapter, "handler");
assertEquals(MethodInvokingMessageHandler.class, handler.getClass());
DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
assertEquals(99, handlerAccessor.getPropertyValue("order"));
assertEquals(Boolean.FALSE, adapterAccessor.getPropertyValue("autoStartup"));
assertEquals(Boolean.FALSE, TestUtils.getPropertyValue(adapter, "autoStartup"));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -20,10 +20,11 @@ import junit.framework.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -86,12 +87,8 @@ public class PNamespaceTest {
private TestBean prepare(EventDrivenConsumer edc) {
DirectFieldAccessor serviceActivatorAccessor = new DirectFieldAccessor(serviceActivator);
Object handler = serviceActivatorAccessor.getPropertyValue("handler");
DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
Object processor = handlerAccessor.getPropertyValue("processor");
DirectFieldAccessor processorAccessor = new DirectFieldAccessor(processor);
return (TestBean) processorAccessor.getPropertyValue("targetObject");
return TestUtils.getPropertyValue(serviceActivator,
"handler.processor.targetObject", TestBean.class);
}

View File

@@ -268,6 +268,7 @@ public class GatewayProxyFactoryBeanTests {
channel.setBeanName("testChannel");
EventDrivenConsumer consumer = new EventDrivenConsumer(channel, new BridgeHandler());
consumer.setBeanName("testBridge");
consumer.afterPropertiesSet();
consumer.start();
proxyFactory.setDefaultRequestChannel(channel);
proxyFactory.setServiceInterface(TestEchoService.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -21,9 +21,9 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -65,10 +65,8 @@ public class SendTimeoutConfigurationTests {
private long getTimeout(String endpointName) {
DirectFieldAccessor endpointAccessor = new DirectFieldAccessor(context.getBean(endpointName));
DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(endpointAccessor.getPropertyValue("handler"));
DirectFieldAccessor templateAccessor = new DirectFieldAccessor(handlerAccessor.getPropertyValue("channelTemplate"));
return ((Long) templateAccessor.getPropertyValue("sendTimeout")).longValue();
return TestUtils.getPropertyValue(context.getBean(endpointName),
"handler.channelTemplate.sendTimeout", Long.class).longValue();
}
}

View File

@@ -31,6 +31,7 @@ import org.springframework.integration.core.Message;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.router.RecipientListRouter;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -64,7 +65,7 @@ public class RecipientListRouterParserTests {
@Test
public void simpleRouter() {
Object endpoint = context.getBean("simpleRouter");
Object handler = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
Object handler = TestUtils.getPropertyValue(endpoint, "handler");
assertEquals(RecipientListRouter.class, handler.getClass());
RecipientListRouter router = (RecipientListRouter) handler;
DirectFieldAccessor accessor = new DirectFieldAccessor(router);
@@ -77,7 +78,7 @@ public class RecipientListRouterParserTests {
@Test
public void customRouter() {
Object endpoint = context.getBean("customRouter");
Object handler = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
Object handler = TestUtils.getPropertyValue(endpoint, "handler");
assertEquals(RecipientListRouter.class, handler.getClass());
RecipientListRouter router = (RecipientListRouter) handler;
DirectFieldAccessor accessor = new DirectFieldAccessor(router);

View File

@@ -39,6 +39,7 @@ import org.springframework.integration.message.MessageDeliveryException;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.router.AbstractMessageRouter;
import org.springframework.integration.router.MethodInvokingRouter;
import org.springframework.integration.test.util.TestUtils;
/**
* @author Mark Fisher
@@ -128,8 +129,8 @@ public class RouterParserTests {
public void timeoutValueConfigured() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"routerParserTests.xml", this.getClass());
DirectFieldAccessor endpointAccessor = new DirectFieldAccessor(context.getBean("routerWithTimeout"));
MethodInvokingRouter router = (MethodInvokingRouter) endpointAccessor.getPropertyValue("handler");
Object endpoint = context.getBean("routerWithTimeout");
MethodInvokingRouter router = TestUtils.getPropertyValue(endpoint, "handler", MethodInvokingRouter.class);
MessageChannelTemplate template = (MessageChannelTemplate)
new DirectFieldAccessor(router).getPropertyValue("channelTemplate");
Long timeout = (Long) new DirectFieldAccessor(template).getPropertyValue("sendTimeout");
@@ -141,8 +142,8 @@ public class RouterParserTests {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"routerParserTests.xml", this.getClass());
Object channelResolverBean = context.getBean("testChannelResolver");
DirectFieldAccessor endpointAccessor = new DirectFieldAccessor(context.getBean("routerWithChannelResolver"));
MethodInvokingRouter router = (MethodInvokingRouter) endpointAccessor.getPropertyValue("handler");
Object endpoint = context.getBean("routerWithChannelResolver");
MethodInvokingRouter router = TestUtils.getPropertyValue(endpoint, "handler", MethodInvokingRouter.class);
ChannelResolver channelResolver = (ChannelResolver)
new DirectFieldAccessor(router).getPropertyValue("channelResolver");
assertSame(channelResolverBean, channelResolver);