16
16
17
17
package org .springframework .integration .amqp .inbound ;
18
18
19
+ import java .io .IOException ;
20
+ import java .util .List ;
19
21
import java .util .concurrent .CountDownLatch ;
20
22
import java .util .concurrent .TimeUnit ;
21
23
22
24
import org .aopalliance .intercept .MethodInterceptor ;
25
+ import org .junit .jupiter .api .AfterAll ;
23
26
import org .junit .jupiter .api .AfterEach ;
27
+ import org .junit .jupiter .api .BeforeAll ;
24
28
import org .junit .jupiter .api .BeforeEach ;
25
29
import org .junit .jupiter .api .Test ;
26
30
31
35
import org .springframework .amqp .rabbit .connection .ConnectionFactory ;
32
36
import org .springframework .amqp .rabbit .core .RabbitAdmin ;
33
37
import org .springframework .amqp .rabbit .core .RabbitTemplate ;
34
- import org .springframework .amqp .rabbit .junit .RabbitAvailable ;
35
38
import org .springframework .aop .framework .ProxyFactory ;
36
39
import org .springframework .beans .BeansException ;
37
40
import org .springframework .beans .factory .annotation .Autowired ;
43
46
import org .springframework .integration .acks .AcknowledgmentCallback ;
44
47
import org .springframework .integration .acks .AcknowledgmentCallback .Status ;
45
48
import org .springframework .integration .amqp .dsl .Amqp ;
49
+ import org .springframework .integration .amqp .support .RabbitTestContainer ;
46
50
import org .springframework .integration .annotation .InboundChannelAdapter ;
47
51
import org .springframework .integration .annotation .Poller ;
48
52
import org .springframework .integration .annotation .ServiceActivator ;
66
70
*/
67
71
@ SpringJUnitConfig
68
72
@ DirtiesContext
69
- @ RabbitAvailable ({
70
- AmqpMessageSourceIntegrationTests .DSL_QUEUE ,
71
- AmqpMessageSourceIntegrationTests .INTERCEPT_QUEUE ,
72
- AmqpMessageSourceIntegrationTests .DLQ ,
73
- AmqpMessageSourceIntegrationTests .NOAUTOACK_QUEUE })
74
- public class AmqpMessageSourceIntegrationTests {
73
+ public class AmqpMessageSourceIntegrationTests implements RabbitTestContainer {
75
74
76
75
static final String DSL_QUEUE = "AmqpMessageSourceIntegrationTests" ;
77
76
@@ -89,6 +88,22 @@ public class AmqpMessageSourceIntegrationTests {
89
88
@ Autowired
90
89
private ConfigurableApplicationContext context ;
91
90
91
+ @ BeforeAll
92
+ static void initQueues () throws IOException , InterruptedException {
93
+ List <String > queueNames = List .of (DSL_QUEUE , DLQ , INTERCEPT_QUEUE , NOAUTOACK_QUEUE );
94
+ for (String queue : queueNames ) {
95
+ RABBITMQ .execInContainer ("rabbitmqadmin" , "declare" , "queue" , "name=" + queue );
96
+ }
97
+ }
98
+
99
+ @ AfterAll
100
+ static void deleteQueues () throws IOException , InterruptedException {
101
+ List <String > queueNames = List .of (DSL_QUEUE , DLQ , INTERCEPT_QUEUE , NOAUTOACK_QUEUE );
102
+ for (String queue : queueNames ) {
103
+ RABBITMQ .execInContainer ("rabbitmqadmin" , "delete" , "queue" , "name=" + queue );
104
+ }
105
+ }
106
+
92
107
@ BeforeEach
93
108
public void before () {
94
109
RabbitAdmin admin = new RabbitAdmin (this .config .connectionFactory ());
@@ -249,7 +264,7 @@ public Object postProcessAfterInitialization(Object bean, String beanName) throw
249
264
250
265
@ Bean
251
266
public ConnectionFactory connectionFactory () {
252
- return new CachingConnectionFactory ("localhost" );
267
+ return new CachingConnectionFactory (RabbitTestContainer . amqpPort () );
253
268
}
254
269
255
270
}
0 commit comments