use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.
the class LegacyCategoryControllerTest method convertNextVersionLegacyConfiguredObject.
@Test
public void convertNextVersionLegacyConfiguredObject() {
final LegacyConfiguredObject node = mock(LegacyConfiguredObject.class);
when(node.getAttribute(LegacyConfiguredObject.NAME)).thenReturn("test");
final LegacyConfiguredObject converted = _controller.convertNextVersionLegacyConfiguredObject(node);
assertThat(converted, is(notNullValue()));
assertThat(converted.getCategory(), is(equalTo(VirtualHostNode.TYPE)));
assertThat(converted.getAttribute(LegacyConfiguredObject.NAME), is(equalTo("test")));
}
use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.
the class QueueControllerTest method convertNextVersionLegacyConfiguredObject.
@Test
public void convertNextVersionLegacyConfiguredObject() {
final String exchangeName = "testExchange";
final String alternateExchangeName = "altExchange";
final String queueName = "testQueue";
final String bindingKey = "testBindingKey";
final LegacyConfiguredObject nextVersionQueue = mock(LegacyConfiguredObject.class);
final Binding nextVersionBinding = mock(Binding.class);
final LegacyConfiguredObject nextVersionVirtualHost = mock(LegacyConfiguredObject.class);
final LegacyConfiguredObject nextVersionAlternateExchange = mock(LegacyConfiguredObject.class);
final LegacyConfiguredObject nextVersionExchange = mock(LegacyConfiguredObject.class);
final AlternateBinding alternateDestination = mock(AlternateBinding.class);
when(alternateDestination.getDestination()).thenReturn(alternateExchangeName);
when(nextVersionQueue.getCategory()).thenReturn(QueueController.TYPE);
when(nextVersionQueue.getParent(VirtualHostController.TYPE)).thenReturn(nextVersionVirtualHost);
when(nextVersionQueue.getAttribute("alternateBinding")).thenReturn(alternateDestination);
when(nextVersionQueue.getAttribute(AbstractConfiguredObject.NAME)).thenReturn(queueName);
when(nextVersionQueue.getAttribute("overflowPolicy")).thenReturn("PRODUCER_FLOW_CONTROL");
when(nextVersionQueue.getAttribute("maximumQueueDepthBytes")).thenReturn(10000L);
when(nextVersionQueue.getAttribute("context")).thenReturn(Collections.singletonMap("queue.queueFlowResumeLimit", "70"));
when(nextVersionQueue.getAttribute("messageGroupType")).thenReturn("SHARED_GROUPS");
when(nextVersionQueue.getAttribute("messageGroupKeyOverride")).thenReturn("test");
when(nextVersionBinding.getDestination()).thenReturn(queueName);
when(nextVersionBinding.getBindingKey()).thenReturn(bindingKey);
when(nextVersionExchange.getAttribute(AbstractConfiguredObject.NAME)).thenReturn(exchangeName);
when(nextVersionExchange.getCategory()).thenReturn(ExchangeController.TYPE);
when(nextVersionExchange.getAttribute("bindings")).thenReturn(Collections.singletonList(nextVersionBinding));
when(nextVersionAlternateExchange.getCategory()).thenReturn(ExchangeController.TYPE);
when(nextVersionAlternateExchange.getCategory()).thenReturn(ExchangeController.TYPE);
when(nextVersionAlternateExchange.getAttribute(LegacyConfiguredObject.NAME)).thenReturn(alternateExchangeName);
when(nextVersionVirtualHost.getChildren(ExchangeController.TYPE)).thenReturn(Arrays.asList(nextVersionExchange, nextVersionAlternateExchange));
when(nextVersionVirtualHost.getChildren(QueueController.TYPE)).thenReturn(Collections.singletonList(nextVersionExchange));
final LegacyConfiguredObject convertedExchange = mock(LegacyConfiguredObject.class);
final LegacyConfiguredObject convertedAltExchange = mock(LegacyConfiguredObject.class);
final LegacyConfiguredObject convertedQueue = mock(LegacyConfiguredObject.class);
when(_legacyVersionManagementController.convertFromNextVersion(nextVersionQueue)).thenReturn(convertedQueue);
when(_legacyVersionManagementController.convertFromNextVersion(nextVersionAlternateExchange)).thenReturn(convertedAltExchange);
when(_legacyVersionManagementController.convertFromNextVersion(nextVersionExchange)).thenReturn(convertedExchange);
final LegacyConfiguredObject destination = _queueController.convertFromNextVersion(nextVersionQueue);
assertThat(destination.getAttribute("alternateExchange"), is(equalTo(convertedAltExchange)));
assertThat(destination.getAttribute("queueFlowControlSizeBytes"), is(equalTo(10000L)));
assertThat(destination.getAttribute("queueFlowResumeSizeBytes"), is(equalTo(7000L)));
assertThat(destination.getAttribute("messageGroupSharedGroups"), is(equalTo(true)));
assertThat(destination.getAttribute("messageGroupKey"), is(equalTo("test")));
final Collection<LegacyConfiguredObject> children = destination.getChildren(BindingController.TYPE);
assertThat(children.size(), is(equalTo(1)));
final LegacyConfiguredObject o = children.iterator().next();
assertThat(o.getCategory(), is(equalTo(BindingController.TYPE)));
assertThat(o.getAttribute(AbstractConfiguredObject.NAME), is(equalTo(bindingKey)));
assertThat(o.getAttribute("queue"), is(equalTo(convertedQueue)));
assertThat(o.getAttribute("exchange"), is(equalTo(convertedExchange)));
}
use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.
the class LegacyCategoryController_v8_0Test method assertPortTLSSettings.
private void assertPortTLSSettings(final LegacyConfiguredObject port) {
assertThat(port.getAttribute(ATTRIBUTE_NAME), equalTo(PORT_NAME));
assertThat(port.getContextValue(OLD_CONTEXT_TLS_PROTOCOL_WHITE_LIST), equalTo(PROTOCOL_ALLOW_LIST));
assertThat(port.getContextValue(OLD_CONTEXT_TLS_PROTOCOL_BLACK_LIST), equalTo(PROTOCOL_DENY_LIST));
final Object context = port.getAttribute(ATTRIBUTE_CONTEXT);
assertThat(context, instanceOf(Map.class));
final Map contextMap = (Map) context;
assertThat(contextMap.get(OLD_CONTEXT_TLS_PROTOCOL_WHITE_LIST), equalTo(PROTOCOL_ALLOW_LIST));
assertThat(contextMap.get(OLD_CONTEXT_TLS_PROTOCOL_BLACK_LIST), equalTo(PROTOCOL_DENY_LIST));
}
use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.
the class LegacyCategoryController_v8_0Test method testCreatePortWithSetAllowDenyTlsProtocolSettings.
@Test
public void testCreatePortWithSetAllowDenyTlsProtocolSettings() {
final List<String> path = Arrays.asList("port", PORT_NAME);
final Map<String, String> oldContext = new HashMap<>();
oldContext.put(OLD_CONTEXT_TLS_PROTOCOL_WHITE_LIST, PROTOCOL_ALLOW_LIST);
oldContext.put(OLD_CONTEXT_TLS_PROTOCOL_BLACK_LIST, PROTOCOL_DENY_LIST);
final Map<String, Object> attributes = new HashMap<>();
attributes.put(ATTRIBUTE_NAME, PORT_NAME);
attributes.put(ATTRIBUTE_CONTEXT, oldContext);
attributes.put("type", "AMQP");
final Map<String, String> newVersionContext = new HashMap<>();
newVersionContext.put(NEW_CONTEXT_TLS_PROTOCOL_ALLOW_LIST, PROTOCOL_ALLOW_LIST);
newVersionContext.put(NEW_CONTEXT_TLS_PROTOCOL_DENY_LIST, PROTOCOL_DENY_LIST);
Map<String, Object> newAttributes = new HashMap<>();
newAttributes.put(ATTRIBUTE_NAME, PORT_NAME);
newAttributes.put(ATTRIBUTE_CONTEXT, newVersionContext);
newAttributes.put("type", "AMQP");
LegacyConfiguredObject newVersionPort = createNewVersionPortMock();
when(_nextVersionManagementController.createOrUpdate(eq(_root), eq(TEST_CATEGORY), eq(path), eq(newAttributes), eq(false))).thenReturn(newVersionPort);
ManagementException error = ManagementException.createUnprocessableManagementException("unexpected");
when(_nextVersionManagementController.createOrUpdate(any(ConfiguredObject.class), anyString(), eq(path), not(eq(newAttributes)), anyBoolean())).thenThrow(error);
LegacyConfiguredObject port = _controller.createOrUpdate(_root, path, attributes, false);
assertThat(port, is(notNullValue()));
assertPortTLSSettings(port);
}
use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.
the class PortControllerTest method convertNextVersionLegacyConfiguredObject.
@Test
public void convertNextVersionLegacyConfiguredObject() {
final LegacyConfiguredObject nextVersionPort = mock(LegacyConfiguredObject.class);
when(nextVersionPort.getAttribute(LegacyConfiguredObject.NAME)).thenReturn("test");
when(nextVersionPort.getAttribute(LegacyConfiguredObject.TYPE)).thenReturn("HTTP");
Map<String, String> context = new HashMap<>();
context.put("qpid.port.http.acceptBacklog", "2000");
when(nextVersionPort.getAttribute(LegacyConfiguredObject.CONTEXT)).thenReturn(context);
final LegacyConfiguredObject converted = _portController.convertNextVersionLegacyConfiguredObject(nextVersionPort);
assertThat(converted, is(notNullValue()));
assertThat(converted.getCategory(), is(equalTo(PortController.TYPE)));
assertThat(converted.getAttribute(LegacyConfiguredObject.NAME), is(equalTo("test")));
assertThat(converted.getAttribute(LegacyConfiguredObject.TYPE), is(equalTo("HTTP")));
Object contextObject = converted.getAttribute(LegacyConfiguredObject.CONTEXT);
assertThat(contextObject, is(instanceOf(Map.class)));
Map<?, ?> convertedContext = (Map<?, ?>) contextObject;
assertThat(convertedContext.get("port.http.maximumQueuedRequests"), is(equalTo("2000")));
}
Aggregations