Search in sources :

Example 26 with Broker

use of org.apache.qpid.server.model.Broker in project qpid-broker-j by apache.

the class LatestManagementControllerAdapterTest method createOrUpdate.

@Test
public void createOrUpdate() throws Exception {
    final String hostName = "test";
    final String queueName = "foo";
    final QueueManagingVirtualHost<?> virtualHost = createTestVirtualHost(hostName);
    final String nodeName = virtualHost.getParent().getName();
    final Broker root = virtualHost.getBroker();
    final ManagementRequest request = mockManagementRequest(root, "POST", "queue", Arrays.asList(nodeName, hostName), Collections.emptyMap());
    when(request.getBody(LinkedHashMap.class)).thenReturn(new LinkedHashMap<String, Object>(Collections.singletonMap("name", queueName)));
    when(request.getRequestURL()).thenReturn("test");
    final Object response = _adapter.createOrUpdate(virtualHost.getBroker(), "queue", Arrays.asList(nodeName, hostName), Collections.singletonMap("name", queueName), true);
    assertThat(response, is(instanceOf(LegacyConfiguredObject.class)));
    final LegacyConfiguredObject object = (LegacyConfiguredObject) response;
    assertThat(object.getAttribute(LegacyConfiguredObject.NAME), is(equalTo(queueName)));
}
Also used : ManagementRequest(org.apache.qpid.server.management.plugin.ManagementRequest) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) Broker(org.apache.qpid.server.model.Broker) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) Test(org.junit.Test)

Example 27 with Broker

use of org.apache.qpid.server.model.Broker in project qpid-broker-j by apache.

the class LatestManagementControllerAdapterTest method handlePut.

@Test
public void handlePut() throws Exception {
    final String hostName = "test";
    final String queueName = "foo";
    final QueueManagingVirtualHost<?> virtualHost = createTestVirtualHost(hostName);
    final String nodeName = virtualHost.getParent().getName();
    final Broker root = virtualHost.getBroker();
    final ManagementRequest request = mockManagementRequest(root, "PUT", "queue", Arrays.asList(nodeName, hostName), Collections.emptyMap());
    when(request.getBody(LinkedHashMap.class)).thenReturn(new LinkedHashMap<String, Object>(Collections.singletonMap("name", queueName)));
    when(request.getRequestURL()).thenReturn("test");
    final ManagementResponse response = _adapter.handlePut(request);
    assertThat(response, is(notNullValue()));
    assertThat(response.getResponseCode(), is(equalTo(201)));
    assertThat(response.getBody(), is(notNullValue()));
    assertThat(response.getBody(), is(instanceOf(LegacyConfiguredObject.class)));
    final LegacyConfiguredObject object = (LegacyConfiguredObject) response.getBody();
    assertThat(object.getAttribute(LegacyConfiguredObject.NAME), is(equalTo("foo")));
}
Also used : ManagementRequest(org.apache.qpid.server.management.plugin.ManagementRequest) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) Broker(org.apache.qpid.server.model.Broker) ManagementResponse(org.apache.qpid.server.management.plugin.ManagementResponse) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) Test(org.junit.Test)

Example 28 with Broker

use of org.apache.qpid.server.model.Broker 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);
}
Also used : CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) SystemConfig(org.apache.qpid.server.model.SystemConfig) Broker(org.apache.qpid.server.model.Broker) ConfiguredObjectFactory(org.apache.qpid.server.model.ConfiguredObjectFactory) DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) EventLogger(org.apache.qpid.server.logging.EventLogger) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode) ConfiguredObjectFactoryImpl(org.apache.qpid.server.model.ConfiguredObjectFactoryImpl) Before(org.junit.Before)

Example 29 with Broker

use of org.apache.qpid.server.model.Broker in project qpid-broker-j by apache.

the class StoreConfigurationChangeListenerTest method testChildAdded.

@Test
public void testChildAdded() {
    notifyBrokerStarted();
    Broker broker = mock(Broker.class);
    when(broker.getCategoryClass()).thenReturn(Broker.class);
    when(broker.isDurable()).thenReturn(true);
    VirtualHost child = mock(VirtualHost.class);
    when(child.getCategoryClass()).thenReturn(VirtualHost.class);
    Model model = mock(Model.class);
    when(model.getChildTypes(any(Class.class))).thenReturn(Collections.<Class<? extends ConfiguredObject>>emptyList());
    when(model.getParentType(eq(VirtualHost.class))).thenReturn((Class) Broker.class);
    when(child.getModel()).thenReturn(model);
    when(child.isDurable()).thenReturn(true);
    final ConfiguredObjectRecord childRecord = mock(ConfiguredObjectRecord.class);
    when(child.asObjectRecord()).thenReturn(childRecord);
    _listener.childAdded(broker, child);
    verify(_store).update(eq(true), eq(childRecord));
}
Also used : Broker(org.apache.qpid.server.model.Broker) Model(org.apache.qpid.server.model.Model) VirtualHost(org.apache.qpid.server.model.VirtualHost) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) Test(org.junit.Test)

Example 30 with Broker

use of org.apache.qpid.server.model.Broker in project qpid-broker-j by apache.

the class StoreConfigurationChangeListenerTest method notifyBrokerStarted.

private void notifyBrokerStarted() {
    Broker broker = mock(Broker.class);
    _listener.stateChanged(broker, State.UNINITIALIZED, State.ACTIVE);
}
Also used : Broker(org.apache.qpid.server.model.Broker)

Aggregations

Broker (org.apache.qpid.server.model.Broker)38 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)15 EventLogger (org.apache.qpid.server.logging.EventLogger)13 Before (org.junit.Before)11 Test (org.junit.Test)8 Subject (javax.security.auth.Subject)7 HashMap (java.util.HashMap)6 TaskExecutor (org.apache.qpid.server.configuration.updater.TaskExecutor)6 VirtualHost (org.apache.qpid.server.model.VirtualHost)6 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)6 CurrentThreadTaskExecutor (org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor)5 Model (org.apache.qpid.server.model.Model)5 TaskExecutorImpl (org.apache.qpid.server.configuration.updater.TaskExecutorImpl)4 SubjectAuthenticationResult (org.apache.qpid.server.security.auth.SubjectAuthenticationResult)4 DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)4 AccessControlException (java.security.AccessControlException)3 Principal (java.security.Principal)3 SSLContext (javax.net.ssl.SSLContext)3 BrokerModel (org.apache.qpid.server.model.BrokerModel)3 Queue (org.apache.qpid.server.model.Queue)3