@SuppressWarnings("unchecked")
@Test
public void testWildCardAddressRemoval() throws Exception {
WildcardAddressManager ad = new WildcardAddressManager(new BindingFactoryFake(), null);
ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Queue1.#"), RoutingType.ANYCAST));
ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic1.#"), RoutingType.MULTICAST));
ad.addBinding(new BindingFake("Topic1.topic", "two"));
ad.addBinding(new BindingFake("Queue1.#", "one"));
Field wildcardAddressField = WildcardAddressManager.class.getDeclaredField("wildCardAddresses");
wildcardAddressField.setAccessible(true);
Map<SimpleString, Address> wildcardAddresses = (Map<SimpleString, Address>)wildcardAddressField.get(ad);
ad.getBindingsForRoutingAddress(SimpleString.toSimpleString("Topic1.#"));
ad.removeAddressInfo(SimpleString.toSimpleString("Topic1.#"));
assertEquals(1, wildcardAddresses.size());
assertNull(ad.getAddressInfo(SimpleString.toSimpleString("Topic1.#")));
assertNull(wildcardAddresses.get(SimpleString.toSimpleString("Topic1.#")));
}