|
19 | 19 |
|
20 | 20 | import static com.rabbitmq.client.amqp.Management.ExchangeType.DIRECT;
|
21 | 21 | import static com.rabbitmq.client.amqp.Management.ExchangeType.FANOUT;
|
22 |
| -import static com.rabbitmq.client.amqp.Management.QueueType.QUORUM; |
| 22 | +import static com.rabbitmq.client.amqp.Management.QueueType.*; |
| 23 | +import static com.rabbitmq.client.amqp.Management.QueueType.STREAM; |
23 | 24 | import static com.rabbitmq.client.amqp.impl.TestUtils.*;
|
24 | 25 | import static com.rabbitmq.client.amqp.impl.TestUtils.CountDownLatchConditions.completed;
|
25 |
| -import static com.rabbitmq.client.amqp.impl.TestUtils.assertThat; |
26 | 26 | import static java.nio.charset.StandardCharsets.*;
|
27 | 27 | import static java.util.Collections.emptyMap;
|
28 | 28 | import static java.util.Collections.singletonMap;
|
29 | 29 | import static java.util.stream.IntStream.range;
|
30 | 30 | import static java.util.stream.Stream.of;
|
31 |
| -import static org.assertj.core.api.Assertions.assertThat; |
32 |
| -import static org.assertj.core.api.Assertions.assertThatThrownBy; |
| 31 | +import static org.assertj.core.api.Assertions.*; |
33 | 32 |
|
34 | 33 | import com.rabbitmq.client.amqp.*;
|
35 | 34 | import com.rabbitmq.client.amqp.impl.TestUtils.DisabledIfAddressV1Permitted;
|
@@ -620,6 +619,54 @@ void consumerWithHigherPriorityShouldGetMessagesFirst() {
|
620 | 619 | lowPriorityConsumer.close();
|
621 | 620 | }
|
622 | 621 |
|
| 622 | + @Test |
| 623 | + void redeclareQueueWithDifferentArguments() { |
| 624 | + Management management = connection.management(); |
| 625 | + management.queue(name).type(CLASSIC).declare(); |
| 626 | + try { |
| 627 | + management.queue(name).type(QUORUM).declare(); |
| 628 | + fail("Declaring an existing queue with different arguments should trigger an exception"); |
| 629 | + } catch (AmqpException e) { |
| 630 | + // OK |
| 631 | + } finally { |
| 632 | + management.queueDeletion().delete(name); |
| 633 | + } |
| 634 | + } |
| 635 | + |
| 636 | + @Test |
| 637 | + void redeclareExchangesWithDifferentArguments() { |
| 638 | + Management management = connection.management(); |
| 639 | + management.exchange(name).type(DIRECT).declare(); |
| 640 | + try { |
| 641 | + management.exchange(name).type(FANOUT).declare(); |
| 642 | + fail("Declaring an existing exchange with different arguments should trigger an exception"); |
| 643 | + } catch (AmqpException e) { |
| 644 | + assertThat(e).hasMessageContaining("409"); |
| 645 | + // OK |
| 646 | + } finally { |
| 647 | + management.exchangeDeletion().delete(name); |
| 648 | + } |
| 649 | + } |
| 650 | + |
| 651 | + @Test |
| 652 | + void declareQueueWithUnsupportedArgument() { |
| 653 | + Management management = connection.management(); |
| 654 | + List<Consumer<Management>> operations = |
| 655 | + List.of( |
| 656 | + m -> m.queue(name).type(CLASSIC).argument("x-max-age", "1000s").declare(), |
| 657 | + m -> m.queue(name).type(QUORUM).argument("x-max-age", "1000s").declare(), |
| 658 | + m -> m.queue(name).type(STREAM).deadLetterRoutingKey("not-supported").declare()); |
| 659 | + operations.forEach( |
| 660 | + operation -> { |
| 661 | + try { |
| 662 | + operation.accept(management); |
| 663 | + fail("Creating a queue with unsupported arguments should trigger an exception"); |
| 664 | + } catch (AmqpException e) { |
| 665 | + assertThat(e).hasMessageContaining("409"); |
| 666 | + } |
| 667 | + }); |
| 668 | + } |
| 669 | + |
623 | 670 | private static String uuid() {
|
624 | 671 | return UUID.randomUUID().toString();
|
625 | 672 | }
|
|
0 commit comments