From commits-return-43743-archive-asf-public=cust-asf.ponee.io@qpid.apache.org Fri Feb 9 12:31:14 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 6BB88180654 for ; Fri, 9 Feb 2018 12:31:14 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 5C53C160C2E; Fri, 9 Feb 2018 11:31:14 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5CD2B160C5E for ; Fri, 9 Feb 2018 12:31:12 +0100 (CET) Received: (qmail 11230 invoked by uid 500); 9 Feb 2018 11:31:11 -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 11214 invoked by uid 99); 9 Feb 2018 11:31:11 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Feb 2018 11:31:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BC211E0779; Fri, 9 Feb 2018 11:31:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kwall@apache.org To: commits@qpid.apache.org Date: Fri, 09 Feb 2018 11:31:11 -0000 Message-Id: <6094f2a538d74b888122d00d705dfc13@git.apache.org> In-Reply-To: <18cf15ab1f1147c1989b5e61235ff120@git.apache.org> References: <18cf15ab1f1147c1989b5e61235ff120@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/3] qpid-broker-j git commit: QPID-8083 [System Tests] [REST/HTTP] Remove many superfluous tests QPID-8083 [System Tests] [REST/HTTP] Remove many superfluous tests Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/81d81723 Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/81d81723 Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/81d81723 Branch: refs/heads/master Commit: 81d81723b65895b234ad639ef922baaf8de150df Parents: 5ea1c70 Author: Keith Wall Authored: Thu Feb 8 18:58:06 2018 +0000 Committer: Keith Wall Committed: Fri Feb 9 11:30:52 2018 +0000 ---------------------------------------------------------------------- .../apache/qpid/tests/http/HttpTestBase.java | 5 + .../endtoend/state/VirtualHostRecoveryTest.java | 139 +++++ .../http/endtoend/store/SpiltStoreTest.java | 146 +++++ .../qpid/tests/http/rest/model/CreateTest.java | 27 + .../qpid/server/store/SplitStoreTest.java | 112 ---- .../qpid/systest/rest/VirtualHostRestTest.java | 619 ------------------- test-profiles/CPPExcludes | 3 - test-profiles/JavaJsonExcludes | 1 - test-profiles/JavaTransientExcludes | 1 - 9 files changed, 317 insertions(+), 736 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/81d81723/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestBase.java ---------------------------------------------------------------------- diff --git a/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestBase.java b/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestBase.java index 7230400..4bc2526 100644 --- a/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestBase.java +++ b/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestBase.java @@ -83,6 +83,11 @@ public abstract class HttpTestBase extends BrokerAdminUsingTestBase return getClass().getSimpleName() + "_" + _testName.getMethodName(); } + protected String getVirtualHostNode() + { + return getClass().getSimpleName() + "_" + _testName.getMethodName(); + } + public HttpTestHelper getHelper() { return _helper; http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/81d81723/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/state/VirtualHostRecoveryTest.java ---------------------------------------------------------------------- diff --git a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/state/VirtualHostRecoveryTest.java b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/state/VirtualHostRecoveryTest.java new file mode 100644 index 0000000..1443297 --- /dev/null +++ b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/state/VirtualHostRecoveryTest.java @@ -0,0 +1,139 @@ +/* + * 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.endtoend.state; + +import static javax.servlet.http.HttpServletResponse.SC_OK; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; +import static org.junit.Assume.assumeThat; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.Session; +import javax.jms.TextMessage; + +import com.fasterxml.jackson.core.type.TypeReference; +import org.junit.Before; +import org.junit.Test; + +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.systests.Utils; +import org.apache.qpid.tests.http.HttpRequestConfig; +import org.apache.qpid.tests.http.HttpTestBase; + +public class VirtualHostRecoveryTest extends HttpTestBase +{ + private static final String TEST_QUEUE = "testQueue"; + + @Before + public void setUp() throws Exception + { + getBrokerAdmin().createQueue(TEST_QUEUE); + assumeThat(getBrokerAdmin().supportsRestart(), is(true)); + } + + @Test + @HttpRequestConfig(useVirtualHostAsHost = true) + public void virtualHostRestart() throws Exception + { + final TextMessage sentMessage = putMessageOnQueue(); + + final String url = "virtualhost"; + changeState(url, "STOPPED"); + assertState(url, "STOPPED"); + + changeState(url, "ACTIVE"); + assertState(url, "ACTIVE"); + + verifyMessagesOnQueue(sentMessage); + } + + @Test + @HttpRequestConfig(useVirtualHostAsHost = false) + public void virtualHostNodeRestart() throws Exception + { + final TextMessage sentMessage = putMessageOnQueue(); + + final String url = String.format("virtualhostnode/%s", getVirtualHostNode()); + changeState(url, "STOPPED"); + assertState(url, "STOPPED"); + + changeState(url, "ACTIVE"); + assertState(url, "ACTIVE"); + + verifyMessagesOnQueue(sentMessage); + } + + private TextMessage putMessageOnQueue() throws Exception + { + Connection connection = getConnection(); + try + { + Session session = connection.createSession(true, Session.SESSION_TRANSACTED); + List _expectedMessages = Utils.sendMessages(session, session.createQueue(TEST_QUEUE), 1); + return (TextMessage) _expectedMessages.get(0); + } + finally + { + connection.close(); + } + } + + private void verifyMessagesOnQueue(final TextMessage expectedMessage) throws Exception + { + Connection connection = getConnection(); + try + { + connection.start(); + Session session = connection.createSession(true, Session.SESSION_TRANSACTED); + MessageConsumer consumer = session.createConsumer(session.createQueue(TEST_QUEUE)); + + final TextMessage receivedMessage = (TextMessage) consumer.receive(getReceiveTimeout()); + assertThat(receivedMessage, is(notNullValue())); + assertThat(receivedMessage.getJMSMessageID(), is(equalTo(expectedMessage.getJMSMessageID()))); + assertThat(receivedMessage.getText(), is(equalTo(expectedMessage.getText()))); + } + finally + { + connection.close(); + } + } + + private void changeState(final String url, final String desiredState) throws Exception + { + Map attributes = Collections.singletonMap(ConfiguredObject.DESIRED_STATE, desiredState); + getHelper().submitRequest(url, "POST", attributes, SC_OK); + } + + private void assertState(final String url, final String expectedActualState) throws Exception + { + Map object = getHelper().getJson(url, new TypeReference>() {}, SC_OK); + final String actualState = (String) object.get(ConfiguredObject.STATE); + assertThat(actualState, is(equalTo(expectedActualState))); + } + +} http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/81d81723/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/store/SpiltStoreTest.java ---------------------------------------------------------------------- diff --git a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/store/SpiltStoreTest.java b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/store/SpiltStoreTest.java new file mode 100644 index 0000000..9b3a353 --- /dev/null +++ b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/store/SpiltStoreTest.java @@ -0,0 +1,146 @@ +/* + * 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.endtoend.store; + +import static javax.servlet.http.HttpServletResponse.SC_CREATED; +import static javax.servlet.http.HttpServletResponse.SC_OK; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; +import static org.junit.Assume.assumeThat; + +import java.io.File; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.Session; +import javax.jms.TextMessage; + +import com.fasterxml.jackson.core.type.TypeReference; +import org.junit.Before; +import org.junit.Test; + +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.VirtualHost; +import org.apache.qpid.server.virtualhost.ProvidedStoreVirtualHost; +import org.apache.qpid.server.virtualhost.ProvidedStoreVirtualHostImpl; +import org.apache.qpid.systests.Utils; +import org.apache.qpid.tests.http.HttpRequestConfig; +import org.apache.qpid.tests.http.HttpTestBase; + +@HttpRequestConfig(useVirtualHostAsHost = false) +public class SpiltStoreTest extends HttpTestBase +{ + private static final String TEST_QUEUE = "testQueue"; + + @Before + public void setUp() throws Exception + { + assumeThat(getBrokerAdmin().supportsRestart(), is(true)); + } + + @Test + public void splitStore() throws Exception + { + final String url = String.format("virtualhost/%s/%s", getVirtualHostNode(), getVirtualHost()); + getHelper().submitRequest(url, "DELETE", SC_OK); + + final Map attributes = new HashMap<>(); + attributes.put(VirtualHost.TYPE, System.getProperty("virtualhostnode.type")); + getHelper().submitRequest(url, "PUT", attributes, SC_CREATED); + + final Map virtualHost = getHelper().getJson(url, + new TypeReference>() {}, + SC_OK); + final String storePath = (String) virtualHost.get("storePath"); + assertThat(new File(storePath).exists(), is(equalTo(true))); + + getBrokerAdmin().createQueue(TEST_QUEUE); + final TextMessage sentMessage = putMessageOnQueue(); + + getBrokerAdmin().restart(); + + verifyMessagesOnQueue(sentMessage); + + getHelper().submitRequest(url, "DELETE", SC_OK); + assertThat(new File(storePath).exists(), is(equalTo(false))); + + attributes.put(VirtualHost.TYPE, ProvidedStoreVirtualHostImpl.VIRTUAL_HOST_TYPE); + getHelper().submitRequest(url, "PUT", attributes, SC_CREATED); + + getBrokerAdmin().createQueue(TEST_QUEUE); + verifyMessagesOnQueue( putMessageOnQueue()); + } + + private TextMessage putMessageOnQueue() throws Exception + { + Connection connection = getConnection(); + try + { + Session session = connection.createSession(true, Session.SESSION_TRANSACTED); + List _expectedMessages = Utils.sendMessages(session, session.createQueue(TEST_QUEUE), 1); + return (TextMessage) _expectedMessages.get(0); + } + finally + { + connection.close(); + } + } + + private void verifyMessagesOnQueue(final TextMessage expectedMessage) throws Exception + { + Connection connection = getConnection(); + try + { + connection.start(); + Session session = connection.createSession(true, Session.SESSION_TRANSACTED); + MessageConsumer consumer = session.createConsumer(session.createQueue(TEST_QUEUE)); + + final TextMessage receivedMessage = (TextMessage) consumer.receive(getReceiveTimeout()); + assertThat(receivedMessage, is(notNullValue())); + assertThat(receivedMessage.getJMSMessageID(), is(equalTo(expectedMessage.getJMSMessageID()))); + assertThat(receivedMessage.getText(), is(equalTo(expectedMessage.getText()))); + } + finally + { + connection.close(); + } + } + + private void changeState(final String url, final String desiredState) throws Exception + { + Map attributes = Collections.singletonMap(ConfiguredObject.DESIRED_STATE, desiredState); + getHelper().submitRequest(url, "POST", attributes, SC_OK); + } + + private void assertState(final String url, final String expectedActualState) throws Exception + { + Map object = getHelper().getJson(url, new TypeReference>() {}, SC_OK); + final String actualState = (String) object.get(ConfiguredObject.STATE); + assertThat(actualState, is(equalTo(expectedActualState))); + } + +} http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/81d81723/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/CreateTest.java ---------------------------------------------------------------------- diff --git a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/CreateTest.java b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/CreateTest.java index a09d9ad..d3e5683 100644 --- a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/CreateTest.java +++ b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/CreateTest.java @@ -22,17 +22,21 @@ package org.apache.qpid.tests.http.rest.model; import static javax.servlet.http.HttpServletResponse.SC_CREATED; import static javax.servlet.http.HttpServletResponse.SC_METHOD_NOT_ALLOWED; import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; +import static javax.servlet.http.HttpServletResponse.SC_OK; import static org.apache.qpid.server.management.plugin.servlet.rest.AbstractServlet.SC_UNPROCESSABLE_ENTITY; import static org.hamcrest.CoreMatchers.endsWith; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.fasterxml.jackson.core.type.TypeReference; import org.junit.Test; import org.apache.qpid.server.logging.logback.VirtualHostFileLogger; @@ -44,6 +48,8 @@ import org.apache.qpid.tests.http.HttpRequestConfig; @HttpRequestConfig public class CreateTest extends HttpTestBase { + private static final String UTF_8 = StandardCharsets.UTF_8.toString(); + @Test public void create() throws Exception { @@ -129,6 +135,27 @@ public class CreateTest extends HttpTestBase getHelper().submitRequest(childUrl, "PUT", childAttrs, SC_UNPROCESSABLE_ENTITY); } + @Test + public void objectsWithSlashes() throws Exception + { + String queueName = "testQueue/with/slashes"; + String queueNameEncoded = URLEncoder.encode(queueName, UTF_8); + String queueNameDoubleEncoded = URLEncoder.encode(queueNameEncoded, UTF_8); + String queueUrl = "queue/" + queueNameDoubleEncoded; + + Map> headers = new HashMap<>(); + int responseCode = getHelper().submitRequest(queueUrl, "PUT", Collections.emptyMap(), headers); + assertThat(responseCode, is(equalTo(SC_CREATED))); + List location = headers.get("Location"); + assertThat(location.size(), is(equalTo(1))); + assertThat(location.get(0), endsWith(queueUrl)); + + final Map queue = getHelper().getJson(queueUrl, + new TypeReference>() {}, SC_OK); + + assertThat(queue.get(ConfiguredObject.NAME), is(equalTo(queueName))); + } + private void createToParent(final String method) throws Exception { final String parentUrl = "queue"; http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/81d81723/systests/src/test/java/org/apache/qpid/server/store/SplitStoreTest.java ---------------------------------------------------------------------- diff --git a/systests/src/test/java/org/apache/qpid/server/store/SplitStoreTest.java b/systests/src/test/java/org/apache/qpid/server/store/SplitStoreTest.java deleted file mode 100644 index 9217ccd..0000000 --- a/systests/src/test/java/org/apache/qpid/server/store/SplitStoreTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * - * 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.server.store; - -import java.util.Collections; -import java.util.Map; - -import javax.jms.Connection; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.Queue; -import javax.jms.Session; - -import org.apache.qpid.configuration.ClientProperties; -import org.apache.qpid.server.model.VirtualHostNode; -import org.apache.qpid.server.virtualhostnode.AbstractVirtualHostNode; -import org.apache.qpid.server.virtualhostnode.JsonVirtualHostNode; -import org.apache.qpid.server.virtualhostnode.JsonVirtualHostNodeImpl; -import org.apache.qpid.test.utils.QpidBrokerTestCase; -import org.apache.qpid.test.utils.TestBrokerConfiguration; - -public class SplitStoreTest extends QpidBrokerTestCase -{ - private String _messageStorePath; - private String _configStorePath; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - - String virtualHostWorkDir = "${json:qpid.work_dir}${json:file.separator}${this:name}${json:file.separator}"; - _messageStorePath = virtualHostWorkDir + "messageStore"; - _configStorePath = virtualHostWorkDir + "configStore"; - } - - @Override - public void startDefaultBroker() throws Exception - { - // Overridden to prevent QBTC starting the Broker. - } - - public void testJsonConfigurationStoreWithPersistentMessageStore() throws Exception - { - doTest(JsonVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE, getTestProfileVirtualHostNodeType()); - } - - public void testSeparateConfigurationAndMessageStoresOfTheSameType() throws Exception - { - doTest(getTestProfileVirtualHostNodeType(), getTestProfileVirtualHostNodeType()); - } - - private void configureAndStartBroker(String virtualHostNodeType, String virtualHostType) throws Exception - { - final String blueprint = String.format( - "{ \"type\" : \"%s\", \"storePath\" : \"%s\" }", virtualHostType, _messageStorePath); - final Map contextMap = Collections.singletonMap(AbstractVirtualHostNode.VIRTUALHOST_BLUEPRINT_CONTEXT_VAR, - blueprint); - - TestBrokerConfiguration config = getDefaultBrokerConfiguration(); - config.setObjectAttribute(VirtualHostNode.class, TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST, VirtualHostNode.TYPE, virtualHostNodeType); - config.setObjectAttribute(VirtualHostNode.class, TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST, VirtualHostNode.CONTEXT, contextMap); - config.setObjectAttribute(VirtualHostNode.class, TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST, JsonVirtualHostNode.STORE_PATH, _configStorePath); - - super.startDefaultBroker(); - } - - private void doTest(String nodeType, String path) throws Exception - { - configureAndStartBroker(nodeType, path); - - Connection connection = getConnection(); - Session session = connection.createSession(true, Session.SESSION_TRANSACTED); - Queue queue = createTestQueue(session); - sendMessage(session, queue, 1); - connection.close(); - - restartDefaultBroker(); - - setTestSystemProperty(ClientProperties.QPID_DECLARE_QUEUES_PROP_NAME, "false"); - connection = getConnection(); - connection.start(); - session = connection.createSession(true, Session.SESSION_TRANSACTED); - MessageConsumer consumer = session.createConsumer(queue); - Message message = consumer.receive(1000); - session.commit(); - - assertNotNull("Message was not received after first restart", message); - assertEquals("Unexpected message received after first restart", 0, message.getIntProperty(INDEX)); - - stopDefaultBroker(); - } - -} http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/81d81723/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java ---------------------------------------------------------------------- diff --git a/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java b/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java index e4b9559..fc15e1c 100644 --- a/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java +++ b/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java @@ -20,41 +20,22 @@ */ package org.apache.qpid.systest.rest; -import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; import static javax.servlet.http.HttpServletResponse.SC_OK; -import static org.apache.qpid.server.management.plugin.servlet.rest.AbstractServlet.SC_UNPROCESSABLE_ENTITY; import java.io.IOException; -import java.net.URLEncoder; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.Session; -import javax.servlet.http.HttpServletResponse; - -import org.junit.Assert; import org.apache.qpid.server.model.Exchange; -import org.apache.qpid.server.model.Queue; -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.queue.LastValueQueue; -import org.apache.qpid.server.queue.PriorityQueue; -import org.apache.qpid.server.queue.SortedQueue; import org.apache.qpid.server.virtualhost.NodeAutoCreationPolicy; import org.apache.qpid.server.virtualhost.QueueManagingVirtualHost; -import org.apache.qpid.server.virtualhost.derby.DerbyVirtualHostImpl; -import org.apache.qpid.server.virtualhostnode.JsonVirtualHostNodeImpl; public class VirtualHostRestTest extends QpidRestTestCase { - private static final String VIRTUALHOST_EXCHANGES_ATTRIBUTE = "exchanges"; - public static final String VIRTUALHOST_QUEUES_ATTRIBUTE = "queues"; - public static final String EMPTY_VIRTUALHOSTNODE_NAME = "emptyVHN"; private Connection _connection; @@ -66,159 +47,6 @@ public class VirtualHostRestTest extends QpidRestTestCase createTestVirtualHostNode(getDefaultBroker(), EMPTY_VIRTUALHOSTNODE_NAME, false); } - public void testGet() throws Exception - { - List> hosts = getRestTestHelper().getJsonAsList("virtualhost"); - assertNotNull("Hosts data cannot be null", hosts); - assertEquals("Unexpected number of hosts", EXPECTED_VIRTUALHOSTS.length, hosts.size()); - for (String hostName : EXPECTED_VIRTUALHOSTS) - { - Map host = getRestTestHelper().find("name", hostName, hosts); - Asserts.assertVirtualHost(hostName, host); - } - } - - public void testGetHost() throws Exception - { - // create AMQP connection to get connection JSON details - _connection = getConnection(); - Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - createTestQueue(session); - - Map hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test"); - Asserts.assertVirtualHost("test", hostDetails); - - @SuppressWarnings("unchecked") - Map statistics = (Map) hostDetails.get(Asserts.STATISTICS_ATTRIBUTE); - - assertEquals("Unexpected number of exchanges in statistics", EXPECTED_EXCHANGES.length, statistics.get( - "exchangeCount")); - assertEquals("Unexpected number of queues in statistics", 1, statistics.get("queueCount")); - assertEquals("Unexpected number of connections in statistics", 1, statistics.get("connectionCount")); - - - List> exchanges = getRestTestHelper().getJsonAsList("exchange/test"); - Asserts.assertVirtualHost("test", hostDetails); - - assertEquals("Unexpected number of exchanges", EXPECTED_EXCHANGES.length, exchanges.size()); - Asserts.assertDurableExchange("amq.fanout", "fanout", getRestTestHelper().find(Exchange.NAME, "amq.fanout", exchanges)); - Asserts.assertDurableExchange("amq.topic", "topic", getRestTestHelper().find(Exchange.NAME, "amq.topic", exchanges)); - Asserts.assertDurableExchange("amq.direct", "direct", getRestTestHelper().find(Exchange.NAME, "amq.direct", exchanges)); - Asserts.assertDurableExchange("amq.match", "headers", getRestTestHelper().find(Exchange.NAME, "amq.match", exchanges)); - - @SuppressWarnings("unchecked") - List> queues = getRestTestHelper().getJsonAsList("queue/test"); - assertEquals("Unexpected number of queues", 1, queues.size()); - Map queue = getRestTestHelper().find(Queue.NAME, getTestQueueName(), queues); - Asserts.assertQueue(getTestQueueName(), "standard", queue); - assertEquals("Unexpected value of queue attribute " + Queue.DURABLE, Boolean.TRUE, queue.get(Queue.DURABLE)); - - @SuppressWarnings("unchecked") - List> connections = getRestTestHelper().getJsonAsList("virtualhost/test/test/getConnections"); - assertEquals("Unexpected number of connections", 1, connections.size()); - Asserts.assertConnection(connections.get(0), isBroker10() ? 2 : 1); - } - - public void testCreateProvidedVirtualHost() throws Exception - { - Map requestData = submitVirtualHost(true, "PUT", HttpServletResponse.SC_CREATED); - String hostName = (String)requestData.get(VirtualHost.NAME); - - Map hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/" - + EMPTY_VIRTUALHOSTNODE_NAME - + "/" - + hostName - + "?depth=1"); - Asserts.assertVirtualHost(hostName, hostDetails); - - assertNewVirtualHost(hostDetails); - } - - public void testCreateVirtualHostByPutUsingParentURI() throws Exception - { - Map data = submitVirtualHost(true, "PUT", HttpServletResponse.SC_CREATED); - String hostName = (String)data.get(VirtualHost.NAME); - - String url = "virtualhost/" + EMPTY_VIRTUALHOSTNODE_NAME + "/" + hostName + "?depth=1"; - Map hostDetails = getRestTestHelper().getJsonAsMap(url); - Asserts.assertVirtualHost(hostName, hostDetails); - assertNewVirtualHost(hostDetails); - } - - public void testCreateVirtualHostByPostUsingParentURI() throws Exception - { - Map data = submitVirtualHost(true, "POST", HttpServletResponse.SC_CREATED); - String hostName = (String)data.get(VirtualHost.NAME); - - Map hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/" - + EMPTY_VIRTUALHOSTNODE_NAME - + "/" - + hostName - + "?depth=1"); - Asserts.assertVirtualHost(hostName, hostDetails); - assertNewVirtualHost(hostDetails); - } - - public void testCreateVirtualHostByPutUsingVirtualHostURI() throws Exception - { - Map data = submitVirtualHost(false, "PUT", HttpServletResponse.SC_CREATED); - String hostName = (String)data.get(VirtualHost.NAME); - Map hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/" - + EMPTY_VIRTUALHOSTNODE_NAME - + "/" - + hostName - + "?depth=1"); - Asserts.assertVirtualHost(hostName, hostDetails); - - assertNewVirtualHost(hostDetails); - - } - - public void testCreateVirtualHostByPostUsingVirtualHostURI() throws Exception - { - Map data = submitVirtualHost(false, "POST", SC_NOT_FOUND); - - String hostName = (String)data.get(VirtualHost.NAME); - getRestTestHelper().submitRequest("virtualhost/" + EMPTY_VIRTUALHOSTNODE_NAME + "/" + hostName, - "GET", SC_NOT_FOUND); - } - - public void testDeleteHost() throws Exception - { - getRestTestHelper().submitRequest("virtualhost/" + TEST3_VIRTUALHOST + "/" + TEST3_VIRTUALHOST, - "DELETE", - SC_OK); - - List> hosts = getRestTestHelper().getJsonAsList("virtualhost/" + TEST3_VIRTUALHOST); - assertEquals("Host should be deleted", 0, hosts.size()); - } - - public void testUpdateByPut() throws Exception - { - assertVirtualHostUpdate("PUT"); - } - - public void testUpdateByPost() throws Exception - { - assertVirtualHostUpdate("POST"); - } - - private void assertVirtualHostUpdate(String method) throws IOException - { - String hostToUpdate = TEST3_VIRTUALHOST; - String restHostUrl = "virtualhost/" + hostToUpdate + "/" + hostToUpdate; - - Map hostDetails = getRestTestHelper().getJsonAsMap(restHostUrl); - Asserts.assertVirtualHost(hostToUpdate, hostDetails); - - Map newAttributes = Collections.singletonMap(VirtualHost.DESCRIPTION, "This is a virtual host"); - getRestTestHelper().submitRequest(restHostUrl, method, newAttributes, SC_OK); - - Map rereadHostDetails = getRestTestHelper().getJsonAsMap(restHostUrl); - Asserts.assertVirtualHost(hostToUpdate, rereadHostDetails); - assertEquals("This is a virtual host", rereadHostDetails.get(VirtualHost.DESCRIPTION)); - } - public void testAddValidAutoCreationPolicies() throws IOException { String hostToUpdate = TEST3_VIRTUALHOST; @@ -371,452 +199,5 @@ public class VirtualHostRestTest extends QpidRestTestCase assertTrue("Retrieved node policies is not empty", ((List)retrievedPolicies).isEmpty()); } - public void testMutateState() throws Exception - { - String restHostUrl = "virtualhost/" + TEST1_VIRTUALHOST + "/" + TEST1_VIRTUALHOST; - - _restTestHelper.waitForAttributeChanged(restHostUrl, VirtualHost.STATE, "ACTIVE"); - assertActualAndDesireStates(restHostUrl, "ACTIVE", "ACTIVE"); - - Map newAttributes = Collections.singletonMap(VirtualHost.DESIRED_STATE, "STOPPED"); - getRestTestHelper().submitRequest(restHostUrl, "PUT", newAttributes, SC_OK); - - _restTestHelper.waitForAttributeChanged(restHostUrl, VirtualHost.STATE, "STOPPED"); - assertActualAndDesireStates(restHostUrl, "STOPPED", "STOPPED"); - - newAttributes = Collections.singletonMap(VirtualHost.DESIRED_STATE, "ACTIVE"); - getRestTestHelper().submitRequest(restHostUrl, "PUT", newAttributes, SC_OK); - - _restTestHelper.waitForAttributeChanged(restHostUrl, VirtualHost.STATE, "ACTIVE"); - - assertActualAndDesireStates(restHostUrl, "ACTIVE", "ACTIVE"); - } - - public void testMutateStateOfVirtualHostWithQueuesAndMessages() throws Exception - { - String testQueueName = getTestQueueName(); - String restHostUrl = "virtualhost/" + TEST1_VIRTUALHOST + "/" + TEST1_VIRTUALHOST; - String restQueueUrl = "queue/" + TEST1_VIRTUALHOST + "/" + TEST1_VIRTUALHOST + "/" + testQueueName; - - _restTestHelper.waitForAttributeChanged(restHostUrl, VirtualHost.STATE, "ACTIVE"); - assertActualAndDesireStates(restHostUrl, "ACTIVE", "ACTIVE"); - - Connection connection = getConnection(); - Session session = connection.createSession(true, Session.SESSION_TRANSACTED); - Destination dest = createTestQueue(session, testQueueName); - session.createProducer(dest).send(session.createTextMessage("My test message")); - session.commit(); - connection.close(); - - assertQueueDepth(restQueueUrl, "Unexpected number of messages before stopped", 1); - - Map newAttributes = Collections.singletonMap(VirtualHost.DESIRED_STATE, "STOPPED"); - getRestTestHelper().submitRequest(restHostUrl, "PUT", newAttributes, SC_OK); - - _restTestHelper.waitForAttributeChanged(restHostUrl, VirtualHost.STATE, "STOPPED"); - assertActualAndDesireStates(restHostUrl, "STOPPED", "STOPPED"); - - newAttributes = Collections.singletonMap(VirtualHost.DESIRED_STATE, "ACTIVE"); - getRestTestHelper().submitRequest(restHostUrl, "PUT", newAttributes, SC_OK); - - _restTestHelper.waitForAttributeChanged(restHostUrl, VirtualHost.STATE, "ACTIVE"); - - assertActualAndDesireStates(restHostUrl, "ACTIVE", "ACTIVE"); - - assertQueueDepth(restQueueUrl, "Unexpected number of messages after restart", 1); - } - - public void testRecoverVirtualHostInDesiredStateStoppedWithDescription() throws Exception - { - String hostToUpdate = TEST3_VIRTUALHOST; - String restUrl = "virtualhost/" + hostToUpdate + "/" + hostToUpdate; - - assertActualAndDesireStates(restUrl, "ACTIVE", "ACTIVE"); - - Map newAttributes = new HashMap<>(); - newAttributes.put(VirtualHost.DESIRED_STATE, "STOPPED"); - newAttributes.put(VirtualHost.DESCRIPTION, "My description"); - - getRestTestHelper().submitRequest(restUrl, "PUT", newAttributes, SC_OK); - - assertActualAndDesireStates(restUrl, "STOPPED", "STOPPED"); - - restartDefaultBroker(); - - Map rereadVirtualhost = getRestTestHelper().getJsonAsMap(restUrl); - Asserts.assertActualAndDesiredState("STOPPED", "STOPPED", rereadVirtualhost); - - assertEquals("Unexpected description after restart", "My description", rereadVirtualhost.get(VirtualHost.DESCRIPTION)); - } - - public void testPutCreateQueue() throws Exception - { - String queueName = getTestQueueName(); - - createQueue(queueName + "-standard", "standard", null); - - Map sortedQueueAttributes = new HashMap(); - sortedQueueAttributes.put(SortedQueue.SORT_KEY, "sortme"); - createQueue(queueName + "-sorted", "sorted", sortedQueueAttributes); - - Map priorityQueueAttributes = new HashMap(); - priorityQueueAttributes.put(PriorityQueue.PRIORITIES, 10); - createQueue(queueName + "-priority", "priority", priorityQueueAttributes); - - Map lvqQueueAttributes = new HashMap(); - lvqQueueAttributes.put(LastValueQueue.LVQ_KEY, "LVQ"); - createQueue(queueName + "-lvq", "lvq", lvqQueueAttributes); - - Map hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1"); - - @SuppressWarnings("unchecked") - List> queues = (List>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE); - Map standardQueue = getRestTestHelper().find(Queue.NAME, queueName + "-standard" , queues); - Map sortedQueue = getRestTestHelper().find(Queue.NAME, queueName + "-sorted" , queues); - Map priorityQueue = getRestTestHelper().find(Queue.NAME, queueName + "-priority" , queues); - Map lvqQueue = getRestTestHelper().find(Queue.NAME, queueName + "-lvq" , queues); - - Asserts.assertQueue(queueName + "-standard", "standard", standardQueue); - Asserts.assertQueue(queueName + "-sorted", "sorted", sortedQueue); - Asserts.assertQueue(queueName + "-priority", "priority", priorityQueue); - Asserts.assertQueue(queueName + "-lvq", "lvq", lvqQueue); - - assertEquals("Unexpected value of queue attribute " + Queue.DURABLE, Boolean.TRUE, standardQueue.get(Queue.DURABLE)); - assertEquals("Unexpected value of queue attribute " + Queue.DURABLE, Boolean.TRUE, sortedQueue.get(Queue.DURABLE)); - assertEquals("Unexpected value of queue attribute " + Queue.DURABLE, Boolean.TRUE, priorityQueue.get(Queue.DURABLE)); - assertEquals("Unexpected value of queue attribute " + Queue.DURABLE, Boolean.TRUE, lvqQueue.get(Queue.DURABLE)); - - assertEquals("Unexpected sorted key attribute", "sortme", sortedQueue.get(SortedQueue.SORT_KEY)); - assertEquals("Unexpected lvq key attribute", "LVQ", lvqQueue.get(LastValueQueue.LVQ_KEY)); - assertEquals("Unexpected priorities key attribute", 10, priorityQueue.get(PriorityQueue.PRIORITIES)); - } - - public void testPutCreateExchange() throws Exception - { - String exchangeName = getTestName(); - - createExchange(exchangeName + "-direct", "direct"); - createExchange(exchangeName + "-topic", "topic"); - createExchange(exchangeName + "-headers", "headers"); - createExchange(exchangeName + "-fanout", "fanout"); - - Map hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1"); - - @SuppressWarnings("unchecked") - List> exchanges = (List>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_EXCHANGES_ATTRIBUTE); - Map directExchange = getRestTestHelper().find(Queue.NAME, exchangeName + "-direct" , exchanges); - Map topicExchange = getRestTestHelper().find(Queue.NAME, exchangeName + "-topic" , exchanges); - Map headersExchange = getRestTestHelper().find(Queue.NAME, exchangeName + "-headers" , exchanges); - Map fanoutExchange = getRestTestHelper().find(Queue.NAME, exchangeName + "-fanout" , exchanges); - - Asserts.assertDurableExchange(exchangeName + "-direct", "direct", directExchange); - Asserts.assertDurableExchange(exchangeName + "-topic", "topic", topicExchange); - Asserts.assertDurableExchange(exchangeName + "-headers", "headers", headersExchange); - Asserts.assertDurableExchange(exchangeName + "-fanout", "fanout", fanoutExchange); - - assertEquals("Unexpected value of queue attribute " + Exchange.DURABLE, Boolean.TRUE, directExchange.get(Exchange.DURABLE)); - assertEquals("Unexpected value of queue attribute " + Exchange.DURABLE, Boolean.TRUE, topicExchange.get(Exchange.DURABLE)); - assertEquals("Unexpected value of queue attribute " + Exchange.DURABLE, Boolean.TRUE, headersExchange.get(Exchange.DURABLE)); - assertEquals("Unexpected value of queue attribute " + Exchange.DURABLE, Boolean.TRUE, fanoutExchange.get(Exchange.DURABLE)); - } - - public void testPutCreateLVQWithoutKey() throws Exception - { - String queueName = getTestQueueName()+ "-lvq"; - createQueue(queueName, "lvq", null); - - Map hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1"); - - @SuppressWarnings("unchecked") - List> queues = (List>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE); - Map lvqQueue = getRestTestHelper().find(Queue.NAME, queueName , queues); - - Asserts.assertQueue(queueName , "lvq", lvqQueue); - assertEquals("Unexpected value of queue attribute " + Queue.DURABLE, Boolean.TRUE, lvqQueue.get(Queue.DURABLE)); - assertEquals("Unexpected lvq key attribute", LastValueQueue.DEFAULT_LVQ_KEY, lvqQueue.get(LastValueQueue.LVQ_KEY)); - } - - public void testPutCreateSortedQueueWithoutKey() throws Exception - { - String queueName = getTestQueueName() + "-sorted"; - int responseCode = tryCreateQueue(queueName, "sorted", null); - assertEquals("Unexpected response code", SC_UNPROCESSABLE_ENTITY, responseCode); - - Map hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1"); - - @SuppressWarnings("unchecked") - List> queues = (List>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE); - Map testQueue = getRestTestHelper().find(Queue.NAME, queueName , queues); - - assertNull("Sorted queue without a key was created ", testQueue); - } - - public void testPutCreatePriorityQueueWithoutKey() throws Exception - { - String queueName = getTestQueueName()+ "-priority"; - createQueue(queueName, "priority", null); - - Map hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1"); - - @SuppressWarnings("unchecked") - List> queues = (List>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE); - Map priorityQueue = getRestTestHelper().find(Queue.NAME, queueName , queues); - - Asserts.assertQueue(queueName , "priority", priorityQueue); - assertEquals("Unexpected value of queue attribute " + Queue.DURABLE, Boolean.TRUE, priorityQueue.get(Queue.DURABLE)); - assertEquals("Unexpected number of priorities", 10, priorityQueue.get(PriorityQueue.PRIORITIES)); - } - - public void testPutCreateStandardQueueWithoutType() throws Exception - { - String queueName = getTestQueueName(); - createQueue(queueName, null, null); - - Map hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1"); - - @SuppressWarnings("unchecked") - List> queues = (List>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE); - Map queue = getRestTestHelper().find(Queue.NAME, queueName , queues); - - Asserts.assertQueue(queueName , "standard", queue); - } - - public void testPutCreateQueueOfUnsupportedType() throws Exception - { - String queueName = getTestQueueName(); - int responseCode = tryCreateQueue(queueName, "unsupported", null); - assertEquals("Unexpected response code", SC_UNPROCESSABLE_ENTITY, responseCode); - - Map hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1"); - - @SuppressWarnings("unchecked") - List> queues = (List>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE); - Map queue = getRestTestHelper().find(Queue.NAME, queueName , queues); - - assertNull("Queue of unsupported type was created", queue); - } - - public void testDeleteQueue() throws Exception - { - String queueName = getTestQueueName(); - createQueue(queueName, null, null); - - String queueUrl = "queue/test/test/" + queueName; - Map queueData = getRestTestHelper().getJsonAsMap(queueUrl); - assertEquals("Unexpected name", queueName, queueData.get(Queue.NAME)); - - getRestTestHelper().submitRequest(queueUrl, "DELETE", SC_OK); - - getRestTestHelper().submitRequest(queueUrl, "GET", SC_NOT_FOUND); - } - - public void testDeleteQueueById() throws Exception - { - String queueName = getTestQueueName(); - createQueue(queueName, null, null); - Map queueDetails = getRestTestHelper().getJsonAsMap("queue/test/test/" + queueName); - getRestTestHelper().submitRequest("queue/test/test?id=" + queueDetails.get(Queue.ID), "DELETE", SC_OK); - getRestTestHelper().submitRequest("queue/test/test/" + queueName, "GET", SC_NOT_FOUND); - } - - public void testDeleteExchange() throws Exception - { - String exchangeName = getTestName(); - createExchange(exchangeName, "direct"); - - int statusCode = getRestTestHelper().submitRequest("exchange/test/test/" + exchangeName, "DELETE"); - - assertEquals("Unexpected response code", 200, statusCode); - getRestTestHelper().submitRequest("exchange/test/test/" + exchangeName, "GET", SC_NOT_FOUND); - } - - public void testDeleteExchangeById() throws Exception - { - String exchangeName = getTestName(); - createExchange(exchangeName, "direct"); - Map echangeDetails = getRestTestHelper().getJsonAsMap("exchange/test/test/" + exchangeName); - - int statusCode = getRestTestHelper().submitRequest("exchange/test/test?id=" + echangeDetails.get(Exchange.ID), "DELETE"); - - assertEquals("Unexpected response code", 200, statusCode); - getRestTestHelper().submitRequest("exchange/test/test/" + exchangeName, "GET", SC_NOT_FOUND); - } - - public void testPutCreateQueueWithAttributes() throws Exception - { - String queueName = getTestQueueName(); - - Map attributes = new HashMap(); - attributes.put(Queue.ALERT_REPEAT_GAP, 1000); - attributes.put(Queue.ALERT_THRESHOLD_MESSAGE_AGE, 3600000); - attributes.put(Queue.ALERT_THRESHOLD_MESSAGE_SIZE, 1000000000); - attributes.put(Queue.ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES, 800); - attributes.put(Queue.MAXIMUM_DELIVERY_ATTEMPTS, 15); - attributes.put(Queue.MAXIMUM_QUEUE_DEPTH_MESSAGES, 2000000000); - - createQueue(queueName + "-standard", "standard", attributes); - - Map sortedQueueAttributes = new HashMap(); - sortedQueueAttributes.putAll(attributes); - sortedQueueAttributes.put(SortedQueue.SORT_KEY, "sortme"); - createQueue(queueName + "-sorted", "sorted", sortedQueueAttributes); - - Map priorityQueueAttributes = new HashMap(); - priorityQueueAttributes.putAll(attributes); - priorityQueueAttributes.put(PriorityQueue.PRIORITIES, 10); - createQueue(queueName + "-priority", "priority", priorityQueueAttributes); - - Map lvqQueueAttributes = new HashMap(); - lvqQueueAttributes.putAll(attributes); - lvqQueueAttributes.put(LastValueQueue.LVQ_KEY, "LVQ"); - createQueue(queueName + "-lvq", "lvq", lvqQueueAttributes); - - Map hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1"); - - @SuppressWarnings("unchecked") - List> queues = (List>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE); - Map standardQueue = getRestTestHelper().find(Queue.NAME, queueName + "-standard" , queues); - Map sortedQueue = getRestTestHelper().find(Queue.NAME, queueName + "-sorted" , queues); - Map priorityQueue = getRestTestHelper().find(Queue.NAME, queueName + "-priority" , queues); - Map lvqQueue = getRestTestHelper().find(Queue.NAME, queueName + "-lvq" , queues); - - attributes.put(Queue.DURABLE, Boolean.TRUE); - Asserts.assertQueue(queueName + "-standard", "standard", standardQueue, attributes); - Asserts.assertQueue(queueName + "-sorted", "sorted", sortedQueue, attributes); - Asserts.assertQueue(queueName + "-priority", "priority", priorityQueue, attributes); - Asserts.assertQueue(queueName + "-lvq", "lvq", lvqQueue, attributes); - - assertEquals("Unexpected sorted key attribute", "sortme", sortedQueue.get(SortedQueue.SORT_KEY)); - assertEquals("Unexpected lvq key attribute", "LVQ", lvqQueue.get(LastValueQueue.LVQ_KEY)); - assertEquals("Unexpected priorities key attribute", 10, priorityQueue.get(PriorityQueue.PRIORITIES)); - } - - public void testObjectsWithSlashes() throws Exception - { - String queueName = "testQueue/with/slashes"; - String queueNameEncoded = URLEncoder.encode(queueName, "UTF-8"); - String queueNameDoubleEncoded = URLEncoder.encode(queueNameEncoded, "UTF-8"); - String queueUrl = "queue/test/test/" + queueNameDoubleEncoded; - - // Test creation - createQueue(queueNameDoubleEncoded, "standard", null); - Map hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1"); - List> queues = (List>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE); - Map queue = getRestTestHelper().find(Queue.NAME, queueName , queues); - Asserts.assertQueue(queueName, "standard", queue); - - // Test deletion - int statusCode = getRestTestHelper().submitRequest(queueUrl, "DELETE"); - assertEquals("Unexpected response code", 200, statusCode); - getRestTestHelper().submitRequest(queueUrl, "GET", SC_NOT_FOUND); - } - - private void createExchange(String exchangeName, String exchangeType) throws IOException - { - Map queueData = new HashMap(); - queueData.put(Exchange.NAME, exchangeName); - queueData.put(Exchange.DURABLE, Boolean.TRUE); - queueData.put(Exchange.TYPE, exchangeType); - - int statusCode = getRestTestHelper().submitRequest("exchange/test/test/" + exchangeName, "PUT", queueData); - assertEquals("Unexpected response code", 201, statusCode); - } - - private void createQueue(String queueName, String queueType, Map attributes) throws Exception - { - int responseCode = tryCreateQueue(queueName, queueType, attributes); - assertEquals("Unexpected response code", 201, responseCode); - } - - private int tryCreateQueue(String queueName, String queueType, Map attributes) throws Exception - { - Map queueData = new HashMap(); - queueData.put(Queue.NAME, queueName); - queueData.put(Queue.DURABLE, Boolean.TRUE); - if (queueType != null) - { - queueData.put(Queue.TYPE, queueType); - } - if (attributes != null) - { - queueData.putAll(attributes); - } - - return getRestTestHelper().submitRequest("queue/test/test/" + queueName, "PUT", queueData); - } - - private Map submitVirtualHost(boolean useParentURI, String method, int statusCode) throws IOException - { - String hostName = getTestName(); - String type = getTestProfileVirtualHostNodeType(); - if (JsonVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE.equals(type)) - { - type = DerbyVirtualHostImpl.VIRTUAL_HOST_TYPE; - } - Map virtualhostData = new HashMap<>(); - virtualhostData.put(VirtualHost.NAME, hostName); - virtualhostData.put(VirtualHost.TYPE, type); - - String url = "virtualhost/" + EMPTY_VIRTUALHOSTNODE_NAME; - if (!useParentURI) - { - url += "/" + hostName; - } - - Map> headers = new HashMap<>(); - int responseCode = getRestTestHelper().submitRequest(url, method, virtualhostData, headers ); - Assert.assertEquals("Unexpected response code from " + method + " " + url, statusCode, responseCode); - if (statusCode == 201) - { - List location = headers.get("Location"); - assertTrue("Location is not returned by REST create request", location != null && location.size() == 1); - String expectedLocation = getRestTestHelper().getManagementURL() + RestTestHelper.API_BASE + url; - if (useParentURI) - { - expectedLocation += "/" + hostName; - } - assertEquals("Unexpected location", expectedLocation, location.get(0)); - } - return virtualhostData; - } - - private void assertNewVirtualHost(Map hostDetails) - { - @SuppressWarnings("unchecked") - Map statistics = (Map) hostDetails.get(Asserts.STATISTICS_ATTRIBUTE); - assertEquals("Unexpected number of exchanges in statistics", EXPECTED_EXCHANGES.length, - statistics.get("exchangeCount")); - assertEquals("Unexpected number of queues in statistics", 0, statistics.get("queueCount")); - assertEquals("Unexpected number of connections in statistics", 0, statistics.get("connectionCount")); - - @SuppressWarnings("unchecked") - List> exchanges = (List>) hostDetails.get(VIRTUALHOST_EXCHANGES_ATTRIBUTE); - assertEquals("Unexpected number of exchanges", EXPECTED_EXCHANGES.length, exchanges.size()); - RestTestHelper restTestHelper = getRestTestHelper(); - Asserts.assertDurableExchange("amq.fanout", "fanout", restTestHelper.find(Exchange.NAME, "amq.fanout", exchanges)); - Asserts.assertDurableExchange("amq.topic", "topic", restTestHelper.find(Exchange.NAME, "amq.topic", exchanges)); - Asserts.assertDurableExchange("amq.direct", "direct", restTestHelper.find(Exchange.NAME, "amq.direct", exchanges)); - Asserts.assertDurableExchange("amq.match", "headers", restTestHelper.find(Exchange.NAME, "amq.match", exchanges)); - - assertNull("Unexpected queues", hostDetails.get(VIRTUALHOST_QUEUES_ATTRIBUTE)); - } - - private void assertActualAndDesireStates(final String restUrl, - final String expectedDesiredState, - final String expectedActualState) throws IOException - { - Map virtualhost = getRestTestHelper().getJsonAsMap(restUrl); - Asserts.assertActualAndDesiredState(expectedDesiredState, expectedActualState, virtualhost); - } - - private void assertQueueDepth(String restQueueUrl, String message, int expectedDepth) throws IOException - { - Map queueDetails = getRestTestHelper().getJsonAsMap(restQueueUrl); - assertNotNull(queueDetails); - Map statistics = (Map) queueDetails.get(Asserts.STATISTICS_ATTRIBUTE); - assertNotNull(statistics); - - assertEquals(message, expectedDepth, statistics.get("queueDepthMessages")); - } } http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/81d81723/test-profiles/CPPExcludes ---------------------------------------------------------------------- diff --git a/test-profiles/CPPExcludes b/test-profiles/CPPExcludes index 2ce365d..f63c003 100755 --- a/test-profiles/CPPExcludes +++ b/test-profiles/CPPExcludes @@ -35,9 +35,6 @@ org.apache.qpid.test.unit.close.FlowToDiskBackingQueueDeleteTest#* // QPID-1730: the C++ server has a totally different logging mechanism. We should split this file differently org.apache.qpid.server.AlertingTest#* -// The C++ server has a totally different persistence mechanism -org.apache.qpid.server.store.SplitStoreTest#* - // CPP Broker does not follow the same Logging convention as the Qpid Broker-J org.apache.qpid.server.BrokerStartupTest#* org.apache.qpid.server.logging.* http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/81d81723/test-profiles/JavaJsonExcludes ---------------------------------------------------------------------- diff --git a/test-profiles/JavaJsonExcludes b/test-profiles/JavaJsonExcludes index 77b4e3d..61f4703 100644 --- a/test-profiles/JavaJsonExcludes +++ b/test-profiles/JavaJsonExcludes @@ -19,7 +19,6 @@ org.apache.qpid.server.store.berkeleydb.* org.apache.qpid.server.store.berkeleydb.replication.* -org.apache.qpid.server.store.SplitStoreTest#* org.apache.qpid.systest.rest.acl.VirtualHostACLTest#* org.apache.qpid.systest.rest.VirtualHostNodeRestTest#testCreateAndDeleteVirtualHostNode org.apache.qpid.systest.rest.VirtualHostRestTest#testPutCreateProvidedVirtualHost http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/81d81723/test-profiles/JavaTransientExcludes ---------------------------------------------------------------------- diff --git a/test-profiles/JavaTransientExcludes b/test-profiles/JavaTransientExcludes index e565ae9..6938e3b 100644 --- a/test-profiles/JavaTransientExcludes +++ b/test-profiles/JavaTransientExcludes @@ -18,7 +18,6 @@ // //These tests require a persistent store -org.apache.qpid.server.store.SplitStoreTest#* org.apache.qpid.server.logging.AlertingTest#testAlertingReallyWorksWithRestart org.apache.qpid.server.logging.AlertingTest#testAlertingReallyWorksWithChanges --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org For additional commands, e-mail: commits-help@qpid.apache.org