Search in sources :

Example 26 with LegacyConfiguredObject

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")));
}
Also used : LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) Test(org.junit.Test)

Example 27 with LegacyConfiguredObject

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)));
}
Also used : AlternateBinding(org.apache.qpid.server.model.AlternateBinding) Binding(org.apache.qpid.server.model.Binding) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) AlternateBinding(org.apache.qpid.server.model.AlternateBinding) Test(org.junit.Test)

Example 28 with LegacyConfiguredObject

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));
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) HashMap(java.util.HashMap) Map(java.util.Map)

Example 29 with LegacyConfiguredObject

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);
}
Also used : LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) ManagementException(org.apache.qpid.server.management.plugin.ManagementException) HashMap(java.util.HashMap) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 30 with LegacyConfiguredObject

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")));
}
Also used : LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) HashMap(java.util.HashMap) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

LegacyConfiguredObject (org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject)37 Test (org.junit.Test)28 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)22 Collection (java.util.Collection)11 ManagementResponse (org.apache.qpid.server.management.plugin.ManagementResponse)10 HashMap (java.util.HashMap)9 List (java.util.List)7 Map (java.util.Map)7 ControllerManagementResponse (org.apache.qpid.server.management.plugin.controller.ControllerManagementResponse)7 GenericLegacyConfiguredObject (org.apache.qpid.server.management.plugin.controller.GenericLegacyConfiguredObject)6 Binding (org.apache.qpid.server.model.Binding)5 ManagementRequest (org.apache.qpid.server.management.plugin.ManagementRequest)4 LinkedHashMap (java.util.LinkedHashMap)3 CategoryController (org.apache.qpid.server.management.plugin.controller.CategoryController)3 AlternateBinding (org.apache.qpid.server.model.AlternateBinding)3 Broker (org.apache.qpid.server.model.Broker)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 ArrayList (java.util.ArrayList)2 UUID (java.util.UUID)2 ManagementException (org.apache.qpid.server.management.plugin.ManagementException)2