Search in sources :

Example 6 with TaskExecutor

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

the class AMQChannelTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    TaskExecutor taskExecutor = mock(TaskExecutor.class);
    _broker = mock(Broker.class);
    when(_broker.getEventLogger()).thenReturn(mock(EventLogger.class));
    when(_broker.getContextValue(Long.class, Broker.CHANNEL_FLOW_CONTROL_ENFORCEMENT_TIMEOUT)).thenReturn(1l);
    _messageStore = mock(MessageStore.class);
    _virtualHost = mock(QueueManagingVirtualHost.class);
    when(_virtualHost.getContextValue(Integer.class, Broker.MESSAGE_COMPRESSION_THRESHOLD_SIZE)).thenReturn(1);
    when(_virtualHost.getContextValue(Long.class, Connection.MAX_UNCOMMITTED_IN_MEMORY_SIZE)).thenReturn(1l);
    when(_virtualHost.getContextValue(Boolean.class, Broker.BROKER_MSG_AUTH)).thenReturn(false);
    when(_virtualHost.getPrincipal()).thenReturn(mock(Principal.class));
    when(_virtualHost.getEventLogger()).thenReturn(mock(EventLogger.class));
    _port = mock(AmqpPort.class);
    when(_port.getChildExecutor()).thenReturn(taskExecutor);
    when(_port.getModel()).thenReturn(BrokerModel.getInstance());
    when(_port.getContextValue(Integer.class, Connection.MAX_MESSAGE_SIZE)).thenReturn(1);
    AuthenticatedPrincipal authenticatedPrincipal = new AuthenticatedPrincipal(new UsernamePrincipal("user", null));
    Set<Principal> authenticatedUser = Collections.<Principal>singleton(authenticatedPrincipal);
    Subject authenticatedSubject = new Subject(true, authenticatedUser, Collections.<Principal>emptySet(), Collections.<Principal>emptySet());
    _protocolOutputConverter = mock(ProtocolOutputConverter.class);
    _amqConnection = mock(AMQPConnection_0_8.class);
    when(_amqConnection.getSubject()).thenReturn(authenticatedSubject);
    when(_amqConnection.getAuthorizedPrincipal()).thenReturn(authenticatedPrincipal);
    when(_amqConnection.getAddressSpace()).thenReturn((VirtualHost) _virtualHost);
    when(_amqConnection.getProtocolOutputConverter()).thenReturn(_protocolOutputConverter);
    when(_amqConnection.getBroker()).thenReturn((Broker) _broker);
    when(_amqConnection.getMethodRegistry()).thenReturn(new MethodRegistry(ProtocolVersion.v0_9));
    when(_amqConnection.getContextProvider()).thenReturn(_virtualHost);
    when(_amqConnection.getContextValue(Long.class, Session.PRODUCER_AUTH_CACHE_TIMEOUT)).thenReturn(Session.PRODUCER_AUTH_CACHE_TIMEOUT_DEFAULT);
    when(_amqConnection.getContextValue(Integer.class, Session.PRODUCER_AUTH_CACHE_SIZE)).thenReturn(Session.PRODUCER_AUTH_CACHE_SIZE_DEFAULT);
    when(_amqConnection.getContextValue(Long.class, Connection.MAX_UNCOMMITTED_IN_MEMORY_SIZE)).thenReturn(Connection.DEFAULT_MAX_UNCOMMITTED_IN_MEMORY_SIZE);
    when(_amqConnection.getTaskExecutor()).thenReturn(taskExecutor);
    when(_amqConnection.getChildExecutor()).thenReturn(taskExecutor);
    when(_amqConnection.getModel()).thenReturn(BrokerModel.getInstance());
    when(_amqConnection.getContextValue(Long.class, AMQPConnection_0_8.BATCH_LIMIT)).thenReturn(AMQPConnection_0_8.DEFAULT_BATCH_LIMIT);
    when(_amqConnection.getContextValue(Long.class, AMQPConnection_0_8.HIGH_PREFETCH_LIMIT)).thenReturn(AMQPConnection_0_8.DEFAULT_BATCH_LIMIT);
    when(_amqConnection.getEventLogger()).thenReturn(mock(EventLogger.class));
    _messageDestination = mock(MessageDestination.class);
}
Also used : MessageStore(org.apache.qpid.server.store.MessageStore) NullMessageStore(org.apache.qpid.server.store.NullMessageStore) Broker(org.apache.qpid.server.model.Broker) MessageDestination(org.apache.qpid.server.message.MessageDestination) QueueManagingVirtualHost(org.apache.qpid.server.virtualhost.QueueManagingVirtualHost) EventLogger(org.apache.qpid.server.logging.EventLogger) MethodRegistry(org.apache.qpid.server.protocol.v0_8.transport.MethodRegistry) Subject(javax.security.auth.Subject) AuthenticatedPrincipal(org.apache.qpid.server.security.auth.AuthenticatedPrincipal) UsernamePrincipal(org.apache.qpid.server.security.auth.UsernamePrincipal) TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) AmqpPort(org.apache.qpid.server.model.port.AmqpPort) UsernamePrincipal(org.apache.qpid.server.security.auth.UsernamePrincipal) AuthenticatedPrincipal(org.apache.qpid.server.security.auth.AuthenticatedPrincipal) Principal(java.security.Principal)

Example 7 with TaskExecutor

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

the class JDBCSystemConfigTest method testInvalidTableNamePrefix.

