X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fxmlrouter%2Fimpl%2FConfigImplTest.java;h=c7b1d9c8660d2d95849411741734017d20620ba0;hb=3b2c669b25bfcb5a3c3f06ff9180d85143bebb2a;hp=aa197eaf54274e44fee6d9ba87555d0381833735;hpb=d7938dd34e22ba8d34b4a89840c6efbb5d866380;p=xmlrouter diff --git a/impl/src/test/java/org/wamblee/xmlrouter/impl/ConfigImplTest.java b/impl/src/test/java/org/wamblee/xmlrouter/impl/ConfigImplTest.java index aa197ea..c7b1d9c 100644 --- a/impl/src/test/java/org/wamblee/xmlrouter/impl/ConfigImplTest.java +++ b/impl/src/test/java/org/wamblee/xmlrouter/impl/ConfigImplTest.java @@ -23,7 +23,6 @@ import java.util.concurrent.atomic.AtomicLong; import org.junit.Before; import org.junit.Test; import org.wamblee.xmlrouter.common.Id; -import org.wamblee.xmlrouter.config.Config; import org.wamblee.xmlrouter.config.Identifiable; public class ConfigImplTest { @@ -35,11 +34,9 @@ public class ConfigImplTest { } private static class MyTypeWrapper implements MyType { - private String prefix; private MyType type; - public MyTypeWrapper(String aPrefix, MyType aType) { - prefix = aPrefix; + public MyTypeWrapper(MyType aType) { type = aType; } @@ -49,13 +46,13 @@ public class ConfigImplTest { @Override public Id getId() { - return new Id(prefix + type.getId().getId()); + return type.getId(); } } public static final class MyTypeConfig extends ConfigImpl { - public MyTypeConfig(Id aId) { - super(aId); + public MyTypeConfig(String aId) { + super(MyType.class, aId); } public MyTypeConfig(MyTypeConfig aConfig) { @@ -63,8 +60,8 @@ public class ConfigImplTest { } @Override - public MyType wrap(String aPrefix, MyType aT) { - return new MyTypeWrapper(aPrefix, aT); + public MyType wrap(MyType aT) { + return new MyTypeWrapper(aT); } } @@ -74,7 +71,7 @@ public class ConfigImplTest { @Before public void setUp() { sequence = new AtomicLong(1L); - config = new MyTypeConfig(new Id(CONFIG_TYPE)); + config = new MyTypeConfig(CONFIG_TYPE); } @Test @@ -89,8 +86,7 @@ public class ConfigImplTest { assertTrue(firstValue instanceof MyTypeWrapper); assertSame(type1, ((MyTypeWrapper) firstValue).getType()); - assertEquals(CONFIG_TYPE + "." + type1.getId().getId(), firstValue - .getId().getId()); + assertEquals(type1.getId().getId(), firstValue.getId().getId()); // add another one. MyType type2 = mock(MyType.class); @@ -121,22 +117,11 @@ public class ConfigImplTest { @Test public void testEquals() { - Config config1 = new ConfigImpl(new Id( - CONFIG_TYPE)) { - @Override - public MyType wrap(String aPrefix, MyType aT) { - return new MyTypeWrapper(aPrefix, aT); - } - }; + Config config1 = new MyTypeConfig(CONFIG_TYPE); assertFalse(config1.equals(null)); assertFalse(config1.equals("hello")); - Config config2 = new ConfigImpl(new Id( - CONFIG_TYPE)) { - @Override - public MyType wrap(String aPrefix, MyType aT) { - return new MyTypeWrapper(aPrefix, aT); - } - }; + Config config2 = new MyTypeConfig(CONFIG_TYPE); + assertEquals(config1, config2); assertEquals(config1.hashCode(), config2.hashCode()); @@ -162,7 +147,7 @@ public class ConfigImplTest { testAdd(); assertEquals(2, config.values().size()); MyTypeConfig copy = new MyTypeConfig(config); - assertEquals(config.getId(), config.getId()); + assertEquals(config.getPrefix(), copy.getPrefix()); assertEquals(config, copy); // verify the copy is not shallow