From 2e9a88b0478d074974818dc384ca45c2bf4fdaa5 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Tue, 9 Aug 2011 17:30:59 +0200 Subject: [PATCH] removed the prefix argument from ConfigImpl.wrap(). --- .../org/wamblee/xmlrouter/impl/ConfigImpl.java | 4 ++-- .../xmlrouter/impl/RobustDocumentType.java | 4 ++-- .../org/wamblee/xmlrouter/impl/RobustFilter.java | 4 +--- .../xmlrouter/impl/RobustIdentifiable.java | 4 +--- .../xmlrouter/impl/RobustTransformation.java | 4 ++-- .../xmlrouter/impl/SingleRouterConfig.java | 11 +++++------ .../xmlrouter/impl/XMLRouterConfigService.java | 4 ++-- .../xmlrouter/impl/CompositeConfigTest.java | 12 ++++++------ .../wamblee/xmlrouter/impl/ConfigImplTest.java | 13 +++++-------- .../xmlrouter/impl/RobustDocumentTypeTest.java | 2 +- .../xmlrouter/impl/RobustIdentifiableTest.java | 16 ++++++++-------- .../xmlrouter/impl/RobustTransformationTest.java | 2 +- 12 files changed, 36 insertions(+), 44 deletions(-) diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java index 0e1da0b..777ecd0 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java @@ -88,7 +88,7 @@ public abstract class ConfigImpl> implements if (registered.containsKey(aT.getId())) { throw new ConfigException("Duplicate id '" + aT.getId() + "'"); } - registered.put(aT.getId(), wrap(id.getId() + ".", aT)); + registered.put(aT.getId(), wrap(aT)); } /** @@ -98,7 +98,7 @@ public abstract class ConfigImpl> implements * Object to wrap. * @return Wrapped object. */ - public abstract T wrap(String aPrefix, T aT); + public abstract T wrap(T aT); /* * (non-Javadoc) diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustDocumentType.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustDocumentType.java index 3f26f7b..5224483 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustDocumentType.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustDocumentType.java @@ -45,8 +45,8 @@ public class RobustDocumentType extends RobustIdentifiable * @param aType * Document type to wrap. */ - public RobustDocumentType(String aPrefix, DocumentType aType) { - super(aPrefix, aType); + public RobustDocumentType(DocumentType aType) { + super(aType); type = aType; } diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustFilter.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustFilter.java index 823c64d..625f894 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustFilter.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustFilter.java @@ -38,15 +38,13 @@ public class RobustFilter extends RobustIdentifiable implements Filter { /** * Constructs the wrapper. * - * @param aPrefix - * prefix to use for ids. * @param aId * Id. * @param aFilter * Filter to wrap. */ public RobustFilter(String aPrefix, Filter aFilter) { - super(aPrefix, aFilter); + super(aFilter); filter = aFilter; } diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustIdentifiable.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustIdentifiable.java index 47b0000..2e63a97 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustIdentifiable.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustIdentifiable.java @@ -38,15 +38,13 @@ public class RobustIdentifiable implements Identifiable { private Id id; - public RobustIdentifiable(String aPrefix, Identifiable aIdentifiable) { - notNull("prefix", aPrefix); + public RobustIdentifiable(Identifiable aIdentifiable) { notNull("identifiable", aIdentifiable); try { id = aIdentifiable.getId(); if (id == null) { throwConfigException("identifiable.getId() returned null", null); } - id = new Id(aPrefix + id.getId()); } catch (Exception e) { throwConfigException("identifiable.getId() threw exception", e); } diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustTransformation.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustTransformation.java index cf0210d..2fa025e 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustTransformation.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustTransformation.java @@ -45,8 +45,8 @@ public class RobustTransformation extends RobustIdentifiable * @param aTransformation * Wrapped transformation. */ - public RobustTransformation(String aPrefix, Transformation aTransformation) { - super(aPrefix, aTransformation); + public RobustTransformation(Transformation aTransformation) { + super(aTransformation); transformation = aTransformation; } diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java index 4ecaad4..d7d8070 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java @@ -42,8 +42,8 @@ public class SingleRouterConfig implements ExtendedRouterConfig { } @Override - public DocumentType wrap(String aPrefix, DocumentType aT) { - return new RobustDocumentType("", aT); + public DocumentType wrap(DocumentType aT) { + return new RobustDocumentType(aT); } } @@ -58,9 +58,8 @@ public class SingleRouterConfig implements ExtendedRouterConfig { } @Override - public Transformation wrap(String aPrefix, - Transformation aTransformation) { - return new RobustTransformation("", aTransformation); + public Transformation wrap(Transformation aTransformation) { + return new RobustTransformation(aTransformation); } } @@ -74,7 +73,7 @@ public class SingleRouterConfig implements ExtendedRouterConfig { } @Override - public Filter wrap(String aPrefix, Filter aFilter) { + public Filter wrap(Filter aFilter) { return new RobustFilter("", aFilter); } } diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java index da883d2..198855e 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java @@ -46,11 +46,11 @@ public class XMLRouterConfigService implements RouterConfigService { config = aConfig; routerConfigs = new ConfigImpl(RouterConfig.class, new Id(aApplication)) { - public RouterConfig wrap(final String aPrefix, final RouterConfig aT) { + public RouterConfig wrap(final RouterConfig aT) { return new RouterConfig() { @Override public Id getId() { - return new Id(aT.getId().toString()); + return aT.getId(); } @Override diff --git a/impl/src/test/java/org/wamblee/xmlrouter/impl/CompositeConfigTest.java b/impl/src/test/java/org/wamblee/xmlrouter/impl/CompositeConfigTest.java index cd0879d..efca721 100644 --- a/impl/src/test/java/org/wamblee/xmlrouter/impl/CompositeConfigTest.java +++ b/impl/src/test/java/org/wamblee/xmlrouter/impl/CompositeConfigTest.java @@ -90,14 +90,14 @@ public class CompositeConfigTest { Config c1 = new ConfigImpl( StringClassInterface.class, id("c1")) { @Override - public Identifiable wrap(String aPrefix, Identifiable aT) { + public Identifiable wrap(Identifiable aT) { return aT; } }; Config c2 = new ConfigImpl( StringClassInterface.class, id("c2")) { @Override - public Identifiable wrap(String aPrefix, Identifiable aT) { + public Identifiable wrap(Identifiable aT) { return aT; } }; @@ -141,14 +141,14 @@ public class CompositeConfigTest { Config c1 = new ConfigImpl( StringClassInterface.class, id("c1")) { @Override - public Identifiable wrap(String aPrefix, Identifiable aT) { + public Identifiable wrap(Identifiable aT) { return aT; } }; Config c2 = new ConfigImpl( StringClassInterface.class, id("c1")) { @Override - public Identifiable wrap(String aPrefix, Identifiable aT) { + public Identifiable wrap(Identifiable aT) { return aT; } }; @@ -162,14 +162,14 @@ public class CompositeConfigTest { Config c1 = new ConfigImpl( StringClassInterface.class, id("c.x")) { @Override - public Identifiable wrap(String aPrefix, Identifiable aT) { + public Identifiable wrap(Identifiable aT) { return aT; } }; Config c2 = new ConfigImpl( StringClassInterface.class, id("c")) { @Override - public Identifiable wrap(String aPrefix, Identifiable aT) { + public Identifiable wrap(Identifiable aT) { return aT; } }; 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 8586012..9925c0b 100644 --- a/impl/src/test/java/org/wamblee/xmlrouter/impl/ConfigImplTest.java +++ b/impl/src/test/java/org/wamblee/xmlrouter/impl/ConfigImplTest.java @@ -35,11 +35,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,7 +47,7 @@ public class ConfigImplTest { @Override public Id getId() { - return new Id(prefix + type.getId().getId()); + return type.getId(); } } @@ -63,8 +61,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); } } @@ -89,8 +87,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); diff --git a/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustDocumentTypeTest.java b/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustDocumentTypeTest.java index 2c295b5..8db9ff2 100644 --- a/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustDocumentTypeTest.java +++ b/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustDocumentTypeTest.java @@ -36,7 +36,7 @@ public class RobustDocumentTypeTest { public void setUp() { documentType = mock(DocumentType.class); when(documentType.getId()).thenReturn(new Id("docid")); - robust = new RobustDocumentType("app1", documentType); + robust = new RobustDocumentType(documentType); source = mock(DOMSource.class); } diff --git a/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustIdentifiableTest.java b/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustIdentifiableTest.java index 257ea93..86d55ab 100644 --- a/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustIdentifiableTest.java +++ b/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustIdentifiableTest.java @@ -37,26 +37,26 @@ public class RobustIdentifiableTest { public void testIdIsNull() { when(ident.getId()).thenReturn(null); RobustIdentifiable robust = new RobustIdentifiable( - "prefix", ident); + ident); } @Test(expected = ConfigException.class) public void testIdThrowsException() { doThrow(new RuntimeException("xxx")).when(ident).getId(); RobustIdentifiable robust = new RobustIdentifiable( - "prefix", ident); + ident); } @Test public void testNormalCase() { when(ident.getId()).thenReturn(new Id("myid")); RobustIdentifiable robust = new RobustIdentifiable( - "prefix.", ident); - assertEquals("prefix.myid", robust.getId().toString()); + ident); + assertEquals("myid", robust.getId().toString()); // changes later do not have any effect, the id should be immutable. when(ident.getId()).thenReturn(new Id("myid2")); - assertEquals("prefix.myid", robust.getId().toString()); + assertEquals("myid", robust.getId().toString()); } @Test @@ -70,11 +70,11 @@ public class RobustIdentifiableTest { when(ident3.getId()).thenReturn(new Id("x")); RobustIdentifiable robust1 = new RobustIdentifiable( - "prefix.", ident1); + ident1); RobustIdentifiable robust2 = new RobustIdentifiable( - "prefix.", ident2); + ident2); RobustIdentifiable robust3 = new RobustIdentifiable( - "prefix.", ident3); + ident3); assertEquals(robust1, robust1); assertEquals(robust1, robust3); diff --git a/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustTransformationTest.java b/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustTransformationTest.java index 5e73d6f..f7b4ec6 100644 --- a/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustTransformationTest.java +++ b/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustTransformationTest.java @@ -36,7 +36,7 @@ public class RobustTransformationTest { public void setUp() { transformation = mock(Transformation.class); when(transformation.getId()).thenReturn(new Id("t1")); - robust = new RobustTransformation("transformation", transformation); + robust = new RobustTransformation(transformation); source = mock(DOMSource.class); resSource = mock(DOMSource.class); } -- 2.31.1