qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1648393 [1/2] - in /qpid/trunk/qpid/java/broker-core/src: main/java/org/apache/qpid/server/plugin/ test/java/org/apache/qpid/server/model/ test/java/org/apache/qpid/server/model/testmodel/ test/java/org/apache/qpid/server/model/testmodels/...
Date Mon, 29 Dec 2014 17:08:21 GMT
Author: kwall
Date: Mon Dec 29 17:08:20 2014
New Revision: 1648393

URL: http://svn.apache.org/r1648393
Log:
QPID-6292: [Java Broker Tests] Refactor AbstractConfiguredObjects unit tests to use several smaller test models

We now have two test models:

* 'singleton' with a single object - used for tests around the behaviour of attributes, context variables etc
* 'hierarchy' with a hierarchy of objects - used to test parent/child interactions, supported child types, and
   managed interfaces.

Added:
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/AbstractConfiguredObjectTest.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/ConfiguredObjectTypeRegistryTest.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestCar.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface1.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecCar.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngine.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngineImpl.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestEngine.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface2.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestHybridEngine.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestHybridEngineImpl.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestKitCar.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestKitCarImpl.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngine.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngineImpl.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass1.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestRechargeable.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface3.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestStandardCar.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestStandardCarImpl.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/AbstractConfiguredObjectTest.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/TestConfiguredObject.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestConfiguredObject.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/AbstractConfiguredObjectTest.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestEnum.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestModel.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestSingleton.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategory.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestSingletonImpl.java
      - copied, changed from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/Test2RootCategoryImpl.java
Removed:
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistryTest.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/Test2RootCategory.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/Test2RootCategoryImpl.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategory.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestConfiguredObject.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass0.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass1.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass2.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass4.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass5.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface1.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface2.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface3.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategory.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategoryImpl.java
Modified:
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AttributeValueConverterTest.java

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java?rev=1648393&r1=1648392&r2=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java Mon Dec 29 17:08:20 2014
@@ -84,7 +84,8 @@ public class QpidServiceLoader
 
     private boolean isDisabledConfiguredType(final ConfiguredObjectTypeFactory<?> typeFactory)
     {
-        return Boolean.getBoolean("qpid.type.disabled:" + typeFactory.getCategoryClass().getSimpleName().toLowerCase()
+        String simpleName = typeFactory.getCategoryClass().getSimpleName().toLowerCase();
+        return Boolean.getBoolean("qpid.type.disabled:" + simpleName
                                   + "." + typeFactory.getType());
     }
 }

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AttributeValueConverterTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AttributeValueConverterTest.java?rev=1648393&r1=1648392&r2=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AttributeValueConverterTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AttributeValueConverterTest.java Mon Dec 29 17:08:20 2014
@@ -37,8 +37,8 @@ import java.util.Set;
 
 import junit.framework.TestCase;
 
