summaryrefslogtreecommitdiff
path: root/qpid/java/broker-core/src/test/java/org/apache/qpid/server
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/broker-core/src/test/java/org/apache/qpid/server')
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java72
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategory.java10
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java19
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java9
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java2
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/ConfiguredObjectRecordConverterTest.java142
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java99
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java6
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java14
9 files changed, 339 insertions, 34 deletions
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java
index e147abd170..e5c5a89c10 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java
@@ -26,6 +26,7 @@ import java.util.Map;
import junit.framework.TestCase;
+import org.apache.qpid.server.model.testmodel.TestChildCategory;
import org.apache.qpid.server.model.testmodel.TestModel;
import org.apache.qpid.server.model.testmodel.TestRootCategory;
import org.apache.qpid.server.store.ConfiguredObjectRecord;
@@ -187,4 +188,73 @@ public class AbstractConfiguredObjectTest extends TestCase
assertEquals("myValue", object1.getStringValue());
}
-} \ No newline at end of file
+ public void testCreationOfObjectWithInvalidInterpolatedValues()
+ {
+ final String parentName = "parent";
+ TestRootCategory parent =
+ _model.getObjectFactory().create(TestRootCategory.class,
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME,
+ parentName)
+ );
+
+ parent.setAttributes(Collections.singletonMap(ConfiguredObject.CONTEXT,
+ Collections.singletonMap("contextVal", "foo")));
+
+ final Map<String, Object> attributes = new HashMap<>();
+ attributes.put("intValue", "${contextVal}");
+ attributes.put("name", "child");
+ attributes.put("integerSet", "[ ]");
+ attributes.put(ConfiguredObject.TYPE, "test");
+
+ try
+ {
+ _model.getObjectFactory().create(TestChildCategory.class, attributes, parent);
+ fail("creation of child object should have failed due to invalid value");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // PASS
+ String message = e.getMessage();
+ assertTrue("Message does not contain the attribute name", message.contains("intValue"));
+ assertTrue("Message does not contain the non-interpolated value", message.contains("contextVal"));
+ assertTrue("Message does not contain the interpolated value", message.contains("foo"));
+
+ }
+
+ assertTrue("Child should not have been registered with parent",
+ parent.getChildren(TestChildCategory.class).isEmpty());
+ }
+
+ public void testCreationOfObjectWithInvalidDefaultValues()
+ {
+ final String parentName = "parent";
+ TestRootCategory parent =
+ _model.getObjectFactory().create(TestRootCategory.class,
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME,
+ parentName)
+ );
+
+ final Map<String, Object> attributes = new HashMap<>();
+ attributes.put("intValue", "1");
+ attributes.put("name", "child");
+ attributes.put(ConfiguredObject.TYPE, "test");
+
+ try
+ {
+ _model.getObjectFactory().create(TestChildCategory.class, attributes, parent);
+ fail("creation of child object should have failed due to invalid value");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // PASS
+ String message = e.getMessage();
+ assertTrue("Message does not contain the attribute name", message.contains("integerSet"));
+ assertTrue("Message does not contain the error value", message.contains("foo"));
+
+ }
+
+ assertTrue("Child should not have been registered with parent",
+ parent.getChildren(TestChildCategory.class).isEmpty());
+ }
+
+}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategory.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategory.java
index 0c8dcc8744..d3fe14b7d8 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategory.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategory.java
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.server.model.testmodel;
+import java.util.Set;
+
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.ManagedAttribute;
import org.apache.qpid.server.model.ManagedObject;
@@ -30,6 +32,12 @@ public interface TestChildCategory<X extends TestChildCategory<X>> extends Confi
String NON_INTERPOLATED_VALID_VALUE = "${file.separator}";
- @ManagedAttribute(validValues = { NON_INTERPOLATED_VALID_VALUE })
+ @ManagedAttribute(validValues = { NON_INTERPOLATED_VALID_VALUE }, defaultValue = "")
String getValidValueNotInterpolated();
+
+ @ManagedAttribute( defaultValue = "3" )
+ int getIntValue();
+
+ @ManagedAttribute( defaultValue = "[ \"1\", \"2\", \"foo\" ]" )
+ Set<Integer> getIntegerSet();
}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java
index b5a4182f79..080a352f11 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.model.testmodel;
import java.util.Map;
+import java.util.Set;
import org.apache.qpid.server.model.AbstractConfiguredObject;
import org.apache.qpid.server.model.ManagedAttributeField;
@@ -37,6 +38,12 @@ public class TestChildCategoryImpl
@ManagedAttributeField
private String _validValueNotInterpolated;
+ @ManagedAttributeField
+ private int _intValue;
+
+ @ManagedAttributeField
+ private Set<Integer> _integerSet;
+
@ManagedObjectFactoryConstructor
public TestChildCategoryImpl(final Map<String, Object> attributes, TestRootCategory<?> parent)
@@ -57,4 +64,16 @@ public class TestChildCategoryImpl
{
return _validValueNotInterpolated;
}
+
+ @Override
+ public int getIntValue()
+ {
+ return _intValue;
+ }
+
+ @Override
+ public Set<Integer> getIntegerSet()
+ {
+ return _integerSet;
+ }
}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java
index 56283b1392..6001ed1750 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java
@@ -36,7 +36,6 @@ import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.BrokerModel;
import org.apache.qpid.server.model.ConfiguredObjectFactory;
import org.apache.qpid.server.model.TrustStore;
-import org.apache.qpid.server.model.UnknownConfiguredObjectException;
import org.apache.qpid.server.util.BrokerTestHelper;
public class SimpleLDAPAuthenticationManagerFactoryTest extends TestCase
@@ -108,10 +107,12 @@ public class SimpleLDAPAuthenticationManagerFactoryTest extends TestCase
_factory.create(AuthenticationProvider.class, _configuration, _broker);
fail("Exception not thrown");
}
- catch(UnknownConfiguredObjectException e)
+ catch(IllegalArgumentException e)
{
- assertEquals(e.getCategory(), TrustStore.class);
- assertEquals(e.getName(), "notfound");
+ // PASS
+ assertTrue("Message does not include underlying issue", e.getMessage().contains("name 'notfound'"));
+ assertTrue("Message does not include the attribute name", e.getMessage().contains("trustStore"));
+ assertTrue("Message does not include the expected type", e.getMessage().contains("TrustStore"));
}
}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
index 6d84c7b602..dd8b4cf4dd 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
@@ -115,7 +115,7 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest
_configStore = createConfigStore();
_configStore.openConfigurationStore(_parent, false);
- _rootRecord = new ConfiguredObjectRecordImpl(UUID.randomUUID(), VirtualHost.class.getSimpleName(), Collections.<String, Object>emptyMap());
+ _rootRecord = new ConfiguredObjectRecordImpl(UUID.randomUUID(), VirtualHost.class.getSimpleName(), Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "vhost"));
_configStore.create(_rootRecord);
}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/ConfiguredObjectRecordConverterTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/ConfiguredObjectRecordConverterTest.java
new file mode 100644
index 0000000000..bef3cdcac9
--- /dev/null
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/ConfiguredObjectRecordConverterTest.java
@@ -0,0 +1,142 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.store;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.StringReader;
+import java.util.Collection;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.qpid.server.model.Binding;
+import org.apache.qpid.server.model.BrokerModel;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.Exchange;
+import org.apache.qpid.server.model.Queue;
+import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.VirtualHostNode;
+import org.apache.qpid.test.utils.QpidTestCase;
+
+public class ConfiguredObjectRecordConverterTest extends QpidTestCase
+{
+
+ public void testSecondParentReferencedByName() throws Exception
+ {
+
+ String jsonData = "{\n"
+ + " \"name\" : \"test\",\n"
+ + " \"exchanges\" : [ {\n"
+ + " \"name\" : \"amq.direct\",\n"
+ + " \"type\" : \"direct\"\n"
+ + " } ],\n"
+ + " \"queues\" : [ {\n"
+ + " \"name\" : \"foo\",\n"
+ + " \"bindings\" : [ {\n"
+ + " \"exchange\" : \"amq.direct\",\n"
+ + " \"name\" : \"foo\"\n"
+ + " } ]\n"
+ + " } ]\n"
+ + "} ";
+
+ ConfiguredObjectRecordConverter converter = new ConfiguredObjectRecordConverter(BrokerModel.getInstance());
+ ConfiguredObject parent = mock(ConfiguredObject.class);
+ when(parent.getId()).thenReturn(UUID.randomUUID());
+ when(parent.getCategoryClass()).thenReturn(VirtualHostNode.class);
+ Collection<ConfiguredObjectRecord> records =
+ converter.readFromJson(VirtualHost.class, parent, new StringReader(jsonData));
+
+ UUID exchangeId = null;
+ for (ConfiguredObjectRecord record : records)
+ {
+ if (record.getType().equals(Exchange.class.getSimpleName()))
+ {
+ assertNull("Only one exchange record expected", exchangeId);
+ exchangeId = record.getId();
+ }
+ }
+ assertNotNull("No exchange record found", exchangeId);
+
+ UUID queueId = null;
+ for (ConfiguredObjectRecord record : records)
+ {
+ if (record.getType().equals(Queue.class.getSimpleName()))
+ {
+ assertNull("Only one queue record expected", queueId);
+ queueId = record.getId();
+ }
+ }
+ assertNotNull("No queueId record found", queueId);
+
+ boolean bindingFound = false;
+ for (ConfiguredObjectRecord record : records)
+ {
+ if (record.getType().equals(Binding.class.getSimpleName()))
+ {
+ assertFalse("Expecting only one binding", bindingFound);
+ bindingFound = true;
+ Map<String,UUID> parents = record.getParents();
+ assertEquals("Two parents expected", 2, parents.size());
+ assertEquals("Queue parent id not as expected", queueId, parents.get(Queue.class.getSimpleName()));
+ assertEquals("Exchange parent id not as expected", exchangeId, parents.get(Exchange.class.getSimpleName()));
+
+ }
+ }
+ assertTrue("No binding found", bindingFound);
+ }
+
+ public void testUnresolvedSecondParentFailsToCovert() throws Exception
+ {
+ {
+
+ String jsonData = "{\n"
+ + " \"name\" : \"test\",\n"
+ + " \"exchanges\" : [ {\n"
+ + " \"name\" : \"amq.direct\",\n"
+ + " \"type\" : \"direct\"\n"
+ + " } ],\n"
+ + " \"queues\" : [ {\n"
+ + " \"name\" : \"foo\",\n"
+ + " \"bindings\" : [ {\n"
+ + " \"exchange\" : \"amq.topic\",\n"
+ + " \"name\" : \"foo\"\n"
+ + " } ]\n"
+ + " } ]\n"
+ + "} ";
+
+ ConfiguredObjectRecordConverter converter = new ConfiguredObjectRecordConverter(BrokerModel.getInstance());
+ ConfiguredObject parent = mock(ConfiguredObject.class);
+ when(parent.getId()).thenReturn(UUID.randomUUID());
+ when(parent.getCategoryClass()).thenReturn(VirtualHostNode.class);
+ try
+ {
+ converter.readFromJson(VirtualHost.class, parent, new StringReader(jsonData));
+ fail("The records should not be converted as there is an unresolved reference");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // pass
+ }
+
+ }
+ }
+}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
index ee8f6497bc..b652992021 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
@@ -38,6 +38,7 @@ import org.mockito.ArgumentMatcher;
import org.mockito.InOrder;
import org.apache.qpid.server.model.BrokerModel;
+import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.ConfiguredObjectFactory;
import org.apache.qpid.server.model.ConfiguredObjectFactoryImpl;
import org.apache.qpid.server.model.Queue;
@@ -248,10 +249,14 @@ public class JsonFileConfigStoreTest extends QpidTestCase
createRootRecord();
final UUID id = UUID.randomUUID();
- _store.create(new ConfiguredObjectRecordImpl(id, "Queue", Collections.<String, Object>emptyMap(), getRootAsParentMap()));
+ _store.create(new ConfiguredObjectRecordImpl(id, "Queue",
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "queue"),
+ getRootAsParentMap()));
try
{
- _store.create(new ConfiguredObjectRecordImpl(id, "Exchange", Collections.<String, Object>emptyMap(), getRootAsParentMap()));
+ _store.create(new ConfiguredObjectRecordImpl(id, "Exchange",
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "exchange"),
+ getRootAsParentMap()));
fail("Should not be able to create two objects with same id");
}
catch (StoreException e)
@@ -261,19 +266,61 @@ public class JsonFileConfigStoreTest extends QpidTestCase
}
+ public void testObjectWithoutName() throws Exception
+ {
+ _store.openConfigurationStore(_parent, false);
+ createRootRecord();
+
+ final UUID id = UUID.randomUUID();
+ try
+ {
+ _store.create(new ConfiguredObjectRecordImpl(id, "Exchange",
+ Collections.<String, Object>emptyMap(),
+ getRootAsParentMap()));
+ fail("Should not be able to create an object without a name");
+ }
+ catch (StoreException e)
+ {
+ // pass
+ }
+ }
+
+ public void testObjectWithNonStringName() throws Exception
+ {
+ _store.openConfigurationStore(_parent, false);
+ createRootRecord();
+
+ final UUID id = UUID.randomUUID();
+ try
+ {
+ _store.update(true, new ConfiguredObjectRecordImpl(id, "Exchange",
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME, 3),
+ getRootAsParentMap()));
+ fail("Should not be able to create an object without a name");
+ }
+ catch (StoreException e)
+ {
+ // pass
+ }
+ }
+
public void testChangeTypeOfObject() throws Exception
{
_store.openConfigurationStore(_parent, false);
createRootRecord();
final UUID id = UUID.randomUUID();
- _store.create(new ConfiguredObjectRecordImpl(id, "Queue", Collections.<String, Object>emptyMap(), getRootAsParentMap()));
+ _store.create(new ConfiguredObjectRecordImpl(id, "Queue",
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "queue"),
+ getRootAsParentMap()));
_store.closeConfigurationStore();
_store.openConfigurationStore(_parent, false);
try
{
- _store.update(false, new ConfiguredObjectRecordImpl(id, "Exchange", Collections.<String, Object>emptyMap(), getRootAsParentMap()));
+ _store.update(false, new ConfiguredObjectRecordImpl(id, "Exchange",
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "exchange"),
+ getRootAsParentMap()));
fail("Should not be able to update object to different type");
}
catch (StoreException e)
@@ -329,40 +376,57 @@ public class JsonFileConfigStoreTest extends QpidTestCase
final UUID queueId = new UUID(0, 1);
final UUID queue2Id = new UUID(1, 1);
- final Map<String, Object> EMPTY_ATTR = Collections.emptyMap();
final UUID exchangeId = new UUID(0, 2);
final UUID bindingId = new UUID(0, 3);
final UUID binding2Id = new UUID(1, 3);
Map<String, UUID> parents = getRootAsParentMap();
- final ConfiguredObjectRecordImpl queueRecord = new ConfiguredObjectRecordImpl(queueId, "Queue", EMPTY_ATTR, parents);
+ Map<String, Object> queueAttr = Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "queue");
+ final ConfiguredObjectRecordImpl queueRecord =
+ new ConfiguredObjectRecordImpl(queueId, "Queue",
+ queueAttr,
+ parents);
_store.create(queueRecord);
- final ConfiguredObjectRecordImpl queue2Record = new ConfiguredObjectRecordImpl(queue2Id, "Queue", EMPTY_ATTR, parents);
+ Map<String, Object> queue2Attr = Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "queue2");
+ final ConfiguredObjectRecordImpl queue2Record =
+ new ConfiguredObjectRecordImpl(queue2Id, "Queue",
+ queue2Attr,
+ parents);
_store.create(queue2Record);
- final ConfiguredObjectRecordImpl exchangeRecord = new ConfiguredObjectRecordImpl(exchangeId, "Exchange", EMPTY_ATTR, parents);
+ Map<String, Object> exchangeAttr = Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "exchange");
+ final ConfiguredObjectRecordImpl exchangeRecord =
+ new ConfiguredObjectRecordImpl(exchangeId, "Exchange",
+ exchangeAttr,
+ parents);
_store.create(exchangeRecord);
Map<String,UUID> bindingParents = new HashMap();
bindingParents.put("Exchange", exchangeRecord.getId());
bindingParents.put("Queue", queueRecord.getId());
+ Map<String, Object> bindingAttr = Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "binding");
final ConfiguredObjectRecordImpl bindingRecord =
- new ConfiguredObjectRecordImpl(bindingId, "Binding", EMPTY_ATTR, bindingParents);
+ new ConfiguredObjectRecordImpl(bindingId, "Binding",
+ bindingAttr,
+ bindingParents);
Map<String,UUID> binding2Parents = new HashMap();
binding2Parents.put("Exchange", exchangeRecord.getId());
binding2Parents.put("Queue", queue2Record.getId());
+ Map<String, Object> binding2Attr = Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "binding2");
final ConfiguredObjectRecordImpl binding2Record =
- new ConfiguredObjectRecordImpl(binding2Id, "Binding", EMPTY_ATTR, binding2Parents);
+ new ConfiguredObjectRecordImpl(binding2Id, "Binding",
+ binding2Attr,
+ binding2Parents);
_store.update(true, bindingRecord, binding2Record);
_store.closeConfigurationStore();
_store.openConfigurationStore(_parent, false);
_store.visitConfiguredObjectRecords(_handler);
- verify(_handler).handle(matchesRecord(queueId, "Queue", EMPTY_ATTR));
- verify(_handler).handle(matchesRecord(queue2Id, "Queue", EMPTY_ATTR));
- verify(_handler).handle(matchesRecord(exchangeId, "Exchange", EMPTY_ATTR));
- verify(_handler).handle(matchesRecord(bindingId, "Binding", EMPTY_ATTR));
- verify(_handler).handle(matchesRecord(binding2Id, "Binding", EMPTY_ATTR));
+ verify(_handler).handle(matchesRecord(queueId, "Queue", queueAttr));
+ verify(_handler).handle(matchesRecord(queue2Id, "Queue", queue2Attr));
+ verify(_handler).handle(matchesRecord(exchangeId, "Exchange", exchangeAttr));
+ verify(_handler).handle(matchesRecord(bindingId, "Binding", bindingAttr));
+ verify(_handler).handle(matchesRecord(binding2Id, "Binding", binding2Attr));
_store.closeConfigurationStore();
}
@@ -371,7 +435,10 @@ public class JsonFileConfigStoreTest extends QpidTestCase
private void createRootRecord()
{
UUID rootRecordId = UUID.randomUUID();
- _rootRecord = new ConfiguredObjectRecordImpl(rootRecordId, VIRTUAL_HOST_TYPE, Collections.<String, Object>emptyMap());
+ _rootRecord =
+ new ConfiguredObjectRecordImpl(rootRecordId,
+ VIRTUAL_HOST_TYPE,
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "root"));
_store.create(_rootRecord);
}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java
index 9c8f4ed3ae..8573ae3a42 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java
@@ -22,6 +22,7 @@ package org.apache.qpid.server.util;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -90,6 +91,7 @@ public class BrokerTestHelper
when(broker.getSecurityManager()).thenReturn(new SecurityManager(broker, false));
when(broker.getObjectFactory()).thenReturn(objectFactory);
when(broker.getModel()).thenReturn(objectFactory.getModel());
+ when(broker.getModelVersion()).thenReturn(BrokerModel.MODEL_VERSION);
when(broker.getEventLogger()).thenReturn(eventLogger);
when(broker.getCategoryClass()).thenReturn(Broker.class);
when(broker.getParent(SystemConfig.class)).thenReturn(systemConfig);
@@ -117,9 +119,11 @@ public class BrokerTestHelper
VirtualHostNode virtualHostNode = mock(VirtualHostNode.class);
when(virtualHostNode.getTaskExecutor()).thenReturn(TASK_EXECUTOR);
+ when(virtualHostNode.getParent(eq(Broker.class))).thenReturn(broker);
+
DurableConfigurationStore dcs = mock(DurableConfigurationStore.class);
when(virtualHostNode.getConfigurationStore()).thenReturn(dcs);
- when(virtualHostNode.getParent(Broker.class)).thenReturn(broker);
+ when(virtualHostNode.getParent(eq(VirtualHostNode.class))).thenReturn(virtualHostNode);
when(virtualHostNode.getModel()).thenReturn(objectFactory.getModel());
when(virtualHostNode.getObjectFactory()).thenReturn(objectFactory);
when(virtualHostNode.getCategoryClass()).thenReturn(VirtualHostNode.class);
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java
index 19436627ce..971c96b2ff 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java
@@ -139,7 +139,7 @@ public class AbstractStandardVirtualHostNodeTest extends QpidTestCase
*/
public void testActivateVHNWithVHBlueprint_StoreHasNoVH() throws Exception
{
- DurableConfigurationStore configStore = configStoreThatProducesNoRecords();
+ DurableConfigurationStore configStore = new NullMessageStore() {};
String vhBlueprint = String.format("{ \"type\" : \"%s\", \"name\" : \"%s\"}",
TestMemoryVirtualHost.VIRTUAL_HOST_TYPE,
@@ -162,18 +162,12 @@ public class AbstractStandardVirtualHostNodeTest extends QpidTestCase
assertEquals("Unexpected virtual host state", State.ACTIVE, virtualHost.getState());
assertNotNull("Unexpected virtual host id", virtualHost.getId());
- Map<String, String> updatedContext = node.getContext();
-
- assertTrue("Context should now have utilised flag", updatedContext.containsKey(
- AbstractVirtualHostNode.VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR));
- assertEquals("Utilised flag should be true",
- Boolean.TRUE.toString(),
- updatedContext.get(AbstractVirtualHostNode.VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR));
+ assertEquals("Initial configuration should be empty", "{}", node.getVirtualHostInitialConfiguration());
}
/**
* Tests activating a virtualhostnode with blueprint context variable and the
- * marked utilised flag. Config store does not specify a virtualhost.
+ * but the virtualhostInitialConfiguration set to empty. Config store does not specify a virtualhost.
* Checks virtualhost is not recreated from the blueprint.
*/
public void testActivateVHNWithVHBlueprintUsed_StoreHasNoVH() throws Exception
@@ -185,12 +179,12 @@ public class AbstractStandardVirtualHostNodeTest extends QpidTestCase
TEST_VIRTUAL_HOST_NAME);
Map<String, String> context = new HashMap<>();
context.put(AbstractVirtualHostNode.VIRTUALHOST_BLUEPRINT_CONTEXT_VAR, vhBlueprint);
- context.put(AbstractVirtualHostNode.VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR, Boolean.TRUE.toString());
Map<String, Object> nodeAttributes = new HashMap<>();
nodeAttributes.put(VirtualHostNode.NAME, TEST_VIRTUAL_HOST_NODE_NAME);
nodeAttributes.put(VirtualHostNode.ID, _nodeId);
nodeAttributes.put(VirtualHostNode.CONTEXT, context);
+ nodeAttributes.put(VirtualHostNode.VIRTUALHOST_INITIAL_CONFIGURATION, "{}");
VirtualHostNode<?> node = new TestVirtualHostNode(_broker, nodeAttributes, configStore);
node.open();