2020import org .apache .activemq .broker .jmx .BrokerViewMBean ;
2121import org .apache .activemq .broker .jmx .NetworkConnectorViewMBean ;
2222import org .junit .After ;
23- import org .junit .AfterClass ;
2423import org .junit .Before ;
2524import org .junit .Test ;
2625
2726import javax .management .ObjectName ;
27+ import org .slf4j .Logger ;
28+ import org .slf4j .LoggerFactory ;
2829
30+ import static org .apache .activemq .broker .jmx .BrokerView .DENIED_TRANSPORT_SCHEMES ;
2931import static org .junit .Assert .assertEquals ;
3032import static org .junit .Assert .assertNotNull ;
3133import static org .junit .Assert .fail ;
3638 */
3739public class JmxCreateNCTest {
3840
41+ private static final Logger LOG = LoggerFactory .getLogger (JmxCreateNCTest .class );
42+
3943 private static final String BROKER_NAME = "jmx-broker" ;
4044
4145 private BrokerService broker ;
@@ -79,43 +83,34 @@ public void testBridgeRegistration() throws Exception {
7983 }
8084
8185 @ 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+ }
8991 }
9092
91- protected void testDeniedBridgeBlocked (String scheme ) throws Exception {
93+ protected void testTransportSchemeBridgeBlocked (String scheme ) throws Exception {
9294 // Test composite network connector uri
9395 try {
9496 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 );
10398 } catch (IllegalArgumentException e ) {
10499 assertEquals ("Transport scheme '" + scheme + "' is not allowed" , e .getMessage ());
105100 }
106101
107102 // verify direct connector as well
108103 try {
109104 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 );
111106 } catch (IllegalArgumentException e ) {
112107 assertEquals ("Transport scheme '" + scheme + "' is not allowed" , e .getMessage ());
113108 }
114109
115110 try {
116111 // verify nested composite URI is blocked
117- proxy .addNetworkConnector ("static:(failover:(failover :(tcp://localhost:0," + scheme + "://localhost)))" );
118- fail ("Should have failed trying to add connector bridge" );
112+ proxy .addNetworkConnector ("static:(static:(static :(tcp://localhost:0," + scheme + "://localhost)))" );
113+ fail ("Should have failed trying to add connector bridge with scheme: " + scheme );
119114 } catch (IllegalArgumentException e ) {
120115 assertEquals ("Transport scheme '" + scheme + "' is not allowed" , e .getMessage ());
121116 }
@@ -131,7 +126,7 @@ public void testAddNetworkConnectorMaxComposite() throws Exception {
131126 // verify nested composite URI with more than 5 levels is blocked. This has 6 nested
132127 // (not including first wrapper url
133128 proxy .addNetworkConnector (
134- "static:(failover:(failover:(failover:(failover:(failover :(tcp://localhost:0))))))" );
129+ "static:(static:(static:(static:(static:(static :(tcp://localhost:0))))))" );
135130 fail ("Should have failed trying to add more than 5 connector bridges" );
136131 } catch (IllegalArgumentException e ) {
137132 assertEquals ("URI can't contain more than 5 nested composite URIs" , e .getMessage ());
0 commit comments