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 2014/10/30 16:01:58 UTC

svn commit: r1635520 - in /qpid/trunk/qpid/java/broker-core/src: main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java

Author: orudyy
Date: Thu Oct 30 15:01:58 2014
New Revision: 1635520

URL: http://svn.apache.org/r1635520
Log:
QPID-6200: Change broker upgraders to upgrade virtual host data from model 1.x into virtual host nodes

Modified:
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java
    qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java?rev=1635520&r1=1635519&r2=1635520&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java Thu Oct 30 15:01:58 2014
@@ -40,6 +40,7 @@ import org.apache.qpid.server.util.Actio
 
 public class BrokerStoreUpgraderAndRecoverer
 {
+    public static final String VIRTUALHOSTS = "virtualhosts";
     private final SystemConfig<?> _systemConfig;
     private final Map<String, StoreUpgraderPhase> _upgraders = new HashMap<String, StoreUpgraderPhase>();
 
@@ -74,6 +75,7 @@ public class BrokerStoreUpgraderAndRecov
             if (record.getType().equals("Broker"))
             {
                 record = upgradeRootRecord(record);
+                record = createVirtualHostsRecordsFromBrokerRecordForModel_1_x(record, this);
             }
             else if (record.getType().equals("VirtualHost") && record.getAttributes().containsKey("storeType"))
             {
@@ -107,6 +109,7 @@ public class BrokerStoreUpgraderAndRecov
             if (record.getType().equals("Broker"))
             {
                 record = upgradeRootRecord(record);
+                record = createVirtualHostsRecordsFromBrokerRecordForModel_1_x(record, this);
             }
 
             getNextUpgrader().configuredObject(record);
@@ -150,6 +153,7 @@ public class BrokerStoreUpgraderAndRecov
             else if (record.getType().equals("Broker"))
             {
                 record = upgradeRootRecord(record);
+                record = createVirtualHostsRecordsFromBrokerRecordForModel_1_x(record, this);
             }
 
             getNextUpgrader().configuredObject(record);
@@ -199,6 +203,7 @@ public class BrokerStoreUpgraderAndRecov
             else if (record.getType().equals("Broker"))
             {
                 record = upgradeRootRecord(record);
+                record = createVirtualHostsRecordsFromBrokerRecordForModel_1_x(record, this);
             }
 
             getNextUpgrader().configuredObject(record);
@@ -544,6 +549,61 @@ public class BrokerStoreUpgraderAndRecov
         }
     }
 
