Search in sources :

Example 6 with ConfiguredObjectFactoryImpl

use of org.apache.qpid.server.model.ConfiguredObjectFactoryImpl in project qpid-broker-j by apache.

the class AclFileAccessControlProviderFactoryTest method setUp.

@Before
public void setUp() throws Exception {
    _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) Before(org.junit.Before)

Example 7 with ConfiguredObjectFactoryImpl

use of org.apache.qpid.server.model.ConfiguredObjectFactoryImpl in project qpid-broker-j by apache.

the class PortFactoryTest method setUp.

@Before
public void setUp() throws Exception {
    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, getTestName());
    _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) Before(org.junit.Before)

Example 8 with ConfiguredObjectFactoryImpl

use of org.apache.qpid.server.model.ConfiguredObjectFactoryImpl in project qpid-broker-j by apache.

the class VirtualHostCreationTest method setUp.

@Before
public void setUp() throws Exception {
    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) Before(org.junit.Before)

Example 9 with ConfiguredObjectFactoryImpl

use of org.apache.qpid.server.model.ConfiguredObjectFactoryImpl in project qpid-broker-j by apache.

the class RedirectingVirtualHostNodeTest method setUp.

@Before
public void setUp() throws Exception {
    _broker = BrokerTestHelper.createBrokerMock();
    SystemConfig<?> systemConfig = (SystemConfig<?>) _broker.getParent();
    when(systemConfig.getObjectFactory()).thenReturn(new ConfiguredObjectFactoryImpl(mock(Model.class)));
    _taskExecutor = new CurrentThreadTaskExecutor();
    _taskExecutor.start();
    when(_broker.getTaskExecutor()).thenReturn(_taskExecutor);
    when(_broker.getChildExecutor()).thenReturn(_taskExecutor);
    AuthenticationProvider dummyAuthProvider = mock(AuthenticationProvider.class);
    when(dummyAuthProvider.getName()).thenReturn("dummy");
    when(dummyAuthProvider.getId()).thenReturn(UUID.randomUUID());
    when(dummyAuthProvider.getMechanisms()).thenReturn(Arrays.asList("PLAIN"));
    when(_broker.getChildren(eq(AuthenticationProvider.class))).thenReturn(Collections.singleton(dummyAuthProvider));
    final Map<String, Object> attributes = new HashMap<>();
    attributes.put(Port.NAME, getTestName());
    attributes.put(Port.PORT, 0);
    attributes.put(Port.AUTHENTICATION_PROVIDER, "dummy");
    attributes.put(Port.TYPE, "AMQP");
    _port = (AmqpPort) _broker.getObjectFactory().create(Port.class, attributes, _broker);
}
Also used : SystemConfig(org.apache.qpid.server.model.SystemConfig) HashMap(java.util.HashMap) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) AuthenticationProvider(org.apache.qpid.server.model.AuthenticationProvider) ConfiguredObjectFactoryImpl(org.apache.qpid.server.model.ConfiguredObjectFactoryImpl) Before(org.junit.Before)

Example 10 with ConfiguredObjectFactoryImpl

use of org.apache.qpid.server.model.ConfiguredObjectFactoryImpl in project qpid-broker-j by apache.

the class JDBCVirtualHostNodeTest method testInvalidTableNamePrefix.

@Test
public void testInvalidTableNamePrefix() throws Exception {
    SystemConfig systemConfig = mock(SystemConfig.class);
    Broker broker = mock(Broker.class);
    final ConfiguredObjectFactoryImpl factory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance());
    when(broker.getObjectFactory()).thenReturn(factory);
    when(broker.getModel()).thenReturn(factory.getModel());
    when(broker.getChildExecutor()).thenReturn(_taskExecutor);
    when(broker.getParent()).thenReturn(systemConfig);
    Map<String, Object> attributes = new HashMap<>();
    attributes.put(ConfiguredObject.NAME, getTestName());
    attributes.put(ConfiguredObject.TYPE, JDBCVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE);
    attributes.put("connectionUrl", "jdbc://example.com");
    JDBCVirtualHostNode<?> jdbcVirtualHostNode = new JDBCVirtualHostNodeImpl(attributes, broker);
    // 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 {
            jdbcVirtualHostNode.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 : SystemConfig(org.apache.qpid.server.model.SystemConfig) Broker(org.apache.qpid.server.model.Broker) HashMap(java.util.HashMap) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectFactoryImpl(org.apache.qpid.server.model.ConfiguredObjectFactoryImpl) Test(org.junit.Test)

Aggregations

ConfiguredObjectFactoryImpl (org.apache.qpid.server.model.ConfiguredObjectFactoryImpl)11 Before (org.junit.Before)9 CurrentThreadTaskExecutor (org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor)6 EventLogger (org.apache.qpid.server.logging.EventLogger)6 SystemConfig (org.apache.qpid.server.model.SystemConfig)6 Broker (org.apache.qpid.server.model.Broker)5 ConfiguredObjectFactory (org.apache.qpid.server.model.ConfiguredObjectFactory)5 TaskExecutor (org.apache.qpid.server.configuration.updater.TaskExecutor)4 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)4 HashMap (java.util.HashMap)3 Principal (java.security.Principal)2 AuthenticationProvider (org.apache.qpid.server.model.AuthenticationProvider)2 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)2 DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)2 ConfiguredObjectRecordHandler (org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler)2 File (java.io.File)1 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)1 TaskExecutorImpl (org.apache.qpid.server.configuration.updater.TaskExecutorImpl)1 BrokerImpl (org.apache.qpid.server.model.BrokerImpl)1 VirtualHost (org.apache.qpid.server.model.VirtualHost)1