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