|
16 | 16 | */ |
17 | 17 | package org.apache.activemq.artemis.tests.integration.client; |
18 | 18 |
|
| 19 | +import java.lang.invoke.MethodHandles; |
| 20 | + |
19 | 21 | import org.apache.activemq.artemis.api.core.QueueConfiguration; |
| 22 | +import org.apache.activemq.artemis.api.core.RoutingType; |
20 | 23 | import org.apache.activemq.artemis.api.core.SimpleString; |
21 | 24 | import org.apache.activemq.artemis.api.core.client.ClientConsumer; |
22 | 25 | import org.apache.activemq.artemis.api.core.client.ClientMessage; |
|
27 | 30 | import org.apache.activemq.artemis.core.config.Configuration; |
28 | 31 | import org.apache.activemq.artemis.core.server.ActiveMQServer; |
29 | 32 | import org.apache.activemq.artemis.core.server.ActiveMQServers; |
| 33 | +import org.apache.activemq.artemis.core.server.impl.AddressInfo; |
| 34 | +import org.apache.activemq.artemis.logs.AssertionLoggerHandler; |
30 | 35 | import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; |
31 | 36 | import org.junit.jupiter.api.BeforeEach; |
32 | 37 | import org.junit.jupiter.api.Test; |
| 38 | +import org.slf4j.Logger; |
| 39 | +import org.slf4j.LoggerFactory; |
33 | 40 |
|
34 | 41 | import static org.junit.jupiter.api.Assertions.assertEquals; |
35 | 42 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
36 | 43 | import static org.junit.jupiter.api.Assertions.assertNull; |
| 44 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
| 45 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
37 | 46 |
|
38 | 47 | public class WildCardRoutingTest extends ActiveMQTestBase { |
39 | 48 |
|
| 49 | + private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); |
| 50 | + |
40 | 51 | private ActiveMQServer server; |
41 | 52 | private ServerLocator locator; |
42 | 53 | private ClientSession clientSession; |
@@ -755,6 +766,27 @@ public void testLargeWildcardRouting() throws Exception { |
755 | 766 | assertEquals(0, server.getPostOffice().getBindingsForAddress(address).getBindings().size()); |
756 | 767 | } |
757 | 768 |
|
| 769 | + |
| 770 | + @Test |
| 771 | + public void testInvalidWildcard() throws Exception { |
| 772 | + String wildcardAddress = "a.*.*.*.*.*.*"; |
| 773 | + server.addAddressInfo(new AddressInfo(wildcardAddress).addRoutingType(RoutingType.ANYCAST)); |
| 774 | + |
| 775 | + try (AssertionLoggerHandler loggerHandler = new AssertionLoggerHandler(true)) { |
| 776 | + assertThrows(Exception.class, () -> { |
| 777 | + try { |
| 778 | + ClientProducer producer = clientSession.createProducer(wildcardAddress); |
| 779 | + producer.send(clientSession.createMessage(true)); |
| 780 | + } catch (Exception e) { |
| 781 | + logger.warn(e.getMessage(), e); |
| 782 | + throw e; |
| 783 | + } |
| 784 | + }); |
| 785 | + assertTrue(loggerHandler.findText("AMQ229260")); |
| 786 | + } |
| 787 | + } |
| 788 | + |
| 789 | + |
758 | 790 | @Override |
759 | 791 | @BeforeEach |
760 | 792 | public void setUp() throws Exception { |
|
0 commit comments