OPEN - issue INT-632: MessagingAnnotationPostProcessor is chained too late to allow aspects to be added
http://jira.springframework.org/browse/INT-632 Ground work for testcase.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
|
||||
<classpathentry kind="src" path="src/main/resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.aspectj/com.springsource.org.aspectj.weaver/1.6.3.RELEASE/com.springsource.org.aspectj.weaver-1.6.3.RELEASE.jar" sourcepath="/IVY_CACHE/org.aspectj/com.springsource.org.aspectj.weaver/1.6.3.RELEASE/com.springsource.org.aspectj.weaver-1.6.3.RELEASE.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/net.sourceforge.cglib/com.springsource.net.sf.cglib/2.1.3/com.springsource.net.sf.cglib-2.1.3.jar" sourcepath="/IVY_CACHE/net.sourceforge.cglib/com.springsource.net.sf.cglib/2.1.3/com.springsource.net.sf.cglib-sources-2.1.3.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.aopalliance/com.springsource.org.aopalliance/1.0.0/com.springsource.org.aopalliance-1.0.0.jar" sourcepath="/IVY_CACHE/org.aopalliance/com.springsource.org.aopalliance/1.0.0/com.springsource.org.aopalliance-sources-1.0.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar" sourcepath="/IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-sources-1.1.1.jar"/>
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<dependency org="org.springframework" name="org.springframework.transaction" rev="2.5.6.A" conf="compile->runtime"/>
|
||||
<dependency org="org.springframework" name="org.springframework.test" rev="2.5.6.A" conf="test->runtime"/>
|
||||
<dependency org="org.mockito" name="com.springsource.org.mockito" rev="1.6.0" conf="test->runtime"/>
|
||||
<dependency org="org.aspectj" name="com.springsource.org.aspectj.weaver" rev="1.6.3.RELEASE" conf="test->runtime"/>
|
||||
</dependencies>
|
||||
|
||||
</ivy-module>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
|
||||
|
||||
<annotation-config />
|
||||
<aop:aspectj-autoproxy />
|
||||
<channel id="input"/>
|
||||
<beans:bean id="activatedService"
|
||||
class="org.springframework.integration.config.annotation.MessagingAnnotationPostProcessorAopIntegrationTests$AnnotatedService" />
|
||||
<beans:bean id="handlerAspect"
|
||||
class="org.springframework.integration.config.annotation.MessagingAnnotationPostProcessorAopIntegrationTests$HandlerAspect" />
|
||||
<beans:bean id="serviceAspect"
|
||||
class="org.springframework.integration.config.annotation.MessagingAnnotationPostProcessorAopIntegrationTests$ServiceAspect" />
|
||||
</beans:beans>
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.annotation;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.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.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.channel.SubscribableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class MessagingAnnotationPostProcessorAopIntegrationTests {
|
||||
@Qualifier("input")
|
||||
@Autowired
|
||||
SubscribableChannel input;
|
||||
|
||||
@Test
|
||||
public void parseConfig() throws Exception {
|
||||
assertThat(input, notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendMessage() throws Exception {
|
||||
input.send(MessageBuilder.withPayload("A test message").build());
|
||||
}
|
||||
|
||||
@Aspect
|
||||
public static class HandlerAspect {
|
||||
|
||||
@Before("execution(* org.springframework.integration.message.MessageHandler+.*(..)) && args(message)")
|
||||
public void printMessage(Message<?> message) {
|
||||
System.out.println(message + " hit handler wrapping aspect");
|
||||
}
|
||||
}
|
||||
|
||||
@Aspect
|
||||
public static class ServiceAspect {
|
||||
|
||||
@Before("execution(* printMessage(*)) && args(message)")
|
||||
public void printMessage(Message<?> message) {
|
||||
System.out.println(message + " hit service wrapping aspect");
|
||||
}
|
||||
}
|
||||
|
||||
@MessageEndpoint
|
||||
public static class AnnotatedService {
|
||||
@ServiceActivator(inputChannel = "input")
|
||||
public void printMessage(Message<?> m) {
|
||||
System.out.println(m + " hit service");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user