|
20 | 20 | import org.apache.activemq.broker.jmx.BrokerViewMBean; |
21 | 21 | import org.apache.activemq.broker.jmx.NetworkConnectorViewMBean; |
22 | 22 | import org.junit.After; |
23 | | -import org.junit.AfterClass; |
24 | 23 | import org.junit.Before; |
25 | 24 | import org.junit.Test; |
26 | 25 |
|
27 | 26 | import javax.management.ObjectName; |
| 27 | +import org.slf4j.Logger; |
| 28 | +import org.slf4j.LoggerFactory; |
28 | 29 |
|
| 30 | +import static org.apache.activemq.broker.jmx.BrokerView.DENIED_TRANSPORT_SCHEMES; |
29 | 31 | import static org.junit.Assert.assertEquals; |
30 | 32 | import static org.junit.Assert.assertNotNull; |
31 | 33 | import static org.junit.Assert.fail; |
|
36 | 38 | */ |
37 | 39 | public class JmxCreateNCTest { |
38 | 40 |
|
| 41 | + private static final Logger LOG = LoggerFactory.getLogger(JmxCreateNCTest.class); |
| 42 | + |
39 | 43 | private static final String BROKER_NAME = "jmx-broker"; |
40 | 44 |
|
41 | 45 | private BrokerService broker; |
@@ -79,43 +83,34 @@ public void testBridgeRegistration() throws Exception { |
79 | 83 | } |
80 | 84 |
|
81 | 85 | @Test |
82 | | - public void testVmBridgeBlocked() throws Exception { |
83 | | - testDeniedBridgeBlocked("vm"); |
84 | | - } |
85 | | - |
86 | | - @Test |
87 | | - public void testHttpBridgeBlocked() throws Exception { |
88 | | - testDeniedBridgeBlocked("http"); |
| 86 | + public void testTransportSchemeBridgeBlocked() throws Exception { |
| 87 | + for (String deniedScheme : DENIED_TRANSPORT_SCHEMES) { |
| 88 | + LOG.info("verify testTransportSchemeBridgeBlocked scheme: {}", deniedScheme); |
| 89 | + testTransportSchemeBridgeBlocked(deniedScheme); |
| 90 | + } |
89 | 91 | } |
90 | 92 |
|
91 | | - protected void testDeniedBridgeBlocked(String scheme) throws Exception { |
| 93 | + protected void testTransportSchemeBridgeBlocked(String scheme) throws Exception { |
92 | 94 | // Test composite network connector uri |
93 | 95 | try { |
94 | 96 | proxy.addNetworkConnector("static:(" + scheme + "://localhost)"); |
95 | | - fail("Should have failed trying to add connector bridge"); |
96 | | - } catch (IllegalArgumentException e) { |
97 | | - assertEquals("Transport scheme '" + scheme + "' is not allowed", e.getMessage()); |
98 | | - } |
99 | | - |
100 | | - try { |
101 | | - proxy.addNetworkConnector("multicast:(" + scheme + "://localhost)"); |
102 | | - fail("Should have failed trying to add connector bridge"); |
| 97 | + fail("Should have failed trying to add connector bridge with scheme: " + scheme); |
103 | 98 | } catch (IllegalArgumentException e) { |
104 | 99 | assertEquals("Transport scheme '" + scheme + "' is not allowed", e.getMessage()); |
105 | 100 | } |
106 | 101 |
|
107 | 102 | // verify direct connector as well |
108 | 103 | try { |
109 | 104 | proxy.addNetworkConnector(scheme + "://localhost"); |
110 | | - fail("Should have failed trying to add connector bridge"); |
| 105 | + fail("Should have failed trying to add connector bridge with scheme: " + scheme); |
111 | 106 | } catch (IllegalArgumentException e) { |
112 | 107 | assertEquals("Transport scheme '" + scheme + "' is not allowed", e.getMessage()); |
113 | 108 | } |
114 | 109 |
|
115 | 110 | try { |
116 | 111 | // verify nested composite URI is blocked |
117 | 112 | proxy.addNetworkConnector("static:(failover:(failover:(tcp://localhost:0," + scheme + "://localhost)))"); |
118 | | - fail("Should have failed trying to add connector bridge"); |
| 113 | + fail("Should have failed trying to add connector bridge with scheme: " + scheme); |
119 | 114 | } catch (IllegalArgumentException e) { |
120 | 115 | assertEquals("Transport scheme '" + scheme + "' is not allowed", e.getMessage()); |
121 | 116 | } |
|
0 commit comments