public void testInvalidTableNamePrefix() throws Exception {
    final TaskExecutor taskExecutor = new CurrentThreadTaskExecutor();
    final EventLogger eventLogger = mock(EventLogger.class);
    final Principal systemPrincipal = mock(Principal.class);
    JDBCSystemConfig<?> jdbcSystemConfig = new JDBCSystemConfigImpl(taskExecutor, eventLogger, systemPrincipal, Collections.<String, Object>emptyMap());
    // This list is not exhaustive
    List<String> knownInvalidPrefixes = Arrays.asList("with\"dblquote", "with'quote", "with-dash", "with;semicolon", "with space", "with%percent", "with|pipe", "with(paren", "with)paren", "with[bracket", "with]bracket", "with{brace", "with}brace");
    for (String invalidPrefix : knownInvalidPrefixes) {
        try {
            jdbcSystemConfig.setAttributes(Collections.<String, Object>singletonMap("tableNamePrefix", invalidPrefix));
            fail(String.format("Should not be able to set prefix to '%s'", invalidPrefix));
        } catch (IllegalConfigurationException e) {
        // pass
        }
    }
}
Also used : CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) EventLogger(org.apache.qpid.server.logging.EventLogger) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) Principal(java.security.Principal)

Example 8 with TaskExecutor

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

the class ServerSessionTest method createMockPort.

public AmqpPort createMockPort() {
    AmqpPort port = mock(AmqpPort.class);
    TaskExecutor childExecutor = new TaskExecutorImpl();
    childExecutor.start();
    when(port.getChildExecutor()).thenReturn(childExecutor);
    when(port.getCategoryClass()).thenReturn(Port.class);
    when(port.getModel()).thenReturn(BrokerModel.getInstance());
    return port;
}
Also used : CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) TaskExecutorImpl(org.apache.qpid.server.configuration.updater.TaskExecutorImpl) AmqpPort(org.apache.qpid.server.model.port.AmqpPort)

Example 9 with TaskExecutor

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

the class HttpManagementTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    _id = UUID.randomUUID();
    _broker = mock(Broker.class);
    ConfiguredObjectFactory objectFactory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance());
    when(_broker.getObjectFactory()).thenReturn(objectFactory);
    when(_broker.getModel()).thenReturn(objectFactory.getModel());
    when(_broker.getCategoryClass()).thenReturn(Broker.class);
    when(_broker.getEventLogger()).thenReturn(mock(EventLogger.class));
    TaskExecutor taskExecutor = new TaskExecutorImpl();
    taskExecutor.start();
    when(_broker.getTaskExecutor()).thenReturn(taskExecutor);
    when(_broker.getChildExecutor()).thenReturn(taskExecutor);
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put(HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, false);
    attributes.put(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED, true);
    attributes.put(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED, false);
    attributes.put(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED, true);
    attributes.put(HttpManagement.NAME, getTestName());
    attributes.put(HttpManagement.TIME_OUT, 10000l);
    attributes.put(ConfiguredObject.ID, _id);
    attributes.put(HttpManagement.DESIRED_STATE, State.QUIESCED);
    _management = new HttpManagement(attributes, _broker);
    _management.open();
}
Also used : TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) TaskExecutorImpl(org.apache.qpid.server.configuration.updater.TaskExecutorImpl) Broker(org.apache.qpid.server.model.Broker) ConfiguredObjectFactory(org.apache.qpid.server.model.ConfiguredObjectFactory) EventLogger(org.apache.qpid.server.logging.EventLogger) HashMap(java.util.HashMap) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectFactoryImpl(org.apache.qpid.server.model.ConfiguredObjectFactoryImpl)

Example 10 with TaskExecutor

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

the class VirtualHostCreationTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    EventLogger eventLogger = mock(EventLogger.class);
    TaskExecutor executor = CurrentThreadTaskExecutor.newStartedInstance();
    SystemConfig systemConfig = mock(SystemConfig.class);
    ConfiguredObjectFactory objectFactory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance());
    when(systemConfig.getObjectFactory()).thenReturn(objectFactory);
    when(systemConfig.getModel()).thenReturn(objectFactory.getModel());
    when(systemConfig.getEventLogger()).thenReturn(eventLogger);
    when(systemConfig.getTaskExecutor()).thenReturn(executor);
    when(systemConfig.getChildExecutor()).thenReturn(executor);
    Broker broker = mock(Broker.class);
    when(broker.getObjectFactory()).thenReturn(objectFactory);
    when(broker.getModel()).thenReturn(objectFactory.getModel());
    when(broker.getCategoryClass()).thenReturn(Broker.class);
    when(broker.getParent()).thenReturn(systemConfig);
    when(broker.getTaskExecutor()).thenReturn(executor);
    when(broker.getChildExecutor()).thenReturn(executor);
    _virtualHostNode = BrokerTestHelper.mockWithSystemPrincipal(VirtualHostNode.class, mock(Principal.class));
    when(_virtualHostNode.getParent()).thenReturn(broker);
    when(_virtualHostNode.getObjectFactory()).thenReturn(objectFactory);
    when(_virtualHostNode.getConfigurationStore()).thenReturn(mock(DurableConfigurationStore.class));
    when(_virtualHostNode.getModel()).thenReturn(objectFactory.getModel());
    when(_virtualHostNode.getCategoryClass()).thenReturn(VirtualHostNode.class);
    when(_virtualHostNode.getTaskExecutor()).thenReturn(executor);
    when(_virtualHostNode.getChildExecutor()).thenReturn(executor);
}
Also used : CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) SystemConfig(org.apache.qpid.server.model.SystemConfig) Broker(org.apache.qpid.server.model.Broker) ConfiguredObjectFactory(org.apache.qpid.server.model.ConfiguredObjectFactory) DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) EventLogger(org.apache.qpid.server.logging.EventLogger) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode) 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