You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2018/03/13 16:26:47 UTC

qpid-broker-j git commit: QPID-7197: [Broker-J] Prevent deletion of objects that are in use

Repository: qpid-broker-j
Updated Branches:
  refs/heads/master 7913b0d64 -> d14659c85


QPID-7197: [Broker-J] Prevent deletion of objects that are in use


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/d14659c8
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/d14659c8
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/d14659c8

Branch: refs/heads/master
Commit: d14659c8562da5d31e58b6c6abd6c3c7b008a6a5
Parents: 7913b0d
Author: Alex Rudyy <or...@apache.org>
Authored: Tue Mar 13 16:08:53 2018 +0000
Committer: Alex Rudyy <or...@apache.org>
Committed: Tue Mar 13 16:08:53 2018 +0000

----------------------------------------------------------------------
 .../server/model/AbstractConfiguredObject.java  | 136 +++++++++++++++++++
 .../qpid/server/security/AbstractKeyStore.java  |  25 ----
 .../server/security/AbstractTrustStore.java     |  56 --------
 .../manager/AbstractAuthenticationManager.java  |  22 ---
 .../qpid/server/model/BrokerTestHelper.java     |   3 +
 .../adapter/FileBasedGroupProviderImplTest.java |  20 +--
 .../hierarchy/AbstractConfiguredObjectTest.java |  83 +++++++++++
 .../hierarchy/TestAbstractSensorImpl.java       |  54 ++++++++
 .../testmodels/hierarchy/TestElecEngine.java    |   3 +
 .../hierarchy/TestElecEngineImpl.java           |   9 ++
 .../model/testmodels/hierarchy/TestModel.java   |   7 +-
 .../testmodels/hierarchy/TestPetrolEngine.java  |   5 +
 .../hierarchy/TestPetrolEngineImpl.java         |  10 ++
 .../model/testmodels/hierarchy/TestSensor.java  |  29 ++++
 .../hierarchy/TestTemperatureSensorImpl.java    |  40 ++++++
 .../qpid/server/security/FileKeyStoreTest.java  |  44 +-----
 .../server/security/FileTrustStoreTest.java     |  69 ----------
 .../ManagedAuthenticationManagerTestBase.java   |  24 ----
 ...sswordDatabaseAuthenticationManagerTest.java |  22 +--
 .../RedirectingVirtualHostNodeTest.java         |  15 --
 .../protocol/v0_10/ServerSessionTest.java       |   3 +
 .../logging/logback/BrokerLoggerTest.java       |   4 +-
 22 files changed, 390 insertions(+), 293 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java b/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
index f6bbb78..3fe5684 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
@@ -29,6 +29,7 @@ import java.lang.reflect.Modifier;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Proxy;
 import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
 import java.security.AccessControlContext;
 import java.security.AccessControlException;
 import java.security.AccessController;
@@ -57,6 +58,7 @@ import java.util.concurrent.Executor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Supplier;
 import java.util.regex.Pattern;
 
 import javax.security.auth.Subject;
@@ -2225,6 +2227,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
         ConfiguredObject<?> proxyForValidation = createProxyForValidation(attributes);
         authoriseSetAttributes(proxyForValidation, attributes);
         validateChange(proxyForValidation, attributes.keySet());
+        validateReferences(getHierarchyRoot(this), this);
 
         // for DELETED state we should invoke transition method first to make sure that object can be deleted.
         // If method results in exception being thrown due to various integrity violations
@@ -2243,6 +2246,139 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
         return deleteNoChecks();
     }
 
