Search in sources :

Example 11 with TaskExecutor

use of org.apache.qpid.server.configuration.updater.TaskExecutor in project qpid-broker-j by apache.

the class HeadersBindingTest method setUp.

@Override
protected void setUp() {
    _count++;
    _queue = mock(Queue.class);
    TaskExecutor executor = new CurrentThreadTaskExecutor();
    executor.start();
    QueueManagingVirtualHost vhost = mock(QueueManagingVirtualHost.class);
    when(_queue.getVirtualHost()).thenReturn(vhost);
    when(_queue.getModel()).thenReturn(BrokerModel.getInstance());
    when(_queue.getTaskExecutor()).thenReturn(executor);
    when(_queue.getChildExecutor()).thenReturn(executor);
    final EventLogger eventLogger = new EventLogger();
    when(vhost.getEventLogger()).thenReturn(eventLogger);
    when(vhost.getTaskExecutor()).thenReturn(executor);
    when(vhost.getChildExecutor()).thenReturn(executor);
    _exchange = mock(Exchange.class);
    when(_exchange.getType()).thenReturn(ExchangeDefaults.HEADERS_EXCHANGE_CLASS);
    when(_exchange.getEventLogger()).thenReturn(eventLogger);
    when(_exchange.getModel()).thenReturn(BrokerModel.getInstance());
    when(_exchange.getTaskExecutor()).thenReturn(executor);
    when(_exchange.getChildExecutor()).thenReturn(executor);
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) QueueManagingVirtualHost(org.apache.qpid.server.virtualhost.QueueManagingVirtualHost) EventLogger(org.apache.qpid.server.logging.EventLogger) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) Queue(org.apache.qpid.server.model.Queue)

Example 12 with TaskExecutor

use of org.apache.qpid.server.configuration.updater.TaskExecutor in project qpid-broker-j by apache.

the class PortFactoryTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    SystemConfig systemConfig = mock(SystemConfig.class);
    _portNumber = findFreePort();
    TaskExecutor executor = CurrentThreadTaskExecutor.newStartedInstance();
    when(_authProvider.getName()).thenReturn(_authProviderName);
    when(_broker.getChildren(eq(AuthenticationProvider.class))).thenReturn(Collections.singleton(_authProvider));
    when(_broker.getCategoryClass()).thenReturn(Broker.class);
    when(_broker.getEventLogger()).thenReturn(new EventLogger());
    when(_broker.getParent()).thenReturn(systemConfig);
    when(_broker.getTypeClass()).thenReturn(Broker.class);
    ConfiguredObjectFactory objectFactory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance());
    when(_broker.getObjectFactory()).thenReturn(objectFactory);
    when(_broker.getModel()).thenReturn(objectFactory.getModel());
    when(_authProvider.getModel()).thenReturn(objectFactory.getModel());
    when(_authProvider.getObjectFactory()).thenReturn(objectFactory);
    when(_authProvider.getCategoryClass()).thenReturn(AuthenticationProvider.class);
    when(_authProvider.getMechanisms()).thenReturn(Arrays.asList("PLAIN"));
    when(_keyStore.getModel()).thenReturn(objectFactory.getModel());
    when(_keyStore.getObjectFactory()).thenReturn(objectFactory);
    when(_trustStore.getModel()).thenReturn(objectFactory.getModel());
    when(_trustStore.getObjectFactory()).thenReturn(objectFactory);
    for (ConfiguredObject obj : new ConfiguredObject[] { _authProvider, _broker, _keyStore, _trustStore }) {
        when(obj.getTaskExecutor()).thenReturn(executor);
        when(obj.getChildExecutor()).thenReturn(executor);
    }
    _factory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance());
    _attributes.put(Port.ID, _portId);
    _attributes.put(Port.NAME, getName());
    _attributes.put(Port.PORT, _portNumber);
    _attributes.put(Port.TRANSPORTS, _tcpStringSet);
    _attributes.put(Port.AUTHENTICATION_PROVIDER, _authProviderName);
    _attributes.put(Port.TCP_NO_DELAY, "true");
    _attributes.put(Port.BINDING_ADDRESS, "127.0.0.1");
}
Also used : SystemConfig(org.apache.qpid.server.model.SystemConfig) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) ConfiguredObjectFactory(org.apache.qpid.server.model.ConfiguredObjectFactory) EventLogger(org.apache.qpid.server.logging.EventLogger) AuthenticationProvider(org.apache.qpid.server.model.AuthenticationProvider) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectFactoryImpl(org.apache.qpid.server.model.ConfiguredObjectFactoryImpl)

Example 13 with TaskExecutor

use of org.apache.qpid.server.configuration.updater.TaskExecutor in project qpid-broker-j by apache.

the class AbstractDurableConfigurationStoreTestCase method createTestQueue.

