use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.
the class LegacyManagementControllerTest method get.
@Test
public void get() {
final List<String> path = Collections.emptyList();
final LegacyConfiguredObject object = mock(LegacyConfiguredObject.class);
final Map<String, List<String>> parameters = Collections.emptyMap();
final ConfiguredObject<?> root = mock(ConfiguredObject.class);
when(_nextVersionManagementController.get(eq(root), eq(BrokerController.TYPE), eq(path), any())).thenReturn(object);
final Object result = _controller.get(root, BrokerController.TYPE, path, parameters);
assertThat(result, is(instanceOf(Collection.class)));
Collection data = (Collection) result;
assertThat(data.size(), is(equalTo(1)));
Object obj = data.iterator().next();
assertThat(obj, is(instanceOf(LegacyConfiguredObject.class)));
assertThat(((LegacyConfiguredObject) obj).getCategory(), is(equalTo(BrokerController.TYPE)));
}
use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.
the class BrokerControllerTest method convertNextVersionLegacyConfiguredObject.
@Test
public void convertNextVersionLegacyConfiguredObject() {
final LegacyConfiguredObject object = mock(LegacyConfiguredObject.class);
when(object.getAttribute("modelVersion")).thenReturn("foo");
final Map<String, String> context = new HashMap<>();
context.put("qpid.port.sessionCountLimit", "512");
context.put("qpid.port.heartbeatDelay", "10000");
context.put("qpid.port.closeWhenNoRoute", "true");
when(object.getAttribute("context")).thenReturn(context);
final BrokerController controller = new BrokerController(_legacyVersionManagementController, Collections.emptySet());
assertThat(controller.getCategory(), is(equalTo("Broker")));
final LegacyConfiguredObject converted = controller.convertFromNextVersion(object);
assertThat(converted.getAttribute("modelVersion"), is(equalTo(MODEL_VERSION)));
assertThat(converted.getAttribute("connection.sessionCountLimit"), is(equalTo(512)));
assertThat(converted.getAttribute("connection.heartBeatDelay"), is(equalTo(10000L)));
assertThat(converted.getAttribute("connection.closeWhenNoRoute"), is(equalTo(true)));
}
use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.
the class DestinationControllerTest method convertAttributesToNextVersion.
@Test
public void convertAttributesToNextVersion() {
final String alternateExchangeName = "alternate";
final String queueName = "test";
final Map<String, Object> attributes = new HashMap<>();
attributes.put("alternateExchange", alternateExchangeName);
attributes.put(LegacyConfiguredObject.NAME, queueName);
final DestinationController controller = new DestinationController(_legacyVersionManagementController, "Queue", new String[] { "VirtualHost" }, null, Collections.emptySet());
assertThat(controller.getCategory(), is(equalTo("Queue")));
assertThat(controller.getParentCategories(), is(equalTo(new String[] { "VirtualHost" })));
final ConfiguredObject root = mock(ConfiguredObject.class);
final List<String> exchangePath = Arrays.asList("vhn", "vh");
final LegacyConfiguredObject exchange = mock(LegacyConfiguredObject.class);
when(exchange.getAttribute(LegacyConfiguredObject.NAME)).thenReturn(alternateExchangeName);
when(exchange.getCategory()).thenReturn(ExchangeController.TYPE);
final Collection<LegacyConfiguredObject> exchanges = Collections.singletonList(exchange);
when(_nextVersionManagementController.get(eq(root), eq(ExchangeController.TYPE), eq(exchangePath), eq(Collections.emptyMap()))).thenReturn(exchanges);
final Collection<String> hierarchy = Arrays.asList("virtualhostnode", "virtualhost", "exchange");
when(_nextVersionManagementController.getCategoryHierarchy(eq(root), eq(ExchangeController.TYPE))).thenReturn(hierarchy);
final List<String> path = Arrays.asList("vhn", "vh", queueName);
final Map<String, Object> converted = controller.convertAttributesToNextVersion(root, path, attributes);
assertThat(converted.size(), is(equalTo(2)));
assertThat(converted.get(LegacyConfiguredObject.NAME), is(equalTo(queueName)));
final Object alternateBinding = converted.get("alternateBinding");
assertThat(alternateBinding, is(notNullValue()));
assertThat(alternateBinding, is(instanceOf(Map.class)));
final Map<?, ?> alternateDestination = (Map<?, ?>) alternateBinding;
assertThat(alternateDestination.get("destination"), is(equalTo(alternateExchangeName)));
assertThat(alternateDestination.get("attributes"), is(equalTo(null)));
}
use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.
the class DestinationControllerTest method testLegacyDestination.
@Test
public void testLegacyDestination() {
final String alternateExchangeName = "alt";
final LegacyConfiguredObject nextVersionDestination = mock(LegacyConfiguredObject.class);
final AlternateBinding alternateDestination = mock(AlternateBinding.class);
when(alternateDestination.getDestination()).thenReturn(alternateExchangeName);
when(nextVersionDestination.getAttribute("alternateBinding")).thenReturn(alternateDestination);
final LegacyConfiguredObject vh = mock(LegacyConfiguredObject.class);
when(nextVersionDestination.getParent(VirtualHostController.TYPE)).thenReturn(vh);
final LegacyConfiguredObject alternateExchange = mock(LegacyConfiguredObject.class);
when(alternateExchange.getCategory()).thenReturn(ExchangeController.TYPE);
when(alternateExchange.getAttribute(LegacyConfiguredObject.NAME)).thenReturn(alternateExchangeName);
final Collection<LegacyConfiguredObject> exchanges = Collections.singletonList(alternateExchange);
when(vh.getChildren(ExchangeController.TYPE)).thenReturn(exchanges);
final LegacyConfiguredObject converted = mock(LegacyConfiguredObject.class);
when(_legacyVersionManagementController.convertFromNextVersion(alternateExchange)).thenReturn(converted);
DestinationController.LegacyDestination destination = new DestinationController.LegacyDestination(_legacyVersionManagementController, nextVersionDestination, "Queue");
assertThat(destination.getAttribute("alternateExchange"), is(equalTo(converted)));
}
use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.
the class SessionControllerTest method convertNextVersionLegacyConfiguredObject.
@Test
public void convertNextVersionLegacyConfiguredObject() {
final UUID sessionID = UUID.randomUUID();
final LegacyConfiguredObject nextVersionSession = mock(LegacyConfiguredObject.class);
final LegacyConfiguredObject nextVersionConsumer = mock(LegacyConfiguredObject.class);
when(nextVersionSession.getCategory()).thenReturn(SessionController.TYPE);
when(nextVersionSession.getAttribute(LegacyConfiguredObject.ID)).thenReturn(sessionID);
final ManagementResponse operationResult = new ControllerManagementResponse(ResponseType.MODEL_OBJECT, Collections.singletonList(nextVersionConsumer));
when(nextVersionSession.invoke(eq("getConsumers"), eq(Collections.emptyMap()), eq(true))).thenReturn(operationResult);
final LegacyConfiguredObject convertedConsumer = mock(LegacyConfiguredObject.class);
when(_legacyManagementController.convertFromNextVersion(nextVersionConsumer)).thenReturn(convertedConsumer);
final LegacyConfiguredObject convertedSession = _sessionController.convertNextVersionLegacyConfiguredObject(nextVersionSession);
assertThat(convertedSession.getAttribute(LegacyConfiguredObject.ID), is(equalTo(sessionID)));
final Collection<LegacyConfiguredObject> consumers = convertedSession.getChildren(ConsumerController.TYPE);
assertThat(consumers, is(notNullValue()));
assertThat(consumers.size(), is(equalTo(1)));
assertThat(consumers.iterator().next(), is(equalTo(convertedConsumer)));
}
Aggregations