diff --git a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java index 4f1b5a301f..243d16428a 100644 --- a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java +++ b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java @@ -302,7 +302,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe Class> targetBeanClass = targetBean.getClass(); if (!methodDeclaringClass.isAssignableFrom(targetBeanClass)) { String msg = "The event listener method class '" + methodDeclaringClass.getName() + - "' is not an instance of the actual bean instance '" + + "' is not an instance of the actual bean class '" + targetBeanClass.getName() + "'. If the bean requires proxying " + "(e.g. due to @Transactional), please use class-based proxying."; throw new IllegalStateException(getInvocationErrorMessage(targetBean, msg, args)); diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java index 3ac8672432..2766e07066 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java @@ -391,12 +391,10 @@ public class AnnotatedElementUtils { * the result back into an annotation of the specified {@code annotationType}. *
{@link AliasFor @AliasFor} semantics are fully supported, both * within a single annotation and within the annotation hierarchy. - *
This method delegates to {@link #findMergedAnnotation(AnnotatedElement, String)}.
* @param element the annotated element
* @param annotationType the annotation type to find
* @return the merged, synthesized {@code Annotation}, or {@code null} if not found
* @since 4.2
- * @see #findMergedAnnotation(AnnotatedElement, String)
* @see #findMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
* @see #getMergedAnnotationAttributes(AnnotatedElement, Class)
*/
diff --git a/spring-jms/src/test/java/org/springframework/jms/annotation/AbstractJmsAnnotationDrivenTests.java b/spring-jms/src/test/java/org/springframework/jms/annotation/AbstractJmsAnnotationDrivenTests.java
index 94ae1162cc..5b20d36e75 100644
--- a/spring-jms/src/test/java/org/springframework/jms/annotation/AbstractJmsAnnotationDrivenTests.java
+++ b/spring-jms/src/test/java/org/springframework/jms/annotation/AbstractJmsAnnotationDrivenTests.java
@@ -52,6 +52,7 @@ public abstract class AbstractJmsAnnotationDrivenTests {
@Rule
public final ExpectedException thrown = ExpectedException.none();
+
@Test
public abstract void sampleConfiguration();
@@ -79,6 +80,7 @@ public abstract class AbstractJmsAnnotationDrivenTests {
@Test
public abstract void jmsListeners();
+
/**
* Test for {@link SampleBean} discovery. If a factory with the default name
* is set, an endpoint will use it automatically
@@ -92,18 +94,6 @@ public abstract class AbstractJmsAnnotationDrivenTests {
assertEquals(1, simpleFactory.getListenerContainers().size());
}
- @Component
- static class SampleBean {
-
- @JmsListener(destination = "myQueue")
- public void defaultHandle(String msg) {
- }
-
- @JmsListener(containerFactory = "simpleFactory", destination = "myQueue")
- public void simpleHandle(String msg) {
- }
- }
-
/**
* Test for {@link FullBean} discovery. In this case, no default is set because
* all endpoints provide a default registry. This shows that the default factory
@@ -127,29 +117,6 @@ public abstract class AbstractJmsAnnotationDrivenTests {
assertEquals("queueOut", destination);
}
- @Component
- static class FullBean {
-
- @JmsListener(id = "listener1", containerFactory = "simpleFactory", destination = "queueIn",
- selector = "mySelector", subscription = "mySubscription", concurrency = "1-10")
- @SendTo("queueOut")
- public String fullHandle(String msg) {
- return "reply";
- }
- }
-
- @Component
- static class FullConfigurableBean {
-
- @JmsListener(id = "${jms.listener.id}", containerFactory = "${jms.listener.containerFactory}",
- destination = "${jms.listener.destination}", selector = "${jms.listener.selector}",
- subscription = "${jms.listener.subscription}", concurrency = "${jms.listener.concurrency}")
- @SendTo("${jms.listener.sendTo}")
- public String fullHandle(String msg) {
- return "reply";
- }
- }
-
/**
* Test for {@link CustomBean} and an manually endpoint registered
* with "myCustomEndpointId". The custom endpoint does not provide
@@ -179,14 +146,6 @@ public abstract class AbstractJmsAnnotationDrivenTests {
customRegistry.getListenerContainer("myCustomEndpointId"));
}
- @Component
- static class CustomBean {
-
- @JmsListener(id = "listenerId", containerFactory = "customFactory", destination = "myQueue")
- public void customHandle(String msg) {
- }
- }
-
/**
* Test for {@link DefaultBean} that does not define the container
* factory to use as a default is registered with an explicit
@@ -208,13 +167,6 @@ public abstract class AbstractJmsAnnotationDrivenTests {
assertEquals(1, defaultFactory.getListenerContainers().size());
}
- static class DefaultBean {
-
- @JmsListener(destination = "myQueue")
- public void handleIt(String msg) {
- }
- }
-
/**
* Test for {@link ValidationBean} with a validator ({@link TestValidator}) specified
* in a custom {@link org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory}.
@@ -234,14 +186,6 @@ public abstract class AbstractJmsAnnotationDrivenTests {
listener.onMessage(new StubTextMessage("failValidation"), mock(Session.class));
}
- @Component
- static class ValidationBean {
-
- @JmsListener(containerFactory = "defaultFactory", destination = "myQueue")
- public void defaultHandle(@Validated String msg) {
- }
- }
-
/**
* Test for {@link JmsListenerRepeatableBean} and {@link JmsListenersBean} that validates that the
* {@code @JmsListener} annotation is repeatable and generate one specific container per annotation.
@@ -264,6 +208,71 @@ public abstract class AbstractJmsAnnotationDrivenTests {
assertEquals("2-10", second.getConcurrency());
}
+
+ @Component
+ static class SampleBean {
+
+ @JmsListener(destination = "myQueue")
+ public void defaultHandle(String msg) {
+ }
+
+ @JmsListener(containerFactory = "simpleFactory", destination = "myQueue")
+ public void simpleHandle(String msg) {
+ }
+ }
+
+
+ @Component
+ static class FullBean {
+
+ @JmsListener(id = "listener1", containerFactory = "simpleFactory", destination = "queueIn",
+ selector = "mySelector", subscription = "mySubscription", concurrency = "1-10")
+ @SendTo("queueOut")
+ public String fullHandle(String msg) {
+ return "reply";
+ }
+ }
+
+
+ @Component
+ static class FullConfigurableBean {
+
+ @JmsListener(id = "${jms.listener.id}", containerFactory = "${jms.listener.containerFactory}",
+ destination = "${jms.listener.destination}", selector = "${jms.listener.selector}",
+ subscription = "${jms.listener.subscription}", concurrency = "${jms.listener.concurrency}")
+ @SendTo("${jms.listener.sendTo}")
+ public String fullHandle(String msg) {
+ return "reply";
+ }
+ }
+
+
+ @Component
+ static class CustomBean {
+
+ @JmsListener(id = "listenerId", containerFactory = "customFactory", destination = "myQueue")
+ public void customHandle(String msg) {
+ }
+ }
+
+
+ static class DefaultBean {
+
+ @JmsListener(destination = "myQueue")
+ public void handleIt(String msg) {
+ }
+ }
+
+
+ @Component
+ static class ValidationBean {
+
+ @JmsListener(containerFactory = "defaultFactory", destination = "myQueue")
+ public void defaultHandle(@Validated String msg) {
+ }
+ }
+
+
@Component
static class JmsListenerRepeatableBean {
@@ -271,9 +280,9 @@ public abstract class AbstractJmsAnnotationDrivenTests {
@JmsListener(id = "second", destination = "anotherQueue", concurrency = "2-10")
public void repeatableHandle(String msg) {
}
-
}
+
@Component
static class JmsListenersBean {
@@ -283,9 +292,9 @@ public abstract class AbstractJmsAnnotationDrivenTests {
})
public void repeatableHandle(String msg) {
}
-
}
+
static class TestValidator implements Validator {
@Override
@@ -301,4 +310,5 @@ public abstract class AbstractJmsAnnotationDrivenTests {
}
}
}
+
}
diff --git a/spring-jms/src/test/java/org/springframework/jms/annotation/AnnotationDrivenNamespaceTests.java b/spring-jms/src/test/java/org/springframework/jms/annotation/AnnotationDrivenNamespaceTests.java
index 74f7b7844b..43af9a693d 100644
--- a/spring-jms/src/test/java/org/springframework/jms/annotation/AnnotationDrivenNamespaceTests.java
+++ b/spring-jms/src/test/java/org/springframework/jms/annotation/AnnotationDrivenNamespaceTests.java
@@ -30,7 +30,6 @@ import org.springframework.jms.listener.adapter.ListenerExecutionFailedException
import org.springframework.messaging.handler.annotation.support.MethodArgumentNotValidException;
/**
- *
* @author Stephane Nicoll
*/
public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenTests {
@@ -75,6 +74,7 @@ public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenT
}
@Override
+ @Test
public void defaultContainerFactory() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"annotation-driven-default-container-factory.xml", getClass());
@@ -82,6 +82,7 @@ public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenT
}
@Override
+ @Test
public void jmsHandlerMethodFactoryConfiguration() throws JMSException {
ApplicationContext context = new ClassPathXmlApplicationContext(
"annotation-driven-custom-handler-method-factory.xml", getClass());
@@ -92,6 +93,7 @@ public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenT
}
@Override
+ @Test
public void jmsListenerIsRepeatable() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"annotation-driven-jms-listener-repeatable.xml", getClass());
@@ -99,12 +101,14 @@ public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenT
}
@Override
+ @Test
public void jmsListeners() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"annotation-driven-jms-listeners.xml", getClass());
testJmsListenerRepeatable(context);
}
+
static class CustomJmsListenerConfigurer implements JmsListenerConfigurer {
private MessageListener messageListener;
@@ -121,6 +125,6 @@ public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenT
public void setMessageListener(MessageListener messageListener) {
this.messageListener = messageListener;
}
-
}
+
}
diff --git a/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java b/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java
index 45d2877df8..c2a350e526 100644
--- a/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java
+++ b/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java
@@ -54,6 +54,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
@Rule
public final ExpectedException thrown = ExpectedException.none();
+
@Override
@Test
public void sampleConfiguration() {
@@ -113,6 +114,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
}
@Override
+ @Test
public void jmsListenerIsRepeatable() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsDefaultContainerFactoryConfig.class, JmsListenerRepeatableBean.class);
@@ -120,6 +122,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
}
@Override
+ @Test
public void jmsListeners() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsDefaultContainerFactoryConfig.class, JmsListenersBean.class);
@@ -150,6 +153,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
assertTrue("Should have been stopped " + container, container.isStopped());
}
+
@EnableJms
@Configuration
static class EnableJmsSampleConfig {
@@ -165,6 +169,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
}
}
+
@EnableJms
@Configuration
static class EnableJmsFullConfig {
@@ -175,6 +180,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
}
}
+
@EnableJms
@Configuration
@PropertySource("classpath:/org/springframework/jms/annotation/jms-listener.properties")
@@ -191,6 +197,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
}
}
+
@Configuration
@EnableJms
static class EnableJmsCustomConfig implements JmsListenerConfigurer {
@@ -228,6 +235,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
}
}
+
@Configuration
@EnableJms
static class EnableJmsCustomContainerFactoryConfig implements JmsListenerConfigurer {
@@ -243,6 +251,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
}
}
+
@Configuration
@EnableJms
static class EnableJmsDefaultContainerFactoryConfig {
@@ -253,6 +262,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
}
}
+
@Configuration
@EnableJms
static class EnableJmsHandlerMethodFactoryConfig implements JmsListenerConfigurer {
@@ -275,6 +285,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
}
}
+
@Component
@Lazy
static class LazyBean {
diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java
index 9465e8db0a..e6f4323284 100644
--- a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java
+++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java
@@ -49,9 +49,6 @@ import static org.mockito.Mockito.*;
*/
public class JmsListenerContainerFactoryTests {
- @Rule
- public final ExpectedException thrown = ExpectedException.none();
-
private final ConnectionFactory connectionFactory = new StubConnectionFactory();
private final DestinationResolver destinationResolver = new DynamicDestinationResolver();
@@ -61,6 +58,10 @@ public class JmsListenerContainerFactoryTests {
private final TransactionManager transactionManager = mock(TransactionManager.class);
+ @Rule
+ public final ExpectedException thrown = ExpectedException.none();
+
+
@Test
public void createSimpleContainer() {
SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();
@@ -148,6 +149,7 @@ public class JmsListenerContainerFactoryTests {
assertSame(backOff, new DirectFieldAccessor(container).getPropertyValue("backOff"));
}
+
private void setDefaultJmsConfig(AbstractJmsListenerContainerFactory> factory) {
factory.setConnectionFactory(connectionFactory);
factory.setDestinationResolver(destinationResolver);
diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistrarTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistrarTests.java
index ed6e90826e..fd41c5eef1 100644
--- a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistrarTests.java
+++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistrarTests.java
@@ -30,9 +30,6 @@ import static org.junit.Assert.*;
*/
public class JmsListenerEndpointRegistrarTests {
- @Rule
- public final ExpectedException thrown = ExpectedException.none();
-
private final JmsListenerEndpointRegistrar registrar = new JmsListenerEndpointRegistrar();
private final JmsListenerEndpointRegistry registry = new JmsListenerEndpointRegistry();
@@ -40,12 +37,17 @@ public class JmsListenerEndpointRegistrarTests {
private final JmsListenerContainerTestFactory containerFactory = new JmsListenerContainerTestFactory();
+ @Rule
+ public final ExpectedException thrown = ExpectedException.none();
+
+
@Before
public void setup() {
registrar.setEndpointRegistry(registry);
registrar.setBeanFactory(new StaticListableBeanFactory());
}
+
@Test
public void registerNullEndpoint() {
thrown.expect(IllegalArgumentException.class);
diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistryTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistryTests.java
index 52d2996087..931a6ef626 100644
--- a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistryTests.java
+++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistryTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 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.
@@ -21,18 +21,19 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
/**
- *
* @author Stephane Nicoll
*/
public class JmsListenerEndpointRegistryTests {
- @Rule
- public final ExpectedException thrown = ExpectedException.none();
-
private final JmsListenerEndpointRegistry registry = new JmsListenerEndpointRegistry();
private final JmsListenerContainerTestFactory containerFactory = new JmsListenerContainerTestFactory();
+
+ @Rule
+ public final ExpectedException thrown = ExpectedException.none();
+
+
@Test
public void createWithNullEndpoint() {
thrown.expect(IllegalArgumentException.class);
@@ -59,6 +60,7 @@ public class JmsListenerEndpointRegistryTests {
registry.registerListenerContainer(createEndpoint("test", "queue"), containerFactory);
}
+
private SimpleJmsListenerEndpoint createEndpoint(String id, String destinationName) {
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
endpoint.setId(id);
diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointTests.java
index 8e9143dcc9..d0cc94ba7a 100644
--- a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointTests.java
+++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 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.
@@ -41,6 +41,7 @@ public class JmsListenerEndpointTests {
@Rule
public final ExpectedException thrown = ExpectedException.none();
+
@Test
public void setupJmsMessageContainerFullConfig() {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
@@ -112,5 +113,4 @@ public class JmsListenerEndpointTests {
endpoint.setupListenerContainer(container);
}
-
}
diff --git a/spring-jms/src/test/java/org/springframework/jms/config/MethodJmsListenerEndpointTests.java b/spring-jms/src/test/java/org/springframework/jms/config/MethodJmsListenerEndpointTests.java
index 05a306be8a..c87711073c 100644
--- a/spring-jms/src/test/java/org/springframework/jms/config/MethodJmsListenerEndpointTests.java
+++ b/spring-jms/src/test/java/org/springframework/jms/config/MethodJmsListenerEndpointTests.java
@@ -71,12 +71,6 @@ import static org.mockito.BDDMockito.*;
*/
public class MethodJmsListenerEndpointTests {
- @Rule
- public final TestName name = new TestName();
-
- @Rule
- public final ExpectedException thrown = ExpectedException.none();
-
private final DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
private final DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
@@ -84,11 +78,19 @@ public class MethodJmsListenerEndpointTests {
private final JmsEndpointSampleBean sample = new JmsEndpointSampleBean();
+ @Rule
+ public final TestName name = new TestName();
+
+ @Rule
+ public final ExpectedException thrown = ExpectedException.none();
+
+
@Before
public void setup() {
initializeFactory(factory);
}
+
@Test
public void createMessageListenerNoFactory() {
MethodJmsListenerEndpoint endpoint = new MethodJmsListenerEndpoint();
@@ -401,8 +403,10 @@ public class MethodJmsListenerEndpointTests {
listener.onMessage(createSimpleJmsTextMessage("test"), session); // Message