Search in sources :

Example 21 with DurableConfigurationStore

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());
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) Test(org.junit.Test)

Example 22 with DurableConfigurationStore

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();
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) Test(org.junit.Test)

Example 23 with DurableConfigurationStore

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();
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) HashMap(java.util.HashMap) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) UUID(java.util.UUID) Test(org.junit.Test)

Example 24 with DurableConfigurationStore

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();
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) Test(org.junit.Test)

Example 25 with DurableConfigurationStore

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();
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) HashMap(java.util.HashMap) NullMessageStore(org.apache.qpid.server.store.NullMessageStore) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) Test(org.junit.Test)

Aggregations

DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)30 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)21 Test (org.junit.Test)18 HashMap (java.util.HashMap)14 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)5 ConfiguredObjectRecord (org.apache.qpid.server.store.ConfiguredObjectRecord)4 AccessControlException (java.security.AccessControlException)3 AccessControl (org.apache.qpid.server.security.AccessControl)3 PreferenceStore (org.apache.qpid.server.store.preferences.PreferenceStore)3 UUID (java.util.UUID)2 AbstractSystemConfig (org.apache.qpid.server.model.AbstractSystemConfig)2 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)2 TestMemoryVirtualHost (org.apache.qpid.server.virtualhost.TestMemoryVirtualHost)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 DatabaseException (com.sleepycat.je.DatabaseException)1 ReplicationGroupAdmin (com.sleepycat.je.rep.util.ReplicationGroupAdmin)1 File (java.io.File)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 ArrayList (java.util.ArrayList)1