Config no longer implements Identifiable because this was in violation of the contrac...
authorErik Brakkee <erik@brakkee.org>
Sat, 13 Aug 2011 20:36:08 +0000 (22:36 +0200)
committerErik Brakkee <erik@brakkee.org>
Sat, 13 Aug 2011 20:36:08 +0000 (22:36 +0200)
Added ConfigurationProvider interface
RouterConfigServer is now an internal interface of the XMLRouter.

22 files changed:
config/src/main/java/org/wamblee/xmlrouter/config/Configuration.java [new file with mode: 0644]
config/src/main/java/org/wamblee/xmlrouter/config/ConfigurationProvider.java [new file with mode: 0644]
impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeConfig.java
impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeRouterConfig.java
impl/src/main/java/org/wamblee/xmlrouter/impl/Config.java [moved from config/src/main/java/org/wamblee/xmlrouter/config/Config.java with 85% similarity]
impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigException.java [moved from config/src/main/java/org/wamblee/xmlrouter/config/ConfigException.java with 90% similarity]
impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java
impl/src/main/java/org/wamblee/xmlrouter/impl/ExtendedConfig.java
impl/src/main/java/org/wamblee/xmlrouter/impl/ExtendedRouterConfig.java
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustIdentifiable.java
impl/src/main/java/org/wamblee/xmlrouter/impl/RouterConfig.java [moved from config/src/main/java/org/wamblee/xmlrouter/config/RouterConfig.java with 81% similarity]
impl/src/main/java/org/wamblee/xmlrouter/impl/RouterConfigService.java [moved from config/src/main/java/org/wamblee/xmlrouter/config/RouterConfigService.java with 97% similarity]
impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java
impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java
impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigurationImpl.java
impl/src/test/java/org/wamblee/xmlrouter/impl/CompositeConfigTest.java
impl/src/test/java/org/wamblee/xmlrouter/impl/ConfigImplTest.java
impl/src/test/java/org/wamblee/xmlrouter/impl/RobustIdentifiableTest.java
impl/src/test/java/org/wamblee/xmlrouter/impl/SingleRouterConfigTest.java
impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterConfigServiceTest.java
impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterFunctionTest.java
impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterTest.java

diff --git a/config/src/main/java/org/wamblee/xmlrouter/config/Configuration.java b/config/src/main/java/org/wamblee/xmlrouter/config/Configuration.java
new file mode 100644 (file)
index 0000000..f758fdc
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2005-2011 the original author or authors.
+ * 
+ * Licensed 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.wamblee.xmlrouter.config;
+
+import java.util.Collection;
+
+/**
+ * This class represents a particular configuration of the XML router as
+ * provided by one configuration provider. There can be multiple configuration
+ * providers, each providing it's own part of the configuration.
+ * 
+ * @author Erik Brakkee
+ */
+public final class Configuration {
+
+    private Collection<DocumentType> documentTypes;
+    private Collection<Transformation> transformations;
+    private Collection<Filter> filters;
+
+    /**
+     * Constructs the configuration object. Null objects will be ignored.
+     * DocumentTypes must have unique content-based ids (see
+     * {@link Identifiable}), with the same for transformations and filters.
+     * Objects with the same id as another object processed earlier will be
+     * ignored.
+     * 
+     * @param aDocumentTypes
+     *            Document types.
+     * @param aTransformations
+     *            Transformations.
+     * @param aFilters
+     *            Filters.
+     */
+    public Configuration(Collection<DocumentType> aDocumentTypes,
+        Collection<Transformation> aTransformations, Collection<Filter> aFilters) {
+        documentTypes = aDocumentTypes;
+        transformations = aTransformations;
+    }
+
+    public Collection<DocumentType> getDocumentTypes() {
+        return documentTypes;
+    }
+
+    public Collection<Transformation> getTransformations() {
+        return transformations;
+    }
+
+    public Collection<Filter> getFilters() {
+        return filters;
+    }
+}
diff --git a/config/src/main/java/org/wamblee/xmlrouter/config/ConfigurationProvider.java b/config/src/main/java/org/wamblee/xmlrouter/config/ConfigurationProvider.java
new file mode 100644 (file)
index 0000000..3b5588c
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2005-2011 the original author or authors.
+ * 
+ * Licensed 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.wamblee.xmlrouter.config;
+
+/**
+ * The configuration provider must be imp0lemneted to provide a part of the
+ * configuration. The XML Router calls the configuration provider repeatedly to
+ * find out the current configuration.
+ * 
+ * How the XML router obtains an instance of the configuration provider depends
+ * on how the \ XML router is deployed. In an OSGi type deployment, this could
+ * be for instance through an extender pattern whereby the XML router discovers
+ * configuration providers at runtime.
+ * 
+ * @author Erik Brakkee
+ * 
+ */
+public interface ConfigurationProvider {
+
+    /**
+     * Gets the current configuration to use. An implementation may cache the
+     * configuration objects an return it a second time or it may return a new
+     * configuration object each time.
+     * 
+     * @return Configuration, may not be null.
+     */
+    Configuration getConfiguration();
+}
index 0c6100dc3fc82c2c9a4484bc2af21e258e84d7a0..3b45a3ef25b5d35d395e8703bafec1db0f1946cd 100644 (file)
@@ -23,8 +23,6 @@ import java.util.List;
 import java.util.Set;
 
 import org.wamblee.xmlrouter.common.Id;
