use of org.apache.qpid.server.model.SystemConfig 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");
}
use of org.apache.qpid.server.model.SystemConfig in project qpid-broker-j by apache.
the class AmqpPortImplTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
_taskExecutor = CurrentThreadTaskExecutor.newStartedInstance();
Model model = BrokerModel.getInstance();
SystemConfig systemConfig = mock(SystemConfig.class);
_broker = BrokerTestHelper.mockWithSystemPrincipal(Broker.class, mock(Principal.class));
when(_broker.getParent()).thenReturn(systemConfig);
when(_broker.getTaskExecutor()).thenReturn(_taskExecutor);
when(_broker.getChildExecutor()).thenReturn(_taskExecutor);
when(_broker.getModel()).thenReturn(model);
when(_broker.getId()).thenReturn(UUID.randomUUID());
when(_broker.getCategoryClass()).thenReturn(Broker.class);
when(_broker.getEventLogger()).thenReturn(new EventLogger());
KeyStore<?> keyStore = mock(KeyStore.class);
when(keyStore.getName()).thenReturn(KEYSTORE_NAME);
when(keyStore.getParent()).thenReturn(_broker);
TrustStore<?> trustStore = mock(TrustStore.class);
when(trustStore.getName()).thenReturn(TRUSTSTORE_NAME);
when(trustStore.getParent()).thenReturn(_broker);
AuthenticationProvider<?> authProvider = mock(AuthenticationProvider.class);
when(authProvider.getName()).thenReturn(AUTHENTICATION_PROVIDER_NAME);
when(authProvider.getParent()).thenReturn(_broker);
when(authProvider.getMechanisms()).thenReturn(Arrays.asList("PLAIN"));
when(_broker.getChildren(AuthenticationProvider.class)).thenReturn(Collections.singleton(authProvider));
when(_broker.getChildren(KeyStore.class)).thenReturn(Collections.singleton(keyStore));
when(_broker.getChildren(TrustStore.class)).thenReturn(Collections.singleton(trustStore));
when(_broker.getChildByName(AuthenticationProvider.class, AUTHENTICATION_PROVIDER_NAME)).thenReturn(authProvider);
}
use of org.apache.qpid.server.model.SystemConfig in project qpid-broker-j by apache.
the class HttpPortImplTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
_taskExecutor = CurrentThreadTaskExecutor.newStartedInstance();
Model model = BrokerModel.getInstance();
SystemConfig systemConfig = mock(SystemConfig.class);
_broker = mock(Broker.class);
when(_broker.getParent()).thenReturn(systemConfig);
when(_broker.getTaskExecutor()).thenReturn(_taskExecutor);
when(_broker.getChildExecutor()).thenReturn(_taskExecutor);
when(_broker.getModel()).thenReturn(model);
when(_broker.getEventLogger()).thenReturn(new EventLogger());
when(_broker.getCategoryClass()).thenReturn(Broker.class);
AuthenticationProvider<?> provider = mock(AuthenticationProvider.class);
when(provider.getName()).thenReturn(AUTHENTICATION_PROVIDER_NAME);
when(provider.getParent()).thenReturn(_broker);
when(provider.getMechanisms()).thenReturn(Arrays.asList("PLAIN"));
when(_broker.getChildren(AuthenticationProvider.class)).thenReturn(Collections.<AuthenticationProvider>singleton(provider));
when(_broker.getChildByName(AuthenticationProvider.class, AUTHENTICATION_PROVIDER_NAME)).thenReturn(provider);
}
use of org.apache.qpid.server.model.SystemConfig in project qpid-broker-j by apache.
the class AbstractConfiguredObjectTest method testAuditInformationPersistenceAndRecovery.
public void testAuditInformationPersistenceAndRecovery() throws Exception {
final String creatingUser = "creatingUser";
final Subject creatorSubject = createTestAuthenticatedSubject(creatingUser);
final String objectName = "myName";
final Map<String, Object> attributes = new HashMap<>();
attributes.put(TestSingleton.NAME, objectName);
final TestSingleton object = Subject.doAs(creatorSubject, new PrivilegedAction<TestSingleton>() {
@Override
public TestSingleton run() {
return _model.getObjectFactory().create(TestSingleton.class, attributes, null);
}
});
final ConfiguredObjectRecord cor = object.asObjectRecord();
final Map<String, Object> recordedAttributes = cor.getAttributes();
assertTrue(recordedAttributes.containsKey(ConfiguredObject.LAST_UPDATED_BY));
assertTrue(recordedAttributes.containsKey(ConfiguredObject.LAST_UPDATED_TIME));
assertTrue(recordedAttributes.containsKey(ConfiguredObject.CREATED_BY));
assertTrue(recordedAttributes.containsKey(ConfiguredObject.CREATED_TIME));
assertEquals(creatingUser, recordedAttributes.get(ConfiguredObject.CREATED_BY));
assertEquals(creatingUser, recordedAttributes.get(ConfiguredObject.LAST_UPDATED_BY));
// Now recover the object
final SystemConfig mockSystemConfig = mock(SystemConfig.class);
when(mockSystemConfig.getId()).thenReturn(UUID.randomUUID());
when(mockSystemConfig.getModel()).thenReturn(TestModel.getInstance());
final TestSingleton recovered = (TestSingleton) _model.getObjectFactory().recover(cor, mockSystemConfig).resolve();
recovered.open();
assertEquals("Unexpected recovered object created by", object.getCreatedBy(), recovered.getCreatedBy());
assertEquals("Unexpected recovered object created time", object.getCreatedTime(), recovered.getCreatedTime());
assertEquals("Unexpected recovered object updated by", object.getLastUpdatedBy(), recovered.getLastUpdatedBy());
assertEquals("Unexpected recovered object updated time", object.getLastUpdatedTime(), recovered.getLastUpdatedTime());
}
use of org.apache.qpid.server.model.SystemConfig in project qpid-broker-j by apache.
the class RedirectingVirtualHostNodeTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
_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);
}
Aggregations