You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2018/02/09 11:31:10 UTC
[1/3] qpid-broker-j git commit: QPID-8083 [System Tests] [REST/HTTP]
Refactor VirtualHostLoggerTest
Repository: qpid-broker-j
Updated Branches:
refs/heads/master a9667120e -> a2732dd69
QPID-8083 [System Tests] [REST/HTTP] Refactor VirtualHostLoggerTest
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/a2732dd6
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/a2732dd6
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/a2732dd6
Branch: refs/heads/master
Commit: a2732dd69bd8ac3053c51f7b13e5a9bf8e581c70
Parents: 81d8172
Author: Keith Wall <kw...@apache.org>
Authored: Fri Feb 9 10:25:01 2018 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Fri Feb 9 11:30:52 2018 +0000
----------------------------------------------------------------------
.../endtoend/logging/VirtualHostLoggerTest.java | 192 +++++++++++++++++++
.../qpid/tests/http/rest/model/CreateTest.java | 15 +-
.../systest/rest/VirtualHostLoggerRestTest.java | 141 --------------
test-profiles/JavaTransientExcludes | 1 -
4 files changed, 206 insertions(+), 143 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a2732dd6/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/logging/VirtualHostLoggerTest.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/logging/VirtualHostLoggerTest.java b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/logging/VirtualHostLoggerTest.java
new file mode 100644
index 0000000..86694b5
--- /dev/null
+++ b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/logging/VirtualHostLoggerTest.java
@@ -0,0 +1,192 @@
+/*
+ * 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.logging;
+
+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.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.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import com.google.common.io.CharStreams;
+import org.junit.Test;
+
+import org.apache.qpid.server.logging.logback.VirtualHostFileLogger;
+import org.apache.qpid.server.logging.logback.VirtualHostNameAndLevelLogInclusionRule;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.State;
+import org.apache.qpid.tests.http.HttpRequestConfig;
+import org.apache.qpid.tests.http.HttpTestBase;
+
+@HttpRequestConfig(useVirtualHostAsHost = true)
+public class VirtualHostLoggerTest extends HttpTestBase
+{
+ private static final String LOGGER_NAME = "testLogger1";
+ private static final String LOGGER_RULE = "testRule";
+
+ @Test
+ public void createVirtualHostLoggerAndRule() throws Exception
+ {
+ Map<String, Object> loggerAttributes = new HashMap<>();
+ loggerAttributes.put(ConfiguredObject.NAME, LOGGER_NAME);
+ loggerAttributes.put(ConfiguredObject.TYPE, VirtualHostFileLogger.TYPE);
+
+ getHelper().submitRequest(String.format("virtualhostlogger/%s", LOGGER_NAME),
+ "PUT",
+ loggerAttributes,
+ SC_CREATED);
+
+ Map<String, Object> ruleAttributes = new HashMap<>();
+ ruleAttributes.put(ConfiguredObject.NAME, LOGGER_RULE);
+ ruleAttributes.put(ConfiguredObject.TYPE, VirtualHostNameAndLevelLogInclusionRule.TYPE);
+
+ String loggerRuleRestUrl = String.format("virtualhostloginclusionrule/%s/%s", LOGGER_NAME, LOGGER_RULE);
+
+ getHelper().submitRequest(loggerRuleRestUrl, "PUT", ruleAttributes, SC_CREATED);
+ getHelper().submitRequest(loggerRuleRestUrl, "GET", SC_OK);
+ }
+
+ @Test
+ public void dynamicConfiguration() throws Exception
+ {
+ final String loggerUrl = String.format("virtualhostlogger/%s", LOGGER_NAME);
+ final String loggerRuleUrl = String.format("virtualhostloginclusionrule/%s/%s", LOGGER_NAME, LOGGER_RULE);
+
+ Map<String, Object> loggerAttributes = new HashMap<>();
+ loggerAttributes.put(ConfiguredObject.NAME, LOGGER_NAME);
+ loggerAttributes.put(ConfiguredObject.TYPE, VirtualHostFileLogger.TYPE);
+
+ getHelper().submitRequest(loggerUrl,
+ "PUT",
+ loggerAttributes,
+ SC_CREATED);
+
+ Map<String, Object> ruleAttributes = new HashMap<>();
+ ruleAttributes.put(ConfiguredObject.NAME, LOGGER_RULE);
+ ruleAttributes.put(ConfiguredObject.TYPE, VirtualHostNameAndLevelLogInclusionRule.TYPE);
+ ruleAttributes.put("loggerName", "qpid.message.*");
+
+ getHelper().submitRequest(loggerRuleUrl, "PUT", ruleAttributes, SC_CREATED);
+ getHelper().submitRequest(loggerRuleUrl, "GET", SC_OK);
+
+ Map<String, Object> loggerData = getHelper().getJsonAsMap(loggerUrl);
+ String logFileLocation = String.valueOf(loggerData.get(VirtualHostFileLogger.FILE_NAME));
+ assertThat(logFileLocation, is(notNullValue()));
+ final File logFile = new File(logFileLocation);
+
+ final String downloadUrl = String.format("%s/getFile?fileName=%s", loggerUrl, logFile.getName());
+
+ final int queueCreateMatchesBefore = countLogFileMatches(downloadUrl, "QUE-1001");
+ assertThat("Unexpected queue matches before queue creation", queueCreateMatchesBefore, is(equalTo(0)));
+
+ getHelper().submitRequest("queue/myqueue", "PUT", Collections.emptyMap(), SC_CREATED);
+
+ final int queueCreateMatchesAfter = countLogFileMatches(downloadUrl, "QUE-1001");
+ assertThat("Unexpected queue matches before queue creation", queueCreateMatchesAfter, is(equalTo(1)));
+
+ ruleAttributes.put("level", "OFF");
+ getHelper().submitRequest(loggerRuleUrl, "PUT", ruleAttributes, SC_OK);
+
+ getHelper().submitRequest("queue/myqueue2", "PUT", Collections.emptyMap(), SC_CREATED);
+
+ final int afterLevelChange = countLogFileMatches(downloadUrl, "QUE-1001");
+ assertThat("Unexpected queue matches after level change", afterLevelChange, is(equalTo(queueCreateMatchesAfter)));
+
+ ruleAttributes.put("level", "INFO");
+ getHelper().submitRequest(loggerRuleUrl, "PUT", ruleAttributes, SC_OK);
+
+ getHelper().submitRequest("queue/myqueue3", "PUT", Collections.emptyMap(), SC_CREATED);
+
+ final int afterSecondLevelChange = countLogFileMatches(downloadUrl, "QUE-1001");
+ assertThat("Unexpected queue matches after level change", afterSecondLevelChange, is(equalTo(afterLevelChange + 1)));
+ }
+
+ @Test
+ public void deleteVirtualHostLogger() throws Exception
+ {
+ final String loggerRestUrl = String.format("virtualhostlogger/%s", LOGGER_NAME);
+ Map<String, Object> attributes = new HashMap<>();
+ attributes.put(ConfiguredObject.NAME, LOGGER_NAME);
+ attributes.put(ConfiguredObject.TYPE, VirtualHostFileLogger.TYPE);
+
+ getHelper().submitRequest(loggerRestUrl, "PUT", attributes, SC_CREATED);
+ getHelper().submitRequest(loggerRestUrl, "GET", SC_OK);
+
+ getHelper().submitRequest(loggerRestUrl, "DELETE", null, SC_OK);
+ getHelper().submitRequest(loggerRestUrl, "GET", SC_NOT_FOUND);
+ }
+
+ @Test
+ public void recoverAfterDeletedVirtualHostLoggerAndRules_QPID_8066() throws Exception
+ {
+ assumeThat(getBrokerAdmin().supportsRestart(), is(true));
+
+ final String hostUrl = "virtualhost";
+ final String loggerUrl = String.format("virtualhostlogger/%s", LOGGER_NAME);
+ final String loggerRuleUrl = String.format("virtualhostloginclusionrule/%s/%s", LOGGER_NAME, LOGGER_RULE);
+
+ Map<String, Object> loggerAttributes = new HashMap<>();
+ loggerAttributes.put(ConfiguredObject.NAME, LOGGER_NAME);
+ loggerAttributes.put(ConfiguredObject.TYPE, VirtualHostFileLogger.TYPE);
+ getHelper().submitRequest(loggerUrl, "PUT", loggerAttributes, SC_CREATED);
+
+ Map<String, Object> ruleAttributes = new HashMap<>();
+ ruleAttributes.put(ConfiguredObject.NAME, LOGGER_RULE);
+ ruleAttributes.put(ConfiguredObject.TYPE, VirtualHostNameAndLevelLogInclusionRule.TYPE);
+ getHelper().submitRequest(loggerRuleUrl, "PUT", ruleAttributes, SC_CREATED);
+
+ Map<String, Object> host = getHelper().getJsonAsMap(hostUrl);
+ assertThat(host.get(ConfiguredObject.STATE), is(equalTo(State.ACTIVE.name())));
+ assertThat(getHelper().getJsonAsList("virtualhostlogger").size(), is(equalTo(1)));
+
+ getHelper().submitRequest(loggerUrl, "DELETE", SC_OK);
+
+ getBrokerAdmin().restart();
+
+ host = getHelper().getJsonAsMap(hostUrl);
+ assertThat(host.get(ConfiguredObject.STATE), is(equalTo(State.ACTIVE.name())));
+
+ assertThat(getHelper().getJsonAsList("virtualhostlogger").size(), is(equalTo(0)));
+ }
+
+ private int countLogFileMatches(final String url, final String searchTerm) throws Exception
+ {
+ HttpURLConnection httpCon = getHelper().openManagementConnection(url, "GET");
+ httpCon.connect();
+
+ try (InputStreamReader r = new InputStreamReader(httpCon.getInputStream()))
+ {
+ final List<String> strings = CharStreams.readLines(r);
+ return strings.stream().map(line -> line.contains(searchTerm)).collect(Collectors.toList()).size();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a2732dd6/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 d3e5683..cbf77dc 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
@@ -61,7 +61,7 @@ public class CreateTest extends HttpTestBase
}
@Test
- public void locationHeader() throws Exception
+ public void putToUriLocationHeader() throws Exception
{
final String queueUrl = "queue/myqueue";
Map<String, List<String>> headers = new HashMap<>();
@@ -73,6 +73,19 @@ public class CreateTest extends HttpTestBase
}
@Test
+ public void putToParentUriLocationHeader() throws Exception
+ {
+ final String parentUrl = "queue";
+ final String queueUrl = "queue/myqueue";
+ Map<String, List<String>> headers = new HashMap<>();
+ int responseCode = getHelper().submitRequest(parentUrl, "PUT", Collections.singletonMap(ConfiguredObject.NAME, "myqueue"), headers);
+ assertThat(responseCode, is(equalTo(SC_CREATED)));
+ List<String> location = headers.get("Location");
+ assertThat(location.size(), is(equalTo(1)));
+ assertThat(location.get(0), endsWith(queueUrl));
+ }
+
+ @Test
public void createSubtype() throws Exception
{
final String queueUrl = "queue/myqueue";
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a2732dd6/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostLoggerRestTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostLoggerRestTest.java b/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostLoggerRestTest.java
deleted file mode 100644
index 488c131..0000000
--- a/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostLoggerRestTest.java
+++ /dev/null
@@ -1,141 +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.systest.rest;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.qpid.server.logging.logback.VirtualHostFileLogger;
-import org.apache.qpid.server.logging.logback.VirtualHostNameAndLevelLogInclusionRule;
-import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.Queue;
-import org.apache.qpid.server.model.State;
-import org.apache.qpid.server.model.VirtualHostLogger;
-import org.apache.qpid.util.LogMonitor;
-
-public class VirtualHostLoggerRestTest extends QpidRestTestCase
-{
-
- public void testCreateVirtualHostLoggerAndRule() throws Exception
- {
- String loggerName = "testLogger1";
- String loggerRestUrlBase = "virtualhostlogger/" + TEST1_VIRTUALHOST + "/" + TEST1_VIRTUALHOST;
- String loggerRestUrl = loggerRestUrlBase + "/" + loggerName;
-
- Map<String, Object> virtualHostLoggerAttributes = new HashMap<>();
- virtualHostLoggerAttributes.put(VirtualHostLogger.NAME, loggerName);
- virtualHostLoggerAttributes.put(ConfiguredObject.TYPE, VirtualHostFileLogger.TYPE);
-
- getRestTestHelper().submitRequest(loggerRestUrlBase, "PUT", virtualHostLoggerAttributes, HttpServletResponse.SC_CREATED);
- Map<String, Object> loggerData = getRestTestHelper().getJsonAsMap(loggerRestUrl);
-
- String loggerRuleName = "testRule";
- Map<String, Object> virtualHostRuleAttributes = new HashMap<>();
- virtualHostRuleAttributes.put("name", loggerRuleName);
- virtualHostRuleAttributes.put("level", "DEBUG");
- virtualHostRuleAttributes.put("type", VirtualHostNameAndLevelLogInclusionRule.TYPE);
-
- String loggerRuleRestUrlBase = "virtualhostloginclusionrule/" + TEST1_VIRTUALHOST + "/" + TEST1_VIRTUALHOST + "/" + loggerName;
- String loggerRuleRestUrl = loggerRuleRestUrlBase + "/" + loggerRuleName;
-
- getRestTestHelper().submitRequest(loggerRuleRestUrlBase, "PUT", virtualHostRuleAttributes, HttpServletResponse.SC_CREATED);
- getRestTestHelper().submitRequest(loggerRuleRestUrl, "GET", HttpServletResponse.SC_OK);
-
- String logFileLocation = String.valueOf(loggerData.get(VirtualHostFileLogger.FILE_NAME));
- assertNotNull("Log file attribute is not set ", logFileLocation);
- assertTrue(String.format("Log file '%s' does not exists", logFileLocation), new File(logFileLocation).exists());
-
-
- LogMonitor logMonitor = new LogMonitor(new File(logFileLocation));
- try
- {
- List<String> logs = logMonitor.findMatches("QUE-1001");
- assertEquals("Unexpected number of Queue creation operational logs before Queue creation", 0, logs.size());
- Map<String, Object> queueAttributes = Collections.<String, Object>singletonMap(Queue.NAME, getTestQueueName());
- getRestTestHelper().submitRequest("queue/" + TEST1_VIRTUALHOST + "/" + TEST1_VIRTUALHOST, "PUT", queueAttributes, HttpServletResponse.SC_CREATED);
- logs = logMonitor.waitAndFindMatches("QUE-1001", 1000);
- assertEquals("Unexpected number of Queue creation operational logs after Queue creation", 1, logs.size());
- }
- finally
- {
- logMonitor.close();
- }
- }
-
- public void testDeleteVirtualHostLoggerAndRule() throws Exception
- {
- String loggerName = "testLogger1";
- Map<String, Object> attributes = new HashMap<>();
- attributes.put(VirtualHostLogger.NAME, loggerName);
- attributes.put(ConfiguredObject.TYPE, VirtualHostFileLogger.TYPE);
- String loggerRestUrlBase = "virtualhostlogger/" + TEST1_VIRTUALHOST + "/" + TEST1_VIRTUALHOST;
- String loggerRestUrl = loggerRestUrlBase + "/" + loggerName;
-
- getRestTestHelper().submitRequest(loggerRestUrlBase, "PUT", attributes, HttpServletResponse.SC_CREATED);
- getRestTestHelper().submitRequest(loggerRestUrl, "GET", HttpServletResponse.SC_OK);
-
- getRestTestHelper().submitRequest(loggerRestUrl, "DELETE", null, HttpServletResponse.SC_OK);
- getRestTestHelper().submitRequest(loggerRestUrl, "GET", HttpServletResponse.SC_NOT_FOUND);
- }
-
- public void testDeleteVirtualHostLoggerAndRule_QPID_8066() throws Exception
- {
- final String hostRestUrl = "virtualhost/" + TEST1_VIRTUALHOST + "/" + TEST1_VIRTUALHOST;
- final String loggerRestUrlBase = "virtualhostlogger/" + TEST1_VIRTUALHOST + "/" + TEST1_VIRTUALHOST;
-
- String loggerName = "testLogger1";
- Map<String, Object> attributes = new HashMap<>();
- attributes.put(VirtualHostLogger.NAME, loggerName);
- attributes.put(ConfiguredObject.TYPE, VirtualHostFileLogger.TYPE);
- getRestTestHelper().submitRequest(loggerRestUrlBase, "PUT", attributes, HttpServletResponse.SC_CREATED);
-
- final String loggerRuleRestUrlBase = "virtualhostloginclusionrule/" + TEST1_VIRTUALHOST + "/" + TEST1_VIRTUALHOST + "/" + loggerName;
-
- String loggerRuleName = "loggerRuleName";
- Map<String, Object> virtualHostRuleAttributes = new HashMap<>();
- virtualHostRuleAttributes.put("name", loggerRuleName);
- virtualHostRuleAttributes.put("type", VirtualHostNameAndLevelLogInclusionRule.TYPE);
- getRestTestHelper().submitRequest(loggerRuleRestUrlBase, "PUT", virtualHostRuleAttributes, HttpServletResponse.SC_CREATED);
-
-
- Map<String, Object> host = getRestTestHelper().getJsonAsMap(hostRestUrl);
- assertEquals("Unexpected state before restart",
- State.ACTIVE.name(), host.get(ConfiguredObject.STATE));
- assertEquals("Unexpected number of loggers before restart",
- 1, getRestTestHelper().getJsonAsList(loggerRestUrlBase).size());
-
- getRestTestHelper().submitRequest(loggerRestUrlBase, "DELETE", null, HttpServletResponse.SC_OK);
-
- restartDefaultBroker();
-
- host = getRestTestHelper().getJsonAsMap(hostRestUrl);
- assertEquals("Unexpected state after restart",
- State.ACTIVE.name(), host.get(ConfiguredObject.STATE));
-
- assertEquals("Unexpected number of loggers after restart",
- 0, getRestTestHelper().getJsonAsList(loggerRestUrlBase).size());
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a2732dd6/test-profiles/JavaTransientExcludes
----------------------------------------------------------------------
diff --git a/test-profiles/JavaTransientExcludes b/test-profiles/JavaTransientExcludes
index 6938e3b..89f437b 100644
--- a/test-profiles/JavaTransientExcludes
+++ b/test-profiles/JavaTransientExcludes
@@ -30,5 +30,4 @@ org.apache.qpid.systest.rest.VirtualHostRestTest#testRecoverVirtualHostInDesired
org.apache.qpid.systest.rest.VirtualHostRestTest#testMutateStateOfVirtualHostWithQueuesAndMessages
org.apache.qpid.systest.rest.VirtualHostNodeRestTest#testCreateAndDeleteVirtualHostNode
-org.apache.qpid.systest.rest.VirtualHostLoggerRestTest#testDeleteVirtualHostLoggerAndRule_QPID_8066
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/3] qpid-broker-j git commit: QPID-8083 [System Tests] [REST/HTTP]
Remove many superfluous tests
Posted by kw...@apache.org.
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 <kw...@apache.org>
Authored: Thu Feb 8 18:58:06 2018 +0000
Committer: Keith Wall <kw...@apache.org>
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<Message> _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<String, Object> 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<String, Object> object = getHelper().getJson(url, new TypeReference<Map<String, Object>>() {}, 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<String, Object> attributes = new HashMap<>();
+ attributes.put(VirtualHost.TYPE, System.getProperty("virtualhostnode.type"));
+ getHelper().submitRequest(url, "PUT", attributes, SC_CREATED);
+
+ final Map<String, Object> virtualHost = getHelper().getJson(url,
+ new TypeReference<Map<String, Object>>() {},
+ 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<Message> _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<String, Object> 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<String, Object> object = getHelper().getJson(url, new TypeReference<Map<String, Object>>() {}, 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<String, List<String>> headers = new HashMap<>();
+ int responseCode = getHelper().submitRequest(queueUrl, "PUT", Collections.emptyMap(), headers);
+ assertThat(responseCode, is(equalTo(SC_CREATED)));
+ List<String> location = headers.get("Location");
+ assertThat(location.size(), is(equalTo(1)));
+ assertThat(location.get(0), endsWith(queueUrl));
+
+ final Map<String, Object> queue = getHelper().getJson(queueUrl,
+ new TypeReference<Map<String, Object>>() {}, 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<String, String> 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<Map<String, Object>> 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<String, Object> 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<String, Object> hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test");
- Asserts.assertVirtualHost("test", hostDetails);
-
- @SuppressWarnings("unchecked")
- Map<String, Object> statistics = (Map<String, Object>) 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<Map<String, Object>> 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<Map<String, Object>> queues = getRestTestHelper().getJsonAsList("queue/test");
- assertEquals("Unexpected number of queues", 1, queues.size());
- Map<String, Object> 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<Map<String, Object>> 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<String, Object> requestData = submitVirtualHost(true, "PUT", HttpServletResponse.SC_CREATED);
- String hostName = (String)requestData.get(VirtualHost.NAME);
-
- Map<String, Object> hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/"
- + EMPTY_VIRTUALHOSTNODE_NAME
- + "/"
- + hostName
- + "?depth=1");
- Asserts.assertVirtualHost(hostName, hostDetails);
-
- assertNewVirtualHost(hostDetails);
- }
-
- public void testCreateVirtualHostByPutUsingParentURI() throws Exception
- {
- Map<String, Object> data = submitVirtualHost(true, "PUT", HttpServletResponse.SC_CREATED);
- String hostName = (String)data.get(VirtualHost.NAME);
-
- String url = "virtualhost/" + EMPTY_VIRTUALHOSTNODE_NAME + "/" + hostName + "?depth=1";
- Map<String, Object> hostDetails = getRestTestHelper().getJsonAsMap(url);
- Asserts.assertVirtualHost(hostName, hostDetails);
- assertNewVirtualHost(hostDetails);
- }
-
- public void testCreateVirtualHostByPostUsingParentURI() throws Exception
- {
- Map<String, Object> data = submitVirtualHost(true, "POST", HttpServletResponse.SC_CREATED);
- String hostName = (String)data.get(VirtualHost.NAME);
-
- Map<String, Object> hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/"
- + EMPTY_VIRTUALHOSTNODE_NAME
- + "/"
- + hostName
- + "?depth=1");
- Asserts.assertVirtualHost(hostName, hostDetails);
- assertNewVirtualHost(hostDetails);
- }
-
- public void testCreateVirtualHostByPutUsingVirtualHostURI() throws Exception
- {
- Map<String, Object> data = submitVirtualHost(false, "PUT", HttpServletResponse.SC_CREATED);
- String hostName = (String)data.get(VirtualHost.NAME);
- Map<String, Object> hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/"
- + EMPTY_VIRTUALHOSTNODE_NAME
- + "/"
- + hostName
- + "?depth=1");
- Asserts.assertVirtualHost(hostName, hostDetails);
-
- assertNewVirtualHost(hostDetails);
-
- }
-
- public void testCreateVirtualHostByPostUsingVirtualHostURI() throws Exception
- {
- Map<String, Object> 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<Map<String, Object>> 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<String, Object> hostDetails = getRestTestHelper().getJsonAsMap(restHostUrl);
- Asserts.assertVirtualHost(hostToUpdate, hostDetails);
-
- Map<String, Object> newAttributes = Collections.<String, Object>singletonMap(VirtualHost.DESCRIPTION, "This is a virtual host");
- getRestTestHelper().submitRequest(restHostUrl, method, newAttributes, SC_OK);
-
- Map<String, Object> 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<String, Object> newAttributes = Collections.<String, Object>singletonMap(VirtualHost.DESIRED_STATE, "STOPPED");
- getRestTestHelper().submitRequest(restHostUrl, "PUT", newAttributes, SC_OK);
-
- _restTestHelper.waitForAttributeChanged(restHostUrl, VirtualHost.STATE, "STOPPED");
- assertActualAndDesireStates(restHostUrl, "STOPPED", "STOPPED");
-
- newAttributes = Collections.<String, Object>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<String, Object> newAttributes = Collections.<String, Object>singletonMap(VirtualHost.DESIRED_STATE, "STOPPED");
- getRestTestHelper().submitRequest(restHostUrl, "PUT", newAttributes, SC_OK);
-
- _restTestHelper.waitForAttributeChanged(restHostUrl, VirtualHost.STATE, "STOPPED");
- assertActualAndDesireStates(restHostUrl, "STOPPED", "STOPPED");
-
- newAttributes = Collections.<String, Object>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<String, Object> 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<String, Object> 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<String, Object> sortedQueueAttributes = new HashMap<String, Object>();
- sortedQueueAttributes.put(SortedQueue.SORT_KEY, "sortme");
- createQueue(queueName + "-sorted", "sorted", sortedQueueAttributes);
-
- Map<String, Object> priorityQueueAttributes = new HashMap<String, Object>();
- priorityQueueAttributes.put(PriorityQueue.PRIORITIES, 10);
- createQueue(queueName + "-priority", "priority", priorityQueueAttributes);
-
- Map<String, Object> lvqQueueAttributes = new HashMap<String, Object>();
- lvqQueueAttributes.put(LastValueQueue.LVQ_KEY, "LVQ");
- createQueue(queueName + "-lvq", "lvq", lvqQueueAttributes);
-
- Map<String, Object> hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1");
-
- @SuppressWarnings("unchecked")
- List<Map<String, Object>> queues = (List<Map<String, Object>>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE);
- Map<String, Object> standardQueue = getRestTestHelper().find(Queue.NAME, queueName + "-standard" , queues);
- Map<String, Object> sortedQueue = getRestTestHelper().find(Queue.NAME, queueName + "-sorted" , queues);
- Map<String, Object> priorityQueue = getRestTestHelper().find(Queue.NAME, queueName + "-priority" , queues);
- Map<String, Object> 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<String, Object> hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1");
-
- @SuppressWarnings("unchecked")
- List<Map<String, Object>> exchanges = (List<Map<String, Object>>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_EXCHANGES_ATTRIBUTE);
- Map<String, Object> directExchange = getRestTestHelper().find(Queue.NAME, exchangeName + "-direct" , exchanges);
- Map<String, Object> topicExchange = getRestTestHelper().find(Queue.NAME, exchangeName + "-topic" , exchanges);
- Map<String, Object> headersExchange = getRestTestHelper().find(Queue.NAME, exchangeName + "-headers" , exchanges);
- Map<String, Object> 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<String, Object> hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1");
-
- @SuppressWarnings("unchecked")
- List<Map<String, Object>> queues = (List<Map<String, Object>>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE);
- Map<String, Object> 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<String, Object> hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1");
-
- @SuppressWarnings("unchecked")
- List<Map<String, Object>> queues = (List<Map<String, Object>>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE);
- Map<String, Object> 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<String, Object> hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1");
-
- @SuppressWarnings("unchecked")
- List<Map<String, Object>> queues = (List<Map<String, Object>>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE);
- Map<String, Object> 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<String, Object> hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1");
-
- @SuppressWarnings("unchecked")
- List<Map<String, Object>> queues = (List<Map<String, Object>>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE);
- Map<String, Object> 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<String, Object> hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1");
-
- @SuppressWarnings("unchecked")
- List<Map<String, Object>> queues = (List<Map<String, Object>>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE);
- Map<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> attributes = new HashMap<String, Object>();
- 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<String, Object> sortedQueueAttributes = new HashMap<String, Object>();
- sortedQueueAttributes.putAll(attributes);
- sortedQueueAttributes.put(SortedQueue.SORT_KEY, "sortme");
- createQueue(queueName + "-sorted", "sorted", sortedQueueAttributes);
-
- Map<String, Object> priorityQueueAttributes = new HashMap<String, Object>();
- priorityQueueAttributes.putAll(attributes);
- priorityQueueAttributes.put(PriorityQueue.PRIORITIES, 10);
- createQueue(queueName + "-priority", "priority", priorityQueueAttributes);
-
- Map<String, Object> lvqQueueAttributes = new HashMap<String, Object>();
- lvqQueueAttributes.putAll(attributes);
- lvqQueueAttributes.put(LastValueQueue.LVQ_KEY, "LVQ");
- createQueue(queueName + "-lvq", "lvq", lvqQueueAttributes);
-
- Map<String, Object> hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1");
-
- @SuppressWarnings("unchecked")
- List<Map<String, Object>> queues = (List<Map<String, Object>>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE);
- Map<String, Object> standardQueue = getRestTestHelper().find(Queue.NAME, queueName + "-standard" , queues);
- Map<String, Object> sortedQueue = getRestTestHelper().find(Queue.NAME, queueName + "-sorted" , queues);
- Map<String, Object> priorityQueue = getRestTestHelper().find(Queue.NAME, queueName + "-priority" , queues);
- Map<String, Object> 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<String, Object> hostDetails = getRestTestHelper().getJsonAsMap("virtualhost/test/test?depth=1");
- List<Map<String, Object>> queues = (List<Map<String, Object>>) hostDetails.get(VirtualHostRestTest.VIRTUALHOST_QUEUES_ATTRIBUTE);
- Map<String, Object> 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<String, Object> queueData = new HashMap<String, Object>();
- 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<String, Object> attributes) throws Exception
- {
- int responseCode = tryCreateQueue(queueName, queueType, attributes);
- assertEquals("Unexpected response code", 201, responseCode);
- }
-
- private int tryCreateQueue(String queueName, String queueType, Map<String, Object> attributes) throws Exception
- {
- Map<String, Object> queueData = new HashMap<String, Object>();
- 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<String, Object> 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<String, Object> virtualhostData = new HashMap<>();
- virtualhostData.put(VirtualHost.NAME, hostName);
- virtualhostData.put(VirtualHost.TYPE, type);
-
- String url = "virtualhost/" + EMPTY_VIRTUALHOSTNODE_NAME;
- if (!useParentURI)
- {
- url += "/" + hostName;
- }
-
- Map<String,List<String>> 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<String> 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<String, Object> hostDetails)
- {
- @SuppressWarnings("unchecked")
- Map<String, Object> statistics = (Map<String, Object>) 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<Map<String, Object>> exchanges = (List<Map<String, Object>>) 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<String, Object> virtualhost = getRestTestHelper().getJsonAsMap(restUrl);
- Asserts.assertActualAndDesiredState(expectedDesiredState, expectedActualState, virtualhost);
- }
-
- private void assertQueueDepth(String restQueueUrl, String message, int expectedDepth) throws IOException
- {
- Map<String, Object> queueDetails = getRestTestHelper().getJsonAsMap(restQueueUrl);
- assertNotNull(queueDetails);
- Map<String, Object> statistics = (Map<String, Object>) 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
[3/3] qpid-broker-j git commit: QPID-8083 [System Tests] [REST/HTTP]
Move ExportImportMessagesRestTest
Posted by kw...@apache.org.
QPID-8083 [System Tests] [REST/HTTP] Move ExportImportMessagesRestTest
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/5ea1c709
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/5ea1c709
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/5ea1c709
Branch: refs/heads/master
Commit: 5ea1c709d3dab45d8da72902dd639f32f85bad9e
Parents: a966712
Author: Keith Wall <kw...@apache.org>
Authored: Thu Feb 8 17:17:26 2018 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Fri Feb 9 11:30:52 2018 +0000
----------------------------------------------------------------------
.../message/ExportImportMessagesTest.java | 128 ++++++++++++++
.../rest/ExportImportMessagesRestTest.java | 177 -------------------
2 files changed, 128 insertions(+), 177 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/5ea1c709/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/ExportImportMessagesTest.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/ExportImportMessagesTest.java b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/ExportImportMessagesTest.java
new file mode 100644
index 0000000..da4395e
--- /dev/null
+++ b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/ExportImportMessagesTest.java
@@ -0,0 +1,128 @@
+/*
+ * 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.message;
+
+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.VirtualHost;
+import org.apache.qpid.systests.Utils;
+import org.apache.qpid.tests.http.HttpRequestConfig;
+import org.apache.qpid.tests.http.HttpTestBase;
+import org.apache.qpid.server.util.DataUrlUtils;
+
+@HttpRequestConfig
+public class ExportImportMessagesTest extends HttpTestBase
+{
+ private static final String TEST_QUEUE = "testQueue";
+
+ @Before
+ public void setUp() throws Exception
+ {
+ getHelper().setTls(true);
+ }
+
+ @Test
+ public void exportImport() throws Exception
+ {
+ assumeThat(getBrokerAdmin().supportsRestart(), is(true));
+
+ getBrokerAdmin().createQueue(TEST_QUEUE);
+
+ final TextMessage sentMessage = putMessageOnQueue();
+
+ changeVirtualHostState("STOPPED");
+
+ byte[] extractedBytes = getHelper().getBytes("virtualhost/exportMessageStore");
+ String extractedBytesAsDataUrl = DataUrlUtils.getDataUrlForBytes(extractedBytes);
+
+ changeVirtualHostState("ACTIVE");
+
+ getBrokerAdmin().deleteQueue(TEST_QUEUE);
+ getBrokerAdmin().createQueue(TEST_QUEUE);
+
+ changeVirtualHostState("STOPPED");
+
+ Map<String, Object> importArgs = Collections.singletonMap("source", extractedBytesAsDataUrl);
+ getHelper().postJson("virtualhost/importMessageStore", importArgs, new TypeReference<Void>() {}, SC_OK);
+
+ changeVirtualHostState("ACTIVE");
+ verifyMessagesOnQueue(sentMessage);
+ }
+
+ private void changeVirtualHostState(final String desiredState) throws Exception
+ {
+ Map<String, Object> attributes = Collections.singletonMap(VirtualHost.DESIRED_STATE, desiredState);
+ getHelper().submitRequest("virtualhost", "POST", attributes, SC_OK);
+ }
+
+ private TextMessage putMessageOnQueue() throws Exception
+ {
+ Connection connection = getConnection();
+ try
+ {
+ Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+ List<Message> _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();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/5ea1c709/systests/src/test/java/org/apache/qpid/systest/rest/ExportImportMessagesRestTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/rest/ExportImportMessagesRestTest.java b/systests/src/test/java/org/apache/qpid/systest/rest/ExportImportMessagesRestTest.java
deleted file mode 100644
index 9d9ecd0..0000000
--- a/systests/src/test/java/org/apache/qpid/systest/rest/ExportImportMessagesRestTest.java
+++ /dev/null
@@ -1,177 +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.systest.rest;
-
-import java.io.IOException;
-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.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.servlet.http.HttpServletResponse;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.Queue;
-import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.model.VirtualHostNode;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-import org.apache.qpid.util.DataUrlUtils;
-
-public class ExportImportMessagesRestTest extends QpidRestTestCase
-{
-
- private String _virtualHostNodeName;
- private String _virtualHostName;
- private String _queueName;
- private String _extractOpUrl;
- private String _importOpUrl;
- private Destination _jmsQueue;
- private List<Message> _expectedMessages;
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
-
- _virtualHostNodeName = getTestName() + "_node";
- _virtualHostName = getTestName() + "_host";
- _queueName = getTestQueueName();
-
- createVirtualHostNode(_virtualHostNodeName, _virtualHostName);
-
- createTestQueue(_virtualHostNodeName, _virtualHostName, _queueName);
-
- Connection connection = createConnection(_virtualHostName);
- Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
- _jmsQueue = session.createQueue(isBroker10() ? _queueName : String.format("direct:////%s", _queueName));
- _expectedMessages = sendMessage(session, _jmsQueue, 1);
-
- connection.close();
-
- _extractOpUrl = String.format("virtualhost/%s/%s/exportMessageStore", _virtualHostNodeName, _virtualHostName);
- _importOpUrl = String.format("virtualhost/%s/%s/importMessageStore", _virtualHostNodeName, _virtualHostName);
-
- }
-
- @Override
- protected void customizeConfiguration() throws Exception
- {
- super.customizeConfiguration();
- getDefaultBrokerConfiguration().setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_HTTP_PORT,
- Port.ALLOW_CONFIDENTIAL_OPERATIONS_ON_INSECURE_CHANNELS,
- true);
- }
-
- public void testExtractImportEndToEnd() throws Exception
- {
- if (!isBrokerStorePersistent())
- {
- return;
- }
- changeVirtualHostState(_virtualHostNodeName, _virtualHostName, "STOPPED");
-
- byte[] extractedBytes = getRestTestHelper().getBytes(_extractOpUrl);
- String extractedBytesAsDataUrl = DataUrlUtils.getDataUrlForBytes(extractedBytes);
-
- // Delete and recreate
- deleteVirtualHostNode(_virtualHostNodeName);
- createVirtualHostNode(_virtualHostNodeName, _virtualHostName);
- createTestQueue(_virtualHostNodeName, _virtualHostName, _queueName);
-
- changeVirtualHostState(_virtualHostNodeName, _virtualHostName, "STOPPED");
-
- Map<String, Object> importArgs = Collections.<String, Object>singletonMap("source", extractedBytesAsDataUrl);
- getRestTestHelper().postJson(_importOpUrl, importArgs, Void.class);
-
- changeVirtualHostState(_virtualHostNodeName, _virtualHostName, "ACTIVE");
-
- // Verify imported message present
- Connection connection = createConnection(_virtualHostName);
- connection.start();
-
- Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
- MessageConsumer consumer = session.createConsumer(_jmsQueue);
-
- final TextMessage expectedMessage = (TextMessage) _expectedMessages.get(0);
- final TextMessage receivedMessage = (TextMessage) consumer.receive(getReceiveTimeout());
- assertNotNull("Message not received", receivedMessage);
- assertEquals("Unexpected message id", expectedMessage.getJMSMessageID(), receivedMessage.getJMSMessageID());
- assertEquals("Unexpected message content", expectedMessage.getText(), receivedMessage.getText());
-
- connection.close();
-
- }
-
- private void createTestQueue(final String nodeName, final String hostName, final String queueName) throws Exception
- {
- Map<String, Object> queueAttributes = new HashMap<>();
- queueAttributes.put(Queue.NAME, queueName);
-
- getRestTestHelper().submitRequest(String.format("queue/%s/%s", nodeName, hostName),
- "POST",
- queueAttributes,
- HttpServletResponse.SC_CREATED);
-
- }
-
- private void changeVirtualHostState(final String virtualHostNodeName, final String virtualHostName, final String desiredState) throws IOException
- {
- Map<String, Object>
- attributes = Collections.<String, Object>singletonMap(VirtualHost.DESIRED_STATE, desiredState);
- getRestTestHelper().submitRequest(String.format("virtualhost/%s/%s", virtualHostNodeName, virtualHostName), "PUT", attributes, HttpServletResponse.SC_OK);
- }
-
- private void createVirtualHostNode(String virtualHostNodeName, final String virtualHostName) throws Exception
- {
- String type = getTestProfileVirtualHostNodeType();
-
- final Map virtualHostAttributes = new ObjectMapper().readValue(getTestProfileVirtualHostNodeBlueprint(), Map.class);
- virtualHostAttributes.put(VirtualHost.NAME, virtualHostName);
-
- Map<String, Object> nodeAttributes = new HashMap<>();
- nodeAttributes.put(VirtualHostNode.NAME, virtualHostNodeName);
- nodeAttributes.put(VirtualHostNode.TYPE, type);
- nodeAttributes.put(VirtualHostNode.VIRTUALHOST_INITIAL_CONFIGURATION, new ObjectMapper().writeValueAsString(virtualHostAttributes));
-
-
- getRestTestHelper().submitRequest(String.format("virtualhostnode/%s", virtualHostNodeName),
- "PUT",
- nodeAttributes,
- HttpServletResponse.SC_CREATED);
- }
-
- private void deleteVirtualHostNode(String virtualHostNodeName) throws IOException
- {
- getRestTestHelper().submitRequest(String.format("virtualhostnode/%s", virtualHostNodeName), "DELETE", HttpServletResponse.SC_OK);
- }
-
- private Connection createConnection(final String virtualHostName) throws Exception
- {
- return getConnectionForVHost(virtualHostName);
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org