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