use of org.apache.activemq.artemis.core.postoffice.Address in project activemq-artemis by apache.
the class AddressImplTest method testJ.
@Test
public void testJ() {
SimpleString s1 = new SimpleString("a.b.c.d.e.f");
SimpleString s2 = new SimpleString("a.b.c.x.e.f");
SimpleString s3 = new SimpleString("a.#.c.d.e.f");
Address a1 = new AddressImpl(s1);
Address a2 = new AddressImpl(s2);
Address w = new AddressImpl(s3);
Assert.assertTrue(a1.matches(w));
Assert.assertFalse(a2.matches(w));
}
use of org.apache.activemq.artemis.core.postoffice.Address in project activemq-artemis by apache.
the class AddressImplTest method testA.
@Test
public void testA() {
SimpleString s1 = new SimpleString("a.b.c");
SimpleString s2 = new SimpleString("a.b.c.d.e.f.g.h.i.j.k.l.m.n.*");
Address a1 = new AddressImpl(s1);
Address a2 = new AddressImpl(s2);
Assert.assertFalse(a1.matches(a2));
}
use of org.apache.activemq.artemis.core.postoffice.Address in project activemq-artemis by apache.
the class AddressImplTest method testL.
@Test
public void testL() {
SimpleString s1 = new SimpleString("a.b.c.d.e.f");
SimpleString s2 = new SimpleString("a.b.c.d.e.x");
SimpleString s3 = new SimpleString("a.#.c.d.*.f");
Address a1 = new AddressImpl(s1);
Address a2 = new AddressImpl(s2);
Address w = new AddressImpl(s3);
Assert.assertTrue(a1.matches(w));
Assert.assertFalse(a2.matches(w));
}
use of org.apache.activemq.artemis.core.postoffice.Address in project activemq-artemis by apache.
the class WildcardAddressManager method getBindingsForRoutingAddress.
@Override
public Bindings getBindingsForRoutingAddress(final SimpleString address) throws Exception {
Bindings bindings = super.getBindingsForRoutingAddress(address);
// this should only happen if we're routing to an address that has no mappings when we're running checkAllowable
if (bindings == null && !wildCardAddresses.isEmpty()) {
Address add = addAndUpdateAddressMap(address);
if (!add.containsWildCard()) {
for (Address destAdd : add.getLinkedAddresses()) {
Bindings b = super.getBindingsForRoutingAddress(destAdd.getAddress());
if (b != null) {
Collection<Binding> theBindings = b.getBindings();
for (Binding theBinding : theBindings) {
super.addMappingInternal(address, theBinding);
}
super.getBindingsForRoutingAddress(address).setMessageLoadBalancingType(b.getMessageLoadBalancingType());
}
}
}
bindings = super.getBindingsForRoutingAddress(address);
}
return bindings;
}
use of org.apache.activemq.artemis.core.postoffice.Address 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.#")));
}
Aggregations