Skip to content

Commit 3db34cf

Browse files
committed
Gather RabbitMQ container logs on errors
1 parent da5ba51 commit 3db34cf

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

spring-amqp-client/src/test/java/org/springframework/amqp/client/listener/AmqpListenerAnnotationTests.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import java.util.concurrent.TimeUnit;
2626

2727
import org.aopalliance.aop.Advice;
28+
import org.apache.commons.logging.Log;
29+
import org.apache.commons.logging.LogFactory;
2830
import org.apache.qpid.protonj2.client.Delivery;
2931
import org.apache.qpid.protonj2.client.ReconnectOptions;
3032
import org.assertj.core.api.InstanceOfAssertFactories;
@@ -34,6 +36,7 @@
3436

3537
import org.springframework.amqp.client.AmqpClient;
3638
import org.springframework.amqp.client.AmqpConnectionFactory;
39+
import org.springframework.amqp.client.EnableAmqpTests;
3740
import org.springframework.amqp.client.SingleAmqpConnectionFactory;
3841
import org.springframework.amqp.client.annotation.AmqpListener;
3942
import org.springframework.amqp.client.config.AmqpDefaultConfiguration;
@@ -80,6 +83,8 @@
8083
@DirtiesContext
8184
class AmqpListenerAnnotationTests extends AbstractTestContainerTests {
8285

86+
static final Log LOG = LogFactory.getLog(AmqpListenerAnnotationTests.class);
87+
8388
static final String TEST_QUEUE1 = "/queues/listener_annotation1";
8489

8590
static final String TEST_QUEUE2 = "/queues/listener_annotation2";
@@ -198,18 +203,24 @@ void requestReplyAndContainerFactoryOverrides() {
198203

199204
DataIn dataIn = new DataIn("test_data");
200205

201-
this.amqpClient.to(TEST_QUEUE2)
202-
.body(dataIn)
203-
.replyTo(TEST_REPLY_TO)
204-
.send();
206+
try {
207+
this.amqpClient.to(TEST_QUEUE2)
208+
.body(dataIn)
209+
.replyTo(TEST_REPLY_TO)
210+
.send();
205211

206-
CompletableFuture<DataOut> dataOut =
207-
this.amqpClient.from(TEST_REPLY_TO)
208-
.receiveAndConvert();
212+
CompletableFuture<DataOut> dataOut =
213+
this.amqpClient.from(TEST_REPLY_TO)
214+
.receiveAndConvert();
209215

210-
assertThat(dataOut)
211-
.succeedsWithin(Duration.ofSeconds(30))
212-
.isEqualTo(new DataOut(dataIn.data + "_out"));
216+
assertThat(dataOut)
217+
.succeedsWithin(Duration.ofSeconds(30))
218+
.isEqualTo(new DataOut(dataIn.data + "_out"));
219+
}
220+
catch (Exception e) {
221+
LOG.error("LOGS FROM RABBITMQ CONTAINER: " + RABBITMQ.getLogs());
222+
throw e;
223+
}
213224
}
214225

215226
@Configuration(proxyBeanMethods = false)

0 commit comments

Comments
 (0)