private Queue<?> createTestQueue(String queueName, String queueOwner, boolean exclusive, final Map<String, Object> arguments) throws StoreException {
    Queue queue = BrokerTestHelper.mockWithSystemPrincipal(Queue.class, mock(Principal.class));
    when(queue.getName()).thenReturn(queueName);
    when(queue.isExclusive()).thenReturn(exclusive);
    when(queue.getId()).thenReturn(_queueId);
    when(queue.getType()).thenReturn(STANDARD);
    when(queue.getCategoryClass()).thenReturn(Queue.class);
    when(queue.isDurable()).thenReturn(true);
    TaskExecutor taskExecutor = CurrentThreadTaskExecutor.newStartedInstance();
    when(queue.getTaskExecutor()).thenReturn(taskExecutor);
    when(queue.getChildExecutor()).thenReturn(taskExecutor);
    final QueueManagingVirtualHost vh = mock(QueueManagingVirtualHost.class);
    when(queue.getVirtualHost()).thenReturn(vh);
    final Map<String, Object> attributes = arguments == null ? new LinkedHashMap<>() : new LinkedHashMap<>(arguments);
    attributes.put(Queue.NAME, queueName);
    attributes.put(Queue.TYPE, STANDARD);
    if (exclusive) {
        when(queue.getOwner()).thenReturn(queueOwner);
        attributes.put(Queue.OWNER, queueOwner);
        attributes.put(Queue.EXCLUSIVE, ExclusivityPolicy.CONTAINER);
    }
    when(queue.getAvailableAttributes()).thenReturn(attributes.keySet());
    final ArgumentCaptor<String> requestedAttribute = ArgumentCaptor.forClass(String.class);
    when(queue.getAttribute(requestedAttribute.capture())).then(new Answer() {

        @Override
        public Object answer(final InvocationOnMock invocation) throws Throwable {
            String attrName = requestedAttribute.getValue();
            return attributes.get(attrName);
        }
    });
    when(queue.getActualAttributes()).thenReturn(attributes);
    when(queue.getObjectFactory()).thenReturn(_factory);
    when(queue.getModel()).thenReturn(_factory.getModel());
    ConfiguredObjectRecord objectRecord = mock(ConfiguredObjectRecord.class);
    when(objectRecord.getId()).thenReturn(_queueId);
    when(objectRecord.getType()).thenReturn(Queue.class.getSimpleName());
    when(objectRecord.getAttributes()).thenReturn(attributes);
    when(objectRecord.getParents()).thenReturn(Collections.singletonMap(_rootRecord.getType(), _rootRecord.getId()));
    when(queue.asObjectRecord()).thenReturn(objectRecord);
    return queue;
}
Also used : QueueManagingVirtualHost(org.apache.qpid.server.virtualhost.QueueManagingVirtualHost) Answer(org.mockito.stubbing.Answer) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) Queue(org.apache.qpid.server.model.Queue) Principal(java.security.Principal)

Example 14 with TaskExecutor

use of org.apache.qpid.server.configuration.updater.TaskExecutor in project qpid-broker-j by apache.

the class AclFileAccessControlProviderFactoryTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    _broker = mock(Broker.class);
    _objectFactory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance());
    when(_broker.getObjectFactory()).thenReturn(_objectFactory);
    when(_broker.getModel()).thenReturn(_objectFactory.getModel());
    when(_broker.getCategoryClass()).thenReturn(Broker.class);
    TaskExecutor taskExecutor = new CurrentThreadTaskExecutor();
    taskExecutor.start();
    when(_broker.getTaskExecutor()).thenReturn(taskExecutor);
    when(_broker.getChildExecutor()).thenReturn(taskExecutor);
    when(_broker.getEventLogger()).thenReturn(new EventLogger());
}
Also used : CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) Broker(org.apache.qpid.server.model.Broker) EventLogger(org.apache.qpid.server.logging.EventLogger) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) ConfiguredObjectFactoryImpl(org.apache.qpid.server.model.ConfiguredObjectFactoryImpl)

Aggregations

TaskExecutor (org.apache.qpid.server.configuration.updater.TaskExecutor)14 CurrentThreadTaskExecutor (org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor)11 EventLogger (org.apache.qpid.server.logging.EventLogger)9 Broker (org.apache.qpid.server.model.Broker)7 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)6 Principal (java.security.Principal)4 ConfiguredObjectFactoryImpl (org.apache.qpid.server.model.ConfiguredObjectFactoryImpl)4 HashMap (java.util.HashMap)3 TaskExecutorImpl (org.apache.qpid.server.configuration.updater.TaskExecutorImpl)3 ConfiguredObjectFactory (org.apache.qpid.server.model.ConfiguredObjectFactory)3 AmqpPort (org.apache.qpid.server.model.port.AmqpPort)3 QueueManagingVirtualHost (org.apache.qpid.server.virtualhost.QueueManagingVirtualHost)3 Subject (javax.security.auth.Subject)2 AuthenticationProvider (org.apache.qpid.server.model.AuthenticationProvider)2 Exchange (org.apache.qpid.server.model.Exchange)2 Queue (org.apache.qpid.server.model.Queue)2 SystemConfig (org.apache.qpid.server.model.SystemConfig)2 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)2 AuthenticatedPrincipal (org.apache.qpid.server.security.auth.AuthenticatedPrincipal)2 DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)2