+    private ConfiguredObject<?> getHierarchyRoot(final AbstractConfiguredObject<X> o)
+    {
+        ConfiguredObject<?> object = o;
+        do
+        {
+            ConfiguredObject<?> parent = object.getParent();
+            if (parent == null || managesChildren(parent))
+            {
+                break;
+            }
+            object = parent;
+        }
+        while (true);
+        return object;
+    }
+
+    private boolean managesChildren(final ConfiguredObject<?> object)
+    {
+        return managesChildren(object.getCategoryClass()) || managesChildren(object.getTypeClass());
+    }
+
+    private void validateReferences(final ConfiguredObject<?> object,
+                                    final ConfiguredObject<?> lookupReference)
+    {
+        if (hasReference(object, lookupReference))
+        {
+            throw new IntegrityViolationException(String.format("Configured object %s is referred by %s",
+                                                                lookupReference,
+                                                                object));
+        }
+
+        if (!managesChildren(object))
+        {
+            getModel().getChildTypes(object.getCategoryClass())
+                      .forEach(childClass -> object.getChildren(childClass)
+                                                   .forEach(child -> validateReferences(child, lookupReference)));
+        }
+    }
+
+    private boolean hasReference(final ConfiguredObject<?> object,
+                                 final ConfiguredObject<?> lookupReference)
+    {
+        if (object instanceof AbstractConfiguredObject)
+        {
+            return getModel().getTypeRegistry()
+                             .getAttributes(object.getClass())
+                             .stream()
+                             .anyMatch(attribute -> {
+                                 Class<?> type = attribute.getType();
+                                 Type genericType = attribute.getGenericType();
+                                 return isReferred(lookupReference, type,
+                                                   genericType,
+                                                   () -> {
+                                                       @SuppressWarnings("unchecked")
+                                                       Object value =
+                                                               ((ConfiguredObjectAttribute) attribute).getValue(object);
+                                                       return value;
+                                                   });
+                             });
+        }
+        else
+        {
+            return object.getAttributeNames().stream().anyMatch(name -> {
+                Object value = object.getAttribute(name);
+                if (value != null)
+                {
+                   Class<?> type = value.getClass();
+                   return isReferred(lookupReference, type, type, () -> value);
+                }
+                return false;
+            });
+        }
+
+    }
+
+    private boolean isReferred(final ConfiguredObject<?> lookupReference,
+                               final Class<?> attributeValueType,
+                               final Type attributeGenericType,
+                               final Supplier<?> attributeValue)
+    {
+        final Class<? extends ConfiguredObject> lookupCategory = lookupReference.getCategoryClass();
+        if (lookupCategory.isAssignableFrom(attributeValueType))
+        {
+            return attributeValue.get() == lookupReference;
+        }
+        else if (hasParameterOfType(attributeGenericType, lookupCategory))
+        {
+            Object value = attributeValue.get();
+            if (value instanceof Collection)
+            {
+                return ((Collection<?>) value).stream().anyMatch(m -> m == lookupReference);
+            }
+            else if (value instanceof Object[])
+            {
+                return Arrays.stream((Object[]) value).anyMatch(m -> m == lookupReference);
+            }
+            else if (value instanceof Map)
+            {
+                return ((Map<?, ?>) value).entrySet()
+                                          .stream()
+                                          .anyMatch(e -> e.getKey() == lookupReference
+                                                         || e.getValue() == lookupReference);
+            }
+        }
+        return false;
+    }
+
+    private boolean hasParameterOfType(Type genericType, Class<?> parameterType)
+    {
+        if (genericType instanceof ParameterizedType)
+        {
+            Type[] types = ((ParameterizedType) genericType).getActualTypeArguments();
+            return Arrays.stream(types).anyMatch(type -> {
+                if (type instanceof Class && parameterType.isAssignableFrom((Class) type))
+                {
+                    return true;
+                }
+                else if (type instanceof ParameterizedType)
+                {
+                    Type rawType = ((ParameterizedType) type).getRawType();
+                    return rawType instanceof Class && parameterType.isAssignableFrom((Class) rawType);
+                }
+                else if (type instanceof TypeVariable)
+                {
+                    Type[] bounds = ((TypeVariable) type).getBounds();
+                    return Arrays.stream(bounds).anyMatch(boundType -> hasParameterOfType(boundType, parameterType));
+                }
+                return false;
+            });
+        }
+        return false;
+    }
+
     protected ListenableFuture<Void> deleteNoChecks()
     {
         final String simpleClassName = AbstractConfiguredObject.this.getClass().getSimpleName();

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/main/java/org/apache/qpid/server/security/AbstractKeyStore.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/security/AbstractKeyStore.java b/broker-core/src/main/java/org/apache/qpid/server/security/AbstractKeyStore.java
index 453399a..d240849 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/security/AbstractKeyStore.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/security/AbstractKeyStore.java
@@ -80,31 +80,6 @@ public abstract class AbstractKeyStore<X extends AbstractKeyStore<X>>
     }
 
     @Override
-    protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes)
-    {
-        super.validateChange(proxyForValidation, changedAttributes);
-
-        if (changedAttributes.contains(ConfiguredObject.DESIRED_STATE) && proxyForValidation.getDesiredState() == State.DELETED)
-        {
-            // verify that it is not in use
-            String storeName = getName();
-
-            Collection<Port> ports = new ArrayList<>(getBroker().getPorts());
-            for (Port port : ports)
-            {
-                if (port.getKeyStore() == this)
-                {
-                    throw new IntegrityViolationException(String.format(
-                            "Key store '%s' can't be deleted as it is in use by a port: %s",
-                            storeName,
-                            port.getName()));
-                }
-            }
-        }
-
-    }
-
-    @Override
     protected ListenableFuture<Void> onClose()
     {
         if(_checkExpiryTaskFuture != null)

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/main/java/org/apache/qpid/server/security/AbstractTrustStore.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/security/AbstractTrustStore.java b/broker-core/src/main/java/org/apache/qpid/server/security/AbstractTrustStore.java
index fe4655a..e0760a4 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/security/AbstractTrustStore.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/security/AbstractTrustStore.java
@@ -107,62 +107,6 @@ public abstract class AbstractTrustStore<X extends AbstractTrustStore<X>>
         return _eventLogger;
     }
 
-
-    @Override
-    protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes)
-    {
-        super.validateChange(proxyForValidation, changedAttributes);
-
-        if (changedAttributes.contains(ConfiguredObject.DESIRED_STATE)
-            && proxyForValidation.getDesiredState() == State.DELETED)
-        {
-            // verify that it is not in use
-            String storeName = getName();
-
-            Collection<Port<?>> ports = new ArrayList<>(_broker.getPorts());
-            for (Port<?> port : ports)
-            {
-                Collection<TrustStore> trustStores = port.getTrustStores();
-                if (trustStores != null)
-                {
-                    for (TrustStore store : trustStores)
-                    {
-                        if (storeName.equals(store.getAttribute(TrustStore.NAME)))
-                        {
-                            throw new IntegrityViolationException(String.format(
-                                    "Trust store '%s' can't be deleted as it is in use by a port: %s",
-                                    storeName,
-                                    port.getName()));
-                        }
-                    }
-                }
-            }
-
-            Collection<AuthenticationProvider> authenticationProviders =
-                    new ArrayList<>(_broker.getAuthenticationProviders());
-            for (AuthenticationProvider authProvider : authenticationProviders)
-            {
-                TrustStore otherTrustStore = null;
-                if (authProvider instanceof SimpleLDAPAuthenticationManager)
-                {
-                    otherTrustStore = ((SimpleLDAPAuthenticationManager) authProvider).getTrustStore();
-                }
-                else if (authProvider instanceof OAuth2AuthenticationProvider)
-                {
-                    otherTrustStore = ((OAuth2AuthenticationProvider) authProvider).getTrustStore();
-                }
-
-                if (otherTrustStore == this)
-                {
-                    throw new IntegrityViolationException(String.format(
-                            "Trust store '%s' can't be deleted as it is in use by an authentication manager: '%s'",
-                            getName(),
-                            authProvider.getName()));
-                }
-            }
-        }
-    }
-
     @Override
     protected ListenableFuture<Void> onClose()
     {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java b/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java
index 5b8b219..337b109 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java
@@ -81,28 +81,6 @@ public abstract class AbstractAuthenticationManager<T extends AbstractAuthentica
     }
 
     @Override
