use of org.apache.qpid.server.management.plugin.ManagementRequest in project qpid-broker-j by apache.
the class LatestManagementControllerTest method handleGetForBrokerRootAndQueuePathWithFilter.
@Test
public void handleGetForBrokerRootAndQueuePathWithFilter() 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.singletonMap("name", Collections.singletonList("bar")));
when(request.getMethod()).thenReturn("GET");
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)));
Collection data = (Collection) response.getBody();
assertThat(data.size(), is(equalTo(1)));
Object object = data.iterator().next();
assertThat(object, is(notNullValue()));
assertThat(object, is(instanceOf(Queue.class)));
assertThat(((Queue) object).getName(), is(equalTo("bar")));
}
use of org.apache.qpid.server.management.plugin.ManagementRequest in project qpid-broker-j by apache.
the class LatestManagementControllerTest method getRequestTypeForGetAndModelObjectWithFullPath.
@Test
public void getRequestTypeForGetAndModelObjectWithFullPath() 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();
final List<String> path = Arrays.asList(virtualHost.getParent().getName(), hostName, "bar");
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.MODEL_OBJECT)));
}
use of org.apache.qpid.server.management.plugin.ManagementRequest in project qpid-broker-j by apache.
the class LatestManagementControllerTest method getRequestTypeForGetAndModelObjectWithNotFullPath.
@Test
public void getRequestTypeForGetAndModelObjectWithNotFullPath() 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();
when(request.getPath()).thenReturn(Arrays.asList("*", hostName));
when(request.getParameters()).thenReturn(Collections.emptyMap());
when(request.getMethod()).thenReturn("GET");
final RequestType type = _controller.getRequestType(request);
assertThat(type, 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 getRequestTypeForGetAndUserPreferences.
@Test
public void getRequestTypeForGetAndUserPreferences() 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", "userpreferences");
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.USER_PREFERENCES)));
}
use of org.apache.qpid.server.management.plugin.ManagementRequest in project qpid-broker-j by apache.
the class LatestManagementControllerAdapterTest method handleGet.
@Test
public void handleGet() throws Exception {
final String hostName = "test";
final String queueName = "foo";
final QueueManagingVirtualHost<?> virtualHost = createTestVirtualHost(hostName);
virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, queueName));
final String nodeName = virtualHost.getParent().getName();
final ManagementRequest request = mockManagementRequest(virtualHost.getBroker(), "GET", "queue", Arrays.asList(nodeName, hostName), Collections.singletonMap("name", Collections.singletonList("foo")));
final ManagementResponse response = _adapter.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(1)));
final Object object = data.iterator().next();
assertThat(object, is(notNullValue()));
assertThat(object, is(instanceOf(LegacyConfiguredObject.class)));
assertThat(((LegacyConfiguredObject) object).getAttribute(LegacyConfiguredObject.NAME), is(equalTo("foo")));
}
Aggregations