@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());
  }
 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;
 }