use of org.apache.qpid.server.management.plugin.ManagementRequest in project qpid-broker-j by apache.
the class LatestManagementControllerAdapterTest method handleDelete.
@Test
public void handleDelete() throws Exception {
final String hostName = "test";
final String queueName = "foo";
final QueueManagingVirtualHost<?> virtualHost = createTestVirtualHost(hostName);
virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, queueName));
assertThat(virtualHost.getQueueCount(), is(equalTo(1L)));
final String nodeName = virtualHost.getParent().getName();
final ManagementRequest request = mockManagementRequest(virtualHost.getBroker(), "DELETE", "queue", Arrays.asList(nodeName, hostName), Collections.singletonMap("name", Collections.singletonList("foo")));
final ManagementResponse response = _adapter.handleDelete(request);
assertThat(response, is(notNullValue()));
assertThat(response.getResponseCode(), is(equalTo(200)));
assertThat(virtualHost.getQueueCount(), is(equalTo(0L)));
}
use of org.apache.qpid.server.management.plugin.ManagementRequest in project qpid-broker-j by apache.
the class LatestManagementControllerAdapterTest method mockManagementRequest.
private ManagementRequest mockManagementRequest(ConfiguredObject<?> root, String method, String category, List<String> path, Map<String, List<String>> parameters) {
final ManagementRequest request = mock(ManagementRequest.class);
when(request.getCategory()).thenReturn(category);
doReturn(root).when(request).getRoot();
when(request.getPath()).thenReturn(path);
when(request.getParameters()).thenReturn(parameters);
when(request.getMethod()).thenReturn(method);
return request;
}
use of org.apache.qpid.server.management.plugin.ManagementRequest in project qpid-broker-j by apache.
the class LatestManagementControllerAdapterTest method handlePost.
@Test
public void handlePost() 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 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.management.plugin.ManagementRequest in project qpid-broker-j by apache.
the class AbstractLegacyConfiguredObjectControllerTest method getRequestType.
@Test
public void getRequestType() {
final Map<String, List<String>> parameters = Collections.singletonMap("name", Collections.singletonList("test"));
final ManagementRequest managementRequest = mock(ManagementRequest.class);
doReturn(_root).when(managementRequest).getRoot();
when(managementRequest.getMethod()).thenReturn("GET");
when(managementRequest.getParameters()).thenReturn(parameters);
when(managementRequest.getPath()).thenReturn(Collections.singletonList("test"));
when(managementRequest.getCategory()).thenReturn(TEST_CATEGORY_2);
when(_controller.getCategory(_root)).thenReturn(TEST_CATEGORY);
final RequestType requestType = _controller.getRequestType(managementRequest);
assertThat(requestType, is(equalTo(RequestType.MODEL_OBJECT)));
}
use of org.apache.qpid.server.management.plugin.ManagementRequest in project qpid-broker-j by apache.
the class LatestManagementControllerTest method getRequestTypeForGetAndVisiblePreferences.
@Test
public void getRequestTypeForGetAndVisiblePreferences() throws Exception {
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName, "foo", "bar");
final ManagementRequest request = mock(ManagementRequest.class);
when(request.getCategory()).thenReturn("queue");
doReturn(virtualHost.getBroker()).when(request).getRoot();
List<String> path = Arrays.asList(virtualHost.getParent().getName(), hostName, "bar", "visiblepreferences");
when(request.getPath()).thenReturn(path);
when(request.getParameters()).thenReturn(Collections.emptyMap());
when(request.getMethod()).thenReturn("GET");
final RequestType type = _controller.getRequestType(request);
assertThat(type, is(equalTo(RequestType.VISIBLE_PREFERENCES)));
}
Aggregations