private Address getAddress(final SimpleString address) { Address add = new AddressImpl(address, wildcardConfiguration); Address actualAddress; if (add.containsWildCard()) { actualAddress = wildCardAddresses.get(address); } else { actualAddress = addresses.get(address); } return actualAddress != null ? actualAddress : add; }
@Override public Bindings getMatchingBindings(final SimpleString address) throws Exception { SimpleString realAddress = CompositeAddress.extractAddressName(address); Address add = new AddressImpl(realAddress, wildcardConfiguration); Bindings bindings = bindingsFactory.createBindings(realAddress); for (Binding binding : nameMap.values()) { Address addCheck = new AddressImpl(binding.getAddress(), wildcardConfiguration); if (addCheck.matches(add)) { bindings.addBinding(binding); } } return bindings; }
@Override public AddressInfo removeAddressInfo(SimpleString address) throws Exception { final AddressInfo removed = super.removeAddressInfo(address); if (removed != null) { //Remove from mappings so removeAndUpdateAddressMap processes and cleanup mappings.remove(address); removeAndUpdateAddressMap(new AddressImpl(removed.getName(), wildcardConfiguration)); } return removed; }
private synchronized Address addAndUpdateAddressMap(final SimpleString address) { Address add = new AddressImpl(address, wildcardConfiguration); Address actualAddress; if (add.containsWildCard()) { actualAddress = wildCardAddresses.get(address); } else { actualAddress = addresses.get(address); } if (actualAddress == null) { actualAddress = add; addAddress(address, actualAddress); } if (actualAddress.containsWildCard()) { for (Address destAdd : addresses.values()) { if (destAdd.matches(actualAddress)) { destAdd.addLinkedAddress(actualAddress); actualAddress.addLinkedAddress(destAdd); } } } else { for (Address destAdd : wildCardAddresses.values()) { if (actualAddress.matches(destAdd)) { destAdd.addLinkedAddress(actualAddress); actualAddress.addLinkedAddress(destAdd); } } } return actualAddress; }
@Test public void testT() { SimpleString s1 = new SimpleString("a.b.c.d"); SimpleString s3 = new SimpleString("*a.b.c"); Address a1 = new AddressImpl(s1); Address w = new AddressImpl(s3); Assert.assertFalse(a1.matches(w)); }
@Test public void testP() { SimpleString s1 = new SimpleString("a.b.c.d"); SimpleString s3 = new SimpleString("a.b.c#"); Address a1 = new AddressImpl(s1); Address w = new AddressImpl(s3); Assert.assertFalse(a1.matches(w)); }
@Test public void testS() { SimpleString s1 = new SimpleString("a.b.c.d"); SimpleString s3 = new SimpleString("a.b.c*"); Address a1 = new AddressImpl(s1); Address w = new AddressImpl(s3); Assert.assertFalse(a1.matches(w)); }
@Test public void testDotsSameLength2() { SimpleString s1 = new SimpleString("a.b"); SimpleString s2 = new SimpleString("a.b"); Address a1 = new AddressImpl(s1); Address a2 = new AddressImpl(s2); Assert.assertTrue(a1.matches(a2)); }
@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)); }
@Test public void testQ() { SimpleString s1 = new SimpleString("a.b.c.d"); SimpleString s3 = new SimpleString("#a.b.c"); Address a1 = new AddressImpl(s1); Address w = new AddressImpl(s3); Assert.assertFalse(a1.matches(w)); }
@Test public void testR() { SimpleString s1 = new SimpleString("a.b.c.d"); SimpleString s3 = new SimpleString("#*a.b.c"); Address a1 = new AddressImpl(s1); Address w = new AddressImpl(s3); Assert.assertFalse(a1.matches(w)); }
@Test public void testNoDots() { SimpleString s1 = new SimpleString("abcde"); SimpleString s2 = new SimpleString("abcde"); Address a1 = new AddressImpl(s1); Address a2 = new AddressImpl(s2); Assert.assertTrue(a1.matches(a2)); }
@Test public void testU() { SimpleString s1 = new SimpleString("a.b.c.d"); SimpleString s3 = new SimpleString("*a.b.c"); Address a1 = new AddressImpl(s1); Address w = new AddressImpl(s3); Assert.assertFalse(a1.matches(w)); }
/** * https://issues.apache.org/jira/browse/ARTEMIS-1890 */ @Test public void testV() { final SimpleString s1 = new SimpleString("a.b.d"); final SimpleString s3 = new SimpleString("a.b.#.d"); final Address a1 = new AddressImpl(s1); final Address w = new AddressImpl(s3); Assert.assertTrue(a1.matches(w)); } }
@Test public void testC() { SimpleString s1 = new SimpleString("a.b.c.d"); SimpleString s2 = new SimpleString("a.b.c.x"); SimpleString s3 = new SimpleString("a.b.*.d"); 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)); }
@Test public void testI() { 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.#.b.#"); Address a1 = new AddressImpl(s1); Address a2 = new AddressImpl(s2); Address w = new AddressImpl(s3); Assert.assertTrue(a1.matches(w)); Assert.assertTrue(a2.matches(w)); }
@Test public void testM() { SimpleString s1 = new SimpleString("a.b.c"); SimpleString s2 = new SimpleString("a.b.x.e"); SimpleString s3 = new SimpleString("a.b.c.#"); 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)); }
@Test public void testF() { SimpleString s1 = new SimpleString("a.b.c.d.e.f"); SimpleString s2 = new SimpleString("a.b.c.x.e.f"); SimpleString s3 = new SimpleString("#"); Address a1 = new AddressImpl(s1); Address a2 = new AddressImpl(s2); Address w = new AddressImpl(s3); Assert.assertTrue(a1.matches(w)); Assert.assertTrue(a2.matches(w)); }
@Test public void testG() { 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.#"); Address a1 = new AddressImpl(s1); Address a2 = new AddressImpl(s2); Address w = new AddressImpl(s3); Assert.assertTrue(a1.matches(w)); Assert.assertTrue(a2.matches(w)); }
@Test public void testO() { SimpleString s1 = new SimpleString("a.b.c.d"); SimpleString s2 = new SimpleString("a.b.x.e"); SimpleString s3 = new SimpleString("a.b.c.*"); 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)); }