public void testAttributes() throws Exception
{
TransportConfiguration connectorConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName());
List<Pair<String, String>> connectorInfos = new ArrayList<Pair<String, String>>();
connectorInfos.add(new Pair<String, String>(connectorConfiguration.getName(), null));
BroadcastGroupConfiguration broadcastGroupConfig = BroadcastGroupControlTest.randomBroadcastGroupConfiguration(connectorInfos);
Configuration conf = new ConfigurationImpl();
conf.setSecurityEnabled(false);
conf.setJMXManagementEnabled(true);
conf.setClustered(true);
conf.getConnectorConfigurations().put(connectorConfiguration.getName(), connectorConfiguration);
conf.getBroadcastGroupConfigurations().add(broadcastGroupConfig);
conf.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
service = HornetQServers.newHornetQServer(conf, mbeanServer, false);
service.start();
BroadcastGroupControl broadcastGroupControl = createManagementControl(broadcastGroupConfig.getName());
Assert.assertEquals(broadcastGroupConfig.getName(), broadcastGroupControl.getName());
Assert.assertEquals(broadcastGroupConfig.getGroupAddress(), broadcastGroupControl.getGroupAddress());
Assert.assertEquals(broadcastGroupConfig.getGroupPort(), broadcastGroupControl.getGroupPort());
Assert.assertEquals(broadcastGroupConfig.getLocalBindPort(), broadcastGroupControl.getLocalBindPort());
Assert.assertEquals(broadcastGroupConfig.getBroadcastPeriod(), broadcastGroupControl.getBroadcastPeriod());
Object[] connectorPairs = broadcastGroupControl.getConnectorPairs();
Assert.assertEquals(1, connectorPairs.length);
Object[] connectorPairData = (Object[])connectorPairs[0];
Assert.assertEquals(broadcastGroupConfig.getConnectorInfos().get(0).a, connectorPairData[0]);
Assert.assertEquals(broadcastGroupConfig.getConnectorInfos().get(0).b, connectorPairData[1]);
String jsonString = broadcastGroupControl.getConnectorPairsAsJSON();
Assert.assertNotNull(jsonString);
JSONArray array = new JSONArray(jsonString);
Assert.assertEquals(1, array.length());
JSONObject data = array.getJSONObject(0);
Assert.assertEquals(broadcastGroupConfig.getConnectorInfos().get(0).a, data.optString("a"));
Assert.assertEquals(broadcastGroupConfig.getConnectorInfos().get(0).b, data.optString("b", null));
Assert.assertTrue(broadcastGroupControl.isStarted());
}