diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/annotation/Poller.java b/org.springframework.integration/src/main/java/org/springframework/integration/annotation/Poller.java index 258e164576..afcb7d559b 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/annotation/Poller.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/annotation/Poller.java @@ -22,9 +22,6 @@ import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import java.util.concurrent.TimeUnit; - -import org.springframework.transaction.annotation.Transactional; /** * Annotation that can be specified at method-level alongside a Message Endpoint @@ -39,22 +36,4 @@ import org.springframework.transaction.annotation.Transactional; @Documented public @interface Poller { - int interval(); - - long initialDelay() default 0; - - boolean fixedRate() default false; - - TimeUnit timeUnit() default TimeUnit.MILLISECONDS; - - int maxMessagesPerPoll() default -1; - - String taskExecutor() default ""; - - Transactional transactionAttributes() default @Transactional; - - String transactionManager() default ""; - - String[] adviceChain() default {}; - } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java index f9ac1fb18b..be01b4f929 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java @@ -23,14 +23,11 @@ import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.generic.GenericBeanFactoryAccessor; import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.integration.annotation.Poller; import org.springframework.integration.channel.BeanFactoryChannelResolver; import org.springframework.integration.channel.ChannelResolver; -import org.springframework.integration.channel.PollableChannel; import org.springframework.integration.channel.SubscribableChannel; import org.springframework.integration.core.MessageChannel; import org.springframework.integration.endpoint.AbstractEndpoint; -import org.springframework.integration.endpoint.PollingConsumer; import org.springframework.integration.endpoint.EventDrivenConsumer; import org.springframework.integration.message.MessageHandler; import org.springframework.util.Assert; @@ -60,8 +57,7 @@ public abstract class AbstractMethodAnnotationPostProcessor 0) { - List adviceChain = new ArrayList(); - for (String adviceChainString : adviceChainArray) { - String[] adviceRefs = StringUtils.tokenizeToStringArray(adviceChainString, ","); - for (String adviceRef : adviceRefs) { - adviceChain.add((Advice) beanFactory.getBean(adviceRef, Advice.class)); - } - } - endpoint.setAdviceChain(adviceChain); - } - } - - public static Trigger parseTriggerFromPollerAnnotation(Poller pollerAnnotation) { - IntervalTrigger trigger = new IntervalTrigger( - pollerAnnotation.interval(), pollerAnnotation.timeUnit()); - trigger.setInitialDelay(pollerAnnotation.initialDelay()); - trigger.setFixedRate(pollerAnnotation.fixedRate()); - return trigger; - } - -} diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/ChannelAdapterAnnotationPostProcessor.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/ChannelAdapterAnnotationPostProcessor.java index b25a142ed3..b6778bcc5f 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/ChannelAdapterAnnotationPostProcessor.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/ChannelAdapterAnnotationPostProcessor.java @@ -29,17 +29,13 @@ import org.springframework.integration.channel.BeanFactoryChannelResolver; import org.springframework.integration.channel.ChannelResolutionException; import org.springframework.integration.channel.ChannelResolver; import org.springframework.integration.channel.DirectChannel; -import org.springframework.integration.channel.PollableChannel; import org.springframework.integration.channel.SubscribableChannel; import org.springframework.integration.core.MessageChannel; import org.springframework.integration.endpoint.AbstractEndpoint; import org.springframework.integration.endpoint.EventDrivenConsumer; -import org.springframework.integration.endpoint.PollingConsumer; import org.springframework.integration.endpoint.SourcePollingChannelAdapter; import org.springframework.integration.handler.MethodInvokingMessageHandler; import org.springframework.integration.message.MethodInvokingMessageSource; -import org.springframework.integration.scheduling.IntervalTrigger; -import org.springframework.integration.scheduling.Trigger; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -120,24 +116,13 @@ public class ChannelAdapterAnnotationPostProcessor implements MethodAnnotationPo SourcePollingChannelAdapter adapter = new SourcePollingChannelAdapter(); adapter.setSource(source); adapter.setOutputChannel(channel); - AnnotationConfigUtils.configurePollingEndpointWithPollerAnnotation( - adapter, pollerAnnotation, this.beanFactory); return adapter; } private AbstractEndpoint createOutboundChannelAdapter(MessageChannel channel, MethodInvokingMessageHandler handler, Poller pollerAnnotation) { - if (channel instanceof PollableChannel) { - Trigger trigger = (pollerAnnotation != null) - ? AnnotationConfigUtils.parseTriggerFromPollerAnnotation(pollerAnnotation) - : new IntervalTrigger(0); - PollingConsumer endpoint = new PollingConsumer((PollableChannel) channel, handler); - endpoint.setTrigger(trigger); - return endpoint; - } - if (channel instanceof SubscribableChannel) { - return new EventDrivenConsumer((SubscribableChannel) channel, handler); - } - return null; + Assert.isInstanceOf(SubscribableChannel.class, channel, + "The input channel for an Annotation-based endpoint must be a SubscribableChannel."); + return new EventDrivenConsumer((SubscribableChannel) channel, handler); } private boolean hasReturnValue(Method method) { diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterAdviceChainTestBean.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterAdviceChainTestBean.java deleted file mode 100644 index f86e67bb3e..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterAdviceChainTestBean.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2002-2008 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.config; - -import java.util.concurrent.TimeUnit; - -import org.springframework.integration.annotation.ChannelAdapter; -import org.springframework.integration.annotation.MessageEndpoint; -import org.springframework.integration.annotation.Poller; - -/** - * @author Mark Fisher - */ -@MessageEndpoint -public class PollerAnnotationChannelAdapterAdviceChainTestBean { - - @ChannelAdapter("output") - @Poller(interval=5, timeUnit=TimeUnit.SECONDS, maxMessagesPerPoll=1, - adviceChain="aroundAdvice,beforeAdvice,afterAdvice") - public String testMethod() { - return "test"; - } - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterAdviceChainTests-context.xml b/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterAdviceChainTests-context.xml deleted file mode 100644 index 204fe00fea..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterAdviceChainTests-context.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterAdviceChainTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterAdviceChainTests.java deleted file mode 100644 index 754157c9a8..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterAdviceChainTests.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2002-2008 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.config; - -import static org.junit.Assert.assertEquals; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.integration.channel.PollableChannel; -import org.springframework.integration.core.Message; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Mark Fisher - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -public class PollerAnnotationChannelAdapterAdviceChainTests { - - @Autowired @Qualifier("output") - private PollableChannel output; - - @Autowired - private CountDownLatch latch; - - @Autowired - private TestBeforeAdvice beforeAdvice; - - @Autowired - private TestAfterAdvice afterAdvice; - - @Autowired - private TestAroundAdvice aroundAdvice; - - - @Test - public void testAdviceChain() throws InterruptedException { - Message reply = output.receive(1000); - assertEquals("test", reply.getPayload()); - latch.await(1, TimeUnit.SECONDS); - assertEquals(0, latch.getCount()); - assertEquals(4, aroundAdvice.getPreCount()); - assertEquals(3, beforeAdvice.getLatchCount()); - assertEquals(2, afterAdvice.getLatchCount()); - assertEquals(1, aroundAdvice.getPostCount()); - } - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterTransactionalTestBean.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterTransactionalTestBean.java deleted file mode 100644 index 05eff4dd19..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterTransactionalTestBean.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2002-2008 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.config; - -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.BlockingQueue; - -import org.springframework.integration.annotation.ChannelAdapter; -import org.springframework.integration.annotation.MessageEndpoint; -import org.springframework.integration.annotation.Poller; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author Mark Fisher - */ -@MessageEndpoint -public class PollerAnnotationChannelAdapterTransactionalTestBean { - - private volatile boolean shouldFail; - - private BlockingQueue queue = new ArrayBlockingQueue(1); - - - public void setShouldFail(boolean shouldFail) { - this.shouldFail = shouldFail; - } - - public void setNextValue(String nextValue) { - try { - this.queue.put(nextValue); - } - catch (InterruptedException e) { - } - } - - @ChannelAdapter("output") - @Poller(interval=100, maxMessagesPerPoll=1, - transactionManager="testTransactionManager", - transactionAttributes=@Transactional(propagation=Propagation.REQUIRES_NEW)) - public String testMethod() { - String result = null; - try { - result = this.queue.take(); - } - catch (InterruptedException e) { - } - if (this.shouldFail) { - throw new IllegalArgumentException("intentional test failure"); - } - return result; - } - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterTransactionalTests-context.xml b/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterTransactionalTests-context.xml deleted file mode 100644 index f05847169e..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterTransactionalTests-context.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterTransactionalTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterTransactionalTests.java deleted file mode 100644 index b179f61785..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationChannelAdapterTransactionalTests.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2002-2008 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.config; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.integration.channel.PollableChannel; -import org.springframework.integration.core.Message; -import org.springframework.integration.util.TestTransactionManager; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.transaction.TransactionDefinition; - -/** - * @author Mark Fisher - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -public class PollerAnnotationChannelAdapterTransactionalTests { - - @Autowired @Qualifier("output") - private PollableChannel output; - - @Autowired - private PollerAnnotationChannelAdapterTransactionalTestBean adapter; - - @Autowired - private TestTransactionManager transactionManager; - - - @Before - public void resetTransactionManager() { - transactionManager.reset(); - } - - - @Test - public void commit() throws InterruptedException { - adapter.setShouldFail(false); - adapter.setNextValue("commit-test"); - transactionManager.waitForCompletion(1000); - Message reply = output.receive(1000); - assertEquals("commit-test", reply.getPayload()); - assertEquals(1, transactionManager.getCommitCount()); - assertEquals(0, transactionManager.getRollbackCount()); - } - - @Test - public void rollback() throws InterruptedException { - adapter.setShouldFail(true); - adapter.setNextValue("rollback-test"); - transactionManager.waitForCompletion(1000); - assertNull(output.receive(0)); - assertEquals(0, transactionManager.getCommitCount()); - assertEquals(1, transactionManager.getRollbackCount()); - } - - @Test - public void verifyPropagationSetting() throws InterruptedException { - adapter.setShouldFail(false); - adapter.setNextValue("propagation-test"); - transactionManager.waitForCompletion(1000); - Message reply = output.receive(1000); - assertEquals("propagation-test", reply.getPayload()); - assertEquals(TransactionDefinition.PROPAGATION_REQUIRES_NEW, - transactionManager.getLastDefinition().getPropagationBehavior()); - } - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerAdviceChainTestBean.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerAdviceChainTestBean.java deleted file mode 100644 index 70ce3c9c8b..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerAdviceChainTestBean.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2002-2008 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.config; - -import java.util.concurrent.TimeUnit; - -import org.springframework.integration.annotation.MessageEndpoint; -import org.springframework.integration.annotation.Poller; -import org.springframework.integration.annotation.ServiceActivator; - -/** - * @author Mark Fisher - */ -@MessageEndpoint -public class PollerAnnotationConsumerAdviceChainTestBean { - - @ServiceActivator(inputChannel="input", outputChannel="output") - @Poller(interval=5, timeUnit=TimeUnit.SECONDS, maxMessagesPerPoll=1, - adviceChain="beforeAdvice ,aroundAdvice, afterAdvice ") // spacing intentional - public String testMethod(String input) { - return input.toUpperCase(); - } - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerAdviceChainTests-context.xml b/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerAdviceChainTests-context.xml deleted file mode 100644 index 74e0194a95..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerAdviceChainTests-context.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerAdviceChainTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerAdviceChainTests.java deleted file mode 100644 index e017a048e8..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerAdviceChainTests.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2002-2008 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.config; - -import static org.junit.Assert.assertEquals; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.integration.channel.PollableChannel; -import org.springframework.integration.core.Message; -import org.springframework.integration.core.MessageChannel; -import org.springframework.integration.message.StringMessage; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Mark Fisher - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -public class PollerAnnotationConsumerAdviceChainTests { - - @Autowired @Qualifier("input") - private MessageChannel input; - - @Autowired @Qualifier("output") - private PollableChannel output; - - @Autowired - private CountDownLatch latch; - - @Autowired - private TestBeforeAdvice beforeAdvice; - - @Autowired - private TestAfterAdvice afterAdvice; - - @Autowired - private TestAroundAdvice aroundAdvice; - - - @Test - public void testAdviceChain() throws InterruptedException { - input.send(new StringMessage("test")); - Message reply = output.receive(3000); - assertEquals("TEST", reply.getPayload()); - latch.await(1, TimeUnit.SECONDS); - assertEquals(0, latch.getCount()); - assertEquals(4, beforeAdvice.getLatchCount()); - assertEquals(3, aroundAdvice.getPreCount()); - assertEquals(2, afterAdvice.getLatchCount()); - assertEquals(1, aroundAdvice.getPostCount()); - } - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerTransactionalTestBean.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerTransactionalTestBean.java deleted file mode 100644 index 6169771efd..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerTransactionalTestBean.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2002-2008 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.config; - -import org.springframework.integration.annotation.MessageEndpoint; -import org.springframework.integration.annotation.Poller; -import org.springframework.integration.annotation.ServiceActivator; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author Mark Fisher - */ -@MessageEndpoint -public class PollerAnnotationConsumerTransactionalTestBean { - - @ServiceActivator(inputChannel="input", outputChannel="output") - @Poller(interval=100, maxMessagesPerPoll=1, - transactionManager="testTransactionManager", - transactionAttributes=@Transactional(propagation=Propagation.REQUIRES_NEW)) - public String testMethod(String input) { - if ("bad".equals(input)) { - throw new IllegalArgumentException("bad input"); - } - return input.toUpperCase(); - } - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerTransactionalTests-context.xml b/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerTransactionalTests-context.xml deleted file mode 100644 index cf49160f98..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerTransactionalTests-context.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerTransactionalTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerTransactionalTests.java deleted file mode 100644 index 0d3be2c1b3..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/PollerAnnotationConsumerTransactionalTests.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2002-2008 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.config; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.integration.channel.PollableChannel; -import org.springframework.integration.core.Message; -import org.springframework.integration.core.MessageChannel; -import org.springframework.integration.message.StringMessage; -import org.springframework.integration.util.TestTransactionManager; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.transaction.TransactionDefinition; - -/** - * @author Mark Fisher - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -public class PollerAnnotationConsumerTransactionalTests { - - @Autowired @Qualifier("input") - private MessageChannel input; - - @Autowired @Qualifier("output") - private PollableChannel output; - - @Autowired - private TestTransactionManager transactionManager; - - - @Before - public void resetTransactionManager() { - transactionManager.reset(); - } - - - @Test - public void commit() throws InterruptedException { - input.send(new StringMessage("test")); - transactionManager.waitForCompletion(3000); - Message reply = output.receive(1000); - assertEquals("TEST", reply.getPayload()); - assertEquals(1, transactionManager.getCommitCount()); - assertEquals(0, transactionManager.getRollbackCount()); - } - - @Test - public void rollback() throws InterruptedException { - input.send(new StringMessage("bad")); - transactionManager.waitForCompletion(3000); - assertNull(output.receive(0)); - assertEquals(0, transactionManager.getCommitCount()); - assertEquals(1, transactionManager.getRollbackCount()); - } - - @Test - public void verifyPropagationSetting() throws InterruptedException { - input.send(new StringMessage("test")); - transactionManager.waitForCompletion(3000); - assertEquals(TransactionDefinition.PROPAGATION_REQUIRES_NEW, - transactionManager.getLastDefinition().getPropagationBehavior()); - } - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/ServiceActivatorAnnotationPostProcessorTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/ServiceActivatorAnnotationPostProcessorTests.java index 21b3be34fe..28f5ae2d20 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/ServiceActivatorAnnotationPostProcessorTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/config/ServiceActivatorAnnotationPostProcessorTests.java @@ -27,7 +27,7 @@ import org.junit.Test; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.integration.annotation.MessageEndpoint; import org.springframework.integration.annotation.ServiceActivator; -import org.springframework.integration.channel.QueueChannel; +import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor; import org.springframework.integration.core.MessageChannel; import org.springframework.integration.message.StringMessage; @@ -45,7 +45,7 @@ public class ServiceActivatorAnnotationPostProcessorTests { TestApplicationContext context = TestUtils.createTestApplicationContext(); RootBeanDefinition postProcessorDef = new RootBeanDefinition(MessagingAnnotationPostProcessor.class); context.registerBeanDefinition("postProcessor", postProcessorDef); - context.registerBeanDefinition("testChannel", new RootBeanDefinition(QueueChannel.class)); + context.registerBeanDefinition("testChannel", new RootBeanDefinition(DirectChannel.class)); RootBeanDefinition beanDefinition = new RootBeanDefinition(SimpleServiceActivatorAnnotationTestBean.class); beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(latch); context.registerBeanDefinition("testBean", beanDefinition); diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessorTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessorTests.java index 7470257b10..fe5e46b7d2 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessorTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessorTests.java @@ -22,17 +22,14 @@ import static org.junit.Assert.assertTrue; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; import org.junit.Test; import org.springframework.aop.framework.ProxyFactory; -import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.annotation.ChannelAdapter; import org.springframework.integration.annotation.MessageEndpoint; -import org.springframework.integration.annotation.Poller; import org.springframework.integration.annotation.ServiceActivator; import org.springframework.integration.annotation.Transformer; import org.springframework.integration.channel.BeanFactoryChannelResolver; @@ -43,12 +40,8 @@ import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.core.Message; import org.springframework.integration.core.MessageChannel; import org.springframework.integration.endpoint.AbstractEndpoint; -import org.springframework.integration.endpoint.PollingConsumer; import org.springframework.integration.message.MessageBuilder; -import org.springframework.integration.message.MessageHandler; import org.springframework.integration.message.StringMessage; -import org.springframework.integration.scheduling.IntervalTrigger; -import org.springframework.integration.scheduling.Trigger; import org.springframework.integration.util.TestUtils; import org.springframework.integration.util.TestUtils.TestApplicationContext; @@ -60,7 +53,7 @@ public class MessagingAnnotationPostProcessorTests { @Test public void serviceActivatorAnnotation() { TestApplicationContext context = TestUtils.createTestApplicationContext(); - QueueChannel inputChannel = new QueueChannel(); + DirectChannel inputChannel = new DirectChannel(); context.registerChannel("inputChannel", inputChannel); MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor(); postProcessor.setBeanFactory(context.getBeanFactory()); @@ -172,7 +165,7 @@ public class MessagingAnnotationPostProcessorTests { @Test public void testProxiedMessageEndpointAnnotation() { TestApplicationContext context = TestUtils.createTestApplicationContext(); - QueueChannel inputChannel = new QueueChannel(); + DirectChannel inputChannel = new DirectChannel(); QueueChannel outputChannel = new QueueChannel(); context.registerChannel("inputChannel", inputChannel); context.registerChannel("outputChannel", outputChannel); @@ -192,7 +185,7 @@ public class MessagingAnnotationPostProcessorTests { @Test public void testMessageEndpointAnnotationInherited() { TestApplicationContext context = TestUtils.createTestApplicationContext(); - QueueChannel inputChannel = new QueueChannel(); + DirectChannel inputChannel = new DirectChannel(); QueueChannel outputChannel = new QueueChannel(); context.registerChannel("inputChannel", inputChannel); context.registerChannel("outputChannel", outputChannel); @@ -210,7 +203,7 @@ public class MessagingAnnotationPostProcessorTests { @Test public void testMessageEndpointAnnotationInheritedWithProxy() { TestApplicationContext context = TestUtils.createTestApplicationContext(); - QueueChannel inputChannel = new QueueChannel(); + DirectChannel inputChannel = new DirectChannel(); QueueChannel outputChannel = new QueueChannel(); context.registerChannel("inputChannel", inputChannel); context.registerChannel("outputChannel", outputChannel); @@ -230,7 +223,7 @@ public class MessagingAnnotationPostProcessorTests { @Test public void testMessageEndpointAnnotationInheritedFromInterface() { TestApplicationContext context = TestUtils.createTestApplicationContext(); - QueueChannel inputChannel = new QueueChannel(); + DirectChannel inputChannel = new DirectChannel(); QueueChannel outputChannel = new QueueChannel(); context.registerChannel("inputChannel", inputChannel); context.registerChannel("outputChannel", outputChannel); @@ -248,7 +241,7 @@ public class MessagingAnnotationPostProcessorTests { @Test public void testMessageEndpointAnnotationInheritedFromInterfaceWithAutoCreatedChannels() { TestApplicationContext context = TestUtils.createTestApplicationContext(); - QueueChannel inputChannel = new QueueChannel(); + DirectChannel inputChannel = new DirectChannel(); QueueChannel outputChannel = new QueueChannel(); context.registerChannel("inputChannel", inputChannel); context.registerChannel("outputChannel", outputChannel); @@ -266,7 +259,7 @@ public class MessagingAnnotationPostProcessorTests { @Test public void testMessageEndpointAnnotationInheritedFromInterfaceWithProxy() { TestApplicationContext context = TestUtils.createTestApplicationContext(); - QueueChannel inputChannel = new QueueChannel(); + DirectChannel inputChannel = new DirectChannel(); QueueChannel outputChannel = new QueueChannel(); context.registerChannel("inputChannel", inputChannel); context.registerChannel("outputChannel", outputChannel); @@ -283,51 +276,6 @@ public class MessagingAnnotationPostProcessorTests { context.stop(); } - @Test - public void testEndpointWithPollerAnnotation() { - TestApplicationContext context = TestUtils.createTestApplicationContext(); - QueueChannel testChannel = new QueueChannel(); - context.registerChannel("testChannel", testChannel); - MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor(); - postProcessor.setBeanFactory(context.getBeanFactory()); - postProcessor.afterPropertiesSet(); - AnnotatedEndpointWithPolledAnnotation bean = new AnnotatedEndpointWithPolledAnnotation(); - postProcessor.postProcessAfterInitialization(bean, "testBean"); - PollingConsumer endpoint = (PollingConsumer) context.getBean("testBean.prependFoo.serviceActivator"); - Trigger trigger = (Trigger) new DirectFieldAccessor(endpoint).getPropertyValue("trigger"); - assertEquals(IntervalTrigger.class, trigger.getClass()); - DirectFieldAccessor triggerAccessor = new DirectFieldAccessor(trigger); - assertEquals(new Long(123000), triggerAccessor.getPropertyValue("interval")); - assertEquals(new Long(456000), triggerAccessor.getPropertyValue("initialDelay")); - assertEquals(true, triggerAccessor.getPropertyValue("fixedRate")); - } - - @Test - public void testChannelAdapterAnnotation() throws InterruptedException { - TestApplicationContext context = TestUtils.createTestApplicationContext(); - MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor(); - postProcessor.setBeanFactory(context.getBeanFactory()); - postProcessor.afterPropertiesSet(); - ChannelAdapterAnnotationTestBean testBean = new ChannelAdapterAnnotationTestBean(); - postProcessor.postProcessAfterInitialization(testBean, "testBean"); - ChannelResolver channelResolver = new BeanFactoryChannelResolver(context); - DirectChannel testChannel = (DirectChannel) channelResolver.resolveChannelName("testChannel"); - final CountDownLatch latch = new CountDownLatch(1); - final AtomicReference> receivedMessage = new AtomicReference>(); - testChannel.subscribe(new MessageHandler() { - public void handleMessage(Message message) { - receivedMessage.set(message); - latch.countDown(); - } - }); - context.refresh(); - latch.await(3, TimeUnit.SECONDS); - assertEquals(0, latch.getCount()); - assertNotNull(receivedMessage.get()); - assertEquals("test", receivedMessage.get().getPayload()); - context.stop(); - } - @Test public void testTransformer() { TestApplicationContext context = TestUtils.createTestApplicationContext(); @@ -391,17 +339,6 @@ public class MessagingAnnotationPostProcessorTests { } - @MessageEndpoint - private static class AnnotatedEndpointWithPolledAnnotation { - - @ServiceActivator(inputChannel="testChannel") - @Poller(interval=123, initialDelay=456, fixedRate=true, timeUnit=TimeUnit.SECONDS) - public String prependFoo(String s) { - return "foo" + s; - } - } - - @MessageEndpoint private static class ServiceActivatorAnnotatedBean { @@ -413,17 +350,6 @@ public class MessagingAnnotationPostProcessorTests { } - @MessageEndpoint - private static class ChannelAdapterAnnotationTestBean { - - @ChannelAdapter("testChannel") - @Poller(interval=1000, initialDelay=0, maxMessagesPerPoll=1) - public String test() { - return "test"; - } - } - - @MessageEndpoint private static class TransformerAnnotationTestBean {