use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNodeTest method testDeleteInErrorStateAfterOpen.
@Test
public void testDeleteInErrorStateAfterOpen() {
String nodeName = getTestName();
Map<String, Object> attributes = Collections.<String, Object>singletonMap(TestVirtualHostNode.NAME, nodeName);
final DurableConfigurationStore store = mock(DurableConfigurationStore.class);
doThrow(new RuntimeException("Cannot open store")).when(store).init(any(ConfiguredObject.class));
AbstractStandardVirtualHostNode node = createTestStandardVirtualHostNode(attributes, store);
node.open();
assertEquals("Unexpected node state", State.ERRORED, node.getState());
node.delete();
assertEquals("Unexpected state", State.DELETED, node.getState());
}
use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNodeTest method testOpenFails.
@Test
public void testOpenFails() throws Exception {
String nodeName = getTestName();
Map<String, Object> attributes = Collections.<String, Object>singletonMap(TestVirtualHostNode.NAME, nodeName);
DurableConfigurationStore store = mock(DurableConfigurationStore.class);
AbstractVirtualHostNode node = new TestAbstractVirtualHostNode(_broker, attributes, store);
node.open();
assertEquals("Unexpected node state", State.ERRORED, node.getState());
node.close();
}
use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNodeTest method testActivateVHNWithVHBlueprint_StoreHasExistingVH.
/**
* Tests activating a virtualhostnode with a blueprint context variable. Config store
* does specify a virtualhost. Checks that virtualhost is recovered from store and
* blueprint is ignored..
*/
@Test
public void testActivateVHNWithVHBlueprint_StoreHasExistingVH() throws Exception {
UUID virtualHostId = UUID.randomUUID();
ConfiguredObjectRecord record = createVirtualHostConfiguredObjectRecord(virtualHostId);
DurableConfigurationStore configStore = configStoreThatProduces(record);
String vhBlueprint = String.format("{ \"type\" : \"%s\", \"name\" : \"%s\"}", TestMemoryVirtualHost.VIRTUAL_HOST_TYPE, "vhFromBlueprint");
Map<String, String> context = Collections.singletonMap(AbstractVirtualHostNode.VIRTUALHOST_BLUEPRINT_CONTEXT_VAR, vhBlueprint);
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);
VirtualHostNode<?> node = new TestVirtualHostNode(_broker, nodeAttributes, configStore);
node.open();
node.start();
VirtualHost<?> virtualHost = node.getVirtualHost();
assertNotNull("Virtual host should be recovered", virtualHost);
assertEquals("Unexpected virtual host name", TEST_VIRTUAL_HOST_NAME, virtualHost.getName());
assertEquals("Unexpected virtual host state", State.ACTIVE, virtualHost.getState());
assertEquals("Unexpected virtual host id", virtualHostId, virtualHost.getId());
node.close();
}
use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNodeTest method testStartInErrorStateAfterOpen.
@Test
public void testStartInErrorStateAfterOpen() throws Exception {
String nodeName = getTestName();
Map<String, Object> attributes = Collections.<String, Object>singletonMap(TestVirtualHostNode.NAME, nodeName);
DurableConfigurationStore store = mock(DurableConfigurationStore.class);
doThrow(new RuntimeException("Cannot open store")).when(store).init(any(ConfiguredObject.class));
AbstractVirtualHostNode node = createTestStandardVirtualHostNode(attributes, store);
node.open();
assertEquals("Unexpected node state", State.ERRORED, node.getState());
doNothing().when(store).init(any(ConfiguredObject.class));
node.start();
assertEquals("Unexpected state", State.ACTIVE, node.getState());
node.close();
}
use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNodeTest method testActivateVHNWithVHBlueprint_StoreHasNoVH.
/**
* Tests activating a virtualhostnode with a blueprint context variable. Config store
* does not specify a virtualhost. Checks virtualhost is created from the blueprint.
*/
@Test
public void testActivateVHNWithVHBlueprint_StoreHasNoVH() throws Exception {
DurableConfigurationStore configStore = new NullMessageStore() {
};
String vhBlueprint = String.format("{ \"type\" : \"%s\", \"name\" : \"%s\"}", TestMemoryVirtualHost.VIRTUAL_HOST_TYPE, TEST_VIRTUAL_HOST_NAME);
Map<String, String> context = Collections.singletonMap(AbstractVirtualHostNode.VIRTUALHOST_BLUEPRINT_CONTEXT_VAR, vhBlueprint);
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);
VirtualHostNode<?> node = new TestVirtualHostNode(_broker, nodeAttributes, configStore);
node.open();
node.start();
VirtualHost<?> virtualHost = node.getVirtualHost();
assertNotNull("Virtual host should be created by blueprint", virtualHost);
assertEquals("Unexpected virtual host name", TEST_VIRTUAL_HOST_NAME, virtualHost.getName());
assertEquals("Unexpected virtual host state", State.ACTIVE, virtualHost.getState());
assertNotNull("Unexpected virtual host id", virtualHost.getId());
assertEquals("Initial configuration should be empty", "{}", node.getVirtualHostInitialConfiguration());
node.close();
}
Aggregations