qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1584365 [10/15] - in /qpid/branches/java-broker-config-store-changes/qpid/java: ./ bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/ bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/ bdbstore/src/main/ja...
Date Thu, 03 Apr 2014 19:59:01 GMT
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/BrokerRecovererTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/BrokerRecovererTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/BrokerRecovererTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/BrokerRecovererTest.java Thu Apr  3 19:58:53 2014
@@ -20,74 +20,61 @@
  */
 package org.apache.qpid.server.configuration.startup;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import junit.framework.TestCase;
+import org.apache.qpid.server.BrokerOptions;
+import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.configuration.RecovererProvider;
+import org.apache.qpid.server.configuration.updater.TaskExecutor;
+import org.apache.qpid.server.logging.EventLogger;
+import org.apache.qpid.server.logging.LogRecorder;
+import org.apache.qpid.server.model.*;
+import org.apache.qpid.server.store.ConfiguredObjectRecord;
+import org.apache.qpid.server.store.ConfiguredObjectRecordImpl;
+import org.apache.qpid.server.store.MessageStore;
+import org.apache.qpid.server.store.TestMemoryMessageStore;
 
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
 import java.util.UUID;
 
-import junit.framework.TestCase;
-
-import org.apache.qpid.server.BrokerOptions;
-import org.apache.qpid.server.configuration.ConfigurationEntry;
-import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer;
-import org.apache.qpid.server.configuration.IllegalConfigurationException;
-import org.apache.qpid.server.configuration.RecovererProvider;
-import org.apache.qpid.server.logging.LogRecorder;
-import org.apache.qpid.server.model.AuthenticationProvider;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.GroupProvider;
-import org.apache.qpid.server.model.KeyStore;
-import org.apache.qpid.server.model.Model;
-import org.apache.qpid.server.model.Plugin;
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.TrustStore;
-import org.apache.qpid.server.model.UUIDGenerator;
-import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.model.adapter.AccessControlProviderFactory;
-import org.apache.qpid.server.model.adapter.AuthenticationProviderFactory;
-import org.apache.qpid.server.model.adapter.GroupProviderFactory;
-import org.apache.qpid.server.model.adapter.PortFactory;
-import org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener;
-import org.apache.qpid.server.configuration.updater.TaskExecutor;
-import org.apache.qpid.server.stats.StatisticsGatherer;
-import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 public class BrokerRecovererTest extends TestCase
 {
-    private BrokerRecoverer _brokerRecoverer;
-    private ConfigurationEntry _brokerEntry = mock(ConfigurationEntry.class);
+    private ConfiguredObjectRecord _brokerEntry = mock(ConfiguredObjectRecord.class);
 
     private UUID _brokerId = UUID.randomUUID();
-    private Map<String, Collection<ConfigurationEntry>> _brokerEntryChildren = new HashMap<String, Collection<ConfigurationEntry>>();
-    private ConfigurationEntry _authenticationProviderEntry1;
+    private Map<String, Collection<ConfiguredObjectRecord>> _brokerEntryChildren = new HashMap<String, Collection<ConfiguredObjectRecord>>();
+    private ConfiguredObjectRecord _authenticationProviderEntry1;
     private AuthenticationProvider _authenticationProvider1;
     private UUID _authenticationProvider1Id = UUID.randomUUID();
+    private SystemContext _systemContext;
+    private ConfiguredObjectFactory _configuredObjectFactory;
 
     @Override
     protected void setUp() throws Exception
     {
         super.setUp();
 
-        _brokerRecoverer = new BrokerRecoverer(mock(AuthenticationProviderFactory.class), mock(GroupProviderFactory.class), mock(AccessControlProviderFactory.class), mock(PortFactory.class),
-                mock(StatisticsGatherer.class), mock(VirtualHostRegistry.class), mock(LogRecorder.class),
-                mock(TaskExecutor.class), mock(BrokerOptions.class),
-                mock(StoreConfigurationChangeListener.class));
+        _configuredObjectFactory = new ConfiguredObjectFactory();
+        _systemContext = new SystemContext(mock(TaskExecutor.class),
+                                           _configuredObjectFactory, mock(EventLogger.class), mock(LogRecorder.class), mock(BrokerOptions.class));
+
         when(_brokerEntry.getId()).thenReturn(_brokerId);
-        when(_brokerEntry.getChildren()).thenReturn(_brokerEntryChildren);
+        when(_brokerEntry.getType()).thenReturn(Broker.class.getSimpleName());
         when(_brokerEntry.getAttributes()).thenReturn(Collections.<String, Object>singletonMap(Broker.MODEL_VERSION, Model.MODEL_VERSION));
+        when(_brokerEntry.getParents()).thenReturn(Collections.singletonMap(SystemContext.class.getSimpleName(), _systemContext.asObjectRecord()));
 
         //Add a base AuthenticationProvider for all tests
         _authenticationProvider1 = mock(AuthenticationProvider.class);
         when(_authenticationProvider1.getName()).thenReturn("authenticationProvider1");
         when(_authenticationProvider1.getId()).thenReturn(_authenticationProvider1Id);
-        _authenticationProviderEntry1 = mock(ConfigurationEntry.class);
+        _authenticationProviderEntry1 = mock(ConfiguredObjectRecord.class);
         _brokerEntryChildren.put(AuthenticationProvider.class.getSimpleName(), Arrays.asList(_authenticationProviderEntry1));
     }
 
@@ -120,16 +107,9 @@ public class BrokerRecovererTest extends
 
         when(_brokerEntry.getAttributes()).thenReturn(entryAttributes);
 
-        final ConfigurationEntry virtualHostEntry = mock(ConfigurationEntry.class);
-        String typeName = VirtualHost.class.getSimpleName();
-        when(virtualHostEntry.getType()).thenReturn(typeName);
-        _brokerEntryChildren.put(typeName, Arrays.asList(virtualHostEntry));
-        final VirtualHost virtualHost = mock(VirtualHost.class);
-        when(virtualHost.getName()).thenReturn("test");
+        _systemContext.resolveObjects(_brokerEntry);
+        Broker broker = _systemContext.getBroker();
 
-        RecovererProvider recovererProvider = createRecoveryProvider(new ConfigurationEntry[] { virtualHostEntry, _authenticationProviderEntry1 },
-                new ConfiguredObject[] { virtualHost, _authenticationProvider1 });
-        Broker broker = _brokerRecoverer.create(recovererProvider, _brokerEntry);
         assertNotNull(broker);
         assertEquals(_brokerId, broker.getId());
 
@@ -142,153 +122,136 @@ public class BrokerRecovererTest extends
 
     public void testCreateBrokerWithVirtualHost()
     {
-        final ConfigurationEntry virtualHostEntry = mock(ConfigurationEntry.class);
+        final ConfiguredObjectRecord virtualHostEntry = mock(ConfiguredObjectRecord.class);
 
         String typeName = VirtualHost.class.getSimpleName();
         when(virtualHostEntry.getType()).thenReturn(typeName);
         _brokerEntryChildren.put(typeName, Arrays.asList(virtualHostEntry));
 
-        final VirtualHost virtualHost = mock(VirtualHost.class);
-
-        RecovererProvider recovererProvider = createRecoveryProvider(new ConfigurationEntry[]{virtualHostEntry, _authenticationProviderEntry1},
-                                                                     new ConfiguredObject[]{virtualHost, _authenticationProvider1});
-
-        Broker broker = _brokerRecoverer.create(recovererProvider, _brokerEntry);
+        UUID vhostId = UUID.randomUUID();
+        _systemContext.resolveObjects(_brokerEntry, createVhostRecord(vhostId));
+        Broker<?> broker = _systemContext.getBroker();
 
         assertNotNull(broker);
         assertEquals(_brokerId, broker.getId());
         assertEquals(1, broker.getVirtualHosts().size());
-        assertEquals(virtualHost, broker.getVirtualHosts().iterator().next());
+        assertEquals(vhostId, broker.getVirtualHosts().iterator().next().getId());
+
     }
 
-    public void testCreateBrokerWithPorts()
+    public ConfiguredObjectRecord createVhostRecord(UUID id)
     {
-        ConfigurationEntry portEntry = mock(ConfigurationEntry.class);
-        Port port = mock(Port.class);
-        _brokerEntryChildren.put(Port.class.getSimpleName(), Arrays.asList(portEntry));
-
-        RecovererProvider recovererProvider = createRecoveryProvider(new ConfigurationEntry[]{portEntry, _authenticationProviderEntry1},
-                                                                     new ConfiguredObject[]{port, _authenticationProvider1});
-
-        Broker broker = _brokerRecoverer.create(recovererProvider, _brokerEntry);
-
-        assertNotNull(broker);
-        assertEquals(_brokerId, broker.getId());
-        assertEquals(Collections.singletonList(port), broker.getPorts());
+        final Map<String, Object> vhostAttributes = new HashMap<String, Object>();
+        vhostAttributes.put(VirtualHost.NAME, "vhost");
+        vhostAttributes.put(VirtualHost.TYPE, "STANDARD");
+        vhostAttributes.put(VirtualHost.MESSAGE_STORE_SETTINGS, Collections.singletonMap(MessageStore.STORE_TYPE,
+                                                                                               TestMemoryMessageStore.TYPE));
+        return new ConfiguredObjectRecordImpl(id, VirtualHost.class.getSimpleName(), vhostAttributes, Collections
+                .singletonMap(Broker.class.getSimpleName(), _brokerEntry));
     }
 
-    public void testCreateBrokerWithOneAuthenticationProvider()
+    public ConfiguredObjectRecord createAuthProviderRecord(UUID id, String name)
     {
-        RecovererProvider recovererProvider = createRecoveryProvider(new ConfigurationEntry[]{_authenticationProviderEntry1},
-                                                                     new ConfiguredObject[]{_authenticationProvider1});
-
-        Broker broker = _brokerRecoverer.create(recovererProvider, _brokerEntry);
+        final Map<String, Object> authProviderAttrs = new HashMap<String, Object>();
+        authProviderAttrs.put(AuthenticationProvider.NAME, name);
+        authProviderAttrs.put(AuthenticationProvider.TYPE, "Anonymous");
 
-        assertNotNull(broker);
-        assertEquals(_brokerId, broker.getId());
-        assertEquals(Collections.singletonList(_authenticationProvider1), broker.getAuthenticationProviders());
+        return new ConfiguredObjectRecordImpl(id, AuthenticationProvider.class.getSimpleName(), authProviderAttrs, Collections
+                .singletonMap(Broker.class.getSimpleName(), _brokerEntry));
     }
 
-    public void testCreateBrokerWithMultipleAuthenticationProvidersAndPorts()
+
+    public ConfiguredObjectRecord createGroupProviderRecord(UUID id, String name)
     {
-        //Create a second authentication provider
-        AuthenticationProvider authenticationProvider2 = mock(AuthenticationProvider.class);
-        when(authenticationProvider2.getName()).thenReturn("authenticationProvider2");
-        ConfigurationEntry authenticationProviderEntry2 = mock(ConfigurationEntry.class);
-        _brokerEntryChildren.put(AuthenticationProvider.class.getSimpleName(), Arrays.asList(_authenticationProviderEntry1, authenticationProviderEntry2));
-
-        //Add a couple ports
-        ConfigurationEntry portEntry1 = mock(ConfigurationEntry.class);
-        Port port1 = mock(Port.class);
-        when(port1.getId()).thenReturn(UUIDGenerator.generateRandomUUID());
-        when(port1.getName()).thenReturn("port1");
-        when(port1.getPort()).thenReturn(5671);
-        when(port1.getAttribute(Port.AUTHENTICATION_PROVIDER)).thenReturn("authenticationProvider1");
-        ConfigurationEntry portEntry2 = mock(ConfigurationEntry.class);
-        Port port2 = mock(Port.class);
-        when(port2.getId()).thenReturn(UUIDGenerator.generateRandomUUID());
-        when(port2.getName()).thenReturn("port2");
-        when(port2.getPort()).thenReturn(5672);
-        when(port2.getAttribute(Port.AUTHENTICATION_PROVIDER)).thenReturn("authenticationProvider2");
-        _brokerEntryChildren.put(Port.class.getSimpleName(), Arrays.asList(portEntry1, portEntry2));
-
-        RecovererProvider recovererProvider = createRecoveryProvider(
-                new ConfigurationEntry[]{portEntry1, portEntry2, authenticationProviderEntry2, _authenticationProviderEntry1},
-                new ConfiguredObject[]{port1, port2, authenticationProvider2, _authenticationProvider1});
+        final Map<String, Object> groupProviderAttrs = new HashMap<String, Object>();
+        groupProviderAttrs.put(GroupProvider.NAME, name);
+        groupProviderAttrs.put(GroupProvider.TYPE, "GroupFile");
+        groupProviderAttrs.put("path", "/no-such-path");
 
-        Broker broker = _brokerRecoverer.create(recovererProvider, _brokerEntry);
+        return new ConfiguredObjectRecordImpl(id, GroupProvider.class.getSimpleName(), groupProviderAttrs, Collections
+                .singletonMap(Broker.class.getSimpleName(), _brokerEntry));
+    }
 
-        assertNotNull(broker);
-        assertEquals("Unexpected number of authentication providers", 2, broker.getAuthenticationProviders().size());
+    public ConfiguredObjectRecord createPortRecord(UUID id, int port, Object authProviderRef)
+    {
+        final Map<String, Object> portAttrs = new HashMap<String, Object>();
+        portAttrs.put(Port.NAME, "port-"+port);
+        portAttrs.put(Port.TYPE, "HTTP");
+        portAttrs.put(Port.PORT, port);
+        portAttrs.put(Port.AUTHENTICATION_PROVIDER, authProviderRef);
 
-        Collection<Port> ports = broker.getPorts();
-        assertEquals("Unexpected number of ports", 2, ports.size());
-        assertTrue(ports.contains(port1));
-        assertTrue(ports.contains(port2));
+        return new ConfiguredObjectRecordImpl(id, Port.class.getSimpleName(), portAttrs, Collections
+                .singletonMap(Broker.class.getSimpleName(), _brokerEntry));
     }
 
-    public void testCreateBrokerWithGroupProvider()
+
+    public void testCreateBrokerWithPorts()
     {
-        ConfigurationEntry groupProviderEntry = mock(ConfigurationEntry.class);
-        GroupProvider groupProvider = mock(GroupProvider.class);
-        _brokerEntryChildren.put(GroupProvider.class.getSimpleName(), Arrays.asList(groupProviderEntry));
+        UUID authProviderId = UUID.randomUUID();
+        UUID portId = UUID.randomUUID();
 
-        RecovererProvider recovererProvider = createRecoveryProvider(new ConfigurationEntry[]{groupProviderEntry, _authenticationProviderEntry1},
-                                                                     new ConfiguredObject[]{groupProvider, _authenticationProvider1});
+        _systemContext.resolveObjects(_brokerEntry, createAuthProviderRecord(authProviderId, "authProvider"), createPortRecord(
+                portId,
+                5672,
+                "authProvider"));
+        Broker<?> broker = _systemContext.getBroker();
 
-        Broker broker = _brokerRecoverer.create(recovererProvider, _brokerEntry);
 
         assertNotNull(broker);
         assertEquals(_brokerId, broker.getId());
-        assertEquals(Collections.singletonList(groupProvider), broker.getGroupProviders());
+        assertEquals(1, broker.getPorts().size());
     }
 
-    public void testCreateBrokerWithPlugins()
+    public void testCreateBrokerWithOneAuthenticationProvider()
     {
-        ConfigurationEntry pluginEntry = mock(ConfigurationEntry.class);
-        Plugin plugin = mock(Plugin.class);
-        _brokerEntryChildren.put(Plugin.class.getSimpleName(), Arrays.asList(pluginEntry));
+        UUID authProviderId = UUID.randomUUID();
 
-        RecovererProvider recovererProvider = createRecoveryProvider(new ConfigurationEntry[]{pluginEntry, _authenticationProviderEntry1},
-                                                                     new ConfiguredObject[]{plugin, _authenticationProvider1});
+        _systemContext.resolveObjects(_brokerEntry, createAuthProviderRecord(authProviderId, "authProvider"));
+        Broker<?> broker = _systemContext.getBroker();
 
-        Broker broker = _brokerRecoverer.create(recovererProvider, _brokerEntry);
 
         assertNotNull(broker);
         assertEquals(_brokerId, broker.getId());
-        assertEquals(Collections.singleton(plugin), new HashSet<ConfiguredObject>(broker.getChildren(Plugin.class)));
+        assertEquals(1, broker.getAuthenticationProviders().size());
+
     }
 
-    public void testCreateBrokerWithKeyStores()
+    public void testCreateBrokerWithMultipleAuthenticationProvidersAndPorts()
     {
-        ConfigurationEntry pluginEntry = mock(ConfigurationEntry.class);
-        KeyStore keyStore = mock(KeyStore.class);
-        _brokerEntryChildren.put(KeyStore.class.getSimpleName(), Arrays.asList(pluginEntry));
-
-        RecovererProvider recovererProvider = createRecoveryProvider(new ConfigurationEntry[]{pluginEntry, _authenticationProviderEntry1},
-                                                                     new ConfiguredObject[]{keyStore, _authenticationProvider1});
+        UUID authProviderId = UUID.randomUUID();
+        UUID portId = UUID.randomUUID();
+        UUID authProvider2Id = UUID.randomUUID();
+        UUID port2Id = UUID.randomUUID();
+
+        _systemContext.resolveObjects(_brokerEntry,
+                                      createAuthProviderRecord(authProviderId, "authProvider"),
+                                      createPortRecord(portId, 5672, "authProvider"),
+                                      createAuthProviderRecord(authProvider2Id, "authProvider2"),
+                                      createPortRecord(port2Id, 5673, "authProvider2"));
+        Broker<?> broker = _systemContext.getBroker();
 
-        Broker broker = _brokerRecoverer.create(recovererProvider, _brokerEntry);
 
         assertNotNull(broker);
         assertEquals(_brokerId, broker.getId());
-        assertEquals(Collections.singleton(keyStore), new HashSet<ConfiguredObject>(broker.getChildren(KeyStore.class)));
+        assertEquals(2, broker.getPorts().size());
+
+        assertEquals("Unexpected number of authentication providers", 2, broker.getAuthenticationProviders().size());
+
     }
 
-    public void testCreateBrokerWithTrustStores()
+    public void testCreateBrokerWithGroupProvider()
     {
-        ConfigurationEntry pluginEntry = mock(ConfigurationEntry.class);
-        TrustStore trustStore = mock(TrustStore.class);
-        _brokerEntryChildren.put(TrustStore.class.getSimpleName(), Arrays.asList(pluginEntry));
 
-        RecovererProvider recovererProvider = createRecoveryProvider(new ConfigurationEntry[]{pluginEntry, _authenticationProviderEntry1},
-                                                                     new ConfiguredObject[]{trustStore, _authenticationProvider1});
+        UUID authProviderId = UUID.randomUUID();
+
+        _systemContext.resolveObjects(_brokerEntry, createGroupProviderRecord(authProviderId, "groupProvider"));
+        Broker<?> broker = _systemContext.getBroker();
 
-        Broker broker = _brokerRecoverer.create(recovererProvider, _brokerEntry);
 
         assertNotNull(broker);
         assertEquals(_brokerId, broker.getId());
-        assertEquals(Collections.singleton(trustStore), new HashSet<ConfiguredObject>(broker.getChildren(TrustStore.class)));
+        assertEquals(1, broker.getGroupProviders().size());
+
     }
 
     public void testModelVersionValidationForIncompatibleMajorVersion() throws Exception
@@ -302,7 +265,8 @@ public class BrokerRecovererTest extends
 
             try
             {
-                _brokerRecoverer.create(null, _brokerEntry);
+                _systemContext.resolveObjects(_brokerEntry);
+                Broker<?> broker = _systemContext.getBroker();
                 fail("The broker creation should fail due to unsupported model version");
             }
             catch (IllegalConfigurationException e)
@@ -323,7 +287,7 @@ public class BrokerRecovererTest extends
 
         try
         {
-            _brokerRecoverer.create(null, _brokerEntry);
+            Broker broker = (Broker) _configuredObjectFactory.recover(_brokerEntry, _systemContext).resolve();
             fail("The broker creation should fail due to unsupported model version");
         }
         catch (IllegalConfigurationException e)
@@ -344,7 +308,8 @@ public class BrokerRecovererTest extends
 
             try
             {
-                _brokerRecoverer.create(null, _brokerEntry);
+                Broker broker = (Broker) _configuredObjectFactory.recover(_brokerEntry, _systemContext).resolve();
+
                 fail("The broker creation should fail due to unsupported model version");
             }
             catch (IllegalConfigurationException e)
@@ -359,7 +324,7 @@ public class BrokerRecovererTest extends
         return String.valueOf(attributeValue);
     }
 
