Skip to content

Commit 760bc71

Browse files
committed
Polishing
1 parent da9c80c commit 760bc71

File tree

17 files changed

+195
-149
lines changed

17 files changed

+195
-149
lines changed

spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ private void assertTargetBean(Method method, Object targetBean, Object[] args) {
302302
Class<?> targetBeanClass = targetBean.getClass();
303303
if (!methodDeclaringClass.isAssignableFrom(targetBeanClass)) {
304304
String msg = "The event listener method class '" + methodDeclaringClass.getName() +
305-
"' is not an instance of the actual bean instance '" +
305+
"' is not an instance of the actual bean class '" +
306306
targetBeanClass.getName() + "'. If the bean requires proxying " +
307307
"(e.g. due to @Transactional), please use class-based proxying.";
308308
throw new IllegalStateException(getInvocationErrorMessage(targetBean, msg, args));

spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java

-2
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,10 @@ public static AnnotationAttributes getMergedAnnotationAttributes(AnnotatedElemen
391391
* the result back into an annotation of the specified {@code annotationType}.
392392
* <p>{@link AliasFor @AliasFor} semantics are fully supported, both
393393
* within a single annotation and within the annotation hierarchy.
394-
* <p>This method delegates to {@link #findMergedAnnotation(AnnotatedElement, String)}.
395394
* @param element the annotated element
396395
* @param annotationType the annotation type to find
397396
* @return the merged, synthesized {@code Annotation}, or {@code null} if not found
398397
* @since 4.2
399-
* @see #findMergedAnnotation(AnnotatedElement, String)
400398
* @see #findMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
401399
* @see #getMergedAnnotationAttributes(AnnotatedElement, Class)
402400
*/

spring-jms/src/test/java/org/springframework/jms/annotation/AbstractJmsAnnotationDrivenTests.java

+70-60
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public abstract class AbstractJmsAnnotationDrivenTests {
5252
@Rule
5353
public final ExpectedException thrown = ExpectedException.none();
5454

55+
5556
@Test
5657
public abstract void sampleConfiguration();
5758

@@ -79,6 +80,7 @@ public abstract class AbstractJmsAnnotationDrivenTests {
7980
@Test
8081
public abstract void jmsListeners();
8182

83+
8284
/**
8385
* Test for {@link SampleBean} discovery. If a factory with the default name
8486
* is set, an endpoint will use it automatically
@@ -92,18 +94,6 @@ public void testSampleConfiguration(ApplicationContext context) {
9294
assertEquals(1, simpleFactory.getListenerContainers().size());
9395
}
9496

95-
@Component
96-
static class SampleBean {
97-
98-
@JmsListener(destination = "myQueue")
99-
public void defaultHandle(String msg) {
100-
}
101-
102-
@JmsListener(containerFactory = "simpleFactory", destination = "myQueue")
103-
public void simpleHandle(String msg) {
104-
}
105-
}
106-
10797
/**
10898
* Test for {@link FullBean} discovery. In this case, no default is set because
10999
* all endpoints provide a default registry. This shows that the default factory
@@ -127,29 +117,6 @@ public void testFullConfiguration(ApplicationContext context) {
127117
assertEquals("queueOut", destination);
128118
}
129119

130-
@Component
131-
static class FullBean {
132-
133-
@JmsListener(id = "listener1", containerFactory = "simpleFactory", destination = "queueIn",
134-
selector = "mySelector", subscription = "mySubscription", concurrency = "1-10")
135-
@SendTo("queueOut")
136-
public String fullHandle(String msg) {
137-
return "reply";
138-
}
139-
}
140-
141-
@Component
142-
static class FullConfigurableBean {
143-
144-
@JmsListener(id = "${jms.listener.id}", containerFactory = "${jms.listener.containerFactory}",
145-
destination = "${jms.listener.destination}", selector = "${jms.listener.selector}",
146-
subscription = "${jms.listener.subscription}", concurrency = "${jms.listener.concurrency}")
147-
@SendTo("${jms.listener.sendTo}")
148-
public String fullHandle(String msg) {
149-
return "reply";
150-
}
151-
}
152-
153120
/**
154121
* Test for {@link CustomBean} and an manually endpoint registered
155122
* with "myCustomEndpointId". The custom endpoint does not provide
@@ -179,14 +146,6 @@ public void testCustomConfiguration(ApplicationContext context) {
179146
customRegistry.getListenerContainer("myCustomEndpointId"));
180147
}
181148

182-
@Component
183-
static class CustomBean {
184-
185-
@JmsListener(id = "listenerId", containerFactory = "customFactory", destination = "myQueue")
186-
public void customHandle(String msg) {
187-
}
188-
}
189-
190149
/**
191150
* Test for {@link DefaultBean} that does not define the container
192151
* factory to use as a default is registered with an explicit
@@ -208,13 +167,6 @@ public void testDefaultContainerFactoryConfiguration(ApplicationContext context)
208167
assertEquals(1, defaultFactory.getListenerContainers().size());
209168
}
210169

211-
static class DefaultBean {
212-
213-
@JmsListener(destination = "myQueue")
214-
public void handleIt(String msg) {
215-
}
216-
}
217-
218170
/**
219171
* Test for {@link ValidationBean} with a validator ({@link TestValidator}) specified
220172
* in a custom {@link org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory}.
@@ -234,14 +186,6 @@ public void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context)
234186
listener.onMessage(new StubTextMessage("failValidation"), mock(Session.class));
235187
}
236188

237-
@Component
238-
static class ValidationBean {
239-
240-
@JmsListener(containerFactory = "defaultFactory", destination = "myQueue")
241-
public void defaultHandle(@Validated String msg) {
242-
}
243-
}
244-
245189
/**
246190
* Test for {@link JmsListenerRepeatableBean} and {@link JmsListenersBean} that validates that the
247191
* {@code @JmsListener} annotation is repeatable and generate one specific container per annotation.
@@ -264,16 +208,81 @@ public void testJmsListenerRepeatable(ApplicationContext context) {
264208
assertEquals("2-10", second.getConcurrency());
265209
}
266210

211+
212+
@Component
213+
static class SampleBean {
214+
215+
@JmsListener(destination = "myQueue")
216+
public void defaultHandle(String msg) {
217+
}
218+
219+
@JmsListener(containerFactory = "simpleFactory", destination = "myQueue")
220+
public void simpleHandle(String msg) {
221+
}
222+
}
223+
224+
225+
@Component
226+
static class FullBean {
227+
228+
@JmsListener(id = "listener1", containerFactory = "simpleFactory", destination = "queueIn",
229+
selector = "mySelector", subscription = "mySubscription", concurrency = "1-10")
230+
@SendTo("queueOut")
231+
public String fullHandle(String msg) {
232+
return "reply";
233+
}
234+
}
235+
236+
237+
@Component
238+
static class FullConfigurableBean {
239+
240+
@JmsListener(id = "${jms.listener.id}", containerFactory = "${jms.listener.containerFactory}",
241+
destination = "${jms.listener.destination}", selector = "${jms.listener.selector}",
242+
subscription = "${jms.listener.subscription}", concurrency = "${jms.listener.concurrency}")
243+
@SendTo("${jms.listener.sendTo}")
244+
public String fullHandle(String msg) {
245+
return "reply";
246+
}
247+
}
248+
249+
250+
@Component
251+
static class CustomBean {
252+
253+
@JmsListener(id = "listenerId", containerFactory = "customFactory", destination = "myQueue")
254+
public void customHandle(String msg) {
255+
}
256+
}
257+
258+
259+
static class DefaultBean {
260+
261+
@JmsListener(destination = "myQueue")
262+
public void handleIt(String msg) {
263+
}
264+
}
265+
266+
267+
@Component
268+
static class ValidationBean {
269+
270+
@JmsListener(containerFactory = "defaultFactory", destination = "myQueue")
271+
public void defaultHandle(@Validated String msg) {
272+
}
273+
}
274+
275+
267276
@Component
268277
static class JmsListenerRepeatableBean {
269278

270279
@JmsListener(id = "first", destination = "myQueue")
271280
@JmsListener(id = "second", destination = "anotherQueue", concurrency = "2-10")
272281
public void repeatableHandle(String msg) {
273282
}
274-
275283
}
276284

285+
277286
@Component
278287
static class JmsListenersBean {
279288

@@ -283,9 +292,9 @@ static class JmsListenersBean {
283292
})
284293
public void repeatableHandle(String msg) {
285294
}
286-
287295
}
288296

297+
289298
static class TestValidator implements Validator {
290299

291300
@Override
@@ -301,4 +310,5 @@ public void validate(Object target, Errors errors) {
301310
}
302311
}
303312
}
313+
304314
}

spring-jms/src/test/java/org/springframework/jms/annotation/AnnotationDrivenNamespaceTests.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.springframework.messaging.handler.annotation.support.MethodArgumentNotValidException;
3131

3232
/**
33-
*
3433
* @author Stephane Nicoll
3534
*/
3635
public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenTests {
@@ -75,13 +74,15 @@ public void explicitContainerFactory() {
7574
}
7675

7776
@Override
77+
@Test
7878
public void defaultContainerFactory() {
7979
ApplicationContext context = new ClassPathXmlApplicationContext(
8080
"annotation-driven-default-container-factory.xml", getClass());
8181
testDefaultContainerFactoryConfiguration(context);
8282
}
8383

8484
@Override
85+
@Test
8586
public void jmsHandlerMethodFactoryConfiguration() throws JMSException {
8687
ApplicationContext context = new ClassPathXmlApplicationContext(
8788
"annotation-driven-custom-handler-method-factory.xml", getClass());
@@ -92,19 +93,22 @@ public void jmsHandlerMethodFactoryConfiguration() throws JMSException {
9293
}
9394

9495
@Override
96+
@Test
9597
public void jmsListenerIsRepeatable() {
9698
ApplicationContext context = new ClassPathXmlApplicationContext(
9799
"annotation-driven-jms-listener-repeatable.xml", getClass());
98100
testJmsListenerRepeatable(context);
99101
}
100102

101103
@Override
104+
@Test
102105
public void jmsListeners() {
103106
ApplicationContext context = new ClassPathXmlApplicationContext(
104107
"annotation-driven-jms-listeners.xml", getClass());
105108
testJmsListenerRepeatable(context);
106109
}
107110

111+
108112
static class CustomJmsListenerConfigurer implements JmsListenerConfigurer {
109113

110114
private MessageListener messageListener;
@@ -121,6 +125,6 @@ public void configureJmsListeners(JmsListenerEndpointRegistrar registrar) {
121125
public void setMessageListener(MessageListener messageListener) {
122126
this.messageListener = messageListener;
123127
}
124-
125128
}
129+
126130
}

spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java

+11
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
5454
@Rule
5555
public final ExpectedException thrown = ExpectedException.none();
5656

57+
5758
@Override
5859
@Test
5960
public void sampleConfiguration() {
@@ -113,13 +114,15 @@ public void jmsHandlerMethodFactoryConfiguration() throws JMSException {
113114
}
114115

115116
@Override
117+
@Test
116118
public void jmsListenerIsRepeatable() {
117119
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
118120
EnableJmsDefaultContainerFactoryConfig.class, JmsListenerRepeatableBean.class);
119121
testJmsListenerRepeatable(context);
120122
}
121123

122124
@Override
125+
@Test
123126
public void jmsListeners() {
124127
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
125128
EnableJmsDefaultContainerFactoryConfig.class, JmsListenersBean.class);
@@ -150,6 +153,7 @@ public void lazyComponent() {
150153
assertTrue("Should have been stopped " + container, container.isStopped());
151154
}
152155

156+
153157
@EnableJms
154158
@Configuration
155159
static class EnableJmsSampleConfig {
@@ -165,6 +169,7 @@ public JmsListenerContainerTestFactory simpleFactory() {
165169
}
166170
}
167171

172+
168173
@EnableJms
169174
@Configuration
170175
static class EnableJmsFullConfig {
@@ -175,6 +180,7 @@ public JmsListenerContainerTestFactory simpleFactory() {
175180
}
176181
}
177182

183+
178184
@EnableJms
179185
@Configuration
180186
@PropertySource("classpath:/org/springframework/jms/annotation/jms-listener.properties")
@@ -191,6 +197,7 @@ public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer
191197
}
192198
}
193199

200+
194201
@Configuration
195202
@EnableJms
196203
static class EnableJmsCustomConfig implements JmsListenerConfigurer {
@@ -228,6 +235,7 @@ public MessageListener simpleMessageListener() {
228235
}
229236
}
230237

238+
231239
@Configuration
232240
@EnableJms
233241
static class EnableJmsCustomContainerFactoryConfig implements JmsListenerConfigurer {
@@ -243,6 +251,7 @@ public JmsListenerContainerTestFactory simpleFactory() {
243251
}
244252
}
245253

254+
246255
@Configuration
247256
@EnableJms
248257
static class EnableJmsDefaultContainerFactoryConfig {
@@ -253,6 +262,7 @@ public JmsListenerContainerTestFactory jmsListenerContainerFactory() {
253262
}
254263
}
255264

265+
256266
@Configuration
257267
@EnableJms
258268
static class EnableJmsHandlerMethodFactoryConfig implements JmsListenerConfigurer {
@@ -275,6 +285,7 @@ public JmsListenerContainerTestFactory defaultFactory() {
275285
}
276286
}
277287

288+
278289
@Component
279290
@Lazy
280291
static class LazyBean {

0 commit comments

Comments
 (0)