Search in sources :

Example 16 with Address

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));
}
Also used : Address(org.apache.activemq.artemis.core.postoffice.Address) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) AddressImpl(org.apache.activemq.artemis.core.postoffice.impl.AddressImpl) Test(org.junit.Test)

Example 17 with Address

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));
}
Also used : Address(org.apache.activemq.artemis.core.postoffice.Address) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) AddressImpl(org.apache.activemq.artemis.core.postoffice.impl.AddressImpl) Test(org.junit.Test)

Example 18 with Address

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));
}
Also used : Address(org.apache.activemq.artemis.core.postoffice.Address) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) AddressImpl(org.apache.activemq.artemis.core.postoffice.impl.AddressImpl) Test(org.junit.Test)

Example 19 with Address

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;
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) Address(org.apache.activemq.artemis.core.postoffice.Address) Bindings(org.apache.activemq.artemis.core.postoffice.Bindings)

Example 20 with Address

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.#")));
}
Also used : Field(java.lang.reflect.Field) WildcardAddressManager(org.apache.activemq.artemis.core.postoffice.impl.WildcardAddressManager) Address(org.apache.activemq.artemis.core.postoffice.Address) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Map(java.util.Map) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Aggregations

Address (org.apache.activemq.artemis.core.postoffice.Address)31 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)24 Test (org.junit.Test)24 AddressImpl (org.apache.activemq.artemis.core.postoffice.impl.AddressImpl)23 Bindings (org.apache.activemq.artemis.core.postoffice.Bindings)4 Binding (org.apache.activemq.artemis.core.postoffice.Binding)3 Field (java.lang.reflect.Field)1 Map (java.util.Map)1 QueueBinding (org.apache.activemq.artemis.core.postoffice.QueueBinding)1 WildcardAddressManager (org.apache.activemq.artemis.core.postoffice.impl.WildcardAddressManager)1 AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)1 CompositeAddress (org.apache.activemq.artemis.utils.CompositeAddress)1