From 559ebf1bd286e6d6fe4b11b3a38f4e732364a1a3 Mon Sep 17 00:00:00 2001 From: Iwein Fuld Date: Fri, 9 Apr 2010 12:33:31 +0000 Subject: [PATCH] INT-1017: added TODO for removal of test case --- .../AggregatorMethodResolutionTests.java | 268 +++++++++--------- 1 file changed, 135 insertions(+), 133 deletions(-) diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/aggregator/AggregatorMethodResolutionTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/aggregator/AggregatorMethodResolutionTests.java index 83c0a0c5e7..0ea0cdf490 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/aggregator/AggregatorMethodResolutionTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/aggregator/AggregatorMethodResolutionTests.java @@ -16,16 +16,9 @@ package org.springframework.integration.aggregator; -import static org.junit.Assert.assertEquals; - -import java.lang.reflect.Method; -import java.util.List; - import org.junit.Test; - import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.DirectFieldAccessor; -import org.springframework.integration.aggregator.MethodInvokingAggregator; import org.springframework.integration.annotation.Aggregator; import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.channel.QueueChannel; @@ -33,173 +26,182 @@ import org.springframework.integration.core.Message; import org.springframework.integration.endpoint.EventDrivenConsumer; import org.springframework.integration.message.MessageBuilder; +import java.lang.reflect.Method; +import java.util.List; + +import static org.junit.Assert.assertEquals; + /** * @author Mark Fisher */ +/* + * TODO This class needs to be removed with INT-1017. We need to ensure that the tests herein are superseded by + * MethodInvokingMessageGroupProcessorTests before deleting it entirely. + */ public class AggregatorMethodResolutionTests { - @Test - public void singleAnnotation() throws Exception { - SingleAnnotationTestBean bean = new SingleAnnotationTestBean(); - MethodInvokingAggregator aggregator = new MethodInvokingAggregator(bean); - Method method = this.getMethod(aggregator); - Method expected = SingleAnnotationTestBean.class.getMethod("method1", new Class[] { List.class }); - assertEquals(expected, method); - } + @Test + public void singleAnnotation() throws Exception { + SingleAnnotationTestBean bean = new SingleAnnotationTestBean(); + MethodInvokingAggregator aggregator = new MethodInvokingAggregator(bean); + Method method = this.getMethod(aggregator); + Method expected = SingleAnnotationTestBean.class.getMethod("method1", new Class[]{List.class}); + assertEquals(expected, method); + } - @Test(expected = IllegalArgumentException.class) - public void multipleAnnotations() { - MultipleAnnotationTestBean bean = new MultipleAnnotationTestBean(); - new MethodInvokingAggregator(bean); - } + @Test(expected = IllegalArgumentException.class) + public void multipleAnnotations() { + MultipleAnnotationTestBean bean = new MultipleAnnotationTestBean(); + new MethodInvokingAggregator(bean); + } - @Test - public void noAnnotations() throws Exception { - NoAnnotationTestBean bean = new NoAnnotationTestBean(); - MethodInvokingAggregator aggregator = new MethodInvokingAggregator(bean); - Method method = this.getMethod(aggregator); - Method expected = NoAnnotationTestBean.class.getMethod("method1", new Class[] { List.class }); - assertEquals(expected, method); - } + @Test + public void noAnnotations() throws Exception { + NoAnnotationTestBean bean = new NoAnnotationTestBean(); + MethodInvokingAggregator aggregator = new MethodInvokingAggregator(bean); + Method method = this.getMethod(aggregator); + Method expected = NoAnnotationTestBean.class.getMethod("method1", new Class[]{List.class}); + assertEquals(expected, method); + } - @Test(expected = IllegalArgumentException.class) - public void multiplePublicMethods() { - MultiplePublicMethodTestBean bean = new MultiplePublicMethodTestBean(); - new MethodInvokingAggregator(bean); - } + @Test(expected = IllegalArgumentException.class) + public void multiplePublicMethods() { + MultiplePublicMethodTestBean bean = new MultiplePublicMethodTestBean(); + new MethodInvokingAggregator(bean); + } - @Test(expected = IllegalArgumentException.class) - public void noPublicMethods() { - NoPublicMethodTestBean bean = new NoPublicMethodTestBean(); - new MethodInvokingAggregator(bean); - } + @Test(expected = IllegalArgumentException.class) + public void noPublicMethods() { + NoPublicMethodTestBean bean = new NoPublicMethodTestBean(); + new MethodInvokingAggregator(bean); + } - @Test - public void jdkProxy() { - DirectChannel input = new DirectChannel(); - QueueChannel output = new QueueChannel(); - GreetingService testBean = new GreetingBean(); - ProxyFactory proxyFactory = new ProxyFactory(testBean); - proxyFactory.setProxyTargetClass(false); - testBean = (GreetingService) proxyFactory.getProxy(); - MethodInvokingAggregator aggregator = new MethodInvokingAggregator(testBean); - aggregator.setAutoStartup(false); - aggregator.setOutputChannel(output); - EventDrivenConsumer endpoint = new EventDrivenConsumer(input, aggregator); - endpoint.start(); - Message message = MessageBuilder.withPayload("proxy") - .setCorrelationId("abc") - .build(); - input.send(message); - assertEquals("hello proxy", output.receive(0).getPayload());; - } + @Test + public void jdkProxy() { + DirectChannel input = new DirectChannel(); + QueueChannel output = new QueueChannel(); + GreetingService testBean = new GreetingBean(); + ProxyFactory proxyFactory = new ProxyFactory(testBean); + proxyFactory.setProxyTargetClass(false); + testBean = (GreetingService) proxyFactory.getProxy(); + MethodInvokingAggregator aggregator = new MethodInvokingAggregator(testBean); + aggregator.setAutoStartup(false); + aggregator.setOutputChannel(output); + EventDrivenConsumer endpoint = new EventDrivenConsumer(input, aggregator); + endpoint.start(); + Message message = MessageBuilder.withPayload("proxy") + .setCorrelationId("abc") + .build(); + input.send(message); + assertEquals("hello proxy", output.receive(0).getPayload()); + } - @Test - public void cglibProxy() { - DirectChannel input = new DirectChannel(); - QueueChannel output = new QueueChannel(); - GreetingService testBean = new GreetingBean(); - ProxyFactory proxyFactory = new ProxyFactory(testBean); - proxyFactory.setProxyTargetClass(true); - testBean = (GreetingService) proxyFactory.getProxy(); - MethodInvokingAggregator aggregator = new MethodInvokingAggregator(testBean); - aggregator.setAutoStartup(false); - aggregator.setOutputChannel(output); - EventDrivenConsumer endpoint = new EventDrivenConsumer(input, aggregator); - endpoint.start(); - Message message = MessageBuilder.withPayload("proxy") - .setCorrelationId("abc") - .build(); - input.send(message); - assertEquals("hello proxy", output.receive(0).getPayload());; - } + @Test + public void cglibProxy() { + DirectChannel input = new DirectChannel(); + QueueChannel output = new QueueChannel(); + GreetingService testBean = new GreetingBean(); + ProxyFactory proxyFactory = new ProxyFactory(testBean); + proxyFactory.setProxyTargetClass(true); + testBean = (GreetingService) proxyFactory.getProxy(); + MethodInvokingAggregator aggregator = new MethodInvokingAggregator(testBean); + aggregator.setAutoStartup(false); + aggregator.setOutputChannel(output); + EventDrivenConsumer endpoint = new EventDrivenConsumer(input, aggregator); + endpoint.start(); + Message message = MessageBuilder.withPayload("proxy") + .setCorrelationId("abc") + .build(); + input.send(message); + assertEquals("hello proxy", output.receive(0).getPayload()); + } - private Method getMethod(MethodInvokingAggregator aggregator) { - Object invoker = new DirectFieldAccessor(aggregator).getPropertyValue("methodInvoker"); - return (Method) new DirectFieldAccessor(invoker).getPropertyValue("method"); - } + private Method getMethod(MethodInvokingAggregator aggregator) { + Object invoker = new DirectFieldAccessor(aggregator).getPropertyValue("methodInvoker"); + return (Method) new DirectFieldAccessor(invoker).getPropertyValue("method"); + } - private static class SingleAnnotationTestBean { + private static class SingleAnnotationTestBean { - @Aggregator - public String method1(List input) { - return input.get(0); - } + @Aggregator + public String method1(List input) { + return input.get(0); + } - public String method2(List input) { - return input.get(0); - } - } + public String method2(List input) { + return input.get(0); + } + } - private static class MultipleAnnotationTestBean { + private static class MultipleAnnotationTestBean { - @Aggregator - public String method1(List input) { - return input.get(0); - } + @Aggregator + public String method1(List input) { + return input.get(0); + } - @Aggregator - public String method2(List input) { - return input.get(0); - } - } + @Aggregator + public String method2(List input) { + return input.get(0); + } + } - private static class NoAnnotationTestBean { + private static class NoAnnotationTestBean { - public String method1(List input) { - return input.get(0); - } + public String method1(List input) { + return input.get(0); + } - String method2(List input) { - return input.get(0); - } - } + String method2(List input) { + return input.get(0); + } + } - private static class MultiplePublicMethodTestBean { + private static class MultiplePublicMethodTestBean { - public String upperCase(String s) { - return s.toUpperCase(); - } + public String upperCase(String s) { + return s.toUpperCase(); + } - public String lowerCase(String s) { - return s.toLowerCase(); - } - } + public String lowerCase(String s) { + return s.toLowerCase(); + } + } - private static class NoPublicMethodTestBean { + private static class NoPublicMethodTestBean { - String lowerCase(String s) { - return s.toLowerCase(); - } - } + String lowerCase(String s) { + return s.toLowerCase(); + } + } - public interface GreetingService { + public interface GreetingService { - String sayHello(List names); + String sayHello(List names); - } + } - public static class GreetingBean implements GreetingService { + public static class GreetingBean implements GreetingService { - private String greeting = "hello"; + private String greeting = "hello"; - public void setGreeting(String greeting) { - this.greeting = greeting; - } + public void setGreeting(String greeting) { + this.greeting = greeting; + } - @Aggregator - public String sayHello(List names) { - return greeting + " " + names.get(0); - } + @Aggregator + public String sayHello(List names) { + return greeting + " " + names.get(0); + } - } + } }