-import org.apache.qpid.server.model.testmodel.TestModel;
-import org.apache.qpid.server.model.testmodel.TestRootCategory;
+import org.apache.qpid.server.model.testmodels.hierarchy.TestModel;
+import org.apache.qpid.server.model.testmodels.hierarchy.TestCar;
 
 public class AttributeValueConverterTest extends TestCase
 {
@@ -61,7 +61,7 @@ public class AttributeValueConverterTest
         _context.put("mapWithInterpolatedContents", "{\"${mykey}\" : \"b\"}");
         _context.put("mykey", "mykey1");
 
-        ConfiguredObject object = _objectFactory.create(TestRootCategory.class, _attributes);
+        ConfiguredObject object = _objectFactory.create(TestCar.class, _attributes);
 
         AttributeValueConverter<Map> mapConverter = getConverter(Map.class, Map.class);
 
@@ -96,7 +96,7 @@ public class AttributeValueConverterTest
     {
         _context.put("simpleCollection", "[\"a\", \"b\"]");
 
-        ConfiguredObject object = _objectFactory.create(TestRootCategory.class, _attributes);
+        ConfiguredObject object = _objectFactory.create(TestCar.class, _attributes);
 
         AttributeValueConverter<Collection> collectionConverter = getConverter(Collection.class, Collection.class);
 
@@ -131,7 +131,7 @@ public class AttributeValueConverterTest
     {
         _context.put("simpleList", "[\"a\", \"b\"]");
 
-        ConfiguredObject object = _objectFactory.create(TestRootCategory.class, _attributes);
+        ConfiguredObject object = _objectFactory.create(TestCar.class, _attributes);
 
         AttributeValueConverter<List> listConverter = getConverter(List.class, List.class);
 
@@ -164,7 +164,7 @@ public class AttributeValueConverterTest
     {
         _context.put("simpleSet", "[\"a\", \"b\"]");
 
-        ConfiguredObject object = _objectFactory.create(TestRootCategory.class, _attributes);
+        ConfiguredObject object = _objectFactory.create(TestCar.class, _attributes);
 
         AttributeValueConverter<Set> setConverter = getConverter(Set.class, Set.class);;
 

Added: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/AbstractConfiguredObjectTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/AbstractConfiguredObjectTest.java?rev=1648393&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/AbstractConfiguredObjectTest.java (added)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/AbstractConfiguredObjectTest.java Mon Dec 29 17:08:20 2014
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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.apache.qpid.server.model.testmodels.hierarchy;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.Model;
+import org.apache.qpid.test.utils.QpidTestCase;
+
+/**
+ * Tests behaviour of AbstractConfiguredObjects when hierarchies of objects are used together.
+ * Responsibilities to include adding/removing of children and correct firing of listeners.
+ */
+public class AbstractConfiguredObjectTest extends QpidTestCase
+{
+    private final Model _model = TestModel.getInstance();
+
+    public void testCreateCategoryDefault()
+    {
+        final String objectName = "testCreateCategoryDefault";
+        Map<String, Object> attributes = Collections.<String, Object>singletonMap(ConfiguredObject.NAME, objectName);
+
+        TestCar object = _model.getObjectFactory().create(TestCar.class, attributes);
+
+        assertEquals(objectName, object.getName());
+        assertEquals(TestStandardCarImpl.TEST_STANDARD_CAR_TYPE, object.getType());
+        assertTrue(object instanceof TestStandardCar);
+    }
+
+    public void testCreateUnrecognisedType()
+    {
+        final String objectName = "testCreateCategoryDefault";
+        Map<String, Object> attributes = new HashMap<>();
+        attributes.put(ConfiguredObject.NAME, objectName);
+        attributes.put(ConfiguredObject.TYPE, "notatype");
+
+        try
+        {
+            _model.getObjectFactory().create(TestCar.class, attributes);
+            fail("Exception not thrown");
+        }
+        catch (IllegalConfigurationException ice)
+        {
+            // PASS
+        }
+    }
+
+    public void testCreateCarWithEngine()
+    {
+        final String carName = "myCar";
+        Map<String, Object> carAttributes = new HashMap<>();
+        carAttributes.put(ConfiguredObject.NAME, carName);
+        carAttributes.put(ConfiguredObject.TYPE, TestKitCarImpl.TEST_KITCAR_TYPE);
+
+        TestCar car = _model.getObjectFactory().create(TestCar.class, carAttributes);
+
+        assertEquals(carName, car.getName());
+
+        assertEquals(0, car.getChildren(TestEngine.class).size());
+
+        String engineName = "myEngine";
+
+        Map<String, Object> engineAttributes = new HashMap<>();
+        engineAttributes.put(ConfiguredObject.NAME, engineName);
+        engineAttributes.put(ConfiguredObject.TYPE, TestElecEngineImpl.TEST_ELEC_ENGINE_TYPE);
+
+        TestEngine engine = (TestEngine) car.createChild(TestEngine.class, engineAttributes);
+
+        assertEquals(1, car.getChildren(TestEngine.class).size());
+
+        assertEquals(engineName, engine.getName());
+        assertEquals(TestElecEngineImpl.TEST_ELEC_ENGINE_TYPE, engine.getType());
+
+    }
+
+}

Added: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/ConfiguredObjectTypeRegistryTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/ConfiguredObjectTypeRegistryTest.java?rev=1648393&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/ConfiguredObjectTypeRegistryTest.java (added)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/ConfiguredObjectTypeRegistryTest.java Mon Dec 29 17:08:20 2014
@@ -0,0 +1,74 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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.apache.qpid.server.model.testmodels.hierarchy;
+
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Collection;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry;
+import org.apache.qpid.server.model.ManagedInterface;
+
+public class ConfiguredObjectTypeRegistryTest extends TestCase
+{
+    private ConfiguredObjectTypeRegistry _typeRegistry = TestModel.getInstance().getTypeRegistry();
+
+    public void testTypeSpecialisations()
+    {
+        Collection<Class<? extends ConfiguredObject>> types = _typeRegistry.getTypeSpecialisations(TestEngine.class);
+
+        assertEquals("Unexpected number of specialisations for " + TestEngine.class + " Found : " + types, 3, types.size());
+        assertTrue(types.contains(TestPetrolEngineImpl.class));
+        assertTrue(types.contains(TestHybridEngineImpl.class));
+        assertTrue(types.contains(TestElecEngineImpl.class));
+    }
+
+    public void testGetValidChildTypes()
+    {
+        // The standard car restricts its engine type
+        Collection<String> standardCarValidEnginesTypes = _typeRegistry.getValidChildTypes(TestStandardCarImpl.class, TestEngine.class);
+        assertThat(standardCarValidEnginesTypes, hasItem(TestPetrolEngineImpl.TEST_PETROL_ENGINE_TYPE));
+        assertThat(standardCarValidEnginesTypes, hasItem(TestHybridEngineImpl.TEST_HYBRID_ENGINE_TYPE));
+        assertThat(standardCarValidEnginesTypes.size(), is(2));
+
+        Collection<String> kitCarValidEngineTypes = _typeRegistry.getValidChildTypes(TestKitCarImpl.class, TestEngine.class);
+        // Would it be more useful to producers of management UIs if this were populated with all possible types?
+        assertNull(kitCarValidEngineTypes);
+    }
+
+    public void testManagedInterfaces()
+    {
+        // The electric engine is recharable
+        Set<Class<? extends ManagedInterface>> elecEngIntfcs = _typeRegistry.getManagedInterfaces(TestElecEngine.class);
+        assertThat(elecEngIntfcs, hasItem(TestRechargeable.class));
+        assertThat(elecEngIntfcs.size(), is(1));
+
+        // The pertrol engine implements no additional interfaces
+        Set<Class<? extends ManagedInterface>> stdCarIntfcs = _typeRegistry.getManagedInterfaces(TestPetrolEngine.class);
+        assertThat(stdCarIntfcs.size(), is(0));
+    }
+}

Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestCar.java (from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface1.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestCar.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestCar.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface1.java&r1=1648392&r2=1648393&rev=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface1.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestCar.java Mon Dec 29 17:08:20 2014
@@ -18,16 +18,12 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.model.testmodel;
+package org.apache.qpid.server.model.testmodels.hierarchy;
 
-import org.apache.qpid.server.model.ManagedAnnotation;
-import org.apache.qpid.server.model.ManagedInterface;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.ManagedObject;
 
-/**
- * This is a test managed interface which has ManagedAnnotation.
- * All types implementing this interface will inherit the annotation and will be managed entities of type TestManagedInterface1
- */
-@ManagedAnnotation
-public interface TestManagedInterface1 extends ManagedInterface
+@ManagedObject( defaultType = TestStandardCarImpl.TEST_STANDARD_CAR_TYPE)
+public interface TestCar<X extends TestCar<X>> extends ConfiguredObject<X>
 {
 }

Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecCar.java (from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecCar.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecCar.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java&r1=1648392&r2=1648393&rev=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecCar.java Mon Dec 29 17:08:20 2014
@@ -17,16 +17,11 @@
  * under the License.
  */
 
-package org.apache.qpid.server.model.testmodel;
+package org.apache.qpid.server.model.testmodels.hierarchy;
 
+import org.apache.qpid.server.model.ManagedObject;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-public enum TestEnum
+@ManagedObject(category = false)
+public interface TestElecCar<X extends TestElecCar<X>> extends TestCar<X>
 {
-    TEST_ENUM1,
-    TEST_ENUM2,
-    TEST_ENUM3;
 }

Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngine.java (from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngine.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngine.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java&r1=1648392&r2=1648393&rev=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngine.java Mon Dec 29 17:08:20 2014
@@ -17,16 +17,11 @@
  * under the License.
  */
 
-package org.apache.qpid.server.model.testmodel;
+package org.apache.qpid.server.model.testmodels.hierarchy;
 
+import org.apache.qpid.server.model.ManagedObject;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-public enum TestEnum
+@ManagedObject (category = false)
+public interface TestElecEngine<X extends TestElecEngine<X>> extends TestEngine<X>, TestRechargeable
 {
-    TEST_ENUM1,
-    TEST_ENUM2,
-    TEST_ENUM3;
 }

Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngineImpl.java (from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngineImpl.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngineImpl.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java&r1=1648392&r2=1648393&rev=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngineImpl.java Mon Dec 29 17:08:20 2014
@@ -18,55 +18,34 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.model.testmodel;
+package org.apache.qpid.server.model.testmodels.hierarchy;
 
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.Map;
-import java.util.Set;
 
 import org.apache.qpid.server.model.AbstractConfiguredObject;
-import org.apache.qpid.server.model.ManagedAttributeField;
 import org.apache.qpid.server.model.ManagedObject;
 import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
-import org.apache.qpid.server.model.State;
 
-@ManagedObject( category = false, type = TestChildCategoryImpl.TEST_CHILD_TYPE )
-public class TestChildCategoryImpl
-        extends AbstractConfiguredObject<TestChildCategoryImpl> implements TestChildCategory<TestChildCategoryImpl>
+@ManagedObject( category = false, type = TestElecEngineImpl.TEST_ELEC_ENGINE_TYPE)
+public class TestElecEngineImpl
+        extends AbstractConfiguredObject<TestElecEngineImpl> implements TestElecEngine<TestElecEngineImpl>
 {
-    public static final String TEST_CHILD_TYPE = "testchild";
-
-
-    @ManagedAttributeField
-    private String _validValueNotInterpolated;
-
-    @ManagedAttributeField
-    private int _intValue;
-
-    @ManagedAttributeField
-    private Set<Integer> _integerSet;
-
+    public static final String TEST_ELEC_ENGINE_TYPE = "ELEC";
 
     @ManagedObjectFactoryConstructor
-    public TestChildCategoryImpl(final Map<String, Object> attributes, TestRootCategory<?> parent)
+    public TestElecEngineImpl(final Map<String, Object> attributes, TestCar<?> parent)
     {
         super(parentsMap(parent), attributes);
     }
 
-    @Override
-    public String getValidValueNotInterpolated()
+    @SuppressWarnings("unused")
+    public static Map<String, Collection<String>> getSupportedChildTypes()
     {
-        return _validValueNotInterpolated;
+        Collection<String> types = Arrays.asList(TestElecEngineImpl.TEST_ELEC_ENGINE_TYPE);
+        return Collections.singletonMap(TestEngine.class.getSimpleName(), types);
     }
 
-    @Override
-    public int getIntValue()
-    {
-        return _intValue;
-    }
-
-    @Override
-    public Set<Integer> getIntegerSet()
-    {
-        return _integerSet;
-    }
 }

Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestEngine.java (from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface2.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestEngine.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestEngine.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface2.java&r1=1648392&r2=1648393&rev=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface2.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestEngine.java Mon Dec 29 17:08:20 2014
@@ -18,14 +18,12 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.model.testmodel;
+package org.apache.qpid.server.model.testmodels.hierarchy;
 
-import org.apache.qpid.server.model.ManagedInterface;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.ManagedObject;
 
-/**
- * This is a test managed interface which has no ManagedAnnotation.
- * All types implementing this interface would need to have ManagedAnnotation declared in order to became managed entity.
- */
-public interface TestManagedInterface2 extends ManagedInterface
+@ManagedObject(category = true)
+public interface TestEngine<X extends TestEngine<X>> extends ConfiguredObject<X>
 {
 }

Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestHybridEngine.java (from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestHybridEngine.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestHybridEngine.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java&r1=1648392&r2=1648393&rev=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestHybridEngine.java Mon Dec 29 17:08:20 2014
@@ -16,17 +16,11 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.qpid.server.model.testmodels.hierarchy;
 
-package org.apache.qpid.server.model.testmodel;
+import org.apache.qpid.server.model.ManagedObject;
 
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-public enum TestEnum
+@ManagedObject (category = false)
+public interface TestHybridEngine<X extends TestHybridEngine<X>> extends TestEngine<X>, TestRechargeable
 {
-    TEST_ENUM1,
-    TEST_ENUM2,
-    TEST_ENUM3;
 }

Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestHybridEngineImpl.java (from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestHybridEngineImpl.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestHybridEngineImpl.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java&r1=1648392&r2=1648393&rev=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass3.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestHybridEngineImpl.java Mon Dec 29 17:08:20 2014
@@ -1,5 +1,4 @@
 /*
- *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -16,23 +15,24 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
  */
-package org.apache.qpid.server.model.testmodel;
+
+package org.apache.qpid.server.model.testmodels.hierarchy;
 
 import java.util.Map;
 
+import org.apache.qpid.server.model.AbstractConfiguredObject;
 import org.apache.qpid.server.model.ManagedObject;
+import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
 
-/**
- * This is a test managed type implementing managed interface TestManagedInterface1 and TestManagedInterface3.
- * The instances of this class will be managed entities of types TestManagedInterface1 and TestManagedInterface3.
- */
-@ManagedObject( category = false , type = "ChildClass3" )
-public class TestManagedClass3 extends TestChildCategoryImpl implements TestManagedInterface1,TestManagedInterface3
+@ManagedObject( category = false, type = TestHybridEngineImpl.TEST_HYBRID_ENGINE_TYPE)
+public class TestHybridEngineImpl extends AbstractConfiguredObject<TestHybridEngineImpl> implements TestHybridEngine<TestHybridEngineImpl>
 {
-    public TestManagedClass3(final Map<String, Object> attributes, TestRootCategory<?> parent)
+    public static final String TEST_HYBRID_ENGINE_TYPE = "HYBRID";
+
+    @ManagedObjectFactoryConstructor
+    public TestHybridEngineImpl(final Map<String, Object> attributes, TestCar<?> parent)
     {
-        super(attributes, parent);
+        super(parentsMap(parent), attributes);
     }
 }

Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestKitCar.java (from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestKitCar.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestKitCar.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java&r1=1648392&r2=1648393&rev=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestKitCar.java Mon Dec 29 17:08:20 2014
@@ -16,17 +16,11 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.qpid.server.model.testmodels.hierarchy;
 
-package org.apache.qpid.server.model.testmodel;
+import org.apache.qpid.server.model.ManagedObject;
 
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-public enum TestEnum
+@ManagedObject(category = false)
+public interface TestKitCar<X extends TestKitCar<X>> extends TestCar<X>
 {
-    TEST_ENUM1,
-    TEST_ENUM2,
-    TEST_ENUM3;
 }

Added: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestKitCarImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestKitCarImpl.java?rev=1648393&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestKitCarImpl.java (added)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestKitCarImpl.java Mon Dec 29 17:08:20 2014
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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.apache.qpid.server.model.testmodels.hierarchy;
+
+import java.util.Map;
+
+import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor;
+import org.apache.qpid.server.model.AbstractConfiguredObject;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.ManagedObject;
+import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
+
+@ManagedObject( category = false,
+                type = TestKitCarImpl.TEST_KITCAR_TYPE)
+public class TestKitCarImpl extends AbstractConfiguredObject<TestKitCarImpl>
+        implements TestKitCar<TestKitCarImpl>
+{
+    public static final String TEST_KITCAR_TYPE = "testkitcar";
+
+    @ManagedObjectFactoryConstructor
+    public TestKitCarImpl(final Map<String, Object> attributes)
+    {
+        super(parentsMap(), attributes, newTaskExecutor(), TestModel.getInstance());
+    }
+
+    @Override
+    public <C extends ConfiguredObject> C createChild(final Class<C> childClass,
+                                                      final Map<String, Object> attributes,
+                                                      final ConfiguredObject... otherParents)
+    {
+        return (C) getObjectFactory().create(childClass, attributes, this);
+    }
+
+    private static CurrentThreadTaskExecutor newTaskExecutor()
+    {
+        CurrentThreadTaskExecutor currentThreadTaskExecutor = new CurrentThreadTaskExecutor();
+        currentThreadTaskExecutor.start();
+        return currentThreadTaskExecutor;
+    }
+}

Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java (from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java&r1=1648392&r2=1648393&rev=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java Mon Dec 29 17:08:20 2014
@@ -18,7 +18,7 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.model.testmodel;
+package org.apache.qpid.server.model.testmodels.hierarchy;
 
 import java.util.Arrays;
 import java.util.Collection;
@@ -34,10 +34,10 @@ import org.apache.qpid.server.plugin.Con
 public class TestModel extends Model
 {
     private static final Model INSTANCE = new TestModel();
-    private Class<? extends ConfiguredObject>[] _supportedClasses =
+    private Class<? extends ConfiguredObject>[] _supportedCategories =
             new Class[] {
-                    TestRootCategory.class,
-                    TestChildCategory.class
+                    TestCar.class,
+                    TestEngine.class
             };
 
     private final ConfiguredObjectFactory _objectFactory;
@@ -51,49 +51,38 @@ public class TestModel extends Model
     public TestModel(final ConfiguredObjectFactory objectFactory)
     {
         _objectFactory = objectFactory == null ? new ConfiguredObjectFactoryImpl(this) : objectFactory;
-        ConfiguredObjectRegistration configuredObjectRegistration = new ConfiguredObjectRegistration()
-        {
-            @Override
-            public Collection<Class<? extends ConfiguredObject>> getConfiguredObjectClasses()
-            {
-                return Arrays.<Class<? extends ConfiguredObject>>asList(TestRootCategoryImpl.class, Test2RootCategoryImpl.class);
-            }
-
-            @Override
-            public String getType()
-            {
-                return "org.apache.qpid.server.model.testmodel";
-            }
-        };
-        _registry = new ConfiguredObjectTypeRegistry(Arrays.asList(configuredObjectRegistration), getSupportedCategories());
+
+        ConfiguredObjectRegistration configuredObjectRegistration = new ConfiguredObjectRegistrationImpl();
+
+        _registry = new ConfiguredObjectTypeRegistry(Collections.singletonList(configuredObjectRegistration), Collections.EMPTY_LIST);
     }
 
 
     @Override
     public Collection<Class<? extends ConfiguredObject>> getSupportedCategories()
     {
-        return Arrays.asList(_supportedClasses);
+        return Arrays.asList(_supportedCategories);
     }
 
     @Override
     public Collection<Class<? extends ConfiguredObject>> getChildTypes(final Class<? extends ConfiguredObject> parent)
     {
-        return TestRootCategory.class.isAssignableFrom(parent)
-                ? Collections.<Class<? extends ConfiguredObject>>singleton(TestChildCategory.class)
+        return TestCar.class.isAssignableFrom(parent)
+                ? Collections.<Class<? extends ConfiguredObject>>singleton(TestEngine.class)
                 : Collections.<Class<? extends ConfiguredObject>>emptySet();
     }
 
     @Override
     public Class<? extends ConfiguredObject> getRootCategory()
     {
-        return TestRootCategory.class;
+        return TestCar.class;
     }
 
     @Override
     public Collection<Class<? extends ConfiguredObject>> getParentTypes(final Class<? extends ConfiguredObject> child)
     {
-        return TestChildCategory.class.isAssignableFrom(child)
-                ? Collections.<Class<? extends ConfiguredObject>>singleton(TestRootCategory.class)
+        return TestEngine.class.isAssignableFrom(child)
+                ? Collections.<Class<? extends ConfiguredObject>>singleton(TestCar.class)
                 : Collections.<Class<? extends ConfiguredObject>>emptySet();
     }
 

Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngine.java (from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngine.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngine.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java&r1=1648392&r2=1648393&rev=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngine.java Mon Dec 29 17:08:20 2014
@@ -17,16 +17,11 @@
  * under the License.
  */
 
-package org.apache.qpid.server.model.testmodel;
+package org.apache.qpid.server.model.testmodels.hierarchy;
 
+import org.apache.qpid.server.model.ManagedObject;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-public enum TestEnum
+@ManagedObject (category = false)
+public interface TestPetrolEngine<X extends TestPetrolEngine<X>> extends TestEngine<X>
 {
-    TEST_ENUM1,
-    TEST_ENUM2,
-    TEST_ENUM3;
 }

Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngineImpl.java (from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass1.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngineImpl.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngineImpl.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass1.java&r1=1648392&r2=1648393&rev=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedClass1.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngineImpl.java Mon Dec 29 17:08:20 2014
@@ -18,22 +18,23 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.model.testmodel;
+package org.apache.qpid.server.model.testmodels.hierarchy;
 
 import java.util.Map;
 
+import org.apache.qpid.server.model.AbstractConfiguredObject;
 import org.apache.qpid.server.model.ManagedObject;
+import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
 
-/**
- * This is a test managed type extending TestManagedClass0.
- * Because TestManagedClass0 implements managed interface TestManagedInterface1 with ManagedAnnotation set,
- * the instances of this class will be managed entities of type TestManagedInterface1.
- */
-@ManagedObject( category = false , type = "ChildClass" )
-public class TestManagedClass1 extends TestManagedClass0
+@ManagedObject( category = false, type = TestPetrolEngineImpl.TEST_PETROL_ENGINE_TYPE)
+public class TestPetrolEngineImpl
+        extends AbstractConfiguredObject<TestPetrolEngineImpl> implements TestPetrolEngine<TestPetrolEngineImpl>
 {
-    public TestManagedClass1(final Map<String, Object> attributes, TestRootCategory<?> parent)
+    public static final String TEST_PETROL_ENGINE_TYPE = "PETROL";
+
+    @ManagedObjectFactoryConstructor
+    public TestPetrolEngineImpl(final Map<String, Object> attributes, TestCar<?> parent)
     {
-        super(attributes, parent);
+        super(parentsMap(parent), attributes);
     }
 }

Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestRechargeable.java (from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface3.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestRechargeable.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestRechargeable.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface3.java&r1=1648392&r2=1648393&rev=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestManagedInterface3.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestRechargeable.java Mon Dec 29 17:08:20 2014
@@ -18,12 +18,13 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.model.testmodel;
+package org.apache.qpid.server.model.testmodels.hierarchy;
 
 import org.apache.qpid.server.model.ManagedAnnotation;
 import org.apache.qpid.server.model.ManagedInterface;
 
+
 @ManagedAnnotation
-public interface TestManagedInterface3 extends ManagedInterface
+public interface TestRechargeable extends ManagedInterface
 {
 }

Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestStandardCar.java (from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestStandardCar.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestStandardCar.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java&r1=1648392&r2=1648393&rev=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestStandardCar.java Mon Dec 29 17:08:20 2014
@@ -17,16 +17,11 @@
  * under the License.
  */
 
-package org.apache.qpid.server.model.testmodel;
+package org.apache.qpid.server.model.testmodels.hierarchy;
 
+import org.apache.qpid.server.model.ManagedObject;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-public enum TestEnum
+@ManagedObject(category = false)
+public interface TestStandardCar<X extends TestStandardCar<X>> extends TestCar<X>
 {
-    TEST_ENUM1,
-    TEST_ENUM2,
-    TEST_ENUM3;
 }

Added: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestStandardCarImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestStandardCarImpl.java?rev=1648393&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestStandardCarImpl.java (added)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestStandardCarImpl.java Mon Dec 29 17:08:20 2014
@@ -0,0 +1,60 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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.apache.qpid.server.model.testmodels.hierarchy;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor;
+import org.apache.qpid.server.model.AbstractConfiguredObject;
+import org.apache.qpid.server.model.ManagedObject;
+import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
+
+@ManagedObject( category = false,
+                type = TestStandardCarImpl.TEST_STANDARD_CAR_TYPE,
+                validChildTypes = "org.apache.qpid.server.model.testmodels.hierarchy.TestStandardCarImpl#getSupportedChildTypes()")
+public class TestStandardCarImpl extends AbstractConfiguredObject<TestStandardCarImpl>
+        implements TestStandardCar<TestStandardCarImpl>
+{
+    public static final String TEST_STANDARD_CAR_TYPE = "testpertrolcar";
+
+    @ManagedObjectFactoryConstructor
+    public TestStandardCarImpl(final Map<String, Object> attributes)
+    {
+        super(parentsMap(), attributes, newTaskExecutor(), TestModel.getInstance());
+    }
+
+    private static CurrentThreadTaskExecutor newTaskExecutor()
+    {
+        CurrentThreadTaskExecutor currentThreadTaskExecutor = new CurrentThreadTaskExecutor();
+        currentThreadTaskExecutor.start();
+        return currentThreadTaskExecutor;
+    }
+
+    @SuppressWarnings("unused")
+    public static Map<String, Collection<String>> getSupportedChildTypes()
+    {
+        Collection<String> types = Arrays.asList(TestPetrolEngineImpl.TEST_PETROL_ENGINE_TYPE, TestHybridEngineImpl.TEST_HYBRID_ENGINE_TYPE);
+        return Collections.singletonMap(TestEngine.class.getSimpleName(), types);
+    }
+}

Added: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/AbstractConfiguredObjectTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/AbstractConfiguredObjectTest.java?rev=1648393&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/AbstractConfiguredObjectTest.java (added)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/AbstractConfiguredObjectTest.java Mon Dec 29 17:08:20 2014
@@ -0,0 +1,217 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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.apache.qpid.server.model.testmodels.lifecycle;
+
+import java.util.Collections;
+
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.State;
+import org.apache.qpid.test.utils.QpidTestCase;
+
+public class AbstractConfiguredObjectTest extends QpidTestCase
+{
+
+    public void testOpeningResultsInErroredStateWhenResolutionFails() throws Exception
+    {
+        TestConfiguredObject object = new TestConfiguredObject(getName());
+        object.setThrowExceptionOnPostResolve(true);
+        object.open();
+        assertFalse("Unexpected opened", object.isOpened());
+        assertEquals("Unexpected state", State.ERRORED, object.getState());
+
+        object.setThrowExceptionOnPostResolve(false);
+        object.setAttributes(Collections.<String, Object>singletonMap(Port.DESIRED_STATE, State.ACTIVE));
+        assertTrue("Unexpected opened", object.isOpened());
+        assertEquals("Unexpected state", State.ACTIVE, object.getState());
+    }
+
+    public void testOpeningInERROREDStateAfterFailedOpenOnDesiredStateChangeToActive() throws Exception
+    {
+        TestConfiguredObject object = new TestConfiguredObject(getName());
+        object.setThrowExceptionOnOpen(true);
+        object.open();
+        assertFalse("Unexpected opened", object.isOpened());
+        assertEquals("Unexpected state", State.ERRORED, object.getState());
+
+        object.setThrowExceptionOnOpen(false);
+        object.setAttributes(Collections.<String, Object>singletonMap(Port.DESIRED_STATE, State.ACTIVE));
+        assertTrue("Unexpected opened", object.isOpened());
+        assertEquals("Unexpected state", State.ACTIVE, object.getState());
+    }
+
+    public void testOpeningInERROREDStateAfterFailedOpenOnStart() throws Exception
+    {
+        TestConfiguredObject object = new TestConfiguredObject(getName());
+        object.setThrowExceptionOnOpen(true);
+        object.open();
+        assertFalse("Unexpected opened", object.isOpened());
+        assertEquals("Unexpected state", State.ERRORED, object.getState());
+
+        object.setThrowExceptionOnOpen(false);
+        object.start();
+        assertTrue("Unexpected opened", object.isOpened());
+        assertEquals("Unexpected state", State.ACTIVE, object.getState());
+    }
+
+    public void testDeletionERROREDStateAfterFailedOpenOnDelete() throws Exception
+    {
+        TestConfiguredObject object = new TestConfiguredObject(getName());
+        object.setThrowExceptionOnOpen(true);
+        object.open();
+        assertFalse("Unexpected opened", object.isOpened());
+        assertEquals("Unexpected state", State.ERRORED, object.getState());
+
+        object.delete();
+        assertFalse("Unexpected opened", object.isOpened());
+        assertEquals("Unexpected state", State.DELETED, object.getState());
+    }
+
+    public void testDeletionInERROREDStateAfterFailedOpenOnDesiredStateChangeToDelete() throws Exception
+    {
+        TestConfiguredObject object = new TestConfiguredObject(getName());
+        object.setThrowExceptionOnOpen(true);
+        object.open();
+        assertFalse("Unexpected opened", object.isOpened());
+        assertEquals("Unexpected state", State.ERRORED, object.getState());
+
+        object.setAttributes(Collections.<String, Object>singletonMap(Port.DESIRED_STATE, State.DELETED));
+        assertFalse("Unexpected opened", object.isOpened());
+        assertEquals("Unexpected state", State.DELETED, object.getState());
+    }
+
+
+    public void testCreationWithExceptionThrownFromValidationOnCreate() throws Exception
+    {
+        TestConfiguredObject object = new TestConfiguredObject(getName());
+        object.setThrowExceptionOnValidationOnCreate(true);
+        try
+        {
+            object.create();
+            fail("IllegalConfigurationException is expected to be thrown");
+        }
+        catch(IllegalConfigurationException e)
+        {
+            //pass
+        }
+        assertFalse("Unexpected opened", object.isOpened());
+    }
+
+    public void testCreationWithoutExceptionThrownFromValidationOnCreate() throws Exception
+    {
+        TestConfiguredObject object = new TestConfiguredObject(getName());
+        object.setThrowExceptionOnValidationOnCreate(false);
+        object.create();
+        assertTrue("Unexpected opened", object.isOpened());
+        assertEquals("Unexpected state", State.ACTIVE, object.getState());
+    }
+
+    public void testCreationWithExceptionThrownFromOnOpen() throws Exception
+    {
+        TestConfiguredObject object = new TestConfiguredObject(getName());
+        object.setThrowExceptionOnOpen(true);
+        try
+        {
+            object.create();
+            fail("Exception should have been re-thrown");
+        }
+        catch (RuntimeException re)
+        {
+            // pass
+        }
+
+        assertFalse("Unexpected opened", object.isOpened());
+        assertEquals("Unexpected state", State.DELETED, object.getState());
+    }
+
+    public void testCreationWithExceptionThrownFromOnCreate() throws Exception
+    {
+        TestConfiguredObject object = new TestConfiguredObject(getName());
+        object.setThrowExceptionOnCreate(true);
+        try
+        {
+            object.create();
+            fail("Exception should have been re-thrown");
+        }
+        catch (RuntimeException re)
+        {
+            // pass
+        }
+
+        assertFalse("Unexpected opened", object.isOpened());
+        assertEquals("Unexpected state", State.DELETED, object.getState());
+    }
+
+    public void testUnresolvedChildInERROREDStateIsNotValidatedOrOpenedOrAttainedDesiredStateOnParentOpen() throws Exception
+    {
+        TestConfiguredObject parent = new TestConfiguredObject("parent");
+        TestConfiguredObject child1 = new TestConfiguredObject("child1", parent, parent.getTaskExecutor());
+        child1.registerWithParents();
+        TestConfiguredObject child2 = new TestConfiguredObject("child2", parent, parent.getTaskExecutor());
+        child2.registerWithParents();
+
+        child1.setThrowExceptionOnPostResolve(true);
+
+        parent.open();
+
+        assertTrue("Parent should be resolved", parent.isResolved());
+        assertTrue("Parent should be validated", parent.isValidated());
+        assertTrue("Parent should be opened", parent.isOpened());
+        assertEquals("Unexpected parent state", State.ACTIVE, parent.getState());
+
+        assertTrue("Child2 should be resolved", child2.isResolved());
+        assertTrue("Child2 should be validated", child2.isValidated());
+        assertTrue("Child2 should be opened", child2.isOpened());
+        assertEquals("Unexpected child2 state", State.ACTIVE, child2.getState());
+
+        assertFalse("Child2 should not be resolved", child1.isResolved());
+        assertFalse("Child1 should not be validated", child1.isValidated());
+        assertFalse("Child1 should not be opened", child1.isOpened());
+        assertEquals("Unexpected child1 state", State.ERRORED, child1.getState());
+    }
+
+    public void testUnvalidatedChildInERROREDStateIsNotOpenedOrAttainedDesiredStateOnParentOpen() throws Exception
+    {
+        TestConfiguredObject parent = new TestConfiguredObject("parent");
+        TestConfiguredObject child1 = new TestConfiguredObject("child1", parent, parent.getTaskExecutor());
+        child1.registerWithParents();
+        TestConfiguredObject child2 = new TestConfiguredObject("child2", parent, parent.getTaskExecutor());
+        child2.registerWithParents();
+
+        child1.setThrowExceptionOnValidate(true);
+
+        parent.open();
+
+        assertTrue("Parent should be resolved", parent.isResolved());
+        assertTrue("Parent should be validated", parent.isValidated());
+        assertTrue("Parent should be opened", parent.isOpened());
+        assertEquals("Unexpected parent state", State.ACTIVE, parent.getState());
+
+        assertTrue("Child2 should be resolved", child2.isResolved());
+        assertTrue("Child2 should be validated", child2.isValidated());
+        assertTrue("Child2 should be opened", child2.isOpened());
+        assertEquals("Unexpected child2 state", State.ACTIVE, child2.getState());
+
+        assertTrue("Child1 should be resolved", child1.isResolved());
+        assertFalse("Child1 should not be validated", child1.isValidated());
+        assertFalse("Child1 should not be opened", child1.isOpened());
+        assertEquals("Unexpected child1 state", State.ERRORED, child1.getState());
+    }
+
+}

Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/TestConfiguredObject.java (from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestConfiguredObject.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/TestConfiguredObject.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/TestConfiguredObject.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestConfiguredObject.java&r1=1648392&r2=1648393&rev=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestConfiguredObject.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/TestConfiguredObject.java Mon Dec 29 17:08:20 2014
@@ -16,7 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.qpid.server.model.testmodel;
+
+package org.apache.qpid.server.model.testmodels.lifecycle;
 
 import static org.mockito.Mockito.mock;
 

Added: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/AbstractConfiguredObjectTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/AbstractConfiguredObjectTest.java?rev=1648393&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/AbstractConfiguredObjectTest.java (added)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/AbstractConfiguredObjectTest.java Mon Dec 29 17:08:20 2014
@@ -0,0 +1,445 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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.apache.qpid.server.model.testmodels.singleton;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.Model;
+import org.apache.qpid.server.store.ConfiguredObjectRecord;
+import org.apache.qpid.test.utils.QpidTestCase;
+
+/**
+ * Tests behaviour of AbstractConfiguredObject related to attributes including
+ * persistence, defaulting, and attribute values derived from context variables.
+ */
+public class AbstractConfiguredObjectTest extends QpidTestCase
+{
+    private final Model _model = TestModel.getInstance();
+
+    public void testAttributePersistence()
+    {
+        final String objectName = "testNonPersistAttributes";
+        TestSingleton object =
+                _model.getObjectFactory().create(TestSingleton.class,
+                                                Collections.<String, Object>singletonMap(ConfiguredObject.NAME,
+                                                                                         objectName)
+                                               );
+
+        assertEquals(objectName, object.getName());
+        assertNull(object.getAutomatedNonPersistedValue());
+        assertNull(object.getAutomatedPersistedValue());
+        assertEquals(TestSingletonImpl.DERIVED_VALUE, object.getDerivedValue());
+
+        ConfiguredObjectRecord record = object.asObjectRecord();
+
+        assertEquals(objectName, record.getAttributes().get(ConfiguredObject.NAME));
+
+        assertFalse(record.getAttributes().containsKey(TestSingleton.AUTOMATED_PERSISTED_VALUE));
+        assertFalse(record.getAttributes().containsKey(TestSingleton.AUTOMATED_NONPERSISTED_VALUE));
+        assertFalse(record.getAttributes().containsKey(TestSingleton.DERIVED_VALUE));
+
+        Map<String, Object> updatedAttributes = new HashMap<>();
+
+        final String newValue = "newValue";
+
+        updatedAttributes.put(TestSingleton.AUTOMATED_PERSISTED_VALUE, newValue);
+        updatedAttributes.put(TestSingleton.AUTOMATED_NONPERSISTED_VALUE, newValue);
+        updatedAttributes.put(TestSingleton.DERIVED_VALUE, System.currentTimeMillis());  // Will be ignored
+        object.setAttributes(updatedAttributes);
+
+        assertEquals(newValue, object.getAutomatedPersistedValue());
+        assertEquals(newValue, object.getAutomatedNonPersistedValue());
+
+        record = object.asObjectRecord();
+        assertEquals(objectName, record.getAttributes().get(ConfiguredObject.NAME));
+        assertEquals(newValue, record.getAttributes().get(TestSingleton.AUTOMATED_PERSISTED_VALUE));
+
+        assertFalse(record.getAttributes().containsKey(TestSingleton.AUTOMATED_NONPERSISTED_VALUE));
+        assertFalse(record.getAttributes().containsKey(TestSingleton.DERIVED_VALUE));
+
+    }
+
+    public void testDefaultedAttributeValue()
+    {
+        final String objectName = "myName";
+
+        Map<String, Object> attributes = Collections.<String, Object>singletonMap(TestSingleton.NAME, objectName);
+
+        TestSingleton object1 = _model.getObjectFactory().create(TestSingleton.class,
+                                                                   attributes);
+
+        assertEquals(objectName, object1.getName());
+        assertEquals(TestSingleton.DEFAULTED_VALUE_DEFAULT, object1.getDefaultedValue());
+    }
+
+    public void testOverriddenDefaultedAttributeValue()
+    {
+        final String objectName = "myName";
+
+        Map<String, Object> attributes = new HashMap<>();
+        attributes.put(TestSingleton.NAME, objectName);
+        attributes.put(TestSingleton.DEFAULTED_VALUE, "override");
+
+        TestSingleton object = _model.getObjectFactory().create(TestSingleton.class,
+                                                                   attributes);
+
+        assertEquals(objectName, object.getName());
+        assertEquals("override", object.getDefaultedValue());
+
+    }
+
+    public void testOverriddenDefaultedAttributeValueRevertedToDefault()
+    {
+        final String objectName = "myName";
+
+        Map<String, Object> attributes = new HashMap<>();
+        attributes.put(TestSingleton.NAME, objectName);
+        attributes.put(TestSingleton.DEFAULTED_VALUE, "override");
+
+        TestSingleton object = _model.getObjectFactory().create(TestSingleton.class,
+                                                                   attributes);
+
+        assertEquals(objectName, object.getName());
+        assertEquals("override", object.getDefaultedValue());
+
+        object.setAttributes(Collections.singletonMap(TestSingleton.DEFAULTED_VALUE, null));
+
+        assertEquals(TestSingleton.DEFAULTED_VALUE_DEFAULT, object.getDefaultedValue());
+    }
+
+    public void testEnumAttributeValueFromString()
+    {
+        final String objectName = "myName";
+
+        Map<String, Object> attributes = new HashMap<>();
+        attributes.put(TestSingleton.NAME, objectName);
+        attributes.put(TestSingleton.ENUM_VALUE, TestEnum.TEST_ENUM1.name());
+
+        TestSingleton object1 = _model.getObjectFactory().create(TestSingleton.class,
+                                                                    attributes);
+
+        assertEquals(objectName, object1.getName());
+        assertEquals(TestEnum.TEST_ENUM1, object1.getEnumValue());
+    }
+
+    public void testEnumAttributeValueFromEnum()
+    {
+        final String objectName = "myName";
+
+        Map<String, Object> attributes = new HashMap<>();
+        attributes.put(TestSingleton.NAME, objectName);
+        attributes.put(TestSingleton.ENUM_VALUE, TestEnum.TEST_ENUM1);
+
+        TestSingleton object1 = _model.getObjectFactory().create(TestSingleton.class,
+                                                                    attributes);
+
+        assertEquals(objectName, object1.getName());
+        assertEquals(TestEnum.TEST_ENUM1, object1.getEnumValue());
+    }
+
+    public void testIntegerAttributeValueFromString()
+    {
+        final String objectName = "myName";
+
+        Map<String, Object> attributes = new HashMap<>();
+        attributes.put(TestSingleton.NAME, objectName);
+        attributes.put(TestSingleton.INT_VALUE, "-4");
+
+        TestSingleton object1 = _model.getObjectFactory().create(TestSingleton.class,
+                                                                     attributes);
+
+        assertEquals(objectName, object1.getName());
+        assertEquals(-4, object1.getIntValue());
+    }
+
+    public void testIntegerAttributeValueFromInteger()
+    {
+        final String objectName = "myName";
+
+        Map<String, Object> attributes = new HashMap<>();
+        attributes.put(TestSingleton.NAME, objectName);
+        attributes.put(TestSingleton.INT_VALUE, 5);
+
+        TestSingleton object1 = _model.getObjectFactory().create(TestSingleton.class,
+                                                                     attributes);
+
+        assertEquals(objectName, object1.getName());
+        assertEquals(5, object1.getIntValue());
+    }
+
+    public void testIntegerAttributeValueFromDouble()
+    {
+        final String objectName = "myName";
+
+        Map<String, Object> attributes = new HashMap<>();
+        attributes.put(TestSingleton.NAME, objectName);
+        attributes.put(TestSingleton.INT_VALUE, 6.1);
+
+        TestSingleton object1 = _model.getObjectFactory().create(TestSingleton.class,
+                                                                     attributes);
+
+        assertEquals(objectName, object1.getName());
+        assertEquals(6, object1.getIntValue());
+    }
+
+    public void testStringAttributeValueFromContextVariableProvidedBySystemProperty()
+    {
+        String sysPropertyName = "testStringAttributeValueFromContextVariableProvidedBySystemProperty";
+        String contextToken = "${" + sysPropertyName + "}";
+
+        System.setProperty(sysPropertyName, "myValue");
+
+        final String objectName = "myName";
+
+        Map<String, Object> attributes = new HashMap<>();
+        attributes.put(TestSingleton.NAME, objectName);
+        attributes.put(TestSingleton.STRING_VALUE, contextToken);
+
+        TestSingleton object1 = _model.getObjectFactory().create(TestSingleton.class,
+                                                                    attributes);
+
+        assertEquals(objectName, object1.getName());
+        assertEquals("myValue", object1.getStringValue());
+
+        // System property set empty string
+
+        System.setProperty(sysPropertyName, "");
+        TestSingleton object2 = _model.getObjectFactory().create(TestSingleton.class,
+                                                                    attributes);
+
+        assertEquals("", object2.getStringValue());
+
+        // System property not set
+        System.clearProperty(sysPropertyName);
+
+        TestSingleton object3 = _model.getObjectFactory().create(TestSingleton.class,
+                                                                    attributes);
+
+        // yields the unexpanded token - not sure if this is really useful behaviour?
+        assertEquals(contextToken, object3.getStringValue());
+    }
+
+    public void testMapAttributeValueFromContextVariableProvidedBySystemProperty()
+    {
+        String sysPropertyName = "testMapAttributeValueFromContextVariableProvidedBySystemProperty";
+        String contextToken = "${" + sysPropertyName + "}";
+
+        Map<String,String> expectedMap = new HashMap<>();
+        expectedMap.put("field1", "value1");
+        expectedMap.put("field2", "value2");
+
+        System.setProperty(sysPropertyName, "{ \"field1\" : \"value1\", \"field2\" : \"value2\"}");
+
+        final String objectName = "myName";
+
+        Map<String, Object> attributes = new HashMap<>();
+        attributes.put(TestSingleton.NAME, objectName);
+        attributes.put(TestSingleton.MAP_VALUE, contextToken);
+
+        TestSingleton object1 = _model.getObjectFactory().create(TestSingleton.class,
+                                                                    attributes);
+
+        assertEquals(objectName, object1.getName());
+        assertEquals(expectedMap, object1.getMapValue());
+
+        // System property not set
+        System.clearProperty(sysPropertyName);
+    }
+
+    public void testStringAttributeValueFromContextVariableProvidedObjectsContext()
+    {
+        String contextToken = "${myReplacement}";
+
+        final String objectName = "myName";
+
+        Map<String, Object> attributes = new HashMap<>();
+        attributes.put(ConfiguredObject.NAME, objectName);
+        attributes.put(ConfiguredObject.CONTEXT, Collections.singletonMap("myReplacement", "myValue"));
+        attributes.put(TestSingleton.STRING_VALUE, contextToken);
+
+        TestSingleton object1 = _model.getObjectFactory().create(TestSingleton.class,
+                                                                    attributes);
+        // Check the object's context itself
+        assertTrue(object1.getContext().containsKey("myReplacement"));
+        assertEquals("myValue", object1.getContext().get("myReplacement"));
+
+        assertEquals(objectName, object1.getName());
+        assertEquals("myValue", object1.getStringValue());
+    }
+
+    public void testInvalidIntegerAttributeValueFromContextVariable()
+    {
+        final Map<String, Object> attributes = new HashMap<>();
+
+        attributes.put(TestSingleton.NAME, "myName");
+        attributes.put(TestSingleton.TYPE, TestSingletonImpl.TEST_SINGLETON_TYPE);
+        attributes.put(TestSingleton.CONTEXT, Collections.singletonMap("contextVal", "notAnInteger"));
+        attributes.put(TestSingleton.INT_VALUE, "${contextVal}");
+
+        try
+        {
+            _model.getObjectFactory().create(TestSingleton.class, attributes);
+            fail("creation of child object should have failed due to invalid value");
+        }
+        catch (IllegalArgumentException e)
+        {
+            // PASS
+            String message = e.getMessage();
+            assertTrue("Message does not contain the attribute name", message.contains("intValue"));
+            assertTrue("Message does not contain the non-interpolated value", message.contains("contextVal"));
+            assertTrue("Message does not contain the interpolated value", message.contains("contextVal"));
+
+        }
+    }
+
+    public void testCreateEnforcesAttributeValidValues() throws Exception
+    {
+        final String objectName = getName();
+        Map<String, Object> illegalCreateAttributes = new HashMap<>();
+        illegalCreateAttributes.put(ConfiguredObject.NAME, objectName);
+        illegalCreateAttributes.put(TestSingleton.VALID_VALUE, "illegal");
+
+        try
+        {
+            _model.getObjectFactory().create(TestSingleton.class, illegalCreateAttributes);
+            fail("Exception not thrown");
+        }
+        catch (IllegalConfigurationException ice)
+        {
+            // PASS
+        }
+
+        Map<String, Object> legalCreateAttributes = new HashMap<>();
+        legalCreateAttributes.put(ConfiguredObject.NAME, objectName);
+        legalCreateAttributes.put(TestSingleton.VALID_VALUE, TestSingleton.VALID_VALUE1);
+
+        TestSingleton object = _model.getObjectFactory().create(TestSingleton.class, legalCreateAttributes);
+        assertEquals(TestSingleton.VALID_VALUE1, object.getValidValue());
+    }
+
+    public void testChangeEnforcesAttributeValidValues() throws Exception
+    {
+        final String objectName = getName();
+        Map<String, Object> legalCreateAttributes = new HashMap<>();
+        legalCreateAttributes.put(ConfiguredObject.NAME, objectName);
+        legalCreateAttributes.put(TestSingleton.VALID_VALUE, TestSingleton.VALID_VALUE1);
+
+        TestSingleton object = _model.getObjectFactory().create(TestSingleton.class, legalCreateAttributes);
+        assertEquals(TestSingleton.VALID_VALUE1, object.getValidValue());
+
+        object.setAttributes(Collections.singletonMap(TestSingleton.VALID_VALUE, TestSingleton.VALID_VALUE2));
+        assertEquals(TestSingleton.VALID_VALUE2, object.getValidValue());
+
+        try
+        {
+            object.setAttributes(Collections.singletonMap(TestSingleton.VALID_VALUE, "illegal"));
+            fail("Exception not thrown");
+        }
+        catch (IllegalConfigurationException iae)
+        {
+            // PASS
+        }
+
+        assertEquals(TestSingleton.VALID_VALUE2, object.getValidValue());
+
+        object.setAttributes(Collections.singletonMap(TestSingleton.VALID_VALUE,null));
+        assertNull(object.getValidValue());
+
+    }
+
+    public void testCreateEnforcesAttributeValidValuesWithSets() throws Exception
+    {
+        final String objectName = getName();
+        final Map<String, Object> name = Collections.singletonMap(ConfiguredObject.NAME, (Object)objectName);
+
+        Map<String, Object> illegalCreateAttributes = new HashMap<>(name);
+        illegalCreateAttributes.put(TestSingleton.ENUMSET_VALUES, Collections.singleton(TestEnum.TEST_ENUM3));
+
+        try
+        {
+            _model.getObjectFactory().create(TestSingleton.class, illegalCreateAttributes);
+            fail("Exception not thrown");
+        }
+        catch (IllegalConfigurationException ice)
+        {
+            // PASS
+        }
+
+        {
+            Map<String, Object> legalCreateAttributesEnums = new HashMap<>(name);
+            legalCreateAttributesEnums.put(TestSingleton.ENUMSET_VALUES,
+                                           Arrays.asList(TestEnum.TEST_ENUM2, TestEnum.TEST_ENUM3));
+
+            TestSingleton obj = _model.getObjectFactory().create(TestSingleton.class, legalCreateAttributesEnums);
+            assertTrue(obj.getEnumSetValues().containsAll(Arrays.asList(TestEnum.TEST_ENUM2, TestEnum.TEST_ENUM3)));
+        }
+
+        {
+            Map<String, Object> legalCreateAttributesStrings = new HashMap<>(name);
+            legalCreateAttributesStrings.put(TestSingleton.ENUMSET_VALUES,
+                                             Arrays.asList(TestEnum.TEST_ENUM2.name(), TestEnum.TEST_ENUM3.name()));
+
+            TestSingleton
+                    obj = _model.getObjectFactory().create(TestSingleton.class, legalCreateAttributesStrings);
+            assertTrue(obj.getEnumSetValues().containsAll(Arrays.asList(TestEnum.TEST_ENUM2, TestEnum.TEST_ENUM3)));
+        }
+    }
+
+    public void testDefaultContextIsInContextKeys()
+    {
+        final String objectName = "myName";
+
+        Map<String, Object> attributes = new HashMap<>();
+        attributes.put(ConfiguredObject.NAME, objectName);
+
+        TestSingleton object = _model.getObjectFactory().create(TestSingleton.class,
+                                                                    attributes);
+
+
+        assertTrue("context default not in contextKeys",
+                   object.getContextKeys(true).contains(TestSingleton.TEST_CONTEXT_DEFAULT));
+        assertEquals(object.getContextValue(String.class, TestSingleton.TEST_CONTEXT_DEFAULT), "default");
+
+        setTestSystemProperty(TestSingleton.TEST_CONTEXT_DEFAULT, "notdefault");
+        assertTrue("context default not in contextKeys",
+                   object.getContextKeys(true).contains(TestSingleton.TEST_CONTEXT_DEFAULT));
+        assertEquals(object.getContextValue(String.class, TestSingleton.TEST_CONTEXT_DEFAULT), "notdefault");
+    }
+
+    public void testDerivedAttributeValue()
+    {
+        final String objectName = "myName";
+
+        Map<String, Object> attributes = new HashMap<>();
+        attributes.put(ConfiguredObject.NAME, objectName);
+
+        TestSingleton object = _model.getObjectFactory().create(TestSingleton.class, attributes);
+        assertEquals(TestSingletonImpl.DERIVED_VALUE, object.getDerivedValue());
+
+        // Check that update is ignored
+        object.setAttribute(TestSingleton.DERIVED_VALUE, object.getDerivedValue(), System.currentTimeMillis());
+
+        assertEquals(TestSingletonImpl.DERIVED_VALUE, object.getDerivedValue());
+    }
+}

Copied: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestEnum.java (from r1648392, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestEnum.java?p2=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestEnum.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java&r1=1648392&r2=1648393&rev=1648393&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestEnum.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestEnum.java Mon Dec 29 17:08:20 2014
@@ -17,13 +17,9 @@
  * under the License.
  */
 
-package org.apache.qpid.server.model.testmodel;
+package org.apache.qpid.server.model.testmodels.singleton;
 
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
 public enum TestEnum
 {
     TEST_ENUM1,



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message