use of org.apache.activemq.artemis.core.postoffice.impl.WildcardAddressManager in project activemq-artemis by apache.
the class WildcardAddressManagerUnitTest method testUnitOnWildCardFailingScenario.
@Test
public void testUnitOnWildCardFailingScenario() throws Exception {
int errors = 0;
WildcardAddressManager ad = new WildcardAddressManager(new BindingFactoryFake(), null);
ad.addBinding(new BindingFake("Topic1", "Topic1"));
ad.addBinding(new BindingFake("Topic1", "one"));
ad.addBinding(new BindingFake("*", "two"));
ad.removeBinding(SimpleString.toSimpleString("one"), null);
try {
ad.removeBinding(SimpleString.toSimpleString("two"), null);
} catch (Throwable e) {
// We are not failing the test here as this test is replicating the exact scenario
// that was happening under https://issues.jboss.org/browse/HORNETQ-988
// In which this would be ignored
errors++;
e.printStackTrace();
}
try {
ad.addBinding(new BindingFake("Topic1", "three"));
} catch (Throwable e) {
// We are not failing the test here as this test is replicating the exact scenario
// that was happening under https://issues.jboss.org/browse/HORNETQ-988
// In which this would be ignored
errors++;
e.printStackTrace();
}
assertEquals("Exception happened during the process", 0, errors);
}
use of org.apache.activemq.artemis.core.postoffice.impl.WildcardAddressManager in project activemq-artemis by apache.
the class WildcardAddressManagerUnitTest method testUnitOnWildCardFailingScenarioFQQN.
@Test
public void testUnitOnWildCardFailingScenarioFQQN() throws Exception {
int errors = 0;
WildcardAddressManager ad = new WildcardAddressManager(new BindingFactoryFake(), null);
ad.addBinding(new BindingFake("Topic1", "Topic1"));
ad.addBinding(new BindingFake("Topic1", "one"));
ad.addBinding(new BindingFake("*", "two"));
ad.removeBinding(SimpleString.toSimpleString("Topic1::one"), null);
try {
ad.removeBinding(SimpleString.toSimpleString("*::two"), null);
} catch (Throwable e) {
// We are not failing the test here as this test is replicating the exact scenario
// that was happening under https://issues.jboss.org/browse/HORNETQ-988
// In which this would be ignored
errors++;
e.printStackTrace();
}
try {
ad.addBinding(new BindingFake("Topic1", "three"));
} catch (Throwable e) {
// We are not failing the test here as this test is replicating the exact scenario
// that was happening under https://issues.jboss.org/browse/HORNETQ-988
// In which this would be ignored
errors++;
e.printStackTrace();
}
assertEquals("Exception happened during the process", 0, errors);
}
use of org.apache.activemq.artemis.core.postoffice.impl.WildcardAddressManager in project activemq-artemis by apache.
the class WildcardAddressManagerUnitTest method testWildCardAddressRemoval.
/**
* Test for ARTEMIS-1610
* @throws Exception
*/
@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);
// Calling this method will trigger the wildcard to be added to the wildcard map internal
// to WildcardAddressManager
ad.getBindingsForRoutingAddress(SimpleString.toSimpleString("Topic1.#"));
// Remove the address
ad.removeAddressInfo(SimpleString.toSimpleString("Topic1.#"));
// Verify the address was cleaned up properly
assertEquals(1, wildcardAddresses.size());
assertNull(ad.getAddressInfo(SimpleString.toSimpleString("Topic1.#")));
assertNull(wildcardAddresses.get(SimpleString.toSimpleString("Topic1.#")));
}
use of org.apache.activemq.artemis.core.postoffice.impl.WildcardAddressManager in project activemq-artemis by apache.
the class WildcardAddressManagerUnitTest method testWildCardAddressRemovalDifferentWildcard.
@Test
public void testWildCardAddressRemovalDifferentWildcard() throws Exception {
final WildcardConfiguration configuration = new WildcardConfiguration();
configuration.setAnyWords('>');
WildcardAddressManager ad = new WildcardAddressManager(new BindingFactoryFake(), configuration, null);
ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic1.>"), RoutingType.MULTICAST));
ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic1.test"), RoutingType.MULTICAST));
ad.addBinding(new BindingFake("Topic1.>", "one"));
assertEquals(1, ad.getBindingsForRoutingAddress(SimpleString.toSimpleString("Topic1.>")).getBindings().size());
assertEquals(1, ad.getBindingsForRoutingAddress(SimpleString.toSimpleString("Topic1.test")).getBindings().size());
assertEquals(0, ad.getDirectBindings(SimpleString.toSimpleString("Topic1.test")).getBindings().size());
assertEquals(1, ad.getDirectBindings(SimpleString.toSimpleString("Topic1.>")).getBindings().size());
// Remove the address
ad.removeAddressInfo(SimpleString.toSimpleString("Topic1.test"));
// should still have 1 address and binding
assertEquals(1, ad.getAddresses().size());
assertEquals(1, ad.getBindings().size());
ad.removeBinding(SimpleString.toSimpleString("one"), null);
ad.removeAddressInfo(SimpleString.toSimpleString("Topic1.>"));
assertEquals(0, ad.getAddresses().size());
assertEquals(0, ad.getBindings().size());
}
use of org.apache.activemq.artemis.core.postoffice.impl.WildcardAddressManager in project activemq-artemis by apache.
the class WildcardAddressManagerUnitTest method testWildCardAddressDirectBindings.
@Test
public void testWildCardAddressDirectBindings() throws Exception {
final WildcardConfiguration configuration = new WildcardConfiguration();
configuration.setAnyWords('>');
WildcardAddressManager ad = new WildcardAddressManager(new BindingFactoryFake(), configuration, null);
ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic1.>"), RoutingType.MULTICAST));
ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic1.test"), RoutingType.MULTICAST));
ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic1.test.test1"), RoutingType.MULTICAST));
ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic1.test.test2"), RoutingType.MULTICAST));
ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic2.>"), RoutingType.MULTICAST));
ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic2.test"), RoutingType.MULTICAST));
ad.addBinding(new BindingFake("Topic1.>", "one"));
ad.addBinding(new BindingFake("Topic1.test", "two"));
ad.addBinding(new BindingFake("Topic2.test", "three"));
assertEquals(1, ad.getBindingsForRoutingAddress(SimpleString.toSimpleString("Topic1.>")).getBindings().size());
assertEquals(2, ad.getBindingsForRoutingAddress(SimpleString.toSimpleString("Topic1.test")).getBindings().size());
assertEquals(1, ad.getBindingsForRoutingAddress(SimpleString.toSimpleString("Topic1.test.test1")).getBindings().size());
assertEquals(1, ad.getBindingsForRoutingAddress(SimpleString.toSimpleString("Topic1.test.test2")).getBindings().size());
assertEquals(1, ad.getDirectBindings(SimpleString.toSimpleString("Topic1.>")).getBindings().size());
assertEquals(1, ad.getDirectBindings(SimpleString.toSimpleString("Topic1.test")).getBindings().size());
assertEquals(0, ad.getDirectBindings(SimpleString.toSimpleString("Topic1.test1")).getBindings().size());
assertEquals(0, ad.getDirectBindings(SimpleString.toSimpleString("Topic1.test2")).getBindings().size());
assertEquals(0, ad.getDirectBindings(SimpleString.toSimpleString("Topic2.>")).getBindings().size());
assertEquals(1, ad.getDirectBindings(SimpleString.toSimpleString("Topic2.test")).getBindings().size());
}
Aggregations