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);
}
}
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;
}
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();
}
Aggregations