Search in sources :

Example 1 with TestMemoryVirtualHost

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

the class VirtualHostLoggerTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    _taskExecutor = new TaskExecutorImpl();
    _taskExecutor.start();
    Model model = BrokerModel.getInstance();
    EventLogger eventLogger = mock(EventLogger.class);
    SystemConfig<?> systemConfig = mock(SystemConfig.class);
    when(systemConfig.getModel()).thenReturn(model);
    when(systemConfig.getChildExecutor()).thenReturn(_taskExecutor);
    when(systemConfig.getEventLogger()).thenReturn(eventLogger);
    when(systemConfig.createPreferenceStore()).thenReturn(mock(PreferenceStore.class));
    doReturn(SystemConfig.class).when(systemConfig).getCategoryClass();
    Principal systemPrincipal = mock(Principal.class);
    AccessControl accessControlMock = BrokerTestHelper.createAccessControlMock();
    Broker broker = BrokerTestHelper.mockWithSystemPrincipalAndAccessControl(Broker.class, systemPrincipal, accessControlMock);
    when(broker.getModel()).thenReturn(model);
    when(broker.getChildExecutor()).thenReturn(_taskExecutor);
    when(broker.getParent()).thenReturn(systemConfig);
    doReturn(Broker.class).when(broker).getCategoryClass();
    VirtualHostNode node = BrokerTestHelper.mockWithSystemPrincipalAndAccessControl(VirtualHostNode.class, systemPrincipal, accessControlMock);
    when(node.getModel()).thenReturn(model);
    when(node.getChildExecutor()).thenReturn(_taskExecutor);
    when(node.getParent()).thenReturn(broker);
    when(node.getConfigurationStore()).thenReturn(mock(DurableConfigurationStore.class));
    doReturn(VirtualHostNode.class).when(node).getCategoryClass();
    when(node.createPreferenceStore()).thenReturn(mock(PreferenceStore.class));
    // use real VH object rather then mock in order to test create/start/stop functionality
    Map<String, Object> attributes = new HashMap<>();
    attributes.put(VirtualHost.NAME, getName());
    attributes.put(VirtualHost.TYPE, TestMemoryVirtualHost.VIRTUAL_HOST_TYPE);
    _virtualHost = new TestMemoryVirtualHost(attributes, node);
    _virtualHost.open();
    _baseFolder = new File(TMP_FOLDER, "test-sub-folder");
    _logFile = new File(_baseFolder, "tmp-virtual-host.log." + System.currentTimeMillis());
    if (_baseFolder.exists()) {
        FileUtils.delete(_baseFolder, true);
    }
}
Also used : TaskExecutorImpl(org.apache.qpid.server.configuration.updater.TaskExecutorImpl) TestMemoryVirtualHost(org.apache.qpid.server.virtualhost.TestMemoryVirtualHost) Broker(org.apache.qpid.server.model.Broker) DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) EventLogger(org.apache.qpid.server.logging.EventLogger) HashMap(java.util.HashMap) PreferenceStore(org.apache.qpid.server.store.preferences.PreferenceStore) AccessControl(org.apache.qpid.server.security.AccessControl) BrokerModel(org.apache.qpid.server.model.BrokerModel) Model(org.apache.qpid.server.model.Model) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) File(java.io.File) Principal(java.security.Principal) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode)

Example 2 with TestMemoryVirtualHost

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

the class VirtualHostTest method createVirtualHost.

private QueueManagingVirtualHost<?> createVirtualHost(final String virtualHostName, Map<String, Object> attributes) {
    Map<String, Object> vhAttributes = new HashMap<>();
    vhAttributes.put(VirtualHost.NAME, virtualHostName);
    vhAttributes.put(VirtualHost.TYPE, TestMemoryVirtualHost.VIRTUAL_HOST_TYPE);
    vhAttributes.putAll(attributes);
    TestMemoryVirtualHost host = new TestMemoryVirtualHost(vhAttributes, _virtualHostNode);
    host.addChangeListener(_storeConfigurationChangeListener);
    host.create();
    // Fire the child added event on the node
    _storeConfigurationChangeListener.childAdded(_virtualHostNode, host);
    _virtualHost = host;
    when(_virtualHostNode.getVirtualHost()).thenReturn(_virtualHost);
    return host;
}
Also used : TestMemoryVirtualHost(org.apache.qpid.server.virtualhost.TestMemoryVirtualHost) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString)

Example 3 with TestMemoryVirtualHost

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

the class BrokerImplTest method createVhnWithVh.

private void createVhnWithVh(final BrokerImpl brokerImpl, int nameSuffix, final long totalQueueSize) {
    final Map<String, Object> vhnAttributes = new HashMap<>();
    vhnAttributes.put(VirtualHostNode.TYPE, TestVirtualHostNode.VIRTUAL_HOST_NODE_TYPE);
    vhnAttributes.put(VirtualHostNode.NAME, "testVhn" + nameSuffix);
    final DurableConfigurationStore store = mock(DurableConfigurationStore.class);
    TestVirtualHostNode vhn = new TestVirtualHostNode(brokerImpl, vhnAttributes, store);
    vhn.create();
    final Map<String, Object> vhAttributes = new HashMap<>();
    vhAttributes.put(VirtualHost.TYPE, TestMemoryVirtualHost.VIRTUAL_HOST_TYPE);
    vhAttributes.put(VirtualHost.NAME, "testVh" + nameSuffix);
    TestMemoryVirtualHost vh = new TestMemoryVirtualHost(vhAttributes, vhn) {

        @Override
        public long getTotalDepthOfQueuesBytes() {
            return totalQueueSize;
        }
    };
    vh.create();
}
Also used : TestMemoryVirtualHost(org.apache.qpid.server.virtualhost.TestMemoryVirtualHost) DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) HashMap(java.util.HashMap) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) TestVirtualHostNode(org.apache.qpid.server.virtualhostnode.TestVirtualHostNode)

Aggregations

HashMap (java.util.HashMap)3 TestMemoryVirtualHost (org.apache.qpid.server.virtualhost.TestMemoryVirtualHost)3 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)2 DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)2 File (java.io.File)1 Principal (java.security.Principal)1 TaskExecutorImpl (org.apache.qpid.server.configuration.updater.TaskExecutorImpl)1 EventLogger (org.apache.qpid.server.logging.EventLogger)1 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)1 Broker (org.apache.qpid.server.model.Broker)1 BrokerModel (org.apache.qpid.server.model.BrokerModel)1 Model (org.apache.qpid.server.model.Model)1 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)1 AccessControl (org.apache.qpid.server.security.AccessControl)1 PreferenceStore (org.apache.qpid.server.store.preferences.PreferenceStore)1 TestVirtualHostNode (org.apache.qpid.server.virtualhostnode.TestVirtualHostNode)1 Matchers.anyString (org.mockito.Matchers.anyString)1