-import org.wamblee.xmlrouter.config.Config;
-import org.wamblee.xmlrouter.config.ConfigException;
 import org.wamblee.xmlrouter.config.Identifiable;
 
 /**
@@ -37,17 +35,17 @@ import org.wamblee.xmlrouter.config.Identifiable;
 public class CompositeConfig<T extends Identifiable<T>> implements
     ExtendedConfig<T> {
 
-    private static final Id<Config> ID = new Id<Config>("compositeconfig");
+    private static final String PREFIX = "compositeconfig";
     private static final String READ_ONLY_INSTANCE = "read only instance";
 
     private Class<T> type;
-    private Set<Id<Config>> ids;
+    private Set<String> prefixes;
     private List<Id<T>> valueIds;
     private List<T> values;
 
     public CompositeConfig(Class<T> aType) {
         type = aType;
-        ids = new HashSet<Id<Config>>();
+        prefixes = new HashSet<String>();
         valueIds = new ArrayList<Id<T>>();
         values = new ArrayList<T>();
     }
@@ -58,17 +56,17 @@ public class CompositeConfig<T extends Identifiable<T>> implements
     }
 
     @Override
-    public Id<Config> getId() {
-        return ID;
+    public String getPrefix() {
+        return PREFIX;
     }
 
     public void addConfig(Config<T> aConfig) {
         notNull("aConfig", aConfig);
-        if (ids.contains(aConfig.getId())) {
-            throw new ConfigException("duplicate id '" +
-                aConfig.getId().toString() + "'");
+        if (prefixes.contains(aConfig.getPrefix())) {
+            throw new ConfigException("duplicate prefix '" +
+                aConfig.getPrefix() + "'");
         }
-        String prefix = aConfig.getId().getId() + ".";
+        String prefix = aConfig.getPrefix() + ".";
         for (T item : aConfig.values()) {
             Id<T> newId = new Id<T>(prefix + item.getId());
             if (valueIds.contains(newId)) {
@@ -77,7 +75,7 @@ public class CompositeConfig<T extends Identifiable<T>> implements
             }
         }
 
-        ids.add(aConfig.getId());
+        prefixes.add(aConfig.getPrefix());
 
         for (T item : aConfig.values()) {
             Id<T> newId = new Id<T>(prefix + item.getId());
index fa01c064af7773dfdd60d0ebf02fb3299bb6664b..2b578bdf2c5a2208482b38f1c47aa2ddf3339e97 100644 (file)
@@ -18,10 +18,8 @@ package org.wamblee.xmlrouter.impl;
 import java.util.Collection;
 
 import org.wamblee.xmlrouter.common.Id;
-import org.wamblee.xmlrouter.config.Config;
 import org.wamblee.xmlrouter.config.DocumentType;
 import org.wamblee.xmlrouter.config.Filter;
-import org.wamblee.xmlrouter.config.RouterConfig;
 import org.wamblee.xmlrouter.config.Transformation;
 
 public class CompositeRouterConfig implements ExtendedRouterConfig {
similarity index 85%
rename from config/src/main/java/org/wamblee/xmlrouter/config/Config.java
rename to impl/src/main/java/org/wamblee/xmlrouter/impl/Config.java
index aa5c5409851fbcb6a155ee18a5c046de2f1be1e2..2699255496a200190ce7859a6991bcb887a98f1e 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.wamblee.xmlrouter.config;
+package org.wamblee.xmlrouter.impl;
 
 import java.util.Collection;
 
 import org.wamblee.xmlrouter.common.Id;
+import org.wamblee.xmlrouter.config.Identifiable;
 
 /**
  * Interface for managing a set of configuration items of a given type with
@@ -28,7 +29,12 @@ import org.wamblee.xmlrouter.common.Id;
  * @param <T>
  *            Type for which ids are generated.
  */
