Search in sources :

Example 11 with SystemConfig

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

Example 12 with SystemConfig

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);
}
Also used : SystemConfig(org.apache.qpid.server.model.SystemConfig) Broker(org.apache.qpid.server.model.Broker) EventLogger(org.apache.qpid.server.logging.EventLogger) BrokerModel(org.apache.qpid.server.model.BrokerModel) Model(org.apache.qpid.server.model.Model)

Example 13 with SystemConfig

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);
}
Also used : SystemConfig(org.apache.qpid.server.model.SystemConfig) Broker(org.apache.qpid.server.model.Broker) EventLogger(org.apache.qpid.server.logging.EventLogger) BrokerModel(org.apache.qpid.server.model.BrokerModel) Model(org.apache.qpid.server.model.Model)

Example 14 with SystemConfig

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

Example 15 with SystemConfig

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);
}
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)

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