-    protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes)
-    {
-        super.validateChange(proxyForValidation, changedAttributes);
-
-        if (changedAttributes.contains(ConfiguredObject.DESIRED_STATE) && proxyForValidation.getDesiredState() == State.DELETED)
-        {
-            String providerName = getName();
-            // verify that provider is not in use
-            Collection<Port> ports = new ArrayList<>(_container.getChildren(Port.class));
-            for (Port<?> port : ports)
-            {
-                if (port.getAuthenticationProvider() == this)
-                {
-                    throw new IntegrityViolationException(String.format("Authentication provider '%s' is set on port %s",
-                                                                        providerName,
-                                                                        port.getName()));
-                }
-            }
-        }
-    }
-
-    @Override
     public List<String> getAvailableMechanisms(boolean secure)
     {
         List<String> mechanisms = getMechanisms();

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/model/BrokerTestHelper.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/model/BrokerTestHelper.java b/broker-core/src/test/java/org/apache/qpid/server/model/BrokerTestHelper.java
index f1958ff..0046ec9 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/model/BrokerTestHelper.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/model/BrokerTestHelper.java
@@ -132,6 +132,7 @@ public class BrokerTestHelper
         when(systemConfig.getObjectFactory()).thenReturn(objectFactory);
         when(systemConfig.getModel()).thenReturn(objectFactory.getModel());
         when(systemConfig.getCategoryClass()).thenReturn(SystemConfig.class);
+        when(systemConfig.getTypeClass()).thenReturn(SystemConfig.class);
 
         Broker broker = mockWithSystemPrincipalAndAccessControl(Broker.class, SYSTEM_PRINCIPAL, accessControl);
         when(broker.getId()).thenReturn(UUID.randomUUID());
@@ -140,6 +141,7 @@ public class BrokerTestHelper
         when(broker.getModelVersion()).thenReturn(BrokerModel.MODEL_VERSION);
         when(broker.getEventLogger()).thenReturn(eventLogger);
         when(broker.getCategoryClass()).thenReturn(Broker.class);
+        when(broker.getTypeClass()).thenReturn(Broker.class);
         when(broker.getParent()).thenReturn(systemConfig);
         when(broker.getContextValue(eq(Long.class), eq(Broker.CHANNEL_FLOW_CONTROL_ENFORCEMENT_TIMEOUT))).thenReturn(0l);
         when(broker.getFlowToDiskThreshold()).thenReturn(Long.MAX_VALUE);
@@ -149,6 +151,7 @@ public class BrokerTestHelper
         when(broker.getChildExecutor()).thenReturn(TASK_EXECUTOR);
         when(systemConfig.getChildExecutor()).thenReturn(TASK_EXECUTOR);
         when(systemConfig.createPreferenceStore()).thenReturn(mock(PreferenceStore.class));
+        when(systemConfig.getChildren(Broker.class)).thenReturn(Collections.singleton(broker));
 
         return broker;
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImplTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImplTest.java b/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImplTest.java
index 6f6e4d3..4e25ae0 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImplTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImplTest.java
@@ -25,7 +25,6 @@ import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.Matchers.containsInAnyOrder;
 import static org.hamcrest.Matchers.equalTo;
 import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.io.File;
@@ -42,23 +41,17 @@ import java.util.stream.Collectors;
 import com.google.common.collect.Sets;
 
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
-import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor;
-import org.apache.qpid.server.configuration.updater.TaskExecutor;
-import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.BrokerModel;
+import org.apache.qpid.server.model.BrokerTestHelper;
 import org.apache.qpid.server.model.ConfiguredObjectFactory;
-import org.apache.qpid.server.model.ConfiguredObjectFactoryImpl;
 import org.apache.qpid.server.model.Group;
 import org.apache.qpid.server.model.GroupMember;
 import org.apache.qpid.server.model.GroupProvider;
-import org.apache.qpid.server.model.Model;
 import org.apache.qpid.test.utils.QpidTestCase;
 import org.apache.qpid.test.utils.TestFileUtils;
 
 public class FileBasedGroupProviderImplTest extends QpidTestCase
 {
-    private TaskExecutor _taskExecutor;
     private Broker<?> _broker;
     private File _groupFile;
     private ConfiguredObjectFactory _objectFactory;
@@ -67,15 +60,9 @@ public class FileBasedGroupProviderImplTest extends QpidTestCase
     public void setUp() throws Exception
     {
         super.setUp();
-        _taskExecutor = CurrentThreadTaskExecutor.newStartedInstance();
 
-        final Model model = BrokerModel.getInstance();
-        _objectFactory = new ConfiguredObjectFactoryImpl(model);
-
-        _broker = mock(Broker.class);
-        when(_broker.getTaskExecutor()).thenReturn(_taskExecutor);
-        when(_broker.getChildExecutor()).thenReturn(_taskExecutor);
-        when(_broker.getModel()).thenReturn(model);
+        _broker = BrokerTestHelper.createBrokerMock();
+        _objectFactory = _broker.getObjectFactory();
     }
 
     @Override
@@ -87,7 +74,6 @@ public class FileBasedGroupProviderImplTest extends QpidTestCase
             {
                 _groupFile.delete();
             }
-           _taskExecutor.stop();
         }
         finally
         {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/AbstractConfiguredObjectTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/AbstractConfiguredObjectTest.java b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/AbstractConfiguredObjectTest.java
index 1d11645..efb0407 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/AbstractConfiguredObjectTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/AbstractConfiguredObjectTest.java
@@ -37,6 +37,7 @@ import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.model.AbstractConfigurationChangeListener;
 import org.apache.qpid.server.model.AbstractConfiguredObject;
 import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.IntegrityViolationException;
 import org.apache.qpid.server.model.Model;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.SystemConfig;
@@ -495,6 +496,88 @@ public class AbstractConfiguredObjectTest extends QpidTestCase
         assertEquals("Child heard an unexpected number of state changes", 0, newStates.size());
     }
 
+    public void testDeleteConfiguredObjectReferredFromAttribute()
+    {
+        Map<String, Object> carAttributes = new HashMap<>();
+        carAttributes.put(ConfiguredObject.NAME, "car");
+        carAttributes.put(ConfiguredObject.TYPE, TestKitCarImpl.TEST_KITCAR_TYPE);
+        TestCar car1 = _model.getObjectFactory().create(TestCar.class, carAttributes, null);
+
+        Map<String, Object> sensorAttributes = new HashMap<>();
+        sensorAttributes.put(ConfiguredObject.NAME, "sensor");
+        sensorAttributes.put(ConfiguredObject.TYPE, TestTemperatureSensorImpl.TEST_TEMPERATURE_SENSOR_TYPE);
+        TestSensor sensor = (TestSensor) car1.createChild(TestSensor.class, sensorAttributes);
+
+        Map<String, Object> engineAttributes = new HashMap<>();
+        engineAttributes.put(ConfiguredObject.NAME, "engine");
+        engineAttributes.put(ConfiguredObject.TYPE, TestElecEngineImpl.TEST_ELEC_ENGINE_TYPE);
+        engineAttributes.put("temperatureSensor", sensor.getName());
+        car1.createChild(TestEngine.class, engineAttributes);
+
+        try
+        {
+            sensor.delete();
+            fail("Referred engine cannot be deleted");
+        }
+        catch (IntegrityViolationException e)
+        {
+            // pass
+        }
+    }
+
+    public void testDeleteConfiguredObjectReferredFromCollection()
+    {
+        Map<String, Object> carAttributes = new HashMap<>();
+        carAttributes.put(ConfiguredObject.NAME, "car");
+        carAttributes.put(ConfiguredObject.TYPE, TestKitCarImpl.TEST_KITCAR_TYPE);
+        TestCar car1 = _model.getObjectFactory().create(TestCar.class, carAttributes, null);
+
+        Map<String, Object> sensorAttributes = new HashMap<>();
+        sensorAttributes.put(ConfiguredObject.NAME, "sensor1");
+        sensorAttributes.put(ConfiguredObject.TYPE, TestTemperatureSensorImpl.TEST_TEMPERATURE_SENSOR_TYPE);
+        TestSensor sensor1 = (TestSensor) car1.createChild(TestSensor.class, sensorAttributes);
+
+        sensorAttributes = new HashMap<>();
+        sensorAttributes.put(ConfiguredObject.NAME, "sensor2");
+        sensorAttributes.put(ConfiguredObject.TYPE, TestTemperatureSensorImpl.TEST_TEMPERATURE_SENSOR_TYPE);
+        TestSensor sensor2 = (TestSensor) car1.createChild(TestSensor.class, sensorAttributes);
+
+        Map<String, Object> engineAttributes = new HashMap<>();
+        engineAttributes.put(ConfiguredObject.NAME, "engine");
+        engineAttributes.put(ConfiguredObject.TYPE, TestPetrolEngineImpl.TEST_PETROL_ENGINE_TYPE);
+        engineAttributes.put("temperatureSensors", new String[]{sensor1.getName(), sensor2.getName()});
+        car1.createChild(TestEngine.class, engineAttributes);
+
+        try
+        {
+            sensor1.delete();
+            fail("Referred engine cannot be deleted");
+        }
+        catch (IntegrityViolationException e)
+        {
+            // pass
+        }
+    }
+
+    public void testDeleteConfiguredObject()
+    {
+        Map<String, Object> carAttributes = new HashMap<>();
+        carAttributes.put(ConfiguredObject.NAME, "car");
+        carAttributes.put(ConfiguredObject.TYPE, TestKitCarImpl.TEST_KITCAR_TYPE);
+        TestCar car1 = _model.getObjectFactory().create(TestCar.class, carAttributes, null);
+
+        Map<String, Object> sensorAttributes = new HashMap<>();
+        sensorAttributes.put(ConfiguredObject.NAME, "sensor1");
+        sensorAttributes.put(ConfiguredObject.TYPE, TestTemperatureSensorImpl.TEST_TEMPERATURE_SENSOR_TYPE);
+        TestSensor sensor1 = (TestSensor) car1.createChild(TestSensor.class, sensorAttributes);
+
+        assertEquals("Unexpected number of sensors after creation", 1, car1.getChildren(TestSensor.class).size());
+
+        sensor1.delete();
+
+        assertEquals("Unexpected number of sensors after deletion", 0, car1.getChildren(TestSensor.class).size());
+    }
+
     private void doDuplicateChildCheck(final String attrToDuplicate)
     {
         final String carName = "myCar";

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestAbstractSensorImpl.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestAbstractSensorImpl.java b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestAbstractSensorImpl.java
new file mode 100644
index 0000000..82431b3
--- /dev/null
+++ b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestAbstractSensorImpl.java
@@ -0,0 +1,54 @@
+/*
+ *
+ * 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 com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+
+import org.apache.qpid.server.model.AbstractConfiguredObject;
+import org.apache.qpid.server.model.State;
+import org.apache.qpid.server.model.StateTransition;
+
+public class TestAbstractSensorImpl<X extends TestAbstractSensorImpl<X>> extends AbstractConfiguredObject<X>
+        implements TestSensor<X>
+{
+
+    protected TestAbstractSensorImpl(final TestCar<?> parent,
+                                     final Map<String, Object> attributes)
+    {
+        super(parent, attributes);
+    }
+
+    @Override
+    protected void logOperation(final String operation)
+    {
+
+    }
+
+    @StateTransition(currentState = {State.UNINITIALIZED, State.ERRORED}, desiredState = State.ACTIVE)
+    private ListenableFuture<Void> onActivate()
+    {
+        setState(State.ACTIVE);
+        return Futures.immediateFuture(null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngine.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngine.java b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngine.java
index 7dc3d8d..8eae404 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngine.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngine.java
@@ -19,9 +19,12 @@
 
 package org.apache.qpid.server.model.testmodels.hierarchy;
 
+import org.apache.qpid.server.model.ManagedAttribute;
 import org.apache.qpid.server.model.ManagedObject;
 
 @ManagedObject (category = false)
 public interface TestElecEngine<X extends TestElecEngine<X>> extends TestEngine<X>, TestRechargeable
 {
+    @ManagedAttribute
+    TestSensor<?> getTemperatureSensor();
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngineImpl.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngineImpl.java b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngineImpl.java
index 489d901..3156b1b 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngineImpl.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestElecEngineImpl.java
@@ -25,6 +25,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
 
+import org.apache.qpid.server.model.ManagedAttributeField;
 import org.apache.qpid.server.model.ManagedObject;
 import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
 
@@ -34,6 +35,9 @@ public class TestElecEngineImpl
 {
     public static final String TEST_ELEC_ENGINE_TYPE = "ELEC";
 
+    @ManagedAttributeField
+    private TestSensor<?> _temperatureSensor;
+
     @ManagedObjectFactoryConstructor
     public TestElecEngineImpl(final Map<String, Object> attributes, TestCar<?> parent)
     {
@@ -47,4 +51,9 @@ public class TestElecEngineImpl
         return Collections.singletonMap(TestEngine.class.getSimpleName(), types);
     }
 
+    @Override
+    public TestSensor<?> getTemperatureSensor()
+    {
+        return _temperatureSensor;
+    }
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java
index 2d44e35..08d057d 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java
@@ -39,7 +39,8 @@ public class TestModel extends Model
     private Class<? extends ConfiguredObject>[] _supportedCategories =
             new Class[] {
                     TestCar.class,
-                    TestEngine.class
+                    TestEngine.class,
+                    TestSensor.class
             };
 
     private final ConfiguredObjectFactory _objectFactory;
@@ -82,8 +83,8 @@ public class TestModel extends Model
     public Collection<Class<? extends ConfiguredObject>> getChildTypes(final Class<? extends ConfiguredObject> parent)
     {
         return TestCar.class.isAssignableFrom(parent)
-                ? Collections.<Class<? extends ConfiguredObject>>singleton(TestEngine.class)
-                : Collections.<Class<? extends ConfiguredObject>>emptySet();
+                ? Arrays.asList(TestEngine.class, TestSensor.class)
+                : Collections.emptySet();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngine.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngine.java b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngine.java
index 7ca6953..025d0b3 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngine.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngine.java
@@ -19,9 +19,14 @@
 
 package org.apache.qpid.server.model.testmodels.hierarchy;
 
+import java.util.Collection;
+
+import org.apache.qpid.server.model.ManagedAttribute;
 import org.apache.qpid.server.model.ManagedObject;
 
 @ManagedObject (category = false)
 public interface TestPetrolEngine<X extends TestPetrolEngine<X>> extends TestEngine<X>
 {
+    @ManagedAttribute
+    Collection<TestSensor<?>> getTemperatureSensors();
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngineImpl.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngineImpl.java b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngineImpl.java
index a3dca24..9aa4dd5 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngineImpl.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestPetrolEngineImpl.java
@@ -20,8 +20,10 @@
  */
 package org.apache.qpid.server.model.testmodels.hierarchy;
 
+import java.util.Collection;
 import java.util.Map;
 
+import org.apache.qpid.server.model.ManagedAttributeField;
 import org.apache.qpid.server.model.ManagedObject;
 import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
 
@@ -31,10 +33,18 @@ public class TestPetrolEngineImpl
 {
     public static final String TEST_PETROL_ENGINE_TYPE = "PETROL";
 
+    @ManagedAttributeField
+    private Collection<TestSensor<?>> _temperatureSensors;
+
     @ManagedObjectFactoryConstructor
     public TestPetrolEngineImpl(final Map<String, Object> attributes, TestCar<?> parent)
     {
         super(parent, attributes);
     }
 
+    @Override
+    public Collection<TestSensor<?>> getTemperatureSensors()
+    {
+        return _temperatureSensors;
+    }
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestSensor.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestSensor.java b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestSensor.java
new file mode 100644
index 0000000..560620e
--- /dev/null
+++ b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestSensor.java
@@ -0,0 +1,29 @@
+package org.apache.qpid.server.model.testmodels.hierarchy;/*
+ *
+ * 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.
+ *
+ */
+
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.ManagedObject;
+
+@ManagedObject( defaultType = TestTemperatureSensorImpl.TEST_TEMPERATURE_SENSOR_TYPE)
+public interface TestSensor<X extends TestSensor<X>> extends ConfiguredObject<X>
+{
+
+}

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestTemperatureSensorImpl.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestTemperatureSensorImpl.java b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestTemperatureSensorImpl.java
new file mode 100644
index 0000000..58c656a
--- /dev/null
+++ b/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestTemperatureSensorImpl.java
@@ -0,0 +1,40 @@
+/*
+ *
+ * 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.model.ManagedObject;
+import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
+
+@ManagedObject( category = false,
+        type = TestTemperatureSensorImpl.TEST_TEMPERATURE_SENSOR_TYPE)
+public class TestTemperatureSensorImpl extends TestAbstractSensorImpl<TestTemperatureSensorImpl> implements TestSensor<TestTemperatureSensorImpl>
+{
+
+    public static final String TEST_TEMPERATURE_SENSOR_TYPE = "temperature";
+
+    @ManagedObjectFactoryConstructor
+    protected TestTemperatureSensorImpl(final Map<String, Object> attributes,final TestCar<?> parent)
+    {
+        super(parent, attributes);
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/security/FileKeyStoreTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/security/FileKeyStoreTest.java b/broker-core/src/test/java/org/apache/qpid/server/security/FileKeyStoreTest.java
index e950ef4..68c4f6f 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/security/FileKeyStoreTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/security/FileKeyStoreTest.java
@@ -23,7 +23,6 @@ package org.apache.qpid.server.security;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -36,14 +35,12 @@ import org.apache.qpid.server.logging.EventLogger;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.BrokerModel;
 import org.apache.qpid.server.model.ConfiguredObjectFactory;
-import org.apache.qpid.server.model.IntegrityViolationException;
 import org.apache.qpid.server.model.KeyStore;
 import org.apache.qpid.server.model.Model;
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.test.utils.QpidTestCase;
-import org.apache.qpid.test.utils.TestSSLConstants;
 import org.apache.qpid.server.util.DataUrlUtils;
 import org.apache.qpid.server.util.FileUtils;
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.TestSSLConstants;
 
 public class FileKeyStoreTest extends QpidTestCase
 {
@@ -274,43 +271,6 @@ public class FileKeyStoreTest extends QpidTestCase
 
     }
 
-    public void testDeleteKeyStore_Success() throws Exception
-    {
-        Map<String,Object> attributes = new HashMap<>();
-        attributes.put(FileKeyStore.NAME, "myFileKeyStore");
-        attributes.put(FileKeyStore.STORE_URL, TestSSLConstants.BROKER_KEYSTORE);
-        attributes.put(FileKeyStore.PASSWORD, TestSSLConstants.BROKER_KEYSTORE_PASSWORD);
-
-        FileKeyStoreImpl fileKeyStore = (FileKeyStoreImpl) _factory.create(KeyStore.class, attributes,  _broker);
-
-        fileKeyStore.delete();
-    }
-
-    public void testDeleteKeyStore_KeyManagerInUseByPort() throws Exception
-    {
-        Map<String,Object> attributes = new HashMap<>();
-        attributes.put(FileKeyStore.NAME, "myFileKeyStore");
-        attributes.put(FileKeyStore.STORE_URL, TestSSLConstants.BROKER_KEYSTORE);
-        attributes.put(FileKeyStore.PASSWORD, TestSSLConstants.BROKER_KEYSTORE_PASSWORD);
-
-        FileKeyStoreImpl fileKeyStore = (FileKeyStoreImpl) _factory.create(KeyStore.class, attributes,  _broker);
-
-        Port<?> port = mock(Port.class);
-        when(port.getKeyStore()).thenReturn(fileKeyStore);
-
-        when(_broker.getPorts()).thenReturn(Collections.<Port<?>>singletonList(port));
-
-        try
-        {
-            fileKeyStore.delete();
-            fail("Exception not thrown");
-        }
-        catch (IntegrityViolationException ive)
-        {
-            // PASS
-        }
-    }
-
     private static String createDataUrlForFile(String filename)
     {
         byte[] fileAsBytes = FileUtils.readFileAsBytes(filename);

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/security/FileTrustStoreTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/security/FileTrustStoreTest.java b/broker-core/src/test/java/org/apache/qpid/server/security/FileTrustStoreTest.java
index 9d184be..934d6ed 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/security/FileTrustStoreTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/security/FileTrustStoreTest.java
@@ -27,8 +27,6 @@ import java.security.KeyStore;
 import java.security.cert.CertificateException;
 import java.security.cert.CertificateExpiredException;
 import java.security.cert.X509Certificate;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -39,15 +37,11 @@ import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor;
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.logging.EventLogger;
-import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.BrokerModel;
 import org.apache.qpid.server.model.ConfiguredObjectFactory;
-import org.apache.qpid.server.model.IntegrityViolationException;
 import org.apache.qpid.server.model.Model;
-import org.apache.qpid.server.model.Port;
 import org.apache.qpid.server.model.TrustStore;
-import org.apache.qpid.server.security.auth.manager.SimpleLDAPAuthenticationManager;
 import org.apache.qpid.server.transport.network.security.ssl.QpidPeersOnlyTrustManager;
 import org.apache.qpid.server.transport.network.security.ssl.SSLUtil;
 import org.apache.qpid.server.util.DataUrlUtils;
@@ -291,69 +285,6 @@ public class FileTrustStoreTest extends QpidTestCase
                      fileTrustStore.getStoreUrl());
     }
 
-    public void testDeleteTrustStore_Success() throws Exception
-    {
-        Map<String,Object> attributes = new HashMap<>();
-        attributes.put(FileTrustStore.NAME, "myFileTrustStore");
-        attributes.put(FileTrustStore.STORE_URL, TestSSLConstants.TRUSTSTORE);
-        attributes.put(FileTrustStore.PASSWORD, TestSSLConstants.TRUSTSTORE_PASSWORD);
-
-        TrustStore<?> fileTrustStore = _factory.create(TrustStore.class, attributes,  _broker);
-
-        fileTrustStore.delete();
-    }
-
-    public void testDeleteTrustStore_TrustManagerInUseByAuthProvider() throws Exception
-    {
-        Map<String,Object> attributes = new HashMap<>();
-        attributes.put(FileTrustStore.NAME, "myFileTrustStore");
-        attributes.put(FileTrustStore.STORE_URL, TestSSLConstants.TRUSTSTORE);
-        attributes.put(FileTrustStore.PASSWORD, TestSSLConstants.TRUSTSTORE_PASSWORD);
-
-        TrustStore<?> fileTrustStore = _factory.create(TrustStore.class, attributes,  _broker);
-
-        SimpleLDAPAuthenticationManager ldap = mock(SimpleLDAPAuthenticationManager.class);
-        when(ldap.getTrustStore()).thenReturn(fileTrustStore);
-
-        Collection<AuthenticationProvider<?>> authenticationProviders = Collections.<AuthenticationProvider<?>>singletonList(ldap);
-        when(_broker.getAuthenticationProviders()).thenReturn(authenticationProviders);
-
-        try
-        {
-            fileTrustStore.delete();
-            fail("Exception not thrown");
-        }
-        catch (IntegrityViolationException ive)
-        {
-            // PASS
-        }
-    }
-
-    public void testDeleteTrustStore_TrustManagerInUseByPort() throws Exception
-    {
-        Map<String,Object> attributes = new HashMap<>();
-        attributes.put(FileTrustStore.NAME, "myFileTrustStore");
-        attributes.put(FileTrustStore.STORE_URL, TestSSLConstants.TRUSTSTORE);
-        attributes.put(FileTrustStore.PASSWORD, TestSSLConstants.TRUSTSTORE_PASSWORD);
-
-        TrustStore<?> fileTrustStore = _factory.create(TrustStore.class, attributes,  _broker);
-
-        Port<?> port = mock(Port.class);
-        when(port.getTrustStores()).thenReturn(Collections.<TrustStore>singletonList(fileTrustStore));
-
-        when(_broker.getPorts()).thenReturn(Collections.<Port<?>>singletonList(port));
-
-        try
-        {
-            fileTrustStore.delete();
-            fail("Exception not thrown");
-        }
-        catch (IntegrityViolationException ive)
-        {
-            // PASS
-        }
-    }
-
     private static String createDataUrlForFile(String filename)
     {
         byte[] fileAsBytes = FileUtils.readFileAsBytes(filename);

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ManagedAuthenticationManagerTestBase.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ManagedAuthenticationManagerTestBase.java b/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ManagedAuthenticationManagerTestBase.java
index 444c6be..fe1facc 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ManagedAuthenticationManagerTestBase.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ManagedAuthenticationManagerTestBase.java
@@ -20,13 +20,11 @@
  */
 package org.apache.qpid.server.security.auth.manager;
 
-import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ExecutionException;
@@ -38,10 +36,7 @@ import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.BrokerTestHelper;
-import org.apache.qpid.server.model.IntegrityViolationException;
-import org.apache.qpid.server.model.Port;
 import org.apache.qpid.server.model.User;
-import org.apache.qpid.server.model.port.AmqpPort;
 import org.apache.qpid.server.security.auth.AuthenticationResult;
 import org.apache.qpid.server.security.auth.sasl.SaslNegotiator;
 import org.apache.qpid.server.security.auth.sasl.SaslSettings;
@@ -269,23 +264,4 @@ abstract class ManagedAuthenticationManagerTestBase extends QpidTestCase
         assertNull("Should not be able to create SASL negotiator for unsupported mechanism", negotiator);
     }
 
-    public void testDeleteInUseDisallowed() throws Exception
-    {
-        AmqpPort port = mock(AmqpPort.class);
-        when(port.getAuthenticationProvider()).thenReturn(_authManager);
-        when(port.getName()).thenReturn("mockPort");
-
-        final List<AmqpPort> portList = Collections.singletonList(port);
-        when(_broker.getChildren(eq(Port.class))).thenReturn(portList);
-
-        try
-        {
-            _authManager.delete();
-            fail("Exception not thrown");
-        }
-        catch (IntegrityViolationException e)
-        {
-            // PASS
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManagerTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManagerTest.java b/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManagerTest.java
index aeb48ea..c883736 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManagerTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManagerTest.java
@@ -26,22 +26,15 @@ import static org.apache.qpid.server.security.auth.manager.PlainPasswordDatabase
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.Matchers.equalTo;
 import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 import java.io.File;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor;
-import org.apache.qpid.server.configuration.updater.TaskExecutor;
-import org.apache.qpid.server.logging.EventLogger;
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.BrokerModel;
+import org.apache.qpid.server.model.BrokerTestHelper;
 import org.apache.qpid.server.model.ConfiguredObjectFactory;
-import org.apache.qpid.server.model.ConfiguredObjectFactoryImpl;
-import org.apache.qpid.server.model.Model;
 import org.apache.qpid.server.model.PasswordCredentialManagingAuthenticationProvider;
 import org.apache.qpid.server.model.User;
 import org.apache.qpid.server.security.auth.AuthenticationResult;
@@ -50,7 +43,6 @@ import org.apache.qpid.test.utils.TestFileUtils;
 
 public class PlainPasswordDatabaseAuthenticationManagerTest extends QpidTestCase
 {
-    private TaskExecutor _taskExecutor;
     private Broker<?> _broker;
     private File _passwordFile;
     private ConfiguredObjectFactory _objectFactory;
@@ -59,16 +51,9 @@ public class PlainPasswordDatabaseAuthenticationManagerTest extends QpidTestCase
     public void setUp() throws Exception
     {
         super.setUp();
-        _taskExecutor = CurrentThreadTaskExecutor.newStartedInstance();
 
-        final Model model = BrokerModel.getInstance();
-        _objectFactory = new ConfiguredObjectFactoryImpl(model);
-
-        _broker = mock(Broker.class);
-        when(_broker.getTaskExecutor()).thenReturn(_taskExecutor);
-        when(_broker.getChildExecutor()).thenReturn(_taskExecutor);
-        when(_broker.getModel()).thenReturn(model);
-        when(_broker.getEventLogger()).thenReturn(mock(EventLogger.class));
+        _broker = BrokerTestHelper.createBrokerMock();
+        _objectFactory = _broker.getObjectFactory();
     }
 
     @Override
@@ -80,7 +65,6 @@ public class PlainPasswordDatabaseAuthenticationManagerTest extends QpidTestCase
             {
                 _passwordFile.delete();
             }
-            _taskExecutor.stop();
         }
         finally
         {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/RedirectingVirtualHostNodeTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/RedirectingVirtualHostNodeTest.java b/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/RedirectingVirtualHostNodeTest.java
index 70bdbae..9de1221 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/RedirectingVirtualHostNodeTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/RedirectingVirtualHostNodeTest.java
@@ -127,21 +127,6 @@ public class RedirectingVirtualHostNodeTest extends QpidTestCase
                      1, node.getChildren(VirtualHost.class).size());
     }
 
-    public void testDeleteVHN() throws Exception
-    {
-        final Map<String, Object> attributes = createVirtualHostNodeAttributes();
-
-        RedirectingVirtualHostNode node =
-                (RedirectingVirtualHostNode) _broker.getObjectFactory().create(VirtualHostNode.class,
-                                                                               attributes,
-                                                                               _broker);
-        assertEquals("Unexpected number of virtualhost children before delete",
-                     1, node.getChildren(VirtualHost.class).size());
-        node.delete();
-        assertEquals("Unexpected number of virtualhost children after delete",
-                     0, node.getChildren(VirtualHost.class).size());
-    }
-
     private Map<String, Object> createVirtualHostNodeAttributes()
     {
         final Map<String, Object> attributes = new HashMap<>();

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-plugins/amqp-0-10-protocol/src/test/java/org/apache/qpid/server/protocol/v0_10/ServerSessionTest.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-0-10-protocol/src/test/java/org/apache/qpid/server/protocol/v0_10/ServerSessionTest.java b/broker-plugins/amqp-0-10-protocol/src/test/java/org/apache/qpid/server/protocol/v0_10/ServerSessionTest.java
index e47f0fc..11679e5 100644
--- a/broker-plugins/amqp-0-10-protocol/src/test/java/org/apache/qpid/server/protocol/v0_10/ServerSessionTest.java
+++ b/broker-plugins/amqp-0-10-protocol/src/test/java/org/apache/qpid/server/protocol/v0_10/ServerSessionTest.java
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
 import javax.security.auth.Subject;
@@ -101,6 +102,8 @@ public class ServerSessionTest extends QpidTestCase
         AmqpPort port = createMockPort();
 
         final AMQPConnection_0_10 modelConnection = mock(AMQPConnection_0_10.class);
+        when(modelConnection.getCategoryClass()).thenReturn(Connection.class);
+        when(modelConnection.getTypeClass()).thenReturn(AMQPConnection_0_10.class);
         when(modelConnection.closeAsync()).thenReturn(Futures.immediateFuture(null));
         when(modelConnection.getAddressSpace()).thenReturn(_virtualHost);
         when(modelConnection.getContextProvider()).thenReturn(_virtualHost);

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d14659c8/broker-plugins/logging-logback/src/test/java/org/apache/qpid/server/logging/logback/BrokerLoggerTest.java
----------------------------------------------------------------------
diff --git a/broker-plugins/logging-logback/src/test/java/org/apache/qpid/server/logging/logback/BrokerLoggerTest.java b/broker-plugins/logging-logback/src/test/java/org/apache/qpid/server/logging/logback/BrokerLoggerTest.java
index 0678f2e..f757f4e 100644
--- a/broker-plugins/logging-logback/src/test/java/org/apache/qpid/server/logging/logback/BrokerLoggerTest.java
+++ b/broker-plugins/logging-logback/src/test/java/org/apache/qpid/server/logging/logback/BrokerLoggerTest.java
@@ -59,7 +59,7 @@ public class BrokerLoggerTest extends QpidTestCase
     private AbstractBrokerLogger<?> _brokerLogger;
     private ListAppender _loggerAppender;
     private TaskExecutor _taskExecutor;
-    private Broker<?> _broker;
+    private Broker _broker;
 
     @Override
     public void setUp() throws Exception
@@ -76,6 +76,8 @@ public class BrokerLoggerTest extends QpidTestCase
         Model model = BrokerModel.getInstance();
 
         _broker = mock(Broker.class);
+        when(_broker.getCategoryClass()).thenReturn(Broker.class);
+        when(_broker.getTypeClass()).thenReturn(Broker.class);
         when(_broker.getModel()).thenReturn(model);
         when(_broker.getChildExecutor()).thenReturn(_taskExecutor);
         doReturn(Broker.class).when(_broker).getCategoryClass();


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