/*
* Copyright 2009 Red Hat, Inc.
* Red Hat licenses this file to you under the Apache License, version
* 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package org.hornetq.tests.unit.core.postoffice.impl;
import junit.framework.Assert;
import org.hornetq.api.core.SimpleString;
import org.hornetq.core.postoffice.Address;
import org.hornetq.core.postoffice.impl.AddressImpl;
import org.hornetq.tests.util.UnitTestCase;
/**
* @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
*/
public class AddressImplTest extends UnitTestCase
{
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));
}
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));
}
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));
}
public void testB()
{
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));
}
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));
}
public void testD()
{
SimpleString s1 = new SimpleString("a.b.c.d.e");
SimpleString s2 = new SimpleString("a.b.c.x.e");
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));
}
public void testE()
{
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.*.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));
}
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));
}
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));
}
public void testH()
{
SimpleString s1 = new SimpleString("a.b.c.d.e.f");
SimpleString s2 = new SimpleString("a.b.c.x.e.f");
SimpleString s3 = new SimpleString("#.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));
}
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));
}
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));
}
public void testK()
{
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.e.*");
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));
}
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));
}
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));
}
public void testN()
{
SimpleString s1 = new SimpleString("usd.stock");
SimpleString s2 = new SimpleString("a.b.x.e");
SimpleString s3 = new SimpleString("*.stock.#");
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));
}
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));
}
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));
}
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));
}
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));
}
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));
}
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));
}
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));
}
}