From commits-return-47832-archive-asf-public=cust-asf.ponee.io@qpid.apache.org Sun Feb 24 16:23:38 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id E6EF9180654 for ; Sun, 24 Feb 2019 17:23:37 +0100 (CET) Received: (qmail 41697 invoked by uid 500); 24 Feb 2019 16:23:37 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 41688 invoked by uid 99); 24 Feb 2019 16:23:37 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 24 Feb 2019 16:23:37 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 6DDDA82E8A; Sun, 24 Feb 2019 16:23:36 +0000 (UTC) Date: Sun, 24 Feb 2019 16:23:36 +0000 To: "commits@qpid.apache.org" Subject: [qpid-broker-j] branch master updated: QPID-8280:[Broker-J] Fix legacy binding REST API for version 6.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <155102541640.23048.17947586085612162500@gitbox.apache.org> From: orudyy@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: qpid-broker-j X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: b84bfe722194dd317d4c8dd7df65df1e15b7128b X-Git-Newrev: 71de4a370d21e5fe594e4fbdb695b11f1eb432e1 X-Git-Rev: 71de4a370d21e5fe594e4fbdb695b11f1eb432e1 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated 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 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 exchangePath = path.subList(0, hierarchy.size() - 3); + final List exchangePath = path.subList(0, hierarchy.size() - 2); final LegacyConfiguredObject nextVersionExchange = getNextVersionObject(root, exchangePath, ExchangeController.TYPE); - final List queuePath = new ArrayList<>(path.subList(0, hierarchy.size() - 4)); + final List 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 ids = parameters.get(GenericLegacyConfiguredObject.ID); - final List exchangePath = path.subList(0, hierarchy.size() - 3); + final List 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 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> bindings = getHelper().getJsonAsList("queue/myqueue/getPublishingLinks"); + assertThat(bindings, is(notNullValue())); + + Map 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 findBindingByName(final List> bindings, final String name) + { + return bindings.stream().filter(b -> name.equals(b.get("name"))).findFirst().orElse(null); + } + + @Test + public void get() throws Exception + { + Map arguments = Collections.singletonMap(AMQPFilterTypes.JMS_SELECTOR.getValue(), "1<2"); + Map 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> bindings = getHelper().getJsonAsList("/api/v6.1/binding/amq.direct/myqueue/foo"); + assertThat(bindings, is(notNullValue())); + assertThat(bindings.size(), is(equalTo(1))); + + Map 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 arguments = Collections.singletonMap(AMQPFilterTypes.JMS_SELECTOR.getValue(), "1<2"); + Map 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> bindings = getHelper().getJsonAsList("queue/myqueue/getPublishingLinks"); + assertThat(bindings, is(notNullValue())); + Map 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