You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2019/02/24 16:23:36 UTC
[qpid-broker-j] branch master updated: QPID-8280:[Broker-J] Fix
legacy binding REST API for version 6.1
This is an automated email from the ASF dual-hosted git repository.
orudyy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-broker-j.git
The following commit(s) were added to refs/heads/master by this push:
new 71de4a3 QPID-8280:[Broker-J] Fix legacy binding REST API for version 6.1
71de4a3 is described below
commit 71de4a370d21e5fe594e4fbdb695b11f1eb432e1
Author: Alex Rudyy <or...@apache.org>
AuthorDate: Sun Feb 24 16:23:20 2019 +0000
QPID-8280:[Broker-J] Fix legacy binding REST API for version 6.1
---
.../v6_1/category/BindingController.java | 6 +-
.../apache/qpid/tests/http/v6_1/BindingTest.java | 131 +++++++++++++++++++++
2 files changed, 134 insertions(+), 3 deletions(-)
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BindingController.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BindingController.java
index a117d96..3a60a49 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BindingController.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BindingController.java
@@ -145,10 +145,10 @@ public class BindingController implements CategoryController
"Queue is required for binding creation. Please specify queue either in path or in binding attributes");
}
- final List<String> exchangePath = path.subList(0, hierarchy.size() - 3);
+ final List<String> exchangePath = path.subList(0, hierarchy.size() - 2);
final LegacyConfiguredObject
nextVersionExchange = getNextVersionObject(root, exchangePath, ExchangeController.TYPE);
- final List<String> queuePath = new ArrayList<>(path.subList(0, hierarchy.size() - 4));
+ final List<String> queuePath = new ArrayList<>(path.subList(0, hierarchy.size() - 3));
queuePath.add(queueName);
final LegacyConfiguredObject nextVersionQueue =
getNextVersionObject(root, queuePath, QueueController.TYPE);
@@ -222,7 +222,7 @@ public class BindingController implements CategoryController
final String bindingName = path.size() == hierarchy.size() ? path.get(hierarchy.size() - 1) : null;
final String queueName = path.get(hierarchy.size() - 2);
final List<String> ids = parameters.get(GenericLegacyConfiguredObject.ID);
- final List<String> exchangePath = path.subList(0, hierarchy.size() - 3);
+ final List<String> exchangePath = path.subList(0, hierarchy.size() - 2);
final LegacyConfiguredObject exchange = getNextVersionObject(root, exchangePath, ExchangeController.TYPE);
diff --git a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/v6_1/BindingTest.java b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/v6_1/BindingTest.java
new file mode 100644
index 0000000..0b784ba
--- /dev/null
+++ b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/v6_1/BindingTest.java
@@ -0,0 +1,131 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.tests.http.v6_1;
+
+import static javax.servlet.http.HttpServletResponse.SC_CREATED;
+import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
+import static javax.servlet.http.HttpServletResponse.SC_OK;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.qpid.server.filter.AMQPFilterTypes;
+import org.apache.qpid.tests.http.HttpRequestConfig;
+import org.apache.qpid.tests.http.HttpTestBase;
+
+@HttpRequestConfig
+public class BindingTest extends HttpTestBase
+{
+ private static final String QUEUE_NAME = "myqueue";
+
+ @Before
+ public void setUp()
+ {
+ getBrokerAdmin().createQueue(QUEUE_NAME);
+ }
+
+ @Test
+ public void bind() throws Exception
+ {
+ Map<String, String> arguments = Collections.singletonMap(AMQPFilterTypes.JMS_SELECTOR.getValue(), "1<2");
+ getHelper().submitRequest("/api/v6.1/binding/amq.direct/myqueue/foo",
+ "PUT",
+ Collections.singletonMap("arguments",
+ arguments),
+ SC_CREATED);
+ List<Map<String, Object>> bindings = getHelper().getJsonAsList("queue/myqueue/getPublishingLinks");
+ assertThat(bindings, is(notNullValue()));
+
+ Map<String, Object> binding = findBindingByName(bindings, "foo");
+ assertThat(binding, is(notNullValue()));
+
+ assertThat(binding.get("name"), is(equalTo("foo")));
+ assertThat(binding.get("arguments"), is(notNullValue()));
+
+ Object args = binding.get("arguments");
+ assertThat(args, is(instanceOf(Map.class)));
+ assertThat(args, is(equalTo(arguments)));
+ }
+
+ private Map<String, Object> findBindingByName(final List<Map<String, Object>> bindings, final String name)
+ {
+ return bindings.stream().filter(b -> name.equals(b.get("name"))).findFirst().orElse(null);
+ }
+
+ @Test
+ public void get() throws Exception
+ {
+ Map<String, String> arguments = Collections.singletonMap(AMQPFilterTypes.JMS_SELECTOR.getValue(), "1<2");
+ Map<String, Object> bindOperationArguments = new HashMap<>();
+ bindOperationArguments.put("destination", "myqueue");
+ bindOperationArguments.put("bindingKey", "foo");
+ bindOperationArguments.put("arguments", arguments);
+ getHelper().submitRequest("exchange/amq.direct/bind",
+ "POST",
+ bindOperationArguments,
+ SC_OK);
+ List<Map<String, Object>> bindings = getHelper().getJsonAsList("/api/v6.1/binding/amq.direct/myqueue/foo");
+ assertThat(bindings, is(notNullValue()));
+ assertThat(bindings.size(), is(equalTo(1)));
+
+ Map<String, Object> binding = bindings.get(0);
+ assertThat(binding, is(notNullValue()));
+ assertThat(binding.get("name"), is(equalTo("foo")));
+ assertThat(binding.get("queue"), is(equalTo("myqueue")));
+ assertThat(binding.get("arguments"), is(notNullValue()));
+
+ Object args = binding.get("arguments");
+ assertThat(args, is(instanceOf(Map.class)));
+ assertThat(args, is(equalTo(arguments)));
+ }
+
+ @Test
+ public void delete() throws Exception
+ {
+ Map<String, String> arguments = Collections.singletonMap(AMQPFilterTypes.JMS_SELECTOR.getValue(), "1<2");
+ Map<String, Object> bindOperationArguments = new HashMap<>();
+ bindOperationArguments.put("destination", "myqueue");
+ bindOperationArguments.put("bindingKey", "foo");
+ bindOperationArguments.put("arguments", arguments);
+ getHelper().submitRequest("exchange/amq.direct/bind",
+ "POST",
+ bindOperationArguments,
+ SC_OK);
+ getHelper().submitRequest("/api/v6.1/binding/amq.direct/myqueue/foo", "DELETE");
+ List<Map<String, Object>> bindings = getHelper().getJsonAsList("queue/myqueue/getPublishingLinks");
+ assertThat(bindings, is(notNullValue()));
+ Map<String, Object> binding = findBindingByName(bindings, "foo");
+ assertThat(binding, is(nullValue()));
+
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org