use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNodeTest method testActivateInErrorStateAfterOpen.
@Test
public void testActivateInErrorStateAfterOpen() 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.setAttributes(Collections.<String, Object>singletonMap(VirtualHostNode.DESIRED_STATE, State.ACTIVE));
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 testOpenSucceeds.
@Test
public void testOpenSucceeds() throws Exception {
String nodeName = getTestName();
Map<String, Object> attributes = Collections.<String, Object>singletonMap(TestVirtualHostNode.NAME, nodeName);
final AtomicBoolean onFailureFlag = new AtomicBoolean();
DurableConfigurationStore store = mock(DurableConfigurationStore.class);
AbstractVirtualHostNode node = new TestAbstractVirtualHostNode(_broker, attributes, store) {
@Override
public void onValidate() {
// no op
}
@Override
protected void onExceptionInOpen(RuntimeException e) {
try {
super.onExceptionInOpen(e);
} finally {
onFailureFlag.set(true);
}
}
};
node.open();
assertEquals("Unexpected node state", State.ACTIVE, node.getState());
assertFalse("onExceptionInOpen was called", onFailureFlag.get());
node.close();
}
use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNodeTest method testActivateVHN_StoreHasNoVH.
/**
* Tests activating a virtualhostnode with a config store which does not specify
* a virtualhost. Checks no virtualhost is created.
*/
@Test
public void testActivateVHN_StoreHasNoVH() throws Exception {
DurableConfigurationStore configStore = configStoreThatProducesNoRecords();
Map<String, Object> nodeAttributes = new HashMap<>();
nodeAttributes.put(VirtualHostNode.NAME, TEST_VIRTUAL_HOST_NODE_NAME);
nodeAttributes.put(VirtualHostNode.ID, _nodeId);
VirtualHostNode<?> node = new TestVirtualHostNode(_broker, nodeAttributes, configStore);
node.open();
node.start();
VirtualHost<?> virtualHost = node.getVirtualHost();
assertNull("Virtual host should not be automatically created", virtualHost);
node.close();
}
use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNodeTest method testStopStartVHN.
@Test
public void testStopStartVHN() throws Exception {
DurableConfigurationStore configStore = configStoreThatProducesNoRecords();
Map<String, Object> nodeAttributes = new HashMap<>();
nodeAttributes.put(VirtualHostNode.NAME, TEST_VIRTUAL_HOST_NODE_NAME);
nodeAttributes.put(VirtualHostNode.ID, _nodeId);
VirtualHostNode<?> node = new TestVirtualHostNode(_broker, nodeAttributes, configStore);
node.open();
node.start();
assertEquals("Unexpected virtual host node state", State.ACTIVE, node.getState());
node.stop();
assertEquals("Unexpected virtual host node state after stop", State.STOPPED, node.getState());
node.start();
assertEquals("Unexpected virtual host node state after start", 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 testValidateOnCreateSucceeds.
@Test
public void testValidateOnCreateSucceeds() throws Exception {
String nodeName = getTestName();
Map<String, Object> attributes = Collections.<String, Object>singletonMap(TestVirtualHostNode.NAME, nodeName);
final DurableConfigurationStore store = mock(DurableConfigurationStore.class);
AbstractStandardVirtualHostNode node = createTestStandardVirtualHostNode(attributes, store);
node.create();
// once of validation, once for real
verify(store, times(2)).init(node);
verify(store, times(1)).closeConfigurationStore();
node.close();
}
Aggregations