+    private static ConfiguredObjectRecord createVirtualHostsRecordsFromBrokerRecordForModel_1_x(ConfiguredObjectRecord brokerRecord, StoreUpgraderPhase upgrader)
+    {
+        Map<String, Object> attributes = brokerRecord.getAttributes();
+        if (attributes.containsKey(VIRTUALHOSTS) && attributes.get(VIRTUALHOSTS) instanceof Collection)
+        {
+            Collection<?> virtualHosts = (Collection<?>)attributes.get(VIRTUALHOSTS);
+            for (Object virtualHost: virtualHosts)
+            {
+                if (virtualHost instanceof Map)
+                {
+                    Map<String, Object> virtualHostAttributes = (Map)virtualHost;
+                    if (virtualHostAttributes.containsKey("configPath"))
+                    {
+                        throw new IllegalConfigurationException("Auto-upgrade of virtual host " + attributes.get("name")
+                                + " having XML configuration is not supported. Virtual host configuration file is " + attributes.get("configPath"));
+                    }
+
+                    virtualHostAttributes = new HashMap<>(virtualHostAttributes);
+                    Object nameAttribute = virtualHostAttributes.get("name");
+                    Object idAttribute = virtualHostAttributes.remove("id");
+                    UUID id;
+                    if (idAttribute == null)
+                    {
+                        id = UUID.randomUUID();
+                    }
+                    else
+                    {
+                        if (idAttribute instanceof String)
+                        {
+                            id = UUID.fromString((String)idAttribute);
+                        }
+                        else if (idAttribute instanceof UUID)
+                        {
+                            id = (UUID)idAttribute;
+                        }
+                        else
+                        {
+                            throw new IllegalConfigurationException("Illegal ID value '" + idAttribute + "' for virtual host " + nameAttribute);
+                        }
+                    }
+
+                    ConfiguredObjectRecord nodeRecord = new ConfiguredObjectRecordImpl(id, "VirtualHost", virtualHostAttributes, Collections.singletonMap("Broker", brokerRecord.getId()));
+
+                    upgrader.getUpdateMap().put(nodeRecord.getId(), nodeRecord);
+                    upgrader.configuredObject(nodeRecord);
+                }
+            }
+            attributes = new HashMap<>(attributes);
+            attributes.remove(VIRTUALHOSTS);
+            brokerRecord = new ConfiguredObjectRecordImpl(brokerRecord.getId(), brokerRecord.getType(), attributes, brokerRecord.getParents());
+            upgrader.getUpdateMap().put(brokerRecord.getId(), brokerRecord);
+        }
+        return brokerRecord;
+    }
+
     public Broker<?> perform(final DurableConfigurationStore store)
     {
         List<ConfiguredObjectRecord> upgradedRecords = upgrade(store);

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java?rev=1635520&r1=1635519&r2=1635520&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java Thu Oct 30 15:01:58 2014
@@ -21,7 +21,9 @@
 package org.apache.qpid.server.store;
 
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -32,6 +34,7 @@ import org.apache.qpid.server.BrokerOpti
 import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor;
 import org.apache.qpid.server.logging.EventLogger;
 import org.apache.qpid.server.logging.LogRecorder;
+import org.apache.qpid.server.model.BrokerModel;
 import org.apache.qpid.server.model.BrokerShutdownProvider;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.JsonSystemConfigImpl;
@@ -42,20 +45,37 @@ import org.apache.qpid.test.utils.QpidTe
 
 public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
 {
+    private static final long BROKER_CREATE_TIME = 1401385808828l;
+    private static final String BROKER_NAME = "Broker";
+    private static final String VIRTUALHOST_NAME = "test";
+    private static final long VIRTUALHOST_CREATE_TIME = 1401385905260l;
+    private static final String VIRTUALHOST_CREATED_BY = "webadmin";
+
     private ConfiguredObjectRecord _brokerRecord;
     private CurrentThreadTaskExecutor _taskExecutor;
     private SystemConfig<?> _systemConfig;
+    private List<Map<String, Object>> _virtaulHosts;
+    private UUID _hostId;
+    private UUID _brokerId;
 
     public void setUp() throws Exception
     {
         super.setUp();
+        _virtaulHosts = new ArrayList<>();
+        _hostId = UUID.randomUUID();
+        _brokerId = UUID.randomUUID();
         Map<String, Object> brokerAttributes = new HashMap<>();
-        brokerAttributes.put("createdTime", 1401385808828l);
-        brokerAttributes.put("defaultVirtualHost", "test");
+        brokerAttributes.put("createdTime", BROKER_CREATE_TIME);
+        brokerAttributes.put("defaultVirtualHost", VIRTUALHOST_NAME);
         brokerAttributes.put("modelVersion", "1.3");
-        brokerAttributes.put("name", "Broker");
+        brokerAttributes.put("name", BROKER_NAME);
+        brokerAttributes.put("virtualhosts", _virtaulHosts);
+
+        _brokerRecord = mock(ConfiguredObjectRecord.class);
+        when(_brokerRecord.getId()).thenReturn(_brokerId);
+        when(_brokerRecord.getType()).thenReturn("Broker");
+        when(_brokerRecord.getAttributes()).thenReturn(brokerAttributes);
 
-        _brokerRecord = new ConfiguredObjectRecordImpl(UUID.randomUUID(), "Broker", brokerAttributes);
         _taskExecutor = new CurrentThreadTaskExecutor();
         _taskExecutor.start();
         _systemConfig = new JsonSystemConfigImpl(_taskExecutor,
@@ -68,12 +88,12 @@ public class BrokerStoreUpgraderAndRecov
     public void testUpgradeVirtualHostWithJDBCStoreAndBoneCPPool()
     {
         Map<String, Object> hostAttributes = new HashMap<>();
-        hostAttributes.put("name", "test");
+        hostAttributes.put("name", VIRTUALHOST_NAME);
         hostAttributes.put("modelVersion", "0.4");
         hostAttributes.put("connectionPool", "BONECP");
         hostAttributes.put("connectionURL", "jdbc:derby://localhost:1527/tmp/vh/test;create=true");
-        hostAttributes.put("createdBy", "webadmin");
-        hostAttributes.put("createdTime", 1401385905260l);
+        hostAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        hostAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
         hostAttributes.put("maxConnectionsPerPartition", 7);
         hostAttributes.put("minConnectionsPerPartition", 6);
         hostAttributes.put("partitionCount", 2);
@@ -97,9 +117,9 @@ public class BrokerStoreUpgraderAndRecov
         Map<String,Object> expectedAttributes = new HashMap<>();
         expectedAttributes.put("connectionPoolType", "BONECP");
         expectedAttributes.put("connectionUrl", "jdbc:derby://localhost:1527/tmp/vh/test;create=true");
-        expectedAttributes.put("createdBy", "webadmin");
-        expectedAttributes.put("createdTime", 1401385905260l);
-        expectedAttributes.put("name", "test");
+        expectedAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        expectedAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
+        expectedAttributes.put("name", VIRTUALHOST_NAME);
         expectedAttributes.put("type", "JDBC");
 
         final Map<String, Object> context = new HashMap<>();
@@ -114,17 +134,18 @@ public class BrokerStoreUpgraderAndRecov
         expectedAttributes.put("context", context);
 
         assertEquals("Unexpected attributes", expectedAttributes, upgradedVirtualHostNodeRecord.getAttributes());
+        assertBrokerRecord(records);
     }
 
     public void testUpgradeVirtualHostWithJDBCStoreAndDefaultPool()
     {
         Map<String, Object> hostAttributes = new HashMap<>();
-        hostAttributes.put("name", "test");
+        hostAttributes.put("name", VIRTUALHOST_NAME);
         hostAttributes.put("modelVersion", "0.4");
         hostAttributes.put("connectionPool", "DEFAULT");
         hostAttributes.put("connectionURL", "jdbc:derby://localhost:1527/tmp/vh/test;create=true");
-        hostAttributes.put("createdBy", "webadmin");
-        hostAttributes.put("createdTime", 1401385905260l);
+        hostAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        hostAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
         hostAttributes.put("storeType", "jdbc");
         hostAttributes.put("type", "STANDARD");
         hostAttributes.put("jdbcBigIntType", "mybigint");
@@ -145,9 +166,9 @@ public class BrokerStoreUpgraderAndRecov
         Map<String,Object> expectedAttributes = new HashMap<>();
         expectedAttributes.put("connectionPoolType", "NONE");
         expectedAttributes.put("connectionUrl", "jdbc:derby://localhost:1527/tmp/vh/test;create=true");
-        expectedAttributes.put("createdBy", "webadmin");
-        expectedAttributes.put("createdTime", 1401385905260l);
-        expectedAttributes.put("name", "test");
+        expectedAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        expectedAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
+        expectedAttributes.put("name", VIRTUALHOST_NAME);
         expectedAttributes.put("type", "JDBC");
 
         final Map<String, Object> context = new HashMap<>();
@@ -159,17 +180,18 @@ public class BrokerStoreUpgraderAndRecov
         expectedAttributes.put("context", context);
 
         assertEquals("Unexpected attributes", expectedAttributes, upgradedVirtualHostNodeRecord.getAttributes());
+        assertBrokerRecord(records);
     }
 
     public void testUpgradeVirtualHostWithDerbyStore()
     {
         Map<String, Object> hostAttributes = new HashMap<>();
-        hostAttributes.put("name", "test");
+        hostAttributes.put("name", VIRTUALHOST_NAME);
         hostAttributes.put("modelVersion", "0.4");
         hostAttributes.put("storePath", "/tmp/vh/derby");
         hostAttributes.put("storeType", "derby");
-        hostAttributes.put("createdBy", "webadmin");
-        hostAttributes.put("createdTime", 1401385905260l);
+        hostAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        hostAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
         hostAttributes.put("type", "STANDARD");
 
         ConfiguredObjectRecord virtualHostRecord = new ConfiguredObjectRecordImpl(UUID.randomUUID(), "VirtualHost",
@@ -183,22 +205,23 @@ public class BrokerStoreUpgraderAndRecov
         assertEquals("Unexpected type", "VirtualHostNode", upgradedVirtualHostNodeRecord.getType());
         Map<String,Object> expectedAttributes = new HashMap<>();
         expectedAttributes.put("storePath", "/tmp/vh/derby");
-        expectedAttributes.put("createdBy", "webadmin");
-        expectedAttributes.put("createdTime", 1401385905260l);
-        expectedAttributes.put("name", "test");
+        expectedAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        expectedAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
+        expectedAttributes.put("name", VIRTUALHOST_NAME);
         expectedAttributes.put("type", "DERBY");
         assertEquals("Unexpected attributes", expectedAttributes, upgradedVirtualHostNodeRecord.getAttributes());
+        assertBrokerRecord(records);
     }
 
     public void testUpgradeVirtualHostWithBDBStore()
     {
         Map<String, Object> hostAttributes = new HashMap<>();
-        hostAttributes.put("name", "test");
+        hostAttributes.put("name", VIRTUALHOST_NAME);
         hostAttributes.put("modelVersion", "0.4");
         hostAttributes.put("storePath", "/tmp/vh/bdb");
         hostAttributes.put("storeType", "bdb");
-        hostAttributes.put("createdBy", "webadmin");
-        hostAttributes.put("createdTime", 1401385905260l);
+        hostAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        hostAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
         hostAttributes.put("type", "STANDARD");
         hostAttributes.put("bdbEnvironmentConfig", Collections.singletonMap("je.stats.collect", "false"));
 
@@ -214,21 +237,22 @@ public class BrokerStoreUpgraderAndRecov
         assertEquals("Unexpected type", "VirtualHostNode", upgradedVirtualHostNodeRecord.getType());
         Map<String,Object> expectedAttributes = new HashMap<>();
         expectedAttributes.put("storePath", "/tmp/vh/bdb");
-        expectedAttributes.put("createdBy", "webadmin");
-        expectedAttributes.put("createdTime", 1401385905260l);
-        expectedAttributes.put("name", "test");
+        expectedAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        expectedAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
+        expectedAttributes.put("name", VIRTUALHOST_NAME);
         expectedAttributes.put("type", "BDB");
         expectedAttributes.put("context", Collections.singletonMap("je.stats.collect", "false"));
         assertEquals("Unexpected attributes", expectedAttributes, upgradedVirtualHostNodeRecord.getAttributes());
+        assertBrokerRecord(records);
     }
 
     public void testUpgradeVirtualHostWithBDBHAStore()
     {
         Map<String, Object> hostAttributes = new HashMap<>();
-        hostAttributes.put("name", "test");
+        hostAttributes.put("name", VIRTUALHOST_NAME);
         hostAttributes.put("modelVersion", "0.4");
-        hostAttributes.put("createdBy", "webadmin");
-        hostAttributes.put("createdTime", 1401385905260l);
+        hostAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        hostAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
         hostAttributes.put("type", "BDB_HA");
         hostAttributes.put("storePath", "/tmp/vh/bdbha");
         hostAttributes.put("haCoalescingSync", "true");
@@ -255,8 +279,8 @@ public class BrokerStoreUpgraderAndRecov
         expectedContext.put("je.rep.feederTimeout", "1 m");
 
         Map<String,Object> expectedAttributes = new HashMap<>();
-        expectedAttributes.put("createdBy", "webadmin");
-        expectedAttributes.put("createdTime", 1401385905260l);
+        expectedAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        expectedAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
         expectedAttributes.put("type", "BDB_HA");
         expectedAttributes.put("storePath", "/tmp/vh/bdbha");
         expectedAttributes.put("designatedPrimary", "true");
@@ -267,16 +291,17 @@ public class BrokerStoreUpgraderAndRecov
         expectedAttributes.put("context", expectedContext);
 
         assertEquals("Unexpected attributes", expectedAttributes, upgradedVirtualHostNodeRecord.getAttributes());
+        assertBrokerRecord(records);
     }
 
     public void testUpgradeVirtualHostWithMemoryStore()
     {
         Map<String, Object> hostAttributes = new HashMap<>();
-        hostAttributes.put("name", "test");
+        hostAttributes.put("name", VIRTUALHOST_NAME);
         hostAttributes.put("modelVersion", "0.4");
         hostAttributes.put("storeType", "memory");
-        hostAttributes.put("createdBy", "webadmin");
-        hostAttributes.put("createdTime", 1401385905260l);
+        hostAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        hostAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
         hostAttributes.put("type", "STANDARD");
 
         ConfiguredObjectRecord virtualHostRecord = new ConfiguredObjectRecordImpl(UUID.randomUUID(), "VirtualHost",
@@ -289,13 +314,115 @@ public class BrokerStoreUpgraderAndRecov
         ConfiguredObjectRecord upgradedVirtualHostNodeRecord = findRecordById(virtualHostRecord.getId(), records);
         assertEquals("Unexpected type", "VirtualHostNode", upgradedVirtualHostNodeRecord.getType());
         Map<String,Object> expectedAttributes = new HashMap<>();
-        expectedAttributes.put("createdBy", "webadmin");
-        expectedAttributes.put("createdTime", 1401385905260l);
-        expectedAttributes.put("name", "test");
+        expectedAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        expectedAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
+        expectedAttributes.put("name", VIRTUALHOST_NAME);
+        expectedAttributes.put("type", "Memory");
+        assertEquals("Unexpected attributes", expectedAttributes, upgradedVirtualHostNodeRecord.getAttributes());
+        assertBrokerRecord(records);
+    }
+
+    public void testUpgradeBrokerRecordWithModelVersion1_0()
+    {
+        _brokerRecord.getAttributes().put("modelVersion", "1.0");
+        _brokerRecord.getAttributes().put("virtualhosts", _virtaulHosts);
+        Map<String, Object> hostAttributes = new HashMap<>();
+        hostAttributes.put("name", VIRTUALHOST_NAME);
+        hostAttributes.put("modelVersion", "0.1");
+        hostAttributes.put("storeType", "memory");
+        hostAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        hostAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
+        hostAttributes.put("id", _hostId);
+        _virtaulHosts.add(hostAttributes);
+
+
+        upgradeBrokerRecordAndAssertUpgradeResults();
+    }
+
+    public void testUpgradeBrokerRecordWithModelVersion1_1()
+    {
+        _brokerRecord.getAttributes().put("modelVersion", "1.1");
+        _brokerRecord.getAttributes().put("virtualhosts", _virtaulHosts);
+        Map<String, Object> hostAttributes = new HashMap<>();
+        hostAttributes.put("name", VIRTUALHOST_NAME);
+        hostAttributes.put("modelVersion", "0.2");
+        hostAttributes.put("storeType", "memory");
+        hostAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        hostAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
+        hostAttributes.put("type", "STANDARD");
+        hostAttributes.put("id", _hostId);
+        _virtaulHosts.add(hostAttributes);
+
+        upgradeBrokerRecordAndAssertUpgradeResults();
+    }
+
+    public void testUpgradeBrokerRecordWithModelVersion1_2()
+    {
+        _brokerRecord.getAttributes().put("modelVersion", "1.2");
+        _brokerRecord.getAttributes().put("virtualhosts", _virtaulHosts);
+        Map<String, Object> hostAttributes = new HashMap<>();
+        hostAttributes.put("name", VIRTUALHOST_NAME);
+        hostAttributes.put("modelVersion", "0.3");
+        hostAttributes.put("storeType", "memory");
+        hostAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        hostAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
+        hostAttributes.put("type", "STANDARD");
+        hostAttributes.put("id", _hostId);
+        _virtaulHosts.add(hostAttributes);
+
+        upgradeBrokerRecordAndAssertUpgradeResults();
+    }
+
+    public void testUpgradeBrokerRecordWithModelVersion1_3()
+    {
+        _brokerRecord.getAttributes().put("modelVersion", "1.3");
+        _brokerRecord.getAttributes().put("virtualhosts", _virtaulHosts);
+        Map<String, Object> hostAttributes = new HashMap<>();
+        hostAttributes.put("name", VIRTUALHOST_NAME);
+        hostAttributes.put("modelVersion", "0.4");
+        hostAttributes.put("storeType", "memory");
+        hostAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        hostAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
+        hostAttributes.put("type", "STANDARD");
+        hostAttributes.put("id", _hostId);
+        _virtaulHosts.add(hostAttributes);
+
+        upgradeBrokerRecordAndAssertUpgradeResults();
+    }
+
+    private void upgradeBrokerRecordAndAssertUpgradeResults()
+    {
+        DurableConfigurationStore dcs = new DurableConfigurationStoreStub(_brokerRecord);
+        List<ConfiguredObjectRecord> records = new BrokerStoreUpgraderAndRecoverer(_systemConfig).upgrade(dcs);
+
+        assertVirtualHost(records);
+        assertBrokerRecord(records);
+    }
+
+    private void assertVirtualHost(List<ConfiguredObjectRecord> records)
+    {
+        ConfiguredObjectRecord upgradedVirtualHostNodeRecord = findRecordById(_hostId, records);
+        assertEquals("Unexpected type", "VirtualHostNode", upgradedVirtualHostNodeRecord.getType());
+        Map<String,Object> expectedAttributes = new HashMap<>();
+        expectedAttributes.put("createdBy", VIRTUALHOST_CREATED_BY);
+        expectedAttributes.put("createdTime", VIRTUALHOST_CREATE_TIME);
+        expectedAttributes.put("name", VIRTUALHOST_NAME);
         expectedAttributes.put("type", "Memory");
         assertEquals("Unexpected attributes", expectedAttributes, upgradedVirtualHostNodeRecord.getAttributes());
     }
 
+    private void assertBrokerRecord(List<ConfiguredObjectRecord> records)
+    {
+        ConfiguredObjectRecord upgradedBrokerRecord = findRecordById(_brokerId, records);
+        assertEquals("Unexpected type", "Broker", upgradedBrokerRecord.getType());
+        Map<String,Object> expectedAttributes = new HashMap<>();
+        expectedAttributes.put("defaultVirtualHost", "test");
+        expectedAttributes.put("name", "Broker");
+        expectedAttributes.put("modelVersion", BrokerModel.MODEL_VERSION);
+        expectedAttributes.put("createdTime", 1401385808828l);
+        assertEquals("Unexpected broker attributes", expectedAttributes, upgradedBrokerRecord.getAttributes());
+    }
+
     private ConfiguredObjectRecord findRecordById(UUID id, List<ConfiguredObjectRecord> records)
     {
         for (ConfiguredObjectRecord configuredObjectRecord : records)



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