use of org.apache.qpid.server.model.SystemConfig in project qpid-broker-j by apache.
the class DerbyVirtualHostNodeTest method createBroker.
private BrokerImpl createBroker() {
Map<String, Object> brokerAttributes = Collections.<String, Object>singletonMap(Broker.NAME, "Broker");
SystemConfig parent = BrokerTestHelper.mockWithSystemPrincipal(SystemConfig.class, mock(Principal.class));
when(parent.getEventLogger()).thenReturn(new EventLogger());
when(parent.getCategoryClass()).thenReturn(SystemConfig.class);
when(parent.getTaskExecutor()).thenReturn(_taskExecutor);
when(parent.getChildExecutor()).thenReturn(_taskExecutor);
when(parent.getModel()).thenReturn(BrokerModel.getInstance());
when(parent.getObjectFactory()).thenReturn(new ConfiguredObjectFactoryImpl(BrokerModel.getInstance()));
BrokerImpl broker = new BrokerImpl(brokerAttributes, parent);
broker.start();
return broker;
}
use of org.apache.qpid.server.model.SystemConfig in project qpid-broker-j by apache.
the class AbstractConfiguredObjectTest method recoverParentAndChild.
/**
* Simulates recovery of a parent/child from a store. Neither will be open yet.
*/
private TestCar recoverParentAndChild() {
final SystemConfig mockSystemConfig = mock(SystemConfig.class);
when(mockSystemConfig.getId()).thenReturn(UUID.randomUUID());
when(mockSystemConfig.getModel()).thenReturn(TestModel.getInstance());
final String carName = "myCar";
final Map<String, Object> carAttributes = new HashMap<>();
carAttributes.put(ConfiguredObject.NAME, carName);
carAttributes.put(ConfiguredObject.TYPE, TestKitCarImpl.TEST_KITCAR_TYPE);
ConfiguredObjectRecord carCor = new ConfiguredObjectRecord() {
@Override
public UUID getId() {
return UUID.randomUUID();
}
@Override
public String getType() {
return TestCar.class.getSimpleName();
}
@Override
public Map<String, Object> getAttributes() {
return carAttributes;
}
@Override
public Map<String, UUID> getParents() {
return Collections.singletonMap(SystemConfig.class.getSimpleName(), mockSystemConfig.getId());
}
};
final TestCar car = (TestCar) _model.getObjectFactory().recover(carCor, mockSystemConfig).resolve();
String engineName = "myEngine";
final Map<String, Object> engineAttributes = new HashMap<>();
engineAttributes.put(ConfiguredObject.NAME, engineName);
engineAttributes.put(ConfiguredObject.TYPE, TestElecEngineImpl.TEST_ELEC_ENGINE_TYPE);
ConfiguredObjectRecord engineCor = new ConfiguredObjectRecord() {
@Override
public UUID getId() {
return UUID.randomUUID();
}
@Override
public String getType() {
return TestEngine.class.getSimpleName();
}
@Override
public Map<String, Object> getAttributes() {
return engineAttributes;
}
@Override
public Map<String, UUID> getParents() {
return Collections.singletonMap(TestCar.class.getSimpleName(), car.getId());
}
};
_model.getObjectFactory().recover(engineCor, car).resolve();
return car;
}
use of org.apache.qpid.server.model.SystemConfig in project qpid-broker-j by apache.
the class AbstractVirtualHostTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
SystemConfig systemConfig = mock(SystemConfig.class);
when(systemConfig.getEventLogger()).thenReturn(mock(EventLogger.class));
when(systemConfig.createPreferenceStore()).thenReturn(mock(PreferenceStore.class));
AccessControl accessControlMock = BrokerTestHelper.createAccessControlMock();
Principal systemPrincipal = mock(Principal.class);
Broker<?> broker = BrokerTestHelper.mockWithSystemPrincipalAndAccessControl(Broker.class, systemPrincipal, accessControlMock);
when(broker.getParent()).thenReturn(systemConfig);
when(broker.getModel()).thenReturn(BrokerModel.getInstance());
_taskExecutor = new TaskExecutorImpl();
_taskExecutor.start();
when(broker.getTaskExecutor()).thenReturn(_taskExecutor);
when(broker.getChildExecutor()).thenReturn(_taskExecutor);
_node = BrokerTestHelper.mockWithSystemPrincipalAndAccessControl(VirtualHostNode.class, systemPrincipal, accessControlMock);
when(_node.getParent()).thenReturn(broker);
when(_node.getModel()).thenReturn(BrokerModel.getInstance());
when(_node.getTaskExecutor()).thenReturn(_taskExecutor);
when(_node.getChildExecutor()).thenReturn(_taskExecutor);
when(_node.getConfigurationStore()).thenReturn(mock(DurableConfigurationStore.class));
when(_node.getCategoryClass()).thenReturn(VirtualHostNode.class);
when(_node.createPreferenceStore()).thenReturn(mock(PreferenceStore.class));
_failingStore = mock(MessageStore.class);
doThrow(new RuntimeException("Cannot open store")).when(_failingStore).openMessageStore(any(ConfiguredObject.class));
}
use of org.apache.qpid.server.model.SystemConfig in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNodeTest 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);
}
use of org.apache.qpid.server.model.SystemConfig in project qpid-broker-j by apache.
the class SNITest method doBrokerStartup.
private void doBrokerStartup(boolean useMatching, String defaultAlias) throws Exception {
final File initialConfiguration = createInitialContext();
_brokerWork = TestFileUtils.createTestDirectory("qpid-work", true);
Map<String, String> context = new HashMap<>();
context.put("qpid.work_dir", _brokerWork.toString());
Map<String, Object> attributes = new HashMap<>();
attributes.put(SystemConfig.INITIAL_CONFIGURATION_LOCATION, initialConfiguration.getAbsolutePath());
attributes.put(SystemConfig.TYPE, JsonSystemConfigImpl.SYSTEM_CONFIG_TYPE);
attributes.put(SystemConfig.CONTEXT, context);
_systemLauncher = new SystemLauncher(new DefaultSystemLauncherListener() {
@Override
public void onContainerResolve(final SystemConfig<?> systemConfig) {
_broker = systemConfig.getContainer(Broker.class);
}
});
_systemLauncher.startup(attributes);
final Map<String, Object> authProviderAttr = new HashMap<>();
authProviderAttr.put(AuthenticationProvider.NAME, "myAuthProvider");
authProviderAttr.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE);
final AuthenticationProvider authProvider = _broker.createChild(AuthenticationProvider.class, authProviderAttr);
Map<String, Object> keyStoreAttr = new HashMap<>();
keyStoreAttr.put(FileKeyStore.NAME, "myKeyStore");
keyStoreAttr.put(FileKeyStore.STORE_URL, _keyStoreFile.toURI().toURL().toString());
keyStoreAttr.put(FileKeyStore.PASSWORD, KEYSTORE_PASSWORD);
keyStoreAttr.put(FileKeyStore.USE_HOST_NAME_MATCHING, useMatching);
keyStoreAttr.put(FileKeyStore.CERTIFICATE_ALIAS, defaultAlias);
final KeyStore keyStore = _broker.createChild(KeyStore.class, keyStoreAttr);
Map<String, Object> portAttr = new HashMap<>();
portAttr.put(Port.NAME, "myPort");
portAttr.put(Port.TYPE, "AMQP");
portAttr.put(Port.TRANSPORTS, Collections.singleton(Transport.SSL));
portAttr.put(Port.PORT, 0);
portAttr.put(Port.AUTHENTICATION_PROVIDER, authProvider);
portAttr.put(Port.KEY_STORE, keyStore);
final Port<?> port = _broker.createChild(Port.class, portAttr);
_boundPort = port.getBoundPort();
}
Aggregations