Skip to content

Commit a2ee501

Browse files
committed
Add test for dynamic receiver
1 parent 0ea3cfb commit a2ee501

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/main/java/com/rabbitmq/client/amqp/impl/AmqpConnection.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,13 @@ private void sync(NativeConnectionWrapper wrapper) {
286286
this.nativeConnection = wrapper.connection();
287287
}
288288

289-
private static void checkBroker(org.apache.qpid.protonj2.client.Connection connection) throws ClientException {
289+
private static void checkBroker(org.apache.qpid.protonj2.client.Connection connection)
290+
throws ClientException {
290291
String broker = (String) connection.properties().get("product");
291292
if (!"rabbitmq".equalsIgnoreCase(broker)) {
292-
LOGGER.warn("Connected to another broker than RabbitMQ ('{}'), the library may not behave as expected", broker);
293+
LOGGER.warn(
294+
"Connected to another broker than RabbitMQ ('{}'), the library may not behave as expected",
295+
broker);
293296
}
294297
}
295298

src/test/java/com/rabbitmq/client/amqp/impl/ClientTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,27 @@ void connectionClosing() {
397397
c.close();
398398
}
399399
}
400+
401+
@Test
402+
void dynamicReceiver() throws Exception {
403+
try (Client client = client()) {
404+
org.apache.qpid.protonj2.client.Connection c1 = connection(client);
405+
Session s1 = c1.openSession();
406+
ReceiverOptions receiverOptions = new ReceiverOptions();
407+
receiverOptions.sourceOptions().capabilities("temporary-queue");
408+
Receiver receiver = s1.openDynamicReceiver(receiverOptions);
409+
receiver.openFuture().get();
410+
assertThat(receiver.address()).isNotNull();
411+
412+
org.apache.qpid.protonj2.client.Connection c2 = connection(client);
413+
Session s2 = c2.openSession();
414+
Sender sender = s2.openSender(receiver.address());
415+
String body = UUID.randomUUID().toString();
416+
sender.send(Message.create(body));
417+
418+
Delivery delivery = receiver.receive(10, SECONDS);
419+
assertThat(delivery).isNotNull();
420+
assertThat(delivery.message().body()).isEqualTo(body);
421+
}
422+
}
400423
}

0 commit comments

Comments
 (0)