-public interface Config<T extends Identifiable> extends Identifiable<Config> {
+public interface Config<T extends Identifiable> {
+
+    /**
+     * @return Prefix to use for ids of contained identifiable objects.
+     */
+    String getPrefix();
 
     /**
      * @return The type of contained object.
similarity index 90%
rename from config/src/main/java/org/wamblee/xmlrouter/config/ConfigException.java
rename to impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigException.java
index 5944bfec57ee122be5a67611920044f02bedf566..08a040def5332ea94037b240f82e8e08ca96dedf 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.wamblee.xmlrouter.config;
+package org.wamblee.xmlrouter.impl;
 
 /**
- * Exception thrown in case of duplicates.
+ * Exception thrown in case of configuration errors.
  * 
  * @author Erik Brakkee
  */
index 777ecd0ac2c45864328605eeff9955419197673a..ae2351f97d37c2e4ae08c5dd0d7a7d5ea090352a 100644 (file)
@@ -23,8 +23,6 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.wamblee.xmlrouter.common.Id;
-import org.wamblee.xmlrouter.config.Config;
-import org.wamblee.xmlrouter.config.ConfigException;
 import org.wamblee.xmlrouter.config.Identifiable;
 
 /**
@@ -38,17 +36,17 @@ public abstract class ConfigImpl<T extends Identifiable<T>> implements
     ExtendedConfig<T> {
 
     private Class<T> type;
-    private Id<Config> id;
+    private String prefix;
     private Map<Id<T>, T> registered;
 
     /**
      * Constructs the object.
      */
-    public ConfigImpl(Class<T> aType, Id<Config> aId) {
+    public ConfigImpl(Class<T> aType, String aPrefix) {
         notNull("type", aType);
-        notNull("id", aId);
+        notNull("id", aPrefix);
         type = aType;
-        id = aId;
+        prefix = aPrefix;
         registered = new HashMap<Id<T>, T>();
     }
 
@@ -65,7 +63,7 @@ public abstract class ConfigImpl<T extends Identifiable<T>> implements
      */
     public ConfigImpl(ConfigImpl<T> aConfig) {
         notNull("config", aConfig);
-        id = aConfig.id;
+        prefix = aConfig.prefix;
         registered = new HashMap<Id<T>, T>();
         for (Map.Entry<Id<T>, T> entry : aConfig.registered.entrySet()) {
             registered.put(entry.getKey(), entry.getValue());
@@ -73,8 +71,8 @@ public abstract class ConfigImpl<T extends Identifiable<T>> implements
     }
 
     @Override
-    public Id<Config> getId() {
-        return id;
+    public String getPrefix() {
+        return prefix;
     }
 
     /*
index 2c1b781f6381fddf3781bac348ab671ad6113a5f..5fa8f03dffdad4261d13baf6e6f5005e802c9fba 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.wamblee.xmlrouter.impl;
 
-import org.wamblee.xmlrouter.config.Config;
 import org.wamblee.xmlrouter.config.Identifiable;
 
 public interface ExtendedConfig<T extends Identifiable<T>> extends Config<T> {
index f8b0f75d17e4b16c10cc91fcfdb16bb770dc33b2..8cda134b694e0159bbead6e73823725e973754eb 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.wamblee.xmlrouter.impl;
 
-import org.wamblee.xmlrouter.config.RouterConfig;
 
 /**
  * Extended interface for the router configuration used internally.
index 2e63a9799901f2616e6fdc6fc1438c80adf570a1..f371975fac804c378162084bc0e1a74536fbe2d9 100644 (file)
@@ -21,7 +21,6 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.wamblee.xmlrouter.common.Id;
-import org.wamblee.xmlrouter.config.ConfigException;
 import org.wamblee.xmlrouter.config.Identifiable;
 
 /**
similarity index 81%
rename from config/src/main/java/org/wamblee/xmlrouter/config/RouterConfig.java
rename to impl/src/main/java/org/wamblee/xmlrouter/impl/RouterConfig.java
index 14622508f06e6fc65303c6b45a3465f0f3c89418..120ffbdd6b5181c61814ab4ced5504846d1d8f73 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.wamblee.xmlrouter.config;
+package org.wamblee.xmlrouter.impl;
+
+import org.wamblee.xmlrouter.config.DocumentType;
+import org.wamblee.xmlrouter.config.Filter;
+import org.wamblee.xmlrouter.config.Identifiable;
+import org.wamblee.xmlrouter.config.Transformation;
 
 /**
  * Configuration API for the XML router.
similarity index 97%
rename from config/src/main/java/org/wamblee/xmlrouter/config/RouterConfigService.java
rename to impl/src/main/java/org/wamblee/xmlrouter/impl/RouterConfigService.java
index 9656441ace1bf5ef555871fedcf0e52fb812f971..8738ed109bda44bcdbf62b3520ac12efc104a009 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.wamblee.xmlrouter.config;
+package org.wamblee.xmlrouter.impl;
 
 import org.wamblee.xmlrouter.common.Id;
 
index a72e9a2294d6c49a4d51c3a621c4f4460ac80d9d..195f72da66295517bce3aec611c3fe05f3fd0cc8 100644 (file)
 package org.wamblee.xmlrouter.impl;
 
 import org.wamblee.xmlrouter.common.Id;
-import org.wamblee.xmlrouter.config.Config;
 import org.wamblee.xmlrouter.config.DocumentType;
 import org.wamblee.xmlrouter.config.Filter;
-import org.wamblee.xmlrouter.config.RouterConfig;
 import org.wamblee.xmlrouter.config.Transformation;
 
 /**
@@ -31,7 +29,7 @@ import org.wamblee.xmlrouter.config.Transformation;
 public class SingleRouterConfig implements ExtendedRouterConfig {
 
     public static final class DocumentConfig extends ConfigImpl<DocumentType> {
-        public DocumentConfig(Id<Config> aId) {
+        public DocumentConfig(String aId) {
             super(DocumentType.class, aId);
         }
 
@@ -47,7 +45,7 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
 
     public static final class TransformationConfig extends
         ConfigImpl<Transformation> {
-        public TransformationConfig(Id<Config> aId) {
+        public TransformationConfig(String aId) {
             super(Transformation.class, aId);
         }
 
@@ -62,7 +60,7 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
     }
 
     public static final class FilterConfig extends ConfigImpl<Filter> {
-        public FilterConfig(Id<Config> aId) {
+        public FilterConfig(String aId) {
             super(Filter.class, aId);
         }
 
@@ -76,7 +74,7 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
         }
     }
 
-    private Id<RouterConfig> id;
+    private String prefix;
 
     private DocumentConfig documentTypes;
     private TransformationConfig transformations;
@@ -85,20 +83,18 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
     /**
      * Constructs a router configuration.
      * 
-     * @param aId
+     * @param aPrefix
      *            Unique id for this configuration.
      */
-    public SingleRouterConfig(Id<RouterConfig> aId) {
-        id = aId;
-        documentTypes = new DocumentConfig(new Id<Config>(aId.getId() +
-            ".documenttypes"));
-        transformations = new TransformationConfig(new Id<Config>(aId.getId() +
-            ".transformations"));
-        filters = new FilterConfig(new Id<Config>(aId.getId() + ".filters"));
+    public SingleRouterConfig(String aPrefix) {
+        prefix = aPrefix;
+        documentTypes = new DocumentConfig(aPrefix + ".documenttypes");
+        transformations = new TransformationConfig(aPrefix + ".transformations");
+        filters = new FilterConfig(aPrefix + ".filters");
     }
 
     public SingleRouterConfig(SingleRouterConfig aConfig) {
-        id = aConfig.id;
+        prefix = aConfig.prefix;
         documentTypes = new DocumentConfig(aConfig.documentTypes);
         transformations = new TransformationConfig(aConfig.transformations);
         filters = new FilterConfig(aConfig.filters);
@@ -106,7 +102,11 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
 
     @Override
     public Id<RouterConfig> getId() {
-        return id;
+        return new Id<RouterConfig>(prefix);
+    }
+
+    public String getPrefix() {
+        return prefix;
     }
 
     @Override
index 198855ee2752c9f5e2f38cce6908bd898b29dedf..a20da62d53f60ca6a6b36306b0177b7a41db29c1 100644 (file)
@@ -18,12 +18,8 @@ package org.wamblee.xmlrouter.impl;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.wamblee.xmlrouter.common.Id;
-import org.wamblee.xmlrouter.config.Config;
-import org.wamblee.xmlrouter.config.ConfigException;
 import org.wamblee.xmlrouter.config.DocumentType;
 import org.wamblee.xmlrouter.config.Filter;
-import org.wamblee.xmlrouter.config.RouterConfig;
-import org.wamblee.xmlrouter.config.RouterConfigService;
 import org.wamblee.xmlrouter.config.Transformation;
 
 /**
@@ -45,7 +41,7 @@ public class XMLRouterConfigService implements RouterConfigService {
         sequence = new AtomicLong(1L);
         config = aConfig;
         routerConfigs = new ConfigImpl<RouterConfig>(RouterConfig.class,
-            new Id<Config>(aApplication)) {
+            aApplication) {
             public RouterConfig wrap(final RouterConfig aT) {
                 return new RouterConfig() {
                     @Override
@@ -74,8 +70,7 @@ public class XMLRouterConfigService implements RouterConfigService {
 
     @Override
     public RouterConfig emptyConfig(String aId) {
-        return new SingleRouterConfig(new Id<RouterConfig>(application + "." +
-            aId));
+        return new SingleRouterConfig(application + "." + aId);
     }
 
     @Override
index 7a915766ec93d9bca00647dc9c96d13e5131a17d..7c570ff23baaa723c4e0c105919f24751c19702c 100644 (file)
@@ -20,7 +20,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import org.wamblee.general.Pair;
 import org.wamblee.xmlrouter.common.Id;
-import org.wamblee.xmlrouter.config.RouterConfig;
 
 /**
  * Implements the XML Router configuration interface including the required
index efca7216cf4262de03de06fd04703e361125d8a9..ad7c1c06d0e5c70e0c7fc2140b6a1667e88f17a0 100644 (file)
@@ -22,8 +22,6 @@ import java.util.List;
 
 import org.junit.Test;
 import org.wamblee.xmlrouter.common.Id;
-import org.wamblee.xmlrouter.config.Config;
-import org.wamblee.xmlrouter.config.ConfigException;
 import org.wamblee.xmlrouter.config.Identifiable;
 
 public class CompositeConfigTest {
@@ -88,14 +86,14 @@ public class CompositeConfigTest {
     public void testAddConfig() {
         CompositeConfig<StringClassInterface> composite = composite();
         Config<StringClassInterface> c1 = new ConfigImpl(
-            StringClassInterface.class, id("c1")) {
+            StringClassInterface.class, "c1") {
             @Override
             public Identifiable wrap(Identifiable aT) {
                 return aT;
             }
         };
         Config<StringClassInterface> c2 = new ConfigImpl(
-            StringClassInterface.class, id("c2")) {
+            StringClassInterface.class, "c2") {
             @Override
             public Identifiable wrap(Identifiable aT) {
                 return aT;
@@ -139,14 +137,14 @@ public class CompositeConfigTest {
     public void testDuplicatesNotAllowed() {
         CompositeConfig<StringClassInterface> composite = composite();
         Config<StringClassInterface> c1 = new ConfigImpl(
-            StringClassInterface.class, id("c1")) {
+            StringClassInterface.class, "c1") {
             @Override
             public Identifiable wrap(Identifiable aT) {
                 return aT;
             }
         };
         Config<StringClassInterface> c2 = new ConfigImpl(
-            StringClassInterface.class, id("c1")) {
+            StringClassInterface.class, "c1") {
             @Override
             public Identifiable wrap(Identifiable aT) {
                 return aT;
@@ -160,14 +158,14 @@ public class CompositeConfigTest {
     public void testDuplicateItem() {
         CompositeConfig<StringClassInterface> composite = composite();
         Config<StringClassInterface> c1 = new ConfigImpl(
-            StringClassInterface.class, id("c.x")) {
+            StringClassInterface.class, "c.x") {
             @Override
             public Identifiable wrap(Identifiable aT) {
                 return aT;
             }
         };
         Config<StringClassInterface> c2 = new ConfigImpl(
-            StringClassInterface.class, id("c")) {
+            StringClassInterface.class, "c") {
             @Override
             public Identifiable wrap(Identifiable aT) {
                 return aT;
index 9925c0b74a7637aa6065cca0cd7a49a7f597474f..c7b1d9c8660d2d95849411741734017d20620ba0 100644 (file)
@@ -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 {
@@ -52,7 +51,7 @@ public class ConfigImplTest {
     }
 
     public static final class MyTypeConfig extends ConfigImpl<MyType> {
-        public MyTypeConfig(Id<Config> aId) {
+        public MyTypeConfig(String aId) {
             super(MyType.class, aId);
         }
 
@@ -72,7 +71,7 @@ public class ConfigImplTest {
     @Before
     public void setUp() {
         sequence = new AtomicLong(1L);
-        config = new MyTypeConfig(new Id<Config>(CONFIG_TYPE));
+        config = new MyTypeConfig(CONFIG_TYPE);
     }
 
     @Test
@@ -118,10 +117,10 @@ public class ConfigImplTest {
     @Test
     public void testEquals() {
 
-        Config<MyType> config1 = new MyTypeConfig(new Id<Config>(CONFIG_TYPE));
+        Config<MyType> config1 = new MyTypeConfig(CONFIG_TYPE);
         assertFalse(config1.equals(null));
         assertFalse(config1.equals("hello"));
-        Config<MyType> config2 = new MyTypeConfig(new Id<Config>(CONFIG_TYPE));
+        Config<MyType> config2 = new MyTypeConfig(CONFIG_TYPE);
 
         assertEquals(config1, config2);
         assertEquals(config1.hashCode(), config2.hashCode());
@@ -148,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
index 86d55ab921c07230edb3cf4ac76592a7a1715d02..511f583196175a564b5ab64b418818b59469995d 100644 (file)
@@ -21,7 +21,6 @@ import static org.mockito.Mockito.*;
 import org.junit.Before;
 import org.junit.Test;
 import org.wamblee.xmlrouter.common.Id;
-import org.wamblee.xmlrouter.config.ConfigException;
 import org.wamblee.xmlrouter.config.Identifiable;
 
 public class RobustIdentifiableTest {
index 5f151d29536fd0a4a89874403d99d11be466161a..7a71a6c2e8bda9924698ea03f982d5aa471695f4 100644 (file)
@@ -23,7 +23,6 @@ import org.junit.Test;
 import org.wamblee.xmlrouter.common.Id;
 import org.wamblee.xmlrouter.config.DocumentType;
 import org.wamblee.xmlrouter.config.Filter;
-import org.wamblee.xmlrouter.config.RouterConfig;
 import org.wamblee.xmlrouter.config.Transformation;
 
 public class SingleRouterConfigTest {
@@ -32,7 +31,7 @@ public class SingleRouterConfigTest {
 
     @Before
     public void setUp() {
-        config = new SingleRouterConfig(new Id<RouterConfig>("routerconfig"));
+        config = new SingleRouterConfig("routerconfig");
         assertEquals("routerconfig", config.getId().getId());
     }
 
@@ -87,23 +86,19 @@ public class SingleRouterConfigTest {
 
     @Test
     public void testEqualityEmptyConfig() {
-        RouterConfig config1 = new SingleRouterConfig(new Id<RouterConfig>(
-            "routerconfig"));
-        RouterConfig config2 = new SingleRouterConfig(new Id<RouterConfig>(
-            "routerconfig"));
+        RouterConfig config1 = new SingleRouterConfig("routerconfig");
+        RouterConfig config2 = new SingleRouterConfig("routerconfig");
         assertEquals(config1, config2);
     }
 
     @Test
     public void testEqualsNonEmpty() {
-        RouterConfig config1 = new SingleRouterConfig(new Id<RouterConfig>(
-            "routerconfig"));
+        RouterConfig config1 = new SingleRouterConfig("routerconfig");
 
         assertFalse(config1.equals(null));
         assertFalse(config.equals("hello"));
 
-        RouterConfig config2 = new SingleRouterConfig(new Id<RouterConfig>(
-            "routerconfig"));
+        RouterConfig config2 = new SingleRouterConfig("routerconfig");
         DocumentType type1 = mock(DocumentType.class);
         when(type1.getId()).thenReturn(new Id<DocumentType>("type1"));
         DocumentType type2 = mock(DocumentType.class);
index e56b5c07d1e7dea33f2992448c0dbb63414f1e5f..9f2f5063e604c3c9e20ed2ed29f884b6e71e6207 100644 (file)
@@ -24,10 +24,8 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.wamblee.xmlrouter.common.Id;
-import org.wamblee.xmlrouter.config.ConfigException;
 import org.wamblee.xmlrouter.config.DocumentType;
 import org.wamblee.xmlrouter.config.Filter;
-import org.wamblee.xmlrouter.config.RouterConfig;
 import org.wamblee.xmlrouter.config.Transformation;
 
 public class XMLRouterConfigServiceTest {
index d7c504e97555e15f98276deb20dcac9db7f9c61a..cc663438a2b5853727b6af25dab2c7a3607a383e 100644 (file)
@@ -29,7 +29,6 @@ import org.junit.Test;
 import org.wamblee.general.SystemClock;
 import org.wamblee.xmlrouter.common.Id;
 import org.wamblee.xmlrouter.config.DocumentType;
-import org.wamblee.xmlrouter.config.RouterConfig;
 import org.wamblee.xmlrouter.config.Transformation;
 import org.wamblee.xmlrouter.listener.EventInfo;
 import org.wamblee.xmlrouter.listener.EventListener;
index c4375c70331044e221015ac3108dbc61b4fbf526..c6b1aa0b8f65227b08b40a34442632632052e311 100644 (file)
@@ -33,7 +33,6 @@ import org.wamblee.general.SystemClock;
 import org.wamblee.xmlrouter.common.Id;
 import org.wamblee.xmlrouter.config.DocumentType;
 import org.wamblee.xmlrouter.config.Filter;
-import org.wamblee.xmlrouter.config.RouterConfig;
 import org.wamblee.xmlrouter.config.Transformation;
 import org.wamblee.xmlrouter.listener.EventInfo;
 import org.wamblee.xmlrouter.listener.EventListener;
@@ -86,8 +85,7 @@ public class XMLRouterTest {
         Logger logger = Logger.getLogger(XMLRouter.class.getName());
         setLogLevel(logger, Level.FINEST);
 
-        routerConfig = new SingleRouterConfig(new Id<RouterConfig>(
-            "routerconfig"));
+        routerConfig = new SingleRouterConfig("routerconfig");
         config = new XMLRouterConfigurationImpl(routerConfig);
         EventListener logListener = new LoggingEventListener(Level.INFO);
         listener = spy(logListener);