Restructured the project creating a router directory for the router bundle implementa...
[xmlrouter] / impl / src / test / java / org / wamblee / xmlrouter / impl / CompositeConfigTest.java
diff --git a/impl/src/test/java/org/wamblee/xmlrouter/impl/CompositeConfigTest.java b/impl/src/test/java/org/wamblee/xmlrouter/impl/CompositeConfigTest.java
deleted file mode 100644 (file)
index ad7c1c0..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * 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.impl;
-
-import static junit.framework.Assert.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-import org.wamblee.xmlrouter.common.Id;
-import org.wamblee.xmlrouter.config.Identifiable;
-
-public class CompositeConfigTest {
-
-    public static interface StringClassInterface extends
-        Identifiable<StringClassInterface> {
-
-    }
-
-    public static class StringClass implements StringClassInterface {
-
-        private String value;
-
-        public StringClass(String aValue) {
-            value = aValue;
-        }
-
-        public StringClass(int aValue) {
-            this(aValue + "");
-        }
-
-        @Override
-        public Id<StringClassInterface> getId() {
-            return new Id<StringClassInterface>(value + "");
-        }
-
-        @Override
-        public int hashCode() {
-            return value.hashCode();
-        }
-
-        @Override
-        public boolean equals(Object aObj) {
-            if (aObj == null) {
-                return false;
-            }
-            if (!(aObj instanceof StringClass)) {
-                return false;
-            }
-            StringClass obj = (StringClass) aObj;
-            return value.equals(obj.value);
-        }
-    }
-
-    @Test
-    public void testEmptyConfig() {
-        Config<StringClassInterface> composite = composite();
-        assertTrue(composite.values().isEmpty());
-    }
-
-    @Test(expected = RuntimeException.class)
-    public void testAddNotAllowed() {
-        composite().add(new StringClass(10));
-    }
-
-    @Test(expected = RuntimeException.class)
-    public void testRemoveNotAllowed() {
-        composite().remove(new Id<StringClassInterface>("xxx"));
-    }
-
-    @Test
-    public void testAddConfig() {
-        CompositeConfig<StringClassInterface> composite = composite();
-        Config<StringClassInterface> c1 = new ConfigImpl(
-            StringClassInterface.class, "c1") {
-            @Override
-            public Identifiable wrap(Identifiable aT) {
-                return aT;
-            }
-        };
-        Config<StringClassInterface> c2 = new ConfigImpl(
-            StringClassInterface.class, "c2") {
-            @Override
-            public Identifiable wrap(Identifiable aT) {
-                return aT;
-            }
-        };
-
-        StringClass i1 = new StringClass(10);
-        StringClass i2 = new StringClass(20);
-        StringClass i3 = new StringClass(30);
-        StringClass i4 = new StringClass(40);
-
-        c1.add(i1);
-        c1.add(i2);
-        c2.add(i3);
-        c2.add(i4);
-
-        composite.addConfig(c1);
-        List<StringClassInterface> values = composite.values();
-        List<String> ids = new ArrayList<String>();
-        for (StringClassInterface intf : values) {
-            ids.add(intf.getId().getId());
-        }
-        assertTrue(ids.contains("c1.10"));
-        assertTrue(ids.contains("c1.20"));
-
-        composite.addConfig(c2);
-        values = composite.values();
-        assertEquals(4, values.size());
-
-        ids = new ArrayList<String>();
-        for (StringClassInterface intf : values) {
-            ids.add(intf.getId().getId());
-        }
-        assertTrue(ids.contains("c1.10"));
-        assertTrue(ids.contains("c1.20"));
-        assertTrue(ids.contains("c2.30"));
-        assertTrue(ids.contains("c2.40"));
-    }
-
-    @Test(expected = ConfigException.class)
-    public void testDuplicatesNotAllowed() {
-        CompositeConfig<StringClassInterface> composite = composite();
-        Config<StringClassInterface> c1 = new ConfigImpl(
-            StringClassInterface.class, "c1") {
-            @Override
-            public Identifiable wrap(Identifiable aT) {
-                return aT;
-            }
-        };
-        Config<StringClassInterface> c2 = new ConfigImpl(
-            StringClassInterface.class, "c1") {
-            @Override
-            public Identifiable wrap(Identifiable aT) {
-                return aT;
-            }
-        };
-        composite.addConfig(c1);
-        composite.addConfig(c2);
-    }
-
-    @Test
-    public void testDuplicateItem() {
-        CompositeConfig<StringClassInterface> composite = composite();
-        Config<StringClassInterface> c1 = new ConfigImpl(
-            StringClassInterface.class, "c.x") {
-            @Override
-            public Identifiable wrap(Identifiable aT) {
-                return aT;
-            }
-        };
-        Config<StringClassInterface> c2 = new ConfigImpl(
-            StringClassInterface.class, "c") {
-            @Override
-            public Identifiable wrap(Identifiable aT) {
-                return aT;
-            }
-        };
-
-        StringClass i1 = new StringClass("y");
-        StringClass i2 = new StringClass("x.y");
-        c1.add(i1);
-        c2.add(i2);
-        composite.addConfig(c1);
-        try {
-            composite.addConfig(c2);
-            fail();
-        } catch (ConfigException e) {
-            // ok.
-        }
-        assertEquals(1, composite.values().size());
-        assertEquals("c.x.y", composite.values().iterator().next().getId()
-            .getId());
-    }
-
-    private CompositeConfig<StringClassInterface> composite() {
-        return new CompositeConfig<StringClassInterface>(
-            StringClassInterface.class);
-    }
-
-    private Id<Config> id(String aId) {
-        return new Id<Config>(aId);
-    }
-}