@@ -52,6 +52,7 @@ public abstract class AbstractJmsAnnotationDrivenTests {
52
52
@ Rule
53
53
public final ExpectedException thrown = ExpectedException .none ();
54
54
55
+
55
56
@ Test
56
57
public abstract void sampleConfiguration ();
57
58
@@ -79,6 +80,7 @@ public abstract class AbstractJmsAnnotationDrivenTests {
79
80
@ Test
80
81
public abstract void jmsListeners ();
81
82
83
+
82
84
/**
83
85
* Test for {@link SampleBean} discovery. If a factory with the default name
84
86
* is set, an endpoint will use it automatically
@@ -92,18 +94,6 @@ public void testSampleConfiguration(ApplicationContext context) {
92
94
assertEquals (1 , simpleFactory .getListenerContainers ().size ());
93
95
}
94
96
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
-
107
97
/**
108
98
* Test for {@link FullBean} discovery. In this case, no default is set because
109
99
* all endpoints provide a default registry. This shows that the default factory
@@ -127,29 +117,6 @@ public void testFullConfiguration(ApplicationContext context) {
127
117
assertEquals ("queueOut" , destination );
128
118
}
129
119
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
-
153
120
/**
154
121
* Test for {@link CustomBean} and an manually endpoint registered
155
122
* with "myCustomEndpointId". The custom endpoint does not provide
@@ -179,14 +146,6 @@ public void testCustomConfiguration(ApplicationContext context) {
179
146
customRegistry .getListenerContainer ("myCustomEndpointId" ));
180
147
}
181
148
182
- @ Component
183
- static class CustomBean {
184
-
185
- @ JmsListener (id = "listenerId" , containerFactory = "customFactory" , destination = "myQueue" )
186
- public void customHandle (String msg ) {
187
- }
188
- }
189
-
190
149
/**
191
150
* Test for {@link DefaultBean} that does not define the container
192
151
* factory to use as a default is registered with an explicit
@@ -208,13 +167,6 @@ public void testDefaultContainerFactoryConfiguration(ApplicationContext context)
208
167
assertEquals (1 , defaultFactory .getListenerContainers ().size ());
209
168
}
210
169
211
- static class DefaultBean {
212
-
213
- @ JmsListener (destination = "myQueue" )
214
- public void handleIt (String msg ) {
215
- }
216
- }
217
-
218
170
/**
219
171
* Test for {@link ValidationBean} with a validator ({@link TestValidator}) specified
220
172
* in a custom {@link org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory}.
@@ -234,14 +186,6 @@ public void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context)
234
186
listener .onMessage (new StubTextMessage ("failValidation" ), mock (Session .class ));
235
187
}
236
188
237
- @ Component
238
- static class ValidationBean {
239
-
240
- @ JmsListener (containerFactory = "defaultFactory" , destination = "myQueue" )
241
- public void defaultHandle (@ Validated String msg ) {
242
- }
243
- }
244
-
245
189
/**
246
190
* Test for {@link JmsListenerRepeatableBean} and {@link JmsListenersBean} that validates that the
247
191
* {@code @JmsListener} annotation is repeatable and generate one specific container per annotation.
@@ -264,16 +208,81 @@ public void testJmsListenerRepeatable(ApplicationContext context) {
264
208
assertEquals ("2-10" , second .getConcurrency ());
265
209
}
266
210
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
+
267
276
@ Component
268
277
static class JmsListenerRepeatableBean {
269
278
270
279
@ JmsListener (id = "first" , destination = "myQueue" )
271
280
@ JmsListener (id = "second" , destination = "anotherQueue" , concurrency = "2-10" )
272
281
public void repeatableHandle (String msg ) {
273
282
}
274
-
275
283
}
276
284
285
+
277
286
@ Component
278
287
static class JmsListenersBean {
279
288
@@ -283,9 +292,9 @@ static class JmsListenersBean {
283
292
})
284
293
public void repeatableHandle (String msg ) {
285
294
}
286
-
287
295
}
288
296
297
+
289
298
static class TestValidator implements Validator {
290
299
291
300
@ Override
@@ -301,4 +310,5 @@ public void validate(Object target, Errors errors) {
301
310
}
302
311
}
303
312
}
313
+
304
314
}
0 commit comments