Search in sources :

Example 1 with SystemConfig

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;
}
Also used : BrokerImpl(org.apache.qpid.server.model.BrokerImpl) SystemConfig(org.apache.qpid.server.model.SystemConfig) EventLogger(org.apache.qpid.server.logging.EventLogger) Principal(java.security.Principal) ConfiguredObjectFactoryImpl(org.apache.qpid.server.model.ConfiguredObjectFactoryImpl)

Example 2 with SystemConfig

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;
}
Also used : SystemConfig(org.apache.qpid.server.model.SystemConfig) HashMap(java.util.HashMap) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) UUID(java.util.UUID)

Example 3 with SystemConfig

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));
}
Also used : MessageStore(org.apache.qpid.server.store.MessageStore) SystemConfig(org.apache.qpid.server.model.SystemConfig) TaskExecutorImpl(org.apache.qpid.server.configuration.updater.TaskExecutorImpl) DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) EventLogger(org.apache.qpid.server.logging.EventLogger) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) PreferenceStore(org.apache.qpid.server.store.preferences.PreferenceStore) AccessControl(org.apache.qpid.server.security.AccessControl) Principal(java.security.Principal) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode)

Example 4 with SystemConfig

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);
}
Also used : SystemConfig(org.apache.qpid.server.model.SystemConfig) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) ConfiguredObjectFactoryImpl(org.apache.qpid.server.model.ConfiguredObjectFactoryImpl)

Example 5 with SystemConfig

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();
}
Also used : SystemConfig(org.apache.qpid.server.model.SystemConfig) Broker(org.apache.qpid.server.model.Broker) HashMap(java.util.HashMap) AuthenticationProvider(org.apache.qpid.server.model.AuthenticationProvider) FileKeyStore(org.apache.qpid.server.security.FileKeyStore) KeyStore(org.apache.qpid.server.model.KeyStore) SystemLauncher(org.apache.qpid.server.SystemLauncher) DefaultSystemLauncherListener(org.apache.qpid.server.SystemLauncherListener.DefaultSystemLauncherListener) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) File(java.io.File)

Aggregations

SystemConfig (org.apache.qpid.server.model.SystemConfig)16 EventLogger (org.apache.qpid.server.logging.EventLogger)10 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)8 HashMap (java.util.HashMap)7 Broker (org.apache.qpid.server.model.Broker)7 ConfiguredObjectFactoryImpl (org.apache.qpid.server.model.ConfiguredObjectFactoryImpl)7 CurrentThreadTaskExecutor (org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor)4 AuthenticationProvider (org.apache.qpid.server.model.AuthenticationProvider)4 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)4 BrokerModel (org.apache.qpid.server.model.BrokerModel)3 Model (org.apache.qpid.server.model.Model)3 ConfiguredObjectRecord (org.apache.qpid.server.store.ConfiguredObjectRecord)3 DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)3 Principal (java.security.Principal)2 Subject (javax.security.auth.Subject)2 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)2 TaskExecutor (org.apache.qpid.server.configuration.updater.TaskExecutor)2 TaskExecutorImpl (org.apache.qpid.server.configuration.updater.TaskExecutorImpl)2 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)2 ConfiguredObjectFactory (org.apache.qpid.server.model.ConfiguredObjectFactory)2