Search in sources :

Example 1 with AbstractVirtualHost

use of org.apache.qpid.server.virtualhost.AbstractVirtualHost in project qpid-broker-j by apache.

the class BrokerTestHelper method createVirtualHost.

private static QueueManagingVirtualHost<?> createVirtualHost(final Map<String, Object> attributes, final Broker<?> broker, boolean defaultVHN, AccessControl accessControl) {
    ConfiguredObjectFactory objectFactory = broker.getObjectFactory();
    VirtualHostNode virtualHostNode = mockWithSystemPrincipalAndAccessControl(VirtualHostNode.class, SYSTEM_PRINCIPAL, accessControl);
    String virtualHostNodeName = String.format("%s_%s", attributes.get(VirtualHostNode.NAME), "_node");
    when(virtualHostNode.getName()).thenReturn(virtualHostNodeName);
    when(virtualHostNode.getTaskExecutor()).thenReturn(TASK_EXECUTOR);
    when(virtualHostNode.getChildExecutor()).thenReturn(TASK_EXECUTOR);
    when(virtualHostNode.isDefaultVirtualHostNode()).thenReturn(defaultVHN);
    when(virtualHostNode.getParent()).thenReturn(broker);
    Collection<VirtualHostNode<?>> nodes = broker.getVirtualHostNodes();
    nodes = new ArrayList<>(nodes != null ? nodes : Collections.<VirtualHostNode<?>>emptyList());
    nodes.add(virtualHostNode);
    when(broker.getVirtualHostNodes()).thenReturn(nodes);
    DurableConfigurationStore dcs = mock(DurableConfigurationStore.class);
    when(virtualHostNode.getConfigurationStore()).thenReturn(dcs);
    when(virtualHostNode.getModel()).thenReturn(objectFactory.getModel());
    when(virtualHostNode.getObjectFactory()).thenReturn(objectFactory);
    when(virtualHostNode.getCategoryClass()).thenReturn(VirtualHostNode.class);
    when(virtualHostNode.getTaskExecutor()).thenReturn(TASK_EXECUTOR);
    when(virtualHostNode.getChildExecutor()).thenReturn(TASK_EXECUTOR);
    when(virtualHostNode.createPreferenceStore()).thenReturn(mock(PreferenceStore.class));
    AbstractVirtualHost host = (AbstractVirtualHost) objectFactory.create(VirtualHost.class, attributes, virtualHostNode);
    host.start();
    when(virtualHostNode.getVirtualHost()).thenReturn(host);
    _createdVirtualHosts.add(host);
    QpidTestCase testCase = QpidTestCase.getCurrentInstance();
    testCase.registerTearDown(_closeVirtualHosts);
    return host;
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) AbstractVirtualHost(org.apache.qpid.server.virtualhost.AbstractVirtualHost) QpidTestCase(org.apache.qpid.test.utils.QpidTestCase) AbstractVirtualHost(org.apache.qpid.server.virtualhost.AbstractVirtualHost) TestMemoryVirtualHost(org.apache.qpid.server.virtualhost.TestMemoryVirtualHost) QueueManagingVirtualHost(org.apache.qpid.server.virtualhost.QueueManagingVirtualHost) PreferenceStore(org.apache.qpid.server.store.preferences.PreferenceStore)

Aggregations

DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)1 PreferenceStore (org.apache.qpid.server.store.preferences.PreferenceStore)1 AbstractVirtualHost (org.apache.qpid.server.virtualhost.AbstractVirtualHost)1 QueueManagingVirtualHost (org.apache.qpid.server.virtualhost.QueueManagingVirtualHost)1 TestMemoryVirtualHost (org.apache.qpid.server.virtualhost.TestMemoryVirtualHost)1 QpidTestCase (org.apache.qpid.test.utils.QpidTestCase)1