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