@Test
  public void testMod() throws Exception {
    final BrokerService brokerService = new BrokerService();
    startBroker(brokerService);
    assertTrue("broker alive", brokerService.isStarted());
    assertEquals("no network connectors", 0, brokerService.getNetworkConnectors().size());

    DiscoveryNetworkConnector nc = createNetworkConnector();
    javaConfigBroker.addNetworkConnector(nc);
    TimeUnit.SECONDS.sleep(SLEEP);

    assertEquals("one network connectors", 1, brokerService.getNetworkConnectors().size());

    // track the original
    NetworkConnector networkConnector = brokerService.getNetworkConnectors().get(0);
    assertEquals("network ttl is default", 1, networkConnector.getNetworkTTL());

    nc.setNetworkTTL(2);
    javaConfigBroker.updateNetworkConnector(nc);
    TimeUnit.SECONDS.sleep(SLEEP);
    assertEquals("still one network connectors", 1, brokerService.getNetworkConnectors().size());

    NetworkConnector modNetworkConnector = brokerService.getNetworkConnectors().get(0);
    assertEquals("got ttl update", 2, modNetworkConnector.getNetworkTTL());

    // apply again - ensure no change
    javaConfigBroker.updateNetworkConnector(nc);
    assertEquals("no new network connectors", 1, brokerService.getNetworkConnectors().size());
    assertSame("same instance", modNetworkConnector, brokerService.getNetworkConnectors().get(0));
  }
 private DiscoveryNetworkConnector createNetworkConnector() throws Exception {
   DiscoveryNetworkConnector nc = new DiscoveryNetworkConnector();
   nc.setUri(new URI("static:(tcp://localhost:5555)"));
   nc.setNetworkTTL(1);
   nc.setName("one");
   nc.setExcludedDestinations(
       Arrays.asList(new ActiveMQTopic("LAN.>"), new ActiveMQQueue("LAN.>")));
   nc.setDynamicallyIncludedDestinations(
       Arrays.<ActiveMQDestination>asList(new ActiveMQQueue("DynamicallyIncluded.*")));
   nc.setStaticallyIncludedDestinations(
       Arrays.<ActiveMQDestination>asList(new ActiveMQTopic("StaticallyIncluded.*")));
   nc.setDurableDestinations(
       new HashSet<>(Arrays.<ActiveMQDestination>asList(new ActiveMQTopic("durableDest"))));
   return nc;
 }
  @Test
  public void testRemove() throws Exception {
    final BrokerService brokerService = new BrokerService();
    startBroker(brokerService);
    assertTrue("broker alive", brokerService.isStarted());
    assertEquals("no network connectors", 0, brokerService.getNetworkConnectors().size());

    DiscoveryNetworkConnector nc1 = new DiscoveryNetworkConnector();
    nc1.setUri(new URI("static:(tcp://localhost:5555)"));
    nc1.setNetworkTTL(1);
    nc1.setName("one");

    DiscoveryNetworkConnector nc2 = new DiscoveryNetworkConnector();
    nc2.setUri(new URI("static:(tcp://localhost:5555)"));
    nc2.setNetworkTTL(1);
    nc2.setName("one");

    javaConfigBroker.addNetworkConnector(nc1);
    javaConfigBroker.addNetworkConnector(nc2);

    TimeUnit.SECONDS.sleep(SLEEP);
    assertEquals("correct network connectors", 2, brokerService.getNetworkConnectors().size());

    javaConfigBroker.removeNetworkConnector(nc2);

    assertTrue(
        "expected mod on time",
        Wait.waitFor(
            new Wait.Condition() {
              @Override
              public boolean isSatisified() throws Exception {
                return 1 == brokerService.getNetworkConnectors().size();
              }
            }));

    NetworkConnector remainingNetworkConnector = brokerService.getNetworkConnectors().get(0);
    assertEquals("name match", "one", remainingNetworkConnector.getName());
  }