Search in sources :

Example 6 with ManagementRequest

use of org.apache.qpid.server.management.plugin.ManagementRequest in project qpid-broker-j by apache.

the class LatestManagementControllerTest method handleGetForBrokerRootAndQueueSingletonPath.

@Test
public void handleGetForBrokerRootAndQueueSingletonPath() throws Exception {
    final String hostName = "test";
    final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName, "foo", "bar");
    final String nodeName = virtualHost.getParent().getName();
    final ManagementRequest request = mock(ManagementRequest.class);
    when(request.getCategory()).thenReturn("queue");
    doReturn(virtualHost.getBroker()).when(request).getRoot();
    when(request.getPath()).thenReturn(Arrays.asList(nodeName, hostName, "foo"));
    when(request.getMethod()).thenReturn("GET");
    final ManagementResponse response = _controller.handleGet(request);
    assertThat(response, is(notNullValue()));
    assertThat(response.getResponseCode(), is(equalTo(200)));
    assertThat(response.getBody(), is(notNullValue()));
    assertThat(response.getBody(), is(instanceOf(Queue.class)));
    final Queue data = (Queue) response.getBody();
    assertThat(data.getName(), is(equalTo("foo")));
}
Also used : ManagementRequest(org.apache.qpid.server.management.plugin.ManagementRequest) ManagementResponse(org.apache.qpid.server.management.plugin.ManagementResponse) Queue(org.apache.qpid.server.model.Queue) Test(org.junit.Test)

Example 7 with ManagementRequest

use of org.apache.qpid.server.management.plugin.ManagementRequest in project qpid-broker-j by apache.

the class RestServlet method doDelete.

@Override
protected void doDelete(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse, final ConfiguredObject<?> managedObject) throws IOException {
    try {
        final ManagementRequest request = new ServletManagementRequest(managedObject, httpServletRequest);
        final ManagementController controller = getManagementController();
        final ManagementResponse response = controller.handleDelete(request);
        sendResponse(request, response, httpServletRequest, httpServletResponse, controller);
    } catch (ManagementException e) {
        sendResponse(e, httpServletRequest, httpServletResponse);
    }
}
Also used : ManagementRequest(org.apache.qpid.server.management.plugin.ManagementRequest) ManagementException(org.apache.qpid.server.management.plugin.ManagementException) ManagementResponse(org.apache.qpid.server.management.plugin.ManagementResponse) ManagementController(org.apache.qpid.server.management.plugin.ManagementController)

Example 8 with ManagementRequest

use of org.apache.qpid.server.management.plugin.ManagementRequest in project qpid-broker-j by apache.

the class RestServlet method doPut.

@Override
protected void doPut(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse, final ConfiguredObject<?> managedObject) throws IOException {
    try {
        final ManagementRequest request = new ServletManagementRequest(managedObject, httpServletRequest);
        final ManagementController controller = getManagementController();
        final ManagementResponse response = controller.handlePut(request);
        sendResponse(request, response, httpServletRequest, httpServletResponse, controller);
    } catch (ManagementException e) {
        sendResponse(e, httpServletRequest, httpServletResponse);
    }
}
Also used : ManagementRequest(org.apache.qpid.server.management.plugin.ManagementRequest) ManagementException(org.apache.qpid.server.management.plugin.ManagementException) ManagementResponse(org.apache.qpid.server.management.plugin.ManagementResponse) ManagementController(org.apache.qpid.server.management.plugin.ManagementController)

Example 9 with ManagementRequest

use of org.apache.qpid.server.management.plugin.ManagementRequest in project qpid-broker-j by apache.

the class RestServlet method doGet.

@Override
protected void doGet(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse, final ConfiguredObject<?> managedObject) throws IOException {
    try {
        final ManagementRequest request = new ServletManagementRequest(managedObject, httpServletRequest);
        final ManagementController controller = getManagementController();
        final ManagementResponse response = controller.handleGet(request);
        sendResponse(request, response, httpServletRequest, httpServletResponse, controller);
    } catch (ManagementException e) {
        sendResponse(e, httpServletRequest, httpServletResponse);
    }
}
Also used : ManagementRequest(org.apache.qpid.server.management.plugin.ManagementRequest) ManagementException(org.apache.qpid.server.management.plugin.ManagementException) ManagementResponse(org.apache.qpid.server.management.plugin.ManagementResponse) ManagementController(org.apache.qpid.server.management.plugin.ManagementController)

Example 10 with ManagementRequest

use of org.apache.qpid.server.management.plugin.ManagementRequest in project qpid-broker-j by apache.

the class LatestManagementControllerTest method handleGetForBrokerRootAndQueuePathWithoutQueueName.

@Test
public void handleGetForBrokerRootAndQueuePathWithoutQueueName() throws Exception {
    final String hostName = "test";
    final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName, "foo", "bar");
    final String nodeName = virtualHost.getParent().getName();
    final ManagementRequest request = mock(ManagementRequest.class);
    when(request.getCategory()).thenReturn("queue");
    doReturn(virtualHost.getBroker()).when(request).getRoot();
    when(request.getPath()).thenReturn(Arrays.asList(nodeName, hostName));
    when(request.getParameters()).thenReturn(Collections.emptyMap());
    when(request.getMethod()).thenReturn("GET");
    final ManagementResponse response = _controller.handleGet(request);
    assertThat(response, is(notNullValue()));
    assertThat(response.getResponseCode(), is(equalTo(200)));
    assertThat(response.getBody(), is(notNullValue()));
    assertThat(response.getBody(), is(instanceOf(Collection.class)));
    final Collection data = (Collection) response.getBody();
    assertThat(data.size(), is(equalTo(2)));
    final Iterator iterator = data.iterator();
    final Object object = iterator.next();
    final Object object2 = iterator.next();
    assertThat(object, is(notNullValue()));
    assertThat(object, is(instanceOf(Queue.class)));
    assertThat(((Queue) object).getName(), is(equalTo("foo")));
    assertThat(object2, is(notNullValue()));
    assertThat(object2, is(instanceOf(Queue.class)));
    assertThat(((Queue) object2).getName(), is(equalTo("bar")));
}
Also used : ManagementRequest(org.apache.qpid.server.management.plugin.ManagementRequest) ManagementResponse(org.apache.qpid.server.management.plugin.ManagementResponse) Iterator(java.util.Iterator) Collection(java.util.Collection) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) Test(org.junit.Test)

Aggregations

ManagementRequest (org.apache.qpid.server.management.plugin.ManagementRequest)18 Test (org.junit.Test)13 ManagementResponse (org.apache.qpid.server.management.plugin.ManagementResponse)11 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)6 RequestType (org.apache.qpid.server.management.plugin.RequestType)5 ManagementController (org.apache.qpid.server.management.plugin.ManagementController)4 ManagementException (org.apache.qpid.server.management.plugin.ManagementException)4 LegacyConfiguredObject (org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject)4 Collection (java.util.Collection)3 Broker (org.apache.qpid.server.model.Broker)3 Iterator (java.util.Iterator)1 List (java.util.List)1 Queue (org.apache.qpid.server.model.Queue)1