-    private  RecovererProvider createRecoveryProvider(final ConfigurationEntry[] entries, final ConfiguredObject[] objectsToRecoverer)
+    private  RecovererProvider createRecoveryProvider(final ConfiguredObjectRecord[] entries, final ConfiguredObject[] objectsToRecoverer)
     {
         RecovererProvider recovererProvider = new RecovererProvider()
         {
@@ -369,12 +334,11 @@ public class BrokerRecovererTest extends
                 @SuppressWarnings({ "unchecked", "rawtypes" })
                 final ConfiguredObjectRecoverer<?  extends ConfiguredObject> recoverer = new ConfiguredObjectRecoverer()
                 {
-                    @Override
-                    public ConfiguredObject create(RecovererProvider recovererProvider, ConfigurationEntry entry, ConfiguredObject... parents)
+                    public ConfiguredObject create(RecovererProvider recovererProvider, ConfiguredObjectRecord entry, ConfiguredObject... parents)
                     {
                         for (int i = 0; i < entries.length; i++)
                         {
-                            ConfigurationEntry e = entries[i];
+                            ConfiguredObjectRecord e = entries[i];
                             if (entry == e)
                             {
                                 return objectsToRecoverer[i];

Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileKeyStoreCreationTest.java (from r1582544, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/KeyStoreRecovererTest.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileKeyStoreCreationTest.java?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileKeyStoreCreationTest.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/KeyStoreRecovererTest.java&r1=1582544&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/KeyStoreRecovererTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileKeyStoreCreationTest.java Thu Apr  3 19:58:53 2014
@@ -20,29 +20,24 @@
  */
 package org.apache.qpid.server.configuration.startup;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import junit.framework.TestCase;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.KeyStore;
+import org.apache.qpid.server.security.AbstractKeyStoreAdapter;
+import org.apache.qpid.server.security.FileKeyStore;
+import org.apache.qpid.server.security.SecurityManager;
+import org.apache.qpid.test.utils.TestSSLConstants;
 
+import javax.net.ssl.KeyManagerFactory;
+import javax.security.auth.Subject;
 import java.security.PrivilegedAction;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
-import javax.net.ssl.KeyManagerFactory;
-import javax.security.auth.Subject;
-
-import junit.framework.TestCase;
-
-import org.apache.qpid.server.configuration.ConfigurationEntry;
-import org.apache.qpid.server.configuration.IllegalConfigurationException;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.KeyStore;
-import org.apache.qpid.server.model.adapter.AbstractKeyStoreAdapter;
-import org.apache.qpid.server.security.*;
-import org.apache.qpid.server.security.SecurityManager;
-import org.apache.qpid.test.utils.TestSSLConstants;
+import static org.mockito.Mockito.mock;
 
-public class KeyStoreRecovererTest extends TestCase
+public class FileKeyStoreCreationTest extends TestCase
 {
 
     public void testCreateWithAllAttributesProvided()
@@ -52,12 +47,8 @@ public class KeyStoreRecovererTest exten
 
         UUID id = UUID.randomUUID();
         Broker broker = mock(Broker.class);
-        ConfigurationEntry entry = mock(ConfigurationEntry.class);
-        when(entry.getAttributes()).thenReturn(attributes);
-        when(entry.getId()).thenReturn(id);
 
-        KeyStoreRecoverer recoverer = new KeyStoreRecoverer();
-        final KeyStore keyStore = recoverer.create(null, entry, broker);
+        final KeyStore keyStore = new FileKeyStore(id,broker,attributes);
 
         assertNotNull("Key store configured object is not created", keyStore);
         assertEquals(id, keyStore.getId());
@@ -93,20 +84,15 @@ public class KeyStoreRecovererTest exten
 
         UUID id = UUID.randomUUID();
         Broker broker = mock(Broker.class);
-        ConfigurationEntry entry = mock(ConfigurationEntry.class);
-        when(entry.getId()).thenReturn(id);
-
-        KeyStoreRecoverer recoverer = new KeyStoreRecoverer();
 
         String[] mandatoryProperties = {KeyStore.NAME, KeyStore.PATH, KeyStore.PASSWORD};
         for (int i = 0; i < mandatoryProperties.length; i++)
         {
             Map<String, Object> properties =  new HashMap<String, Object>(attributes);
             properties.remove(mandatoryProperties[i]);
-            when(entry.getAttributes()).thenReturn(properties);
             try
             {
-                recoverer.create(null, entry, broker);
+                new FileKeyStore(id, broker, properties);
                 fail("Cannot create key store without a " + mandatoryProperties[i]);
             }
             catch(IllegalArgumentException e)
@@ -128,4 +114,5 @@ public class KeyStoreRecovererTest exten
         return attributes;
     }
 
+
 }

Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileTrustStoreCreationTest.java (from r1582544, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/TrustStoreRecovererTest.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileTrustStoreCreationTest.java?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileTrustStoreCreationTest.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/TrustStoreRecovererTest.java&r1=1582544&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/TrustStoreRecovererTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileTrustStoreCreationTest.java Thu Apr  3 19:58:53 2014
@@ -21,7 +21,6 @@
 package org.apache.qpid.server.configuration.startup;
 
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 import java.security.PrivilegedAction;
 import java.util.HashMap;
@@ -31,16 +30,15 @@ import java.util.UUID;
 import javax.net.ssl.TrustManagerFactory;
 import javax.security.auth.Subject;
 
-import org.apache.qpid.server.configuration.ConfigurationEntry;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.TrustStore;
-import org.apache.qpid.server.model.adapter.AbstractKeyStoreAdapter;
-import org.apache.qpid.server.security.*;
+import org.apache.qpid.server.security.AbstractKeyStoreAdapter;
+import org.apache.qpid.server.security.FileTrustStore;
 import org.apache.qpid.server.security.SecurityManager;
 import org.apache.qpid.test.utils.QpidTestCase;
 import org.apache.qpid.test.utils.TestSSLConstants;
 
-public class TrustStoreRecovererTest extends QpidTestCase
+public class FileTrustStoreCreationTest extends QpidTestCase
 {
     public void testCreateWithAllAttributesProvided()
     {
@@ -49,13 +47,8 @@ public class TrustStoreRecovererTest ext
 
         UUID id = UUID.randomUUID();
         Broker broker = mock(Broker.class);
-        ConfigurationEntry entry = mock(ConfigurationEntry.class);
-        when(entry.getAttributes()).thenReturn(attributes);
-        when(entry.getId()).thenReturn(id);
 
-        TrustStoreRecoverer recoverer = new TrustStoreRecoverer();
-
-        final TrustStore trustStore = recoverer.create(null, entry, broker);
+        final TrustStore trustStore = new FileTrustStore(id, broker, attributes);
         assertNotNull("Trust store configured object is not created", trustStore);
         assertEquals(id, trustStore.getId());
 
@@ -90,21 +83,15 @@ public class TrustStoreRecovererTest ext
 
         UUID id = UUID.randomUUID();
         Broker broker = mock(Broker.class);
-        ConfigurationEntry entry = mock(ConfigurationEntry.class);
-        when(entry.getAttributes()).thenReturn(attributes);
-        when(entry.getId()).thenReturn(id);
-
-        TrustStoreRecoverer recoverer = new TrustStoreRecoverer();
 
         String[] mandatoryProperties = {TrustStore.NAME, TrustStore.PATH, TrustStore.PASSWORD};
         for (int i = 0; i < mandatoryProperties.length; i++)
         {
             Map<String, Object> properties =  new HashMap<String, Object>(attributes);
             properties.remove(mandatoryProperties[i]);
-            when(entry.getAttributes()).thenReturn(properties);
             try
             {
-                recoverer.create(null, entry, broker);
+                TrustStore trustStore = new FileTrustStore(id, broker, properties);
                 fail("Cannot create key store without a " + mandatoryProperties[i]);
             }
             catch(IllegalArgumentException e)
@@ -126,4 +113,5 @@ public class TrustStoreRecovererTest ext
         return attributes;
     }
 
+
 }

Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderCreationTest.java (from r1582544, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderRecovererTest.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderCreationTest.java?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderCreationTest.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderRecovererTest.java&r1=1582544&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderRecovererTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/PreferencesProviderCreationTest.java Thu Apr  3 19:58:53 2014
@@ -21,18 +21,6 @@
 
 package org.apache.qpid.server.configuration.startup;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.qpid.server.configuration.ConfigurationEntry;
-import org.apache.qpid.server.configuration.ConfigurationEntryStore;
-import org.apache.qpid.server.configuration.RecovererProvider;
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.PreferencesProvider;
@@ -41,6 +29,14 @@ import org.apache.qpid.server.util.Broke
 import org.apache.qpid.test.utils.QpidTestCase;
 import org.apache.qpid.test.utils.TestFileUtils;
 
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 /*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
@@ -61,7 +57,7 @@ import org.apache.qpid.test.utils.TestFi
 * under the License.
 *
 */
-public class PreferencesProviderRecovererTest extends QpidTestCase
+public class PreferencesProviderCreationTest extends QpidTestCase
 {
     private AuthenticationProvider _authenticationProvider;
     private Broker _broker;
@@ -89,18 +85,18 @@ public class PreferencesProviderRecovere
 
     public void testRecoverFileSystemPreferencesProvider()
     {
-        PreferencesProviderRecoverer recoverer = new PreferencesProviderRecoverer();
 
         Map<String, Object> attributes = new HashMap<String, Object>();
         UUID id = UUID.randomUUID();
         attributes.put(PreferencesProvider.TYPE, FileSystemPreferencesProvider.PROVIDER_TYPE);
         attributes.put(PreferencesProvider.NAME, "test-provider");
-        File file = TestFileUtils.createTempFile(this, ".prefs.json", "{\"test_user\":{\"pref1\": \"pref1Value\", \"pref2\": 1.0} }");
+        File file = TestFileUtils.createTempFile(this,
+                                                 ".prefs.json",
+                                                 "{\"test_user\":{\"pref1\": \"pref1Value\", \"pref2\": 1.0} }");
         try
         {
             attributes.put(FileSystemPreferencesProvider.PATH, file.getAbsolutePath());
-            ConfigurationEntry entry = new ConfigurationEntry(id, PreferencesProvider.class.getSimpleName(), attributes, Collections.<UUID>emptySet(), mock(ConfigurationEntryStore.class));
-            PreferencesProvider provider = recoverer.create(mock(RecovererProvider.class), entry, _authenticationProvider);
+            PreferencesProvider provider = new FileSystemPreferencesProvider(id,attributes,_authenticationProvider);
             assertNotNull("Preferences provider was not recovered", provider);
             assertEquals("Unexpected name", "test-provider", provider.getName());
             assertEquals("Unexpected id", id, provider.getId());

Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostCreationTest.java (from r1582544, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostCreationTest.java?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostCreationTest.java&p1=qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java&r1=1582544&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostCreationTest.java Thu Apr  3 19:58:53 2014
@@ -20,68 +20,44 @@
  */
 package org.apache.qpid.server.configuration.startup;
 
-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 junit.framework.TestCase;
-
 import org.apache.qpid.server.configuration.ConfigurationEntry;
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.adapter.StandardVirtualHostAdapter;
 import org.apache.qpid.server.security.SecurityManager;
-import org.apache.qpid.server.stats.StatisticsGatherer;
+import org.apache.qpid.server.store.MessageStore;
+import org.apache.qpid.server.store.TestMemoryMessageStore;
 import org.apache.qpid.server.virtualhost.StandardVirtualHostFactory;
-import org.apache.qpid.test.utils.TestFileUtils;
-
-public class VirtualHostRecovererTest extends TestCase
-{
-    public void testCreate()
-    {
-        StatisticsGatherer statisticsGatherer = mock(StatisticsGatherer.class);
-        SecurityManager securityManager = mock(SecurityManager.class);
-        ConfigurationEntry entry = mock(ConfigurationEntry.class);
-        Broker parent = mock(Broker.class);
-        when(parent.getAttribute(Broker.VIRTUALHOST_HOUSEKEEPING_CHECK_PERIOD)).thenReturn(3000l);
-        when(parent.getSecurityManager()).thenReturn(securityManager);
 
-        VirtualHostRecoverer recoverer = new VirtualHostRecoverer(statisticsGatherer);
-        Map<String, Object> attributes = new HashMap<String, Object>();
-        String name = getName();
-        attributes.put(VirtualHost.NAME, name);
-        File file = TestFileUtils.createTempFile(this, ".xml", "<virtualhosts><virtualhost><name>" + name + "</name><" + name
-                + "></" + name + "></virtualhost></virtualhosts>");
-        attributes.put(VirtualHost.CONFIG_PATH, file.getAbsolutePath());
-        when(entry.getAttributes()).thenReturn(attributes);
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
 
-        VirtualHost host = recoverer.create(null, entry, parent);
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
-        assertNotNull("Null is returned", host);
-        assertEquals("Unexpected name", getName(), host.getName());
-    }
+public class VirtualHostCreationTest extends TestCase
+{
 
     public void testCreateVirtualHostFromStoreConfigAttributes()
     {
-        StatisticsGatherer statisticsGatherer = mock(StatisticsGatherer.class);
         SecurityManager securityManager = mock(SecurityManager.class);
         ConfigurationEntry entry = mock(ConfigurationEntry.class);
         Broker parent = mock(Broker.class);
         when(parent.getAttribute(Broker.VIRTUALHOST_HOUSEKEEPING_CHECK_PERIOD)).thenReturn(3000l);
         when(parent.getSecurityManager()).thenReturn(securityManager);
 
-        VirtualHostRecoverer recoverer = new VirtualHostRecoverer(statisticsGatherer);
         Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put(VirtualHost.NAME, getName());
         attributes.put(VirtualHost.TYPE, StandardVirtualHostFactory.TYPE);
 
-        attributes.put(VirtualHost.STORE_TYPE, "TESTMEMORY");
+        attributes.put(VirtualHost.MESSAGE_STORE_SETTINGS, Collections.singletonMap(MessageStore.STORE_TYPE, TestMemoryMessageStore.TYPE));
         when(entry.getAttributes()).thenReturn(attributes);
 
-        VirtualHost host = recoverer.create(null, entry, parent);
+        VirtualHost host = new StandardVirtualHostAdapter(UUID.randomUUID(),attributes,parent);
 
         assertNotNull("Null is returned", host);
         assertEquals("Unexpected name", getName(), host.getName());
@@ -91,27 +67,20 @@ public class VirtualHostRecovererTest ex
     {
         Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put(VirtualHost.NAME, getName());
-        attributes.put(VirtualHost.CONFIG_PATH, "/path/to/virtualhost.xml");
-        String[] mandatoryAttributes = {VirtualHost.NAME, VirtualHost.CONFIG_PATH};
-
-        checkMandatoryAttributesAreValidated(mandatoryAttributes, attributes);
-
-        attributes = new HashMap<String, Object>();
-        attributes.put(VirtualHost.NAME, getName());
-        attributes.put(VirtualHost.STORE_TYPE, "MEMORY");
-        mandatoryAttributes = new String[]{VirtualHost.NAME, VirtualHost.STORE_TYPE};
+        attributes.put(VirtualHost.TYPE, StandardVirtualHostFactory.TYPE);
+        attributes.put(VirtualHost.MESSAGE_STORE_SETTINGS, Collections.singletonMap(MessageStore.STORE_TYPE,
+                                                                                    TestMemoryMessageStore.TYPE));
+        String[] mandatoryAttributes = {VirtualHost.NAME, VirtualHost.TYPE, VirtualHost.MESSAGE_STORE_SETTINGS};
 
         checkMandatoryAttributesAreValidated(mandatoryAttributes, attributes);
     }
 
     public void checkMandatoryAttributesAreValidated(String[] mandatoryAttributes, Map<String, Object> attributes)
     {
-        StatisticsGatherer statisticsGatherer = mock(StatisticsGatherer.class);
         SecurityManager securityManager = mock(SecurityManager.class);
         ConfigurationEntry entry = mock(ConfigurationEntry.class);
         Broker parent = mock(Broker.class);
         when(parent.getSecurityManager()).thenReturn(securityManager);
-        VirtualHostRecoverer recoverer = new VirtualHostRecoverer(statisticsGatherer);
 
         for (String name : mandatoryAttributes)
         {
@@ -120,7 +89,7 @@ public class VirtualHostRecovererTest ex
             when(entry.getAttributes()).thenReturn(copy);
             try
             {
-                recoverer.create(null, entry, parent);
+                VirtualHost host = new StandardVirtualHostAdapter(UUID.randomUUID(),copy,parent);
                 fail("Cannot create a virtual host without a mandatory attribute " + name);
             }
             catch(IllegalConfigurationException e)

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java Thu Apr  3 19:58:53 2014
@@ -20,28 +20,22 @@
  */
 package org.apache.qpid.server.configuration.store;
 
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
 import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfigurationEntryImpl;
 import org.apache.qpid.server.configuration.ConfigurationEntryStore;
-import org.apache.qpid.server.model.AuthenticationProvider;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.GroupProvider;
-import org.apache.qpid.server.model.KeyStore;
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.PreferencesProvider;
-import org.apache.qpid.server.model.Transport;
-import org.apache.qpid.server.model.TrustStore;
-import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.*;
 import org.apache.qpid.server.model.adapter.FileSystemPreferencesProvider;
 import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManager;
 import org.apache.qpid.server.security.auth.manager.ExternalAuthenticationManager;
+import org.apache.qpid.server.store.ConfiguredObjectRecord;
 import org.apache.qpid.test.utils.QpidTestCase;
 
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
 public abstract class ConfigurationEntryStoreTestCase extends QpidTestCase
 {
     private ConfigurationEntryStore _store;
@@ -79,7 +73,7 @@ public abstract class ConfigurationEntry
         _virtualHostId = UUID.randomUUID();
         _virtualHostAttributes = new HashMap<String, Object>();
         _virtualHostAttributes.put(VirtualHost.NAME, "test");
-        _virtualHostAttributes.put(VirtualHost.CONFIG_PATH, "/path/to/phantom/test");
+        _virtualHostAttributes.put(VirtualHost.TYPE, "STANDARD");
 
         _authenticationProviderId = UUID.randomUUID();
         _authenticationProviderAttributes = new HashMap<String, Object>();
@@ -92,6 +86,7 @@ public abstract class ConfigurationEntry
     }
 
     // ??? perhaps it should not be abstract
+
     protected abstract ConfigurationEntryStore createStore(UUID brokerId, Map<String, Object> brokerAttributes) throws Exception;
 
     protected abstract void addConfiguration(UUID id, String type, Map<String, Object> attributes, UUID parentId);
@@ -133,36 +128,72 @@ public abstract class ConfigurationEntry
 
     public void testRemove()
     {
-        Map<String, Object> virtualHostAttributes = new HashMap<String, Object>();
+        final Map<String, Object> virtualHostAttributes = new HashMap<String, Object>();
         virtualHostAttributes.put(VirtualHost.NAME, getName());
-        virtualHostAttributes.put(VirtualHost.CONFIG_PATH, "/path/to/phantom/virtualhost/config");
-        UUID virtualHostId = UUID.randomUUID();
+        virtualHostAttributes.put(VirtualHost.TYPE, "STANDARD");
+        final UUID virtualHostId = UUID.randomUUID();
         addConfiguration(virtualHostId, VirtualHost.class.getSimpleName(), virtualHostAttributes);
 
         assertNotNull("Virtual host with id " + virtualHostId + " should exist", _store.getEntry(virtualHostId));
 
-        _store.remove(virtualHostId);
-        assertNull("Authentication provider configuration should be removed", _store.getEntry(virtualHostId));
+        _store.remove(createConfiguredObjectRecord(virtualHostId, VirtualHost.class, virtualHostAttributes));
+        assertNull("Virtual host configuration should be removed", _store.getEntry(virtualHostId));
+    }
+
+    protected ConfiguredObjectRecord createConfiguredObjectRecord(final UUID virtualHostId,
+                                                                  final Class<? extends ConfiguredObject> type,
+                                                                  final Map<String, Object> virtualHostAttributes)
+    {
+        return new ConfiguredObjectRecord()
+        {
+            @Override
+            public UUID getId()
+            {
+                return virtualHostId;
+            }
+
+            @Override
+            public String getType()
+            {
+                return type.getSimpleName();
+            }
+
+            @Override
+            public Map<String, Object> getAttributes()
+            {
+                return virtualHostAttributes;
+            }
+
+            @Override
+            public Map<String, ConfiguredObjectRecord> getParents()
+            {
+                // TODO RG : rectify this
+                return null;
+            }
+        };
     }
 
     public void testRemoveMultipleEntries()
     {
         Map<String, Object> virtualHost1Attributes = new HashMap<String, Object>();
         virtualHost1Attributes.put(VirtualHost.NAME, "test1");
-        virtualHost1Attributes.put(VirtualHost.CONFIG_PATH, "/path/to/phantom/virtualhost/config1");
+        virtualHost1Attributes.put(VirtualHost.TYPE, "STANDARD");
         UUID virtualHost1Id = UUID.randomUUID();
         addConfiguration(virtualHost1Id, VirtualHost.class.getSimpleName(), virtualHost1Attributes);
 
         Map<String, Object> virtualHost2Attributes = new HashMap<String, Object>();
         virtualHost2Attributes.put(VirtualHost.NAME, "test1");
-        virtualHost2Attributes.put(VirtualHost.CONFIG_PATH, "/path/to/phantom/virtualhost/config2");
+        virtualHost2Attributes.put(VirtualHost.TYPE, "STANDARD");
         UUID virtualHost2Id = UUID.randomUUID();
         addConfiguration(virtualHost2Id, VirtualHost.class.getSimpleName(), virtualHost2Attributes);
 
         assertNotNull("Virtual host with id " + virtualHost1Id + " should exist", _store.getEntry(virtualHost1Id));
         assertNotNull("Virtual host with id " + virtualHost2Id + " should exist", _store.getEntry(virtualHost2Id));
 
-        UUID[] deletedIds = _store.remove(virtualHost1Id, virtualHost2Id);
+        UUID[] deletedIds =
+                _store.remove(createConfiguredObjectRecord(virtualHost1Id, VirtualHost.class, virtualHost1Attributes),
+                              createConfiguredObjectRecord(virtualHost2Id, VirtualHost.class, virtualHost2Attributes));
+
         assertNotNull("Unexpected deleted ids", deletedIds);
         assertEquals("Unexpected id of first deleted virtual host", virtualHost1Id , deletedIds[0]);
         assertEquals("Unexpected id of second deleted virtual host", virtualHost2Id , deletedIds[1]);
@@ -189,7 +220,8 @@ public abstract class ConfigurationEntry
         attributes.put(Broker.CONNECTION_HEART_BEAT_DELAY, 12000);
         attributes.put(Broker.STATISTICS_REPORTING_PERIOD, 14000);
         attributes.put(Broker.STATISTICS_REPORTING_RESET_ENABLED, false);
-        ConfigurationEntry updatedBrokerEntry = new ConfigurationEntry(_brokerId, Broker.class.getSimpleName(), attributes,
+        ConfigurationEntry
+                updatedBrokerEntry = new ConfigurationEntryImpl(_brokerId, Broker.class.getSimpleName(), attributes,
                 brokerConfigEntry.getChildrenIds(), _store);
 
         _store.save(updatedBrokerEntry);
@@ -207,9 +239,9 @@ public abstract class ConfigurationEntry
     {
         Map<String, Object> virtualHostAttributes = new HashMap<String, Object>();
         virtualHostAttributes.put(VirtualHost.NAME, "test1");
-        virtualHostAttributes.put(VirtualHost.CONFIG_PATH, "/path/to/phantom/virtualhost/config1");
+        virtualHostAttributes.put(VirtualHost.TYPE, "STANDARD");
         UUID virtualHostId = UUID.randomUUID();
-        ConfigurationEntry hostEntry = new ConfigurationEntry(virtualHostId, VirtualHost.class.getSimpleName(), virtualHostAttributes,
+        ConfigurationEntry hostEntry = new ConfigurationEntryImpl(virtualHostId, VirtualHost.class.getSimpleName(), virtualHostAttributes,
                 Collections.<UUID> emptySet(), _store);
 
         _store.save(hostEntry);
@@ -228,9 +260,9 @@ public abstract class ConfigurationEntry
 
         Map<String, Object> virtualHostAttributes = new HashMap<String, Object>();
         virtualHostAttributes.put(VirtualHost.NAME, "test");
-        virtualHostAttributes.put(VirtualHost.CONFIG_PATH, "/path/to/new/phantom/test/configuration");
+        virtualHostAttributes.put(VirtualHost.TYPE, "STANDARD");
 
-        ConfigurationEntry updatedEntry = new ConfigurationEntry(_virtualHostId, VirtualHost.class.getSimpleName(), virtualHostAttributes,
+        ConfigurationEntry updatedEntry = new ConfigurationEntryImpl(_virtualHostId, VirtualHost.class.getSimpleName(), virtualHostAttributes,
                 hostEntry.getChildrenIds(), _store);
         _store.save(updatedEntry);
 
@@ -247,7 +279,7 @@ public abstract class ConfigurationEntry
         Map<String, Object> authenticationProviderAttributes = new HashMap<String, Object>();
         authenticationProviderAttributes.put(AuthenticationProvider.NAME, "authenticationProvider1");
         authenticationProviderAttributes.put(AuthenticationProvider.TYPE, ExternalAuthenticationManager.class.getSimpleName());
-        ConfigurationEntry providerEntry = new ConfigurationEntry(authenticationProviderId, AuthenticationProvider.class.getSimpleName(),
+        ConfigurationEntry providerEntry = new ConfigurationEntryImpl(authenticationProviderId, AuthenticationProvider.class.getSimpleName(),
                 authenticationProviderAttributes, Collections.<UUID> emptySet(), _store);
 
         _store.save(providerEntry);
@@ -267,7 +299,7 @@ public abstract class ConfigurationEntry
         Map<String, Object> authenticationProviderAttributes = new HashMap<String, Object>();
         authenticationProviderAttributes.put(AuthenticationProvider.NAME, "authenticationProvider1");
         authenticationProviderAttributes.put(AuthenticationProvider.TYPE, ExternalAuthenticationManager.class.getSimpleName());
-        ConfigurationEntry updatedEntry = new ConfigurationEntry(_authenticationProviderId, AuthenticationProvider.class.getSimpleName(),
+        ConfigurationEntry updatedEntry = new ConfigurationEntryImpl(_authenticationProviderId, AuthenticationProvider.class.getSimpleName(),
                 authenticationProviderAttributes, Collections.<UUID> emptySet(), _store);
         _store.save(updatedEntry);
 
@@ -289,7 +321,8 @@ public abstract class ConfigurationEntry
         attributes.put(TrustStore.TRUST_MANAGER_FACTORY_ALGORITHM, "NON-STANDARD");
         attributes.put(TrustStore.DESCRIPTION, "Description");
 
-        ConfigurationEntry trustStoreEntry = new ConfigurationEntry(trustStoreId, TrustStore.class.getSimpleName(), attributes,
+        ConfigurationEntry
+                trustStoreEntry = new ConfigurationEntryImpl(trustStoreId, TrustStore.class.getSimpleName(), attributes,
                 Collections.<UUID> emptySet(), _store);
 
         _store.save(trustStoreEntry);
@@ -313,7 +346,7 @@ public abstract class ConfigurationEntry
         attributes.put(KeyStore.DESCRIPTION, "Description");
         attributes.put(KeyStore.CERTIFICATE_ALIAS, "Alias");
 
-        ConfigurationEntry keyStoreEntry = new ConfigurationEntry(keyStoreId, KeyStore.class.getSimpleName(), attributes, Collections.<UUID> emptySet(),
+        ConfigurationEntry keyStoreEntry = new ConfigurationEntryImpl(keyStoreId, KeyStore.class.getSimpleName(), attributes, Collections.<UUID> emptySet(),
                 _store);
 
         _store.save(keyStoreEntry);
@@ -331,7 +364,7 @@ public abstract class ConfigurationEntry
         Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put(GroupProvider.NAME, getName());
 
-        ConfigurationEntry groupProviderEntry = new ConfigurationEntry(groupProviderId, GroupProvider.class.getSimpleName(), attributes,
+        ConfigurationEntry groupProviderEntry = new ConfigurationEntryImpl(groupProviderId, GroupProvider.class.getSimpleName(), attributes,
                 Collections.<UUID> emptySet(), _store);
 
         _store.save(groupProviderEntry);
@@ -356,7 +389,8 @@ public abstract class ConfigurationEntry
         attributes.put(Port.NEED_CLIENT_AUTH, true);
         attributes.put(Port.WANT_CLIENT_AUTH, true);
 
-        ConfigurationEntry portEntry = new ConfigurationEntry(portId, Port.class.getSimpleName(), attributes, Collections.<UUID> emptySet(), _store);
+        ConfigurationEntry portEntry = new ConfigurationEntryImpl(portId, Port.class.getSimpleName(), attributes, Collections
+                .<UUID> emptySet(), _store);
 
         _store.save(portEntry);
 
@@ -372,8 +406,8 @@ public abstract class ConfigurationEntry
         UUID virtualHostId = UUID.randomUUID();
         Map<String, Object> virtualHostAttributes = new HashMap<String, Object>();
         virtualHostAttributes.put(VirtualHost.NAME, "test1");
-        virtualHostAttributes.put(VirtualHost.CONFIG_PATH, "/path/to/phantom/virtualhost/config1");
-        ConfigurationEntry hostEntry = new ConfigurationEntry(virtualHostId, VirtualHost.class.getSimpleName(), virtualHostAttributes,
+        virtualHostAttributes.put(VirtualHost.TYPE, "STANDARD");
+        ConfigurationEntry hostEntry = new ConfigurationEntryImpl(virtualHostId, VirtualHost.class.getSimpleName(), virtualHostAttributes,
                 Collections.<UUID> emptySet(), _store);
 
         UUID keyStoreId = UUID.randomUUID();
@@ -386,7 +420,7 @@ public abstract class ConfigurationEntry
         attributes.put(KeyStore.DESCRIPTION, "Description");
         attributes.put(KeyStore.CERTIFICATE_ALIAS, "Alias");
 
-        ConfigurationEntry keyStoreEntry = new ConfigurationEntry(keyStoreId, KeyStore.class.getSimpleName(), attributes, Collections.<UUID> emptySet(),
+        ConfigurationEntry keyStoreEntry = new ConfigurationEntryImpl(keyStoreId, KeyStore.class.getSimpleName(), attributes, Collections.<UUID> emptySet(),
                 _store);
 
         _store.save(hostEntry, keyStoreEntry);
@@ -418,7 +452,7 @@ public abstract class ConfigurationEntry
     protected void addPreferencesProvider(UUID preferencesProviderId, String name, String path)
     {
         ConfigurationEntry authenticationProviderEntry = _store.getEntry(_authenticationProviderId);
-        ConfigurationEntry newAuthenticationProviderConfigEntry = new ConfigurationEntry(authenticationProviderEntry.getId(),
+        ConfigurationEntry newAuthenticationProviderConfigEntry = new ConfigurationEntryImpl(authenticationProviderEntry.getId(),
                 authenticationProviderEntry.getType(), authenticationProviderEntry.getAttributes(),
                 Collections.<UUID>singleton(preferencesProviderId), _store);
 
@@ -427,7 +461,7 @@ public abstract class ConfigurationEntry
         preferencesProviderAttributes.put(FileSystemPreferencesProvider.PATH, path);
         preferencesProviderAttributes.put(PreferencesProvider.NAME, name);
 
-        ConfigurationEntry preferencesProviderEntry = new ConfigurationEntry(preferencesProviderId, PreferencesProvider.class.getSimpleName(),
+        ConfigurationEntry preferencesProviderEntry = new ConfigurationEntryImpl(preferencesProviderId, PreferencesProvider.class.getSimpleName(),
                 preferencesProviderAttributes, Collections.<UUID> emptySet(), _store);
 
         _store.save(newAuthenticationProviderConfigEntry, preferencesProviderEntry);

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java Thu Apr  3 19:58:53 2014
@@ -20,28 +20,40 @@
  */
 package org.apache.qpid.server.configuration.store;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
+import org.apache.qpid.server.BrokerOptions;
 import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfigurationEntryImpl;
 import org.apache.qpid.server.configuration.ConfigurationEntryStore;
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.configuration.updater.TaskExecutor;
+import org.apache.qpid.server.logging.EventLogger;
+import org.apache.qpid.server.logging.LogRecorder;
 import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObjectFactory;
 import org.apache.qpid.server.model.PreferencesProvider;
+import org.apache.qpid.server.model.SystemContext;
 import org.apache.qpid.server.model.adapter.FileSystemPreferencesProvider;
+import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.test.utils.TestFileUtils;
 import org.codehaus.jackson.JsonGenerationException;
 import org.codehaus.jackson.map.JsonMappingException;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.SerializationConfig;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+
 public class JsonConfigurationEntryStoreTest extends ConfigurationEntryStoreTestCase
 {
     private File _storeFile;
@@ -64,15 +76,41 @@ public class JsonConfigurationEntryStore
     }
 
     @Override
-    protected ConfigurationEntryStore createStore(UUID brokerId, Map<String, Object> brokerAttributes) throws Exception
+    protected JsonConfigurationEntryStore createStore(UUID brokerId, Map<String, Object> brokerAttributes) throws Exception
     {
         _storeFile = createStoreFile(brokerId, brokerAttributes);
-        JsonConfigurationEntryStore store = new JsonConfigurationEntryStore(_storeFile.getAbsolutePath(), null, false, Collections.<String,String>emptyMap());
+        return createStore();
+    }
+
+    private JsonConfigurationEntryStore createStore()
+    {
+        String absolutePath = _storeFile.getAbsolutePath();
+        return createStore(absolutePath);
+    }
+
+    private JsonConfigurationEntryStore createStore(final String absolutePath)
+    {
+        return createStore(absolutePath, null);
+    }
+
+    private JsonConfigurationEntryStore createStore(final String absolutePath,
+                                                    final DurableConfigurationStore initialStore)
+    {
+        final BrokerOptions brokerOptions = mock(BrokerOptions.class);
+        when(brokerOptions.getConfigurationStoreLocation()).thenReturn(absolutePath);
+        SystemContext context = new SystemContext(new TaskExecutor(),
+                                                  new ConfiguredObjectFactory(),
+                                                  mock(EventLogger.class),
+                                                  mock(LogRecorder.class),
+                                                  brokerOptions);
+
+        JsonConfigurationEntryStore store = new JsonConfigurationEntryStore(context, initialStore, false,
+                                                                            Collections.<String,String>emptyMap());
         return store;
     }
 
     private File createStoreFile(UUID brokerId, Map<String, Object> brokerAttributes) throws IOException,
-            JsonGenerationException, JsonMappingException
+                                                                                             JsonGenerationException, JsonMappingException
     {
         return createStoreFile(brokerId, brokerAttributes, true);
     }
@@ -104,8 +142,8 @@ public class JsonConfigurationEntryStore
         ConfigurationEntry parentEntry = getStore().getEntry(parentId);
         Set<UUID> children = new HashSet<UUID>(parentEntry.getChildrenIds());
         children.add(id);
-        ConfigurationEntry newParentEntry = new ConfigurationEntry(parentEntry.getId(), parentEntry.getType(), parentEntry.getAttributes(), children, store);
-        store.save(newParentEntry, new ConfigurationEntry(id, type, attributes, Collections.<UUID> emptySet(), store));
+        ConfigurationEntry newParentEntry = new ConfigurationEntryImpl(parentEntry.getId(), parentEntry.getType(), parentEntry.getAttributes(), children, store);
+        store.save(newParentEntry, new ConfigurationEntryImpl(id, type, attributes, Collections.<UUID> emptySet(), store));
     }
 
     public void testAttributeIsResolvedFromSystemProperties()
@@ -117,11 +155,12 @@ public class JsonConfigurationEntryStore
         ConfigurationEntry brokerConfigEntry = store.getRootEntry();
         Map<String, Object> attributes = new HashMap<String, Object>(brokerConfigEntry.getAttributes());
         attributes.put(Broker.DEFAULT_VIRTUAL_HOST, "${my.test.property}");
-        ConfigurationEntry updatedBrokerEntry = new ConfigurationEntry(brokerConfigEntry.getId(), Broker.class.getSimpleName(),
+        ConfigurationEntry
+                updatedBrokerEntry = new ConfigurationEntryImpl(brokerConfigEntry.getId(), Broker.class.getSimpleName(),
                 attributes, brokerConfigEntry.getChildrenIds(), store);
         store.save(updatedBrokerEntry);
 
-        JsonConfigurationEntryStore store2 = new JsonConfigurationEntryStore(_storeFile.getAbsolutePath(), null, false, Collections.<String,String>emptyMap());
+        JsonConfigurationEntryStore store2 = createStore();
 
         assertEquals("Unresolved default virtualhost  value", defaultVhost, store2.getRootEntry().getAttributes().get(Broker.DEFAULT_VIRTUAL_HOST));
     }
@@ -131,7 +170,7 @@ public class JsonConfigurationEntryStore
         File file = TestFileUtils.createTempFile(this, ".json");
         try
         {
-            new JsonConfigurationEntryStore(file.getAbsolutePath(), null, false, Collections.<String,String>emptyMap());
+            createStore(file.getAbsolutePath());
             fail("Cannot create a new store without initial store");
         }
         catch(IllegalConfigurationException e)
@@ -147,7 +186,7 @@ public class JsonConfigurationEntryStore
         brokerAttributes.put(Broker.NAME, getTestName());
         File file = createStoreFile(brokerId, brokerAttributes);
 
-        JsonConfigurationEntryStore store = new JsonConfigurationEntryStore(file.getAbsolutePath(), null, false, Collections.<String,String>emptyMap());
+        JsonConfigurationEntryStore store = createStore(file.getAbsolutePath());
         ConfigurationEntry root = store.getRootEntry();
         assertNotNull("Root entry is not found", root);
         assertEquals("Unexpected root entry", brokerId, root.getId());
@@ -164,10 +203,10 @@ public class JsonConfigurationEntryStore
         Map<String, Object> brokerAttributes = new HashMap<String, Object>();
         File initialStoreFile = createStoreFile(brokerId, brokerAttributes);
 
-        JsonConfigurationEntryStore initialStore = new JsonConfigurationEntryStore(initialStoreFile.getAbsolutePath(), null, false, Collections.<String,String>emptyMap());
+        JsonConfigurationEntryStore initialStore = createStore(initialStoreFile.getAbsolutePath());
 
         File storeFile = TestFileUtils.createTempFile(this, ".json");
-        JsonConfigurationEntryStore store = new JsonConfigurationEntryStore(storeFile.getAbsolutePath(), initialStore, false, Collections.<String,String>emptyMap());
+        JsonConfigurationEntryStore store = createStore(storeFile.getAbsolutePath(), initialStore);
 
         ConfigurationEntry root = store.getRootEntry();
         assertNotNull("Root entry is not found", root);
@@ -201,7 +240,7 @@ public class JsonConfigurationEntryStore
             try
             {
                 storeFile = createStoreFile(brokerId, brokerAttributes);
-                new JsonConfigurationEntryStore(storeFile.getAbsolutePath(), null, false, Collections.<String, String>emptyMap());
+                createStore(storeFile.getAbsolutePath());
                 fail("The store creation should fail due to unsupported store version");
             }
             catch (IllegalConfigurationException e)
@@ -227,7 +266,7 @@ public class JsonConfigurationEntryStore
         try
         {
             storeFile = createStoreFile(brokerId, brokerAttributes, false);
-            new JsonConfigurationEntryStore(storeFile.getAbsolutePath(), null, false, Collections.<String, String>emptyMap());
+            createStore(storeFile.getAbsolutePath());
             fail("The store creation should fail due to unspecified store version");
         }
         catch (IllegalConfigurationException e)
@@ -252,7 +291,7 @@ public class JsonConfigurationEntryStore
         addPreferencesProvider(preferencesProviderId, name, path);
 
         // verify that store can deserialise child of a child
-        JsonConfigurationEntryStore newStore = new JsonConfigurationEntryStore(_storeFile.getAbsolutePath(), null, false, Collections.<String, String>emptyMap());
+        JsonConfigurationEntryStore newStore = createStore();
 
         ConfigurationEntry authenticationProviderEntry = newStore.getEntry(_authenticationProviderId);
         assertEquals("Unexpected preference provider ID in authentication provider children set", preferencesProviderId, authenticationProviderEntry.getChildrenIds().iterator().next());
@@ -265,4 +304,5 @@ public class JsonConfigurationEntryStore
         assertEquals("Unexpected preferences provider type", FileSystemPreferencesProvider.PROVIDER_TYPE,
                 attributes.get(PreferencesProvider.TYPE));
     }
+
 }

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java Thu Apr  3 19:58:53 2014
@@ -35,6 +35,7 @@ import java.util.UUID;
 
 import org.apache.qpid.server.BrokerOptions;
 import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfigurationEntryImpl;
 import org.apache.qpid.server.configuration.ConfigurationEntryStore;
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.model.Broker;
@@ -42,6 +43,7 @@ import org.apache.qpid.server.model.Port
 import org.apache.qpid.server.model.Protocol;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.store.ConfiguredObjectRecord;
 import org.apache.qpid.test.utils.QpidTestCase;
 
 public class ManagementModeStoreHandlerTest extends QpidTestCase
@@ -213,7 +215,7 @@ public class ManagementModeStoreHandlerT
         when(virtualHost.getId()).thenReturn(virtualHostId);
         when(virtualHost.getType()).thenReturn(VirtualHost.class.getSimpleName());
         Map<String, Object> attributes = new HashMap<String, Object>();
-        attributes.put(VirtualHost.CONFIG_PATH, "/path/to/host.xml");
+        attributes.put(VirtualHost.TYPE, "STANDARD");
         when(virtualHost.getAttributes()).thenReturn(attributes);
         when(_store.getEntry(virtualHostId)).thenReturn(virtualHost);
         when(_root.getChildrenIds()).thenReturn(new HashSet<UUID>(Arrays.asList(_portEntryId, virtualHostId)));
@@ -253,7 +255,8 @@ public class ManagementModeStoreHandlerT
 
         Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put(Port.NAME, "TEST");
-        ConfigurationEntry configurationEntry = new ConfigurationEntry(_portEntryId, Port.class.getSimpleName(), attributes,
+        ConfigurationEntry
+                configurationEntry = new ConfigurationEntryImpl(_portEntryId, Port.class.getSimpleName(), attributes,
                 Collections.<UUID> emptySet(), null);
         _handler.save(configurationEntry);
         verify(_store).save(any(ConfigurationEntry.class));
@@ -269,7 +272,8 @@ public class ManagementModeStoreHandlerT
         ConfigurationEntry root = _handler.getRootEntry();
         Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put(Broker.NAME, "TEST");
-        ConfigurationEntry configurationEntry = new ConfigurationEntry(_rootId, Broker.class.getSimpleName(), attributes,
+        ConfigurationEntry
+                configurationEntry = new ConfigurationEntryImpl(_rootId, Broker.class.getSimpleName(), attributes,
                 root.getChildrenIds(), null);
         _handler.save(configurationEntry);
         verify(_store).save(any(ConfigurationEntry.class));
@@ -283,7 +287,8 @@ public class ManagementModeStoreHandlerT
         UUID portId = getOptionsPortId();
         Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put(Port.NAME, "TEST");
-        ConfigurationEntry configurationEntry = new ConfigurationEntry(portId, Port.class.getSimpleName(), attributes,
+        ConfigurationEntry
+                configurationEntry = new ConfigurationEntryImpl(portId, Port.class.getSimpleName(), attributes,
                 Collections.<UUID> emptySet(), null);
         try
         {
@@ -300,9 +305,34 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeHttpPortOverride(1000);
         _handler = new ManagementModeStoreHandler(_store, _options);
-
-        _handler.remove(_portEntryId);
-        verify(_store).remove(_portEntryId);
+        ConfiguredObjectRecord record = new ConfiguredObjectRecord()
+        {
+            @Override
+            public UUID getId()
+            {
+                return _portEntryId;
+            }
+
+            @Override
+            public String getType()
+            {
+                return Port.class.getSimpleName();
+            }
+
+            @Override
+            public Map<String, Object> getAttributes()
+            {
+                return Collections.emptyMap();
+            }
+
+            @Override
+            public Map<String, ConfiguredObjectRecord> getParents()
+            {
+                return null;
+            }
+        };
+        _handler.remove(record);
+        verify(_store).remove(record);
     }
 
     public void testRemoveCLIPort()
@@ -310,9 +340,11 @@ public class ManagementModeStoreHandlerT
         _options.setManagementModeHttpPortOverride(1000);
         _handler = new ManagementModeStoreHandler(_store, _options);
         UUID portId = getOptionsPortId();
+        ConfiguredObjectRecord record = mock(ConfiguredObjectRecord.class);
+        when(record.getId()).thenReturn(portId);
         try
         {
-            _handler.remove(portId);
+            _handler.remove(record);
             fail("Exception should be thrown on trying to remove CLI port");
         }
         catch (IllegalConfigurationException e)

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStoreTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStoreTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStoreTest.java Thu Apr  3 19:58:53 2014
@@ -20,6 +20,14 @@
  */
 package org.apache.qpid.server.configuration.store;
 
+import org.apache.qpid.server.BrokerOptions;
+import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfigurationEntryImpl;
+import org.apache.qpid.server.configuration.ConfigurationEntryStore;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.model.Broker;
+import org.codehaus.jackson.map.ObjectMapper;
+
 import java.io.File;
 import java.util.Collections;
 import java.util.HashMap;
@@ -28,16 +36,8 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
-import org.apache.qpid.server.BrokerOptions;
-import org.apache.qpid.server.configuration.ConfigurationEntry;
-import org.apache.qpid.server.configuration.ConfigurationEntryStore;
-import org.apache.qpid.server.configuration.IllegalConfigurationException;
-import org.apache.qpid.server.model.Broker;
-import org.codehaus.jackson.map.ObjectMapper;
-
 public class MemoryConfigurationEntryStoreTest extends ConfigurationEntryStoreTestCase
 {
-
     @Override
     protected ConfigurationEntryStore createStore(UUID brokerId, Map<String, Object> brokerAttributes) throws Exception
     {
@@ -56,8 +56,8 @@ public class MemoryConfigurationEntrySto
         ConfigurationEntry parentEntry = getStore().getEntry(parentId);
         Set<UUID> children = new HashSet<UUID>(parentEntry.getChildrenIds());
         children.add(id);
-        ConfigurationEntry newParentEntry = new ConfigurationEntry(parentEntry.getId(), parentEntry.getType(), parentEntry.getAttributes(), children, store);
-        store.save(newParentEntry, new ConfigurationEntry(id, type, attributes, Collections.<UUID> emptySet(), store));
+        ConfigurationEntry newParentEntry = new ConfigurationEntryImpl(parentEntry.getId(), parentEntry.getType(), parentEntry.getAttributes(), children, store);
+        store.save(newParentEntry, new ConfigurationEntryImpl(id, type, attributes, Collections.<UUID> emptySet(), store));
     }
 
     public void testCreateWithNullLocationAndNullInitialStore()
@@ -130,4 +130,5 @@ public class MemoryConfigurationEntrySto
     {
         assertEquals("Unexpected type", "memory", getStore().getType());
     }
+
 }

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java Thu Apr  3 19:58:53 2014
@@ -20,6 +20,7 @@
  */
 package org.apache.qpid.server.configuration.store;
 
+import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.verify;
@@ -28,13 +29,13 @@ import static org.mockito.Mockito.when;
 
 import java.util.UUID;
 
-import org.apache.qpid.server.configuration.ConfigurationEntry;
 import org.apache.qpid.server.configuration.ConfigurationEntryStore;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.store.ConfiguredObjectRecord;
 import org.apache.qpid.test.utils.QpidTestCase;
 
 public class StoreConfigurationChangeListenerTest extends QpidTestCase
@@ -55,8 +56,10 @@ public class StoreConfigurationChangeLis
         UUID id = UUID.randomUUID();
         ConfiguredObject object = mock(VirtualHost.class);
         when(object.getId()).thenReturn(id);
+        ConfiguredObjectRecord record = mock(ConfiguredObjectRecord.class);
+        when(object.asObjectRecord()).thenReturn(record);
         _listener.stateChanged(object, State.ACTIVE, State.DELETED);
-        verify(_store).remove(id);
+        verify(_store).remove(record);
     }
 
     public void testChildAdded()
@@ -67,18 +70,7 @@ public class StoreConfigurationChangeLis
         VirtualHost child = mock(VirtualHost.class);
         when(child.getCategoryClass()).thenReturn(VirtualHost.class);
         _listener.childAdded(broker, child);
-        verify(_store).save(any(ConfigurationEntry.class), any(ConfigurationEntry.class));
-    }
-
-    public void testChildRemoved()
-    {
-        notifyBrokerStarted();
-        Broker broker = mock(Broker.class);
-        when(broker.getCategoryClass()).thenReturn(Broker.class);
-        VirtualHost child = mock(VirtualHost.class);
-        when(child.getCategoryClass()).thenReturn(VirtualHost.class);
-        _listener.childRemoved(broker, child);
-        verify(_store).save(any(ConfigurationEntry.class));
+        verify(_store).update(eq(true), any(ConfiguredObjectRecord.class));
     }
 
     public void testAttributeSet()
@@ -87,7 +79,7 @@ public class StoreConfigurationChangeLis
         Broker broker = mock(Broker.class);
         when(broker.getCategoryClass()).thenReturn(Broker.class);
         _listener.attributeSet(broker, Broker.QUEUE_FLOW_CONTROL_SIZE_BYTES, null, 1);
-        verify(_store).save(any(ConfigurationEntry.class));
+        verify(_store).update(eq(false),any(ConfiguredObjectRecord.class));
     }
 
     public void testChildAddedForVirtualHost()

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java Thu Apr  3 19:58:53 2014
@@ -20,9 +20,6 @@
  */
 package org.apache.qpid.server.logging.messages;
 
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.PropertiesConfiguration;
-
 import org.apache.qpid.server.logging.EventLogger;
 import org.apache.qpid.server.logging.LogMessage;
 import org.apache.qpid.server.logging.LogSubject;
@@ -35,7 +32,6 @@ import java.util.List;
 
 public abstract class AbstractTestMessages extends QpidTestCase
 {
-    protected Configuration _config = new PropertiesConfiguration();
     protected LogMessage _logMessage = null;
     protected UnitTestMessageLogger _logger;
     protected LogSubject _logSubject = new TestBlankSubject();

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java Thu Apr  3 19:58:53 2014
@@ -20,24 +20,24 @@
  */
 package org.apache.qpid.server.model;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.qpid.server.configuration.ConfigurationEntry;
 import org.apache.qpid.server.configuration.RecovererProvider;
-import org.apache.qpid.server.configuration.startup.VirtualHostRecoverer;
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
+import org.apache.qpid.server.model.adapter.StandardVirtualHostAdapter;
 import org.apache.qpid.server.stats.StatisticsGatherer;
+import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.store.TestMemoryMessageStore;
 import org.apache.qpid.server.util.BrokerTestHelper;
 import org.apache.qpid.server.virtualhost.StandardVirtualHostFactory;
 import org.apache.qpid.test.utils.QpidTestCase;
 
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 public class VirtualHostTest extends QpidTestCase
 {
 
@@ -54,6 +54,15 @@ public class VirtualHostTest extends Qpi
         TaskExecutor taskExecutor = mock(TaskExecutor.class);
         when(taskExecutor.isTaskExecutorThread()).thenReturn(true);
         when(_broker.getTaskExecutor()).thenReturn(taskExecutor);
+        when(_broker.getAttribute(Broker.QUEUE_ALERT_THRESHOLD_MESSAGE_AGE)).thenReturn(0l);
+        when(_broker.getAttribute(Broker.QUEUE_ALERT_THRESHOLD_MESSAGE_SIZE)).thenReturn(0l);
+        when(_broker.getAttribute(Broker.QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_BYTES)).thenReturn(0l);
+        when(_broker.getAttribute(Broker.QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES)).thenReturn(0l);
+        when(_broker.getAttribute(Broker.QUEUE_ALERT_REPEAT_GAP)).thenReturn(10000l);
+        when(_broker.getAttribute(Broker.QUEUE_MAXIMUM_DELIVERY_ATTEMPTS)).thenReturn(0);
+        when(_broker.getAttribute(Broker.QUEUE_FLOW_CONTROL_RESUME_SIZE_BYTES)).thenReturn(0l);
+        when(_broker.getAttribute(Broker.QUEUE_FLOW_CONTROL_SIZE_BYTES)).thenReturn(0l);
+        when(_broker.getAttribute(Broker.QUEUE_DEAD_LETTER_QUEUE_ENABLED)).thenReturn(false);
 
         _recovererProvider = mock(RecovererProvider.class);
         _statisticsGatherer = mock(StatisticsGatherer.class);
@@ -79,7 +88,7 @@ public class VirtualHostTest extends Qpi
         Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put(VirtualHost.NAME, getName());
         attributes.put(VirtualHost.TYPE, StandardVirtualHostFactory.TYPE);
-        attributes.put(VirtualHost.STORE_TYPE, TestMemoryMessageStore.TYPE);
+        attributes.put(VirtualHost.MESSAGE_STORE_SETTINGS, Collections.singletonMap(MessageStore.STORE_TYPE, TestMemoryMessageStore.TYPE));
         attributes.put(VirtualHost.STATE, State.QUIESCED);
 
         VirtualHost host = createHost(attributes);
@@ -140,7 +149,7 @@ public class VirtualHostTest extends Qpi
         Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put(VirtualHost.NAME, getName());
         attributes.put(VirtualHost.TYPE, StandardVirtualHostFactory.TYPE);
-        attributes.put(VirtualHost.STORE_TYPE, TestMemoryMessageStore.TYPE);
+        attributes.put(VirtualHost.MESSAGE_STORE_SETTINGS, Collections.singletonMap(MessageStore.STORE_TYPE, TestMemoryMessageStore.TYPE));
 
         VirtualHost host = createHost(attributes);
         return host;
@@ -148,10 +157,7 @@ public class VirtualHostTest extends Qpi
 
     private VirtualHost createHost(Map<String, Object> attributes)
     {
-        ConfigurationEntry entry = new ConfigurationEntry(UUID.randomUUID(), VirtualHost.class.getSimpleName(), attributes,
-                Collections.<UUID> emptySet(), null);
-
-        return new VirtualHostRecoverer(_statisticsGatherer).create(_recovererProvider, entry, _broker);
+        return new StandardVirtualHostAdapter(UUID.randomUUID(), attributes, _broker);
     }
 
 }



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


Mime
View raw message