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/13 18:11:56 UTC
[1/3] qpid-broker-j git commit: QPID-8038: [Broker-J] Refactor
FileKeyStoreTest as SNITest
Repository: qpid-broker-j
Updated Branches:
refs/heads/master 91eb1cb22 -> 7601044d1
QPID-8038: [Broker-J] Refactor FileKeyStoreTest as SNITest
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/6402bfab
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/6402bfab
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/6402bfab
Branch: refs/heads/master
Commit: 6402bfabde8e7429cff18ab5861ee7fd1f2ac121
Parents: 91eb1cb
Author: Keith Wall <kw...@apache.org>
Authored: Tue Feb 13 15:39:58 2018 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Tue Feb 13 15:39:58 2018 +0000
----------------------------------------------------------------------
.../apache/qpid/server/transport/SNITest.java | 298 +++++++++++++++++++
.../qpid/systest/keystore/FileKeyStoreTest.java | 234 ---------------
2 files changed, 298 insertions(+), 234 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/6402bfab/broker-core/src/test/java/org/apache/qpid/server/transport/SNITest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/transport/SNITest.java b/broker-core/src/test/java/org/apache/qpid/server/transport/SNITest.java
new file mode 100644
index 0000000..49438d8
--- /dev/null
+++ b/broker-core/src/test/java/org/apache/qpid/server/transport/SNITest.java
@@ -0,0 +1,298 @@
+/*
+ * 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.transport;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.InetSocketAddress;
+import java.security.cert.Certificate;
+import java.security.cert.X509Certificate;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.net.ssl.SNIHostName;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLParameters;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.apache.qpid.server.SystemLauncher;
+import org.apache.qpid.server.SystemLauncherListener.DefaultSystemLauncherListener;
+import org.apache.qpid.server.model.AuthenticationProvider;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.BrokerModel;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.JsonSystemConfigImpl;
+import org.apache.qpid.server.model.KeyStore;
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.SystemConfig;
+import org.apache.qpid.server.model.Transport;
+import org.apache.qpid.server.security.FileKeyStore;
+import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManager;
+import org.apache.qpid.server.transport.network.security.ssl.SSLUtil;
+import org.apache.qpid.server.transport.network.security.ssl.SSLUtil.KeyCertPair;
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.TestFileUtils;
+
+public class SNITest extends QpidTestCase
+{
+ private static final int SOCKET_TIMEOUT = 10000;
+ private static final String KEYSTORE_PASSWORD = "password";
+
+ private File _keyStoreFile;
+ private KeyCertPair _fooValid;
+ private KeyCertPair _fooInvalid;
+ private KeyCertPair _barInvalid;
+ private SystemLauncher _systemLauncher;
+ private Broker<?> _broker;
+ private int _boundPort;
+ private File _brokerWork;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ if(SSLUtil.canGenerateCerts())
+ {
+
+ _fooValid = SSLUtil.generateSelfSignedCertificate("RSA",
+ "SHA256WithRSA",
+ 2048,
+ Instant.now().minus(1, ChronoUnit.DAYS).toEpochMilli(),
+ Duration.of(365, ChronoUnit.DAYS).getSeconds(),
+ "CN=foo",
+ Collections.emptySet(),
+ Collections.emptySet());
+ _fooInvalid = SSLUtil.generateSelfSignedCertificate("RSA",
+ "SHA256WithRSA",
+ 2048,
+ Instant.now().plus(1, ChronoUnit.HOURS).toEpochMilli(),
+ Duration.of(365, ChronoUnit.DAYS).getSeconds(),
+ "CN=foo",
+ Collections.emptySet(),
+ Collections.emptySet());
+
+ _barInvalid = SSLUtil.generateSelfSignedCertificate("RSA",
+ "SHA256WithRSA",
+ 2048,
+ Instant.now().plus(1, ChronoUnit.HOURS).toEpochMilli(),
+ Duration.of(365, ChronoUnit.DAYS).getSeconds(),
+ "CN=Qpid",
+ Collections.singleton("bar"),
+ Collections.emptySet());
+
+ java.security.KeyStore inMemoryKeyStore =
+ java.security.KeyStore.getInstance(java.security.KeyStore.getDefaultType());
+
+ inMemoryKeyStore.load(null, KEYSTORE_PASSWORD.toCharArray());
+ inMemoryKeyStore.setKeyEntry("foovalid",
+ _fooValid.getPrivateKey(),
+ KEYSTORE_PASSWORD.toCharArray(),
+ new X509Certificate[]{_fooValid.getCertificate()});
+
+ inMemoryKeyStore.setKeyEntry("fooinvalid",
+ _fooInvalid.getPrivateKey(),
+ KEYSTORE_PASSWORD.toCharArray(),
+ new X509Certificate[]{_fooInvalid.getCertificate()});
+
+ inMemoryKeyStore.setKeyEntry("barinvalid",
+ _barInvalid.getPrivateKey(),
+ KEYSTORE_PASSWORD.toCharArray(),
+ new X509Certificate[]{_barInvalid.getCertificate()});
+
+ _keyStoreFile = File.createTempFile("keyStore", "jks");
+ try (FileOutputStream os = new FileOutputStream(_keyStoreFile))
+ {
+ inMemoryKeyStore.store(os, KEYSTORE_PASSWORD.toCharArray());
+ }
+ }
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ try
+ {
+ if (_systemLauncher != null)
+ {
+ _systemLauncher.shutdown();
+ }
+
+ if (_brokerWork != null)
+ {
+ _brokerWork.delete();
+ }
+ if (_keyStoreFile != null)
+ {
+ _keyStoreFile.delete();
+ }
+ }
+ finally
+ {
+ super.tearDown();
+ }
+
+ }
+
+ public void testValidCertChosen() throws Exception
+ {
+ performTest(true, "fooinvalid", "foo", _fooValid);
+ }
+
+ public void testMatchCertChosenEvenIfInvalid() throws Exception
+ {
+ performTest(true, "fooinvalid", "bar", _barInvalid);
+ }
+
+ public void testDefaultCertChose() throws Exception
+ {
+ performTest(true, "fooinvalid", null, _fooInvalid);
+ }
+
+ public void testMatchingCanBeDisabled() throws Exception
+ {
+ performTest(false, "fooinvalid", "foo", _fooInvalid);
+ }
+
+
+ private void performTest(final boolean useMatching,
+ final String defaultAlias,
+ final String sniHostName,
+ final KeyCertPair expectedCert) throws Exception
+ {
+ if (SSLUtil.canGenerateCerts())
+ {
+ doBrokerStartup(useMatching, defaultAlias);
+ SSLContext context = SSLUtil.tryGetSSLContext();
+ context.init(null,
+ new TrustManager[]
+ {
+ new X509TrustManager()
+ {
+ @Override
+ public X509Certificate[] getAcceptedIssuers()
+ {
+ return null;
+ }
+
+ @Override
+ public void checkClientTrusted(X509Certificate[] certs, String authType)
+ {
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] certs, String authType)
+ {
+ }
+ }
+ },
+ null);
+
+ SSLSocketFactory socketFactory = context.getSocketFactory();
+ try (SSLSocket socket = (SSLSocket) socketFactory.createSocket())
+ {
+ SSLParameters parameters = socket.getSSLParameters();
+ if (sniHostName != null)
+ {
+ parameters.setServerNames(Collections.singletonList(new SNIHostName(sniHostName)));
+ }
+ socket.setSSLParameters(parameters);
+ InetSocketAddress address = new InetSocketAddress("localhost", _boundPort);
+ socket.connect(address, SOCKET_TIMEOUT);
+
+ final Certificate[] certs = socket.getSession().getPeerCertificates();
+ assertEquals(1, certs.length);
+ assertEquals(expectedCert.getCertificate(), certs[0]);
+ }
+ }
+ }
+
+ private void doBrokerStartup(boolean useMatching, String defaultAlias) throws Exception
+ {
+ final File initialConfiguration = createInitialContext();
+ _brokerWork = TestFileUtils.createTestDirectory("qpid-work", true);
+
+ Map<String, String> context = new HashMap<>();
+ context.put("qpid.work_dir", _brokerWork.toString());
+
+ Map<String,Object> attributes = new HashMap<>();
+ attributes.put(SystemConfig.INITIAL_CONFIGURATION_LOCATION, initialConfiguration.getAbsolutePath());
+ attributes.put(SystemConfig.TYPE, JsonSystemConfigImpl.SYSTEM_CONFIG_TYPE);
+ attributes.put(SystemConfig.CONTEXT, context);
+ _systemLauncher = new SystemLauncher(new DefaultSystemLauncherListener()
+ {
+ @Override
+ public void onContainerResolve(final SystemConfig<?> systemConfig)
+ {
+ _broker = systemConfig.getContainer(Broker.class);
+ }
+ });
+ _systemLauncher.startup(attributes);
+
+ final Map<String, Object> authProviderAttr = new HashMap<>();
+ authProviderAttr.put(AuthenticationProvider.NAME, "myAuthProvider");
+ authProviderAttr.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE);
+
+ final AuthenticationProvider authProvider = _broker.createChild(AuthenticationProvider.class, authProviderAttr);
+
+ Map<String, Object> keyStoreAttr = new HashMap<>();
+ keyStoreAttr.put(FileKeyStore.NAME, "myKeyStore");
+ keyStoreAttr.put(FileKeyStore.STORE_URL, _keyStoreFile.toURI().toURL().toString());
+ keyStoreAttr.put(FileKeyStore.PASSWORD, KEYSTORE_PASSWORD);
+ keyStoreAttr.put(FileKeyStore.USE_HOST_NAME_MATCHING, useMatching);
+ keyStoreAttr.put(FileKeyStore.CERTIFICATE_ALIAS, defaultAlias);
+
+ final KeyStore keyStore = _broker.createChild(KeyStore.class, keyStoreAttr);
+
+ Map<String, Object> portAttr = new HashMap<>();
+ portAttr.put(Port.NAME, "myPort");
+ portAttr.put(Port.TYPE, "AMQP");
+ portAttr.put(Port.TRANSPORTS, Collections.singleton(Transport.SSL));
+ portAttr.put(Port.PORT, 0);
+ portAttr.put(Port.AUTHENTICATION_PROVIDER, authProvider);
+ portAttr.put(Port.KEY_STORE, keyStore);
+
+ final Port<?> port = _broker.createChild(Port.class, portAttr);
+
+ _boundPort = port.getBoundPort();
+ }
+
+ private File createInitialContext() throws JsonProcessingException
+ {
+ // create empty initial configuration
+ Map<String,Object> initialConfig = new HashMap<>();
+ initialConfig.put(ConfiguredObject.NAME, "test");
+ initialConfig.put(Broker.MODEL_VERSION, BrokerModel.MODEL_VERSION);
+
+ ObjectMapper mapper = new ObjectMapper();
+ String config = mapper.writeValueAsString(initialConfig);
+ return TestFileUtils.createTempFile(this, ".initial-config.json", config);
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/6402bfab/systests/src/test/java/org/apache/qpid/systest/keystore/FileKeyStoreTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/keystore/FileKeyStoreTest.java b/systests/src/test/java/org/apache/qpid/systest/keystore/FileKeyStoreTest.java
deleted file mode 100644
index 77a6436..0000000
--- a/systests/src/test/java/org/apache/qpid/systest/keystore/FileKeyStoreTest.java
+++ /dev/null
@@ -1,234 +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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.keystore;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.InetSocketAddress;
-import java.security.cert.Certificate;
-import java.security.cert.X509Certificate;
-import java.time.Duration;
-import java.time.Instant;
-import java.time.temporal.ChronoUnit;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.net.ssl.SNIHostName;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLParameters;
-import javax.net.ssl.SSLSocket;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-
-import org.apache.qpid.server.model.DefaultVirtualHostAlias;
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.Transport;
-import org.apache.qpid.server.model.VirtualHostAlias;
-import org.apache.qpid.server.model.VirtualHostNameAlias;
-import org.apache.qpid.server.security.FileKeyStore;
-import org.apache.qpid.server.transport.network.security.ssl.SSLUtil;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-
-public class FileKeyStoreTest extends QpidBrokerTestCase
-{
- private File _keyStoreFile;
- private SSLUtil.KeyCertPair _fooValid;
- private SSLUtil.KeyCertPair _fooInvalid;
- private SSLUtil.KeyCertPair _barInvalid;
- private TrustManager[] _clientTrustManagers;
-
- @Override
- public void setUp() throws Exception
- {
- setSystemProperty("javax.net.debug", "ssl");
- if(SSLUtil.canGenerateCerts())
- {
-
- _fooValid = SSLUtil.generateSelfSignedCertificate("RSA",
- "SHA256WithRSA",
- 2048,
- Instant.now().minus(1, ChronoUnit.DAYS).toEpochMilli(),
- Duration.of(365, ChronoUnit.DAYS).getSeconds(),
- "CN=foo",
- Collections.emptySet(),
- Collections.emptySet());
- _fooInvalid = SSLUtil.generateSelfSignedCertificate("RSA",
- "SHA256WithRSA",
- 2048,
- Instant.now().plus(1, ChronoUnit.HOURS).toEpochMilli(),
- Duration.of(365, ChronoUnit.DAYS).getSeconds(),
- "CN=foo",
- Collections.emptySet(),
- Collections.emptySet());
-
- _barInvalid = SSLUtil.generateSelfSignedCertificate("RSA",
- "SHA256WithRSA",
- 2048,
- Instant.now().plus(1, ChronoUnit.HOURS).toEpochMilli(),
- Duration.of(365, ChronoUnit.DAYS).getSeconds(),
- "CN=Qpid",
- Collections.singleton("bar"),
- Collections.emptySet());
-
- java.security.KeyStore inMemoryKeyStore =
- java.security.KeyStore.getInstance(java.security.KeyStore.getDefaultType());
-
- inMemoryKeyStore.load(null, "password".toCharArray());
- inMemoryKeyStore.setKeyEntry("foovalid",
- _fooValid.getPrivateKey(),
- "password".toCharArray(),
- new X509Certificate[]{_fooValid.getCertificate()});
-
- inMemoryKeyStore.setKeyEntry("fooinvalid",
- _fooInvalid.getPrivateKey(),
- "password".toCharArray(),
- new X509Certificate[]{_fooInvalid.getCertificate()});
-
- inMemoryKeyStore.setKeyEntry("barinvalid",
- _barInvalid.getPrivateKey(),
- "password".toCharArray(),
- new X509Certificate[]{_barInvalid.getCertificate()});
-
- _keyStoreFile = File.createTempFile("keyStore", "jks");
- try (FileOutputStream os = new FileOutputStream(_keyStoreFile))
- {
- inMemoryKeyStore.store(os, "password".toCharArray());
- }
-
- }
- super.setUp();
- }
-
- @Override
- public void startDefaultBroker() throws Exception
- {
- // Do broker startup in tests
- }
-
- private void doBrokerStartup(boolean useMatching, String defaultAlias) throws Exception
- {
- getDefaultBrokerConfiguration().setObjectAttribute(org.apache.qpid.server.model.KeyStore.class, TestBrokerConfiguration.ENTRY_NAME_SSL_KEYSTORE,
- FileKeyStore.STORE_URL, _keyStoreFile.toURI().toURL().toString());
-
- getDefaultBrokerConfiguration().setObjectAttribute(org.apache.qpid.server.model.KeyStore.class, TestBrokerConfiguration.ENTRY_NAME_SSL_KEYSTORE,
- FileKeyStore.PASSWORD, "password");
- getDefaultBrokerConfiguration().setObjectAttribute(org.apache.qpid.server.model.KeyStore.class, TestBrokerConfiguration.ENTRY_NAME_SSL_KEYSTORE,
- FileKeyStore.USE_HOST_NAME_MATCHING, String.valueOf(useMatching));
-
- getDefaultBrokerConfiguration().setObjectAttribute(org.apache.qpid.server.model.KeyStore.class, TestBrokerConfiguration.ENTRY_NAME_SSL_KEYSTORE,
- FileKeyStore.CERTIFICATE_ALIAS, defaultAlias);
-
- Map<String, Object> sslPortAttributes = new HashMap<>();
- sslPortAttributes.put(Port.TRANSPORTS, Collections.singleton(Transport.SSL));
- sslPortAttributes.put(Port.PORT, DEFAULT_SSL_PORT);
- sslPortAttributes.put(Port.AUTHENTICATION_PROVIDER, TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER);
- sslPortAttributes.put(Port.NEED_CLIENT_AUTH, false);
- sslPortAttributes.put(Port.WANT_CLIENT_AUTH, false);
- sslPortAttributes.put(Port.NAME, TestBrokerConfiguration.ENTRY_NAME_SSL_PORT);
- sslPortAttributes.put(Port.KEY_STORE, TestBrokerConfiguration.ENTRY_NAME_SSL_KEYSTORE);
- sslPortAttributes.put(Port.TRUST_STORES, Collections.singleton(TestBrokerConfiguration.ENTRY_NAME_SSL_TRUSTSTORE));
- sslPortAttributes.put(Port.PROTOCOLS, System.getProperty(TEST_AMQP_PORT_PROTOCOLS_PROPERTY));
- getDefaultBrokerConfiguration().addObjectConfiguration(Port.class, sslPortAttributes);
-
- Map<String, Object> aliasAttributes = new HashMap<>();
- aliasAttributes.put(VirtualHostAlias.NAME, "defaultAlias");
- aliasAttributes.put(VirtualHostAlias.TYPE, DefaultVirtualHostAlias.TYPE_NAME);
- getDefaultBrokerConfiguration().addObjectConfiguration(Port.class, TestBrokerConfiguration.ENTRY_NAME_SSL_PORT, VirtualHostAlias.class, aliasAttributes);
-
- aliasAttributes = new HashMap<>();
- aliasAttributes.put(VirtualHostAlias.NAME, "nameAlias");
- aliasAttributes.put(VirtualHostAlias.TYPE, VirtualHostNameAlias.TYPE_NAME);
- getDefaultBrokerConfiguration().addObjectConfiguration(Port.class, TestBrokerConfiguration.ENTRY_NAME_SSL_PORT, VirtualHostAlias.class, aliasAttributes);
-
- super.startDefaultBroker();
- }
-
- public void testValidCertChosen() throws Exception
- {
- performTest(true, "fooinvalid", "foo", _fooValid);
- }
-
- public void testMatchCertChosenEvenIfInvalid() throws Exception
- {
- performTest(true, "fooinvalid", "bar", _barInvalid);
- }
-
- public void testDefaultCertChose() throws Exception
- {
- performTest(true, "fooinvalid", null, _fooInvalid);
- }
-
- public void testMatchingCanBeDisabled() throws Exception
- {
- performTest(false, "fooinvalid", "foo", _fooInvalid);
- }
-
-
- private void performTest(final boolean useMatching,
- final String defaultAlias,
- final String sniHostName,
- final SSLUtil.KeyCertPair expectedCert) throws Exception
- {
- if (isJavaBroker() && SSLUtil.canGenerateCerts())
- {
- doBrokerStartup(useMatching, defaultAlias);
- SSLContext context = SSLUtil.tryGetSSLContext();
- context.init(null,
- new TrustManager[]
- {
- new X509TrustManager()
- {
- @Override
- public X509Certificate[] getAcceptedIssuers()
- {
- return null;
- }
-
- @Override
- public void checkClientTrusted(X509Certificate[] certs, String authType)
- {
- }
-
- @Override
- public void checkServerTrusted(X509Certificate[] certs, String authType)
- {
- }
- }
- },
- null);
-
- SSLSocketFactory socketFactory = context.getSocketFactory();
- SSLSocket socket = (SSLSocket) socketFactory.createSocket();
- SSLParameters parameters = socket.getSSLParameters();
- if(sniHostName != null)
- {
- parameters.setServerNames(Collections.singletonList(new SNIHostName(sniHostName)));
- }
- socket.setSSLParameters(parameters);
- InetSocketAddress address =
- new InetSocketAddress("localhost", getDefaultBroker().getAmqpTlsPort());
- socket.connect(address);
- final Certificate[] certs = socket.getSession().getPeerCertificates();
- assertEquals(1, certs.length);
- assertEquals(expectedCert.getCertificate(), certs[0]);
- }
- }
-}
---------------------------------------------------------------------
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]
Refactor MessageContentCompressionRestTest
Posted by kw...@apache.org.
QPID-8083 [System Tests] [REST/HTTP] Refactor MessageContentCompressionRestTest
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/b603e03f
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/b603e03f
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/b603e03f
Branch: refs/heads/master
Commit: b603e03ff34a2477cbad30cb76a8271395624fd7
Parents: 6402bfa
Author: Keith Wall <kw...@apache.org>
Authored: Tue Feb 13 16:46:31 2018 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Tue Feb 13 16:46:31 2018 +0000
----------------------------------------------------------------------
.../message/CompressedMessageContentTest.java | 262 ++++++++++++++
.../rest/MessageContentCompressionRestTest.java | 338 -------------------
test-profiles/CPPExcludes | 3 -
test-profiles/Java10Excludes | 3 -
4 files changed, 262 insertions(+), 344 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/b603e03f/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/CompressedMessageContentTest.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/CompressedMessageContentTest.java b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/CompressedMessageContentTest.java
new file mode 100644
index 0000000..62a85c6
--- /dev/null
+++ b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/CompressedMessageContentTest.java
@@ -0,0 +1,262 @@
+/*
+ * 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 org.apache.qpid.server.model.Broker.BROKER_MESSAGE_COMPRESSION_ENABLED;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assume.assumeThat;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.nio.charset.StandardCharsets;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.GZIPInputStream;
+
+import javax.jms.Connection;
+import javax.jms.MapMessage;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.qpid.server.model.Protocol;
+import org.apache.qpid.tests.http.HttpRequestConfig;
+import org.apache.qpid.tests.http.HttpTestBase;
+import org.apache.qpid.tests.utils.ConfigItem;
+
+@HttpRequestConfig
+@ConfigItem(name = BROKER_MESSAGE_COMPRESSION_ENABLED, value = "true")
+public class CompressedMessageContentTest extends HttpTestBase
+{
+ private static final String TEST_QUEUE = "testQueue";
+
+ @Before
+ public void setUp() throws Exception
+ {
+ assumeThat(getProtocol(), is(not(equalTo(Protocol.AMQP_1_0))));
+ getHelper().setTls(true);
+ getBrokerAdmin().createQueue(TEST_QUEUE);
+ }
+
+ @Test
+ public void getCompressedMessageContent_noCompressionSupported() throws Exception
+ {
+ final String messageText = sendCompressibleTextMessage();
+
+ String queueRelativePath = String.format("queue/%s", TEST_QUEUE);
+
+ List<Map<String, Object>> messages = getHelper().getJsonAsList(queueRelativePath + "/getMessageInfo");
+ assertThat(messages.size(), is(equalTo(1)));
+ final Map<String, Object> message = messages.get(0);
+ assertThat(message.get("encoding"), is(equalTo("gzip")));
+ long id = ((Number) message.get("id")).longValue();
+
+ byte[] messageBytes = getHelper().getBytes(queueRelativePath + "/getMessageContent?messageId=" + id);
+ String content = new String(messageBytes, StandardCharsets.UTF_8);
+ assertThat("Unexpected message content", content, is(equalTo(messageText)));
+
+ messageBytes = getHelper().getBytes(queueRelativePath + "/getMessageContent?limit=1024&decompressBeforeLimiting=true&messageId=" + id);
+ content = new String(messageBytes, StandardCharsets.UTF_8);
+ assertThat("Unexpected limited message content", content, is(equalTo(messageText.substring(0, 1024))));
+ }
+
+ @Test
+ public void getCompressedMessageContent_compressionSupported() throws Exception
+ {
+ final String messageText = sendCompressibleTextMessage();
+
+ String queueRelativePath = String.format("queue/%s", TEST_QUEUE);
+
+ List<Map<String, Object>> messages = getHelper().getJsonAsList(queueRelativePath + "/getMessageInfo");
+ assertThat(messages.size(), is(equalTo(1)));
+
+ final Map<String, Object> message = messages.get(0);
+ assertThat(message.get("encoding"), is(equalTo("gzip")));
+ long id = ((Number) message.get("id")).longValue();
+
+ getHelper().setAcceptEncoding("gzip, deflate, br");
+ String content = getDecompressedContent(queueRelativePath + "/getMessageContent?messageId=" + id);
+ assertThat("Unexpected message content", content, is(equalTo(messageText)));
+
+ content = getDecompressedContent(queueRelativePath + "/getMessageContent?limit=1024&decompressBeforeLimiting=true&messageId=" + id);
+ assertThat("Unexpected limited message content", content, is(equalTo(messageText.substring(0, 1024))));
+ }
+
+ @Test
+ public void getCompressedMapMessage_noCompressionSupported() throws Exception
+ {
+ final Map<String, Object> mapToSend = sendCompressibleMapMessage();
+
+ String queueRelativePath = String.format("queue/%s", TEST_QUEUE);
+
+ List<Map<String, Object>> messages = getHelper().getJsonAsList(queueRelativePath + "/getMessageInfo");
+ assertThat(messages.size(), is(equalTo(1)));
+
+ final Map<String, Object> message = messages.get(0);
+ assertThat(message.get("encoding"), is(equalTo("gzip")));
+ long id = ((Number) message.get("id")).longValue();
+
+
+ Map<String, Object> content = getHelper().getJsonAsMap(queueRelativePath + "/getMessageContent?returnJson=true&messageId=" + id);
+ assertThat("Unexpected message content: difference ", new HashMap<>(content), is(equalTo(new HashMap<>(mapToSend))));
+ }
+
+ @Test
+ public void getCompressedMapMessage_compressionSupported() throws Exception
+ {
+ final Map<String, Object> mapToSend = sendCompressibleMapMessage();
+
+ String queueRelativePath = String.format("queue/%s", TEST_QUEUE);
+
+ List<Map<String, Object>> messages = getHelper().getJsonAsList(queueRelativePath + "/getMessageInfo");
+ assertThat(messages.size(), is(equalTo(1)));
+
+ final Map<String, Object> message = messages.get(0);
+ assertThat(message.get("encoding"), is(equalTo("gzip")));
+ long id = ((Number) message.get("id")).longValue();
+
+ getHelper().setAcceptEncoding("gzip, deflate, br");
+ HttpURLConnection connection =
+ getHelper().openManagementConnection(queueRelativePath
+ + "/getMessageContent?returnJson=true&messageId="
+ + id,
+ "GET");
+ connection.connect();
+
+ String content = decompressInputStream(connection);
+ Map<String, Object> mapContent = new ObjectMapper().readValue(content, new TypeReference<Map<String, Object>>() {});
+
+ assertThat("Unexpected message content ", new HashMap<>(mapContent), is(equalTo(new HashMap<>(mapToSend))));
+ }
+
+ private String getDecompressedContent(final String url) throws IOException
+ {
+ HttpURLConnection connection = getHelper().openManagementConnection(url, "GET");
+ connection.connect();
+ return decompressInputStream(connection);
+ }
+
+ private String decompressInputStream(final HttpURLConnection connection) throws IOException
+ {
+ try (InputStream is = new GZIPInputStream(connection.getInputStream());
+ ByteArrayOutputStream baos = new ByteArrayOutputStream())
+ {
+ byte[] buffer = new byte[1024];
+ int len;
+ while ((len = is.read(buffer)) != -1)
+ {
+ baos.write(buffer, 0, len);
+ }
+ return new String(baos.toByteArray(), StandardCharsets.UTF_8);
+ }
+ }
+
+ private String sendCompressibleTextMessage() throws Exception
+ {
+ final String messageText = createCompressibleMessageText();
+ Connection connection = getConnection(true);
+ try
+ {
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer producer = session.createProducer(session.createQueue(TEST_QUEUE));
+ TextMessage sentMessage = session.createTextMessage(messageText);
+ producer.send(sentMessage);
+ }
+ finally
+ {
+ connection.close();
+ }
+ return messageText;
+ }
+
+ private Map<String, Object> sendCompressibleMapMessage() throws Exception
+ {
+ final Map<String, Object> mapToSend = createCompressibleMapMessage();
+
+ Connection senderConnection = getConnection(true);
+ try
+ {
+ Session session = senderConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer producer = session.createProducer(session.createQueue(TEST_QUEUE));
+ MapMessage sentMessage = session.createMapMessage();
+ for(Map.Entry<String,Object> entry: mapToSend.entrySet())
+ {
+ String key = entry.getKey();
+ Object value = entry.getValue();
+ sentMessage.setObject(key, value);
+ }
+
+ producer.send(sentMessage);
+ }
+ finally
+ {
+ senderConnection.close();
+ }
+ return mapToSend;
+ }
+
+ private Map<String, Object> createCompressibleMapMessage()
+ {
+ Map<String, Object> mapToSend = new HashMap<>();
+
+ String message = "This is a sample message";
+ int i = 0, l = message.length();
+ do
+ {
+ mapToSend.put("text" + i, message);
+ i++;
+ }
+ while (i * l < 2048 * 1024);
+
+ mapToSend.put("int", 1);
+ return mapToSend;
+ }
+
+ private String createCompressibleMessageText()
+ {
+ StringBuilder stringBuilder = new StringBuilder();
+ while(stringBuilder.length() < 2048*1024)
+ {
+ stringBuilder.append("This should compress easily. ");
+ }
+ return stringBuilder.toString();
+ }
+
+ private Connection getConnection(final boolean compress) throws Exception
+ {
+ Map<String, String> options = Collections.singletonMap("compressMessages", String.valueOf(compress));
+ return getConnectionBuilder().setOptions(options).build();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/b603e03f/systests/src/test/java/org/apache/qpid/systest/rest/MessageContentCompressionRestTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/rest/MessageContentCompressionRestTest.java b/systests/src/test/java/org/apache/qpid/systest/rest/MessageContentCompressionRestTest.java
deleted file mode 100644
index 6f5621b..0000000
--- a/systests/src/test/java/org/apache/qpid/systest/rest/MessageContentCompressionRestTest.java
+++ /dev/null
@@ -1,338 +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.ByteArrayOutputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.zip.GZIPInputStream;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.Maps;
-
-import org.apache.qpid.jms.ConnectionURL;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.systest.rest.RestTestHelper;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-
-public class MessageContentCompressionRestTest extends QpidBrokerTestCase
-{
- private static String VIRTUAL_HOST = "test";
- private RestTestHelper _restTestHelper;
-
- @Override
- public void startDefaultBroker()
- {
- // tests are starting the broker
- }
-
- public void doActualSetUp() throws Exception
- {
- TestBrokerConfiguration config = getDefaultBrokerConfiguration();
- config.addHttpManagementConfiguration();
- config.setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_HTTP_PORT,
- Port.ALLOW_CONFIDENTIAL_OPERATIONS_ON_INSECURE_CHANNELS,
- true);
- super.startDefaultBroker();
-
- _restTestHelper = new RestTestHelper(getDefaultBroker().getHttpPort());
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- try
- {
- super.tearDown();
- }
- finally
- {
- _restTestHelper.tearDown();
- }
- }
-
- public void testGetContentViaRestForCompressedMessageWithAgentNotSupportingCompression() throws Exception
- {
- setTestSystemProperty(Broker.BROKER_MESSAGE_COMPRESSION_ENABLED, String.valueOf(true));
-
- doActualSetUp();
-
- String messageText = createMessageText();
- Connection senderConnection = getConnection(true);
- Session session = senderConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue testQueue = createTestQueue(session);
-
- publishMessage(senderConnection, messageText, testQueue);
-
- String queueRelativePath = "queue/" + VIRTUAL_HOST + "/" + VIRTUAL_HOST + "/" + testQueue.getQueueName();
-
- List<Map<String, Object>> messages = _restTestHelper.getJsonAsList(queueRelativePath + "/getMessageInfo");
- assertEquals("Unexpected number of messages", 1, messages.size());
- long id = ((Number) messages.get(0).get("id")).longValue();
-
- byte[] messageBytes = _restTestHelper.getBytes(queueRelativePath + "/getMessageContent?messageId=" + id);
- String content = new String(messageBytes, StandardCharsets.UTF_8);
- assertEquals("Unexpected message content :" + content, messageText, content);
-
- messageBytes = _restTestHelper.getBytes(queueRelativePath + "/getMessageContent?limit=1024&decompressBeforeLimiting=true&messageId=" + id);
- content = new String(messageBytes, StandardCharsets.UTF_8);
- assertEquals("Unexpected message content :" + content, messageText.substring(0, 1024), content);
- }
-
- public void testGetContentViaRestForCompressedMessageWithAgentSupportingCompression() throws Exception
- {
- setTestSystemProperty(Broker.BROKER_MESSAGE_COMPRESSION_ENABLED, String.valueOf(true));
-
- doActualSetUp();
-
- String messageText = createMessageText();
- Connection senderConnection = getConnection(true);
- Session session = senderConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue testQueue = createTestQueue(session);
-
- publishMessage(senderConnection, messageText, testQueue);
-
- String queueRelativePath = "queue/" + VIRTUAL_HOST + "/" + VIRTUAL_HOST + "/" + testQueue.getQueueName();
-
- List<Map<String, Object>> messages = _restTestHelper.getJsonAsList(queueRelativePath + "/getMessageInfo");
- assertEquals("Unexpected number of messages", 1, messages.size());
- long id = ((Number) messages.get(0).get("id")).longValue();
-
- _restTestHelper.setAcceptEncoding("gzip, deflate, br");
- String content = getDecompressedContent(queueRelativePath + "/getMessageContent?messageId=" + id);
- assertEquals("Unexpected message content :" + content, messageText, content);
-
- content = getDecompressedContent(queueRelativePath + "/getMessageContent?limit=1024&decompressBeforeLimiting=true&messageId=" + id);
- assertEquals("Unexpected message content :" + content, messageText.substring(0, 1024), content);
- }
-
- public void testGetTruncatedContentViaRestForCompressedMessage() throws Exception
- {
- setTestSystemProperty(Broker.BROKER_MESSAGE_COMPRESSION_ENABLED, String.valueOf(true));
-
- doActualSetUp();
-
- String messageText = createMessageText();
- Connection senderConnection = getConnection(true);
- Session session = senderConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue testQueue = createTestQueue(session);
-
- publishMessage(senderConnection, messageText, testQueue);
-
- String queueRelativePath = "queue/" + VIRTUAL_HOST + "/" + VIRTUAL_HOST + "/" + testQueue.getQueueName();
-
- List<Map<String, Object>> messages = _restTestHelper.getJsonAsList(queueRelativePath + "/getMessageInfo");
- assertEquals("Unexpected number of messages", 1, messages.size());
- long id = ((Number) messages.get(0).get("id")).longValue();
-
- _restTestHelper.setAcceptEncoding("gzip");
- try
- {
- getDecompressedContent(queueRelativePath + "/getMessageContent?limit=1024&messageId=" + id);
- fail("Should not be able to decompress truncated gzip");
- }
- catch (EOFException e)
- {
- // pass
- }
- }
-
- private String getDecompressedContent(final String url) throws IOException
- {
- HttpURLConnection connection = _restTestHelper.openManagementConnection(url, "GET");
- connection.connect();
- return decompressInputStream(connection);
- }
-
- public void testGetContentViaRestForCompressedMapMessageWithAgentNotSupportingCompression() throws Exception
- {
- setTestSystemProperty(Broker.BROKER_MESSAGE_COMPRESSION_ENABLED, String.valueOf(true));
-
- doActualSetUp();
-
- Connection senderConnection = getConnection(true);
- Session session = senderConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue testQueue = createTestQueue(session);
-
- Map<String, Object> mapToSend = createMapToSend();
- publishMapMessage(senderConnection, mapToSend, testQueue);
-
- String queueRelativePath = "queue/" + VIRTUAL_HOST + "/" + VIRTUAL_HOST + "/" + testQueue.getQueueName();
-
- List<Map<String, Object>> messages = _restTestHelper.getJsonAsList(queueRelativePath + "/getMessageInfo");
- assertEquals("Unexpected number of messages", 1, messages.size());
- long id = ((Number) messages.get(0).get("id")).longValue();
-
- Map<String, Object> content =
- _restTestHelper.getJsonAsMap(queueRelativePath + "/getMessageContent?returnJson=true&messageId=" + id);
- assertEquals("Unexpected message content: difference " + Maps.difference(mapToSend, content),
- new HashMap<>(mapToSend),
- new HashMap<>(content));
- }
-
- public void testGetContentViaRestForCompressedMapMessageWithAgentSupportingCompression() throws Exception
- {
- setTestSystemProperty(Broker.BROKER_MESSAGE_COMPRESSION_ENABLED, String.valueOf(true));
-
- doActualSetUp();
-
- Connection senderConnection = getConnection(true);
- Session session = senderConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue testQueue = createTestQueue(session);
-
- Map<String, Object> mapToSend = createMapToSend();
- publishMapMessage(senderConnection, mapToSend, testQueue);
-
-
- String queueRelativePath = "queue/" + VIRTUAL_HOST + "/" + VIRTUAL_HOST + "/" + testQueue.getQueueName();
-
- List<Map<String, Object>> messages = _restTestHelper.getJsonAsList(queueRelativePath + "/getMessageInfo");
- assertEquals("Unexpected number of messages", 1, messages.size());
- long id = ((Number) messages.get(0).get("id")).longValue();
-
- _restTestHelper.setAcceptEncoding("gzip, deflate, br");
- HttpURLConnection connection =
- _restTestHelper.openManagementConnection(queueRelativePath
- + "/getMessageContent?returnJson=true&messageId="
- + id,
- "GET");
- connection.connect();
-
- String content = decompressInputStream(connection);
- Map<String, Object> mapContent = new ObjectMapper().readValue(content, Map.class);
- assertEquals("Unexpected message content: difference " + Maps.difference(mapToSend, mapContent),
- new HashMap<>(mapToSend),
- new HashMap<>(mapContent));
- }
-
- private Map<String, Object> createMapToSend()
- {
- Map<String, Object> mapToSend = new HashMap<>();
-
- String message = "This is a sample message";
- int i = 0, l = message.length();
- do
- {
- mapToSend.put("text" + i, message);
- i++;
- }
- while (i * l < 2048 * 1024);
-
- mapToSend.put("int", 1);
- return mapToSend;
- }
-
- private String decompressInputStream(final HttpURLConnection connection) throws IOException
- {
- String content;
- try (InputStream is = new GZIPInputStream(connection.getInputStream());
- ByteArrayOutputStream baos = new ByteArrayOutputStream())
- {
- byte[] buffer = new byte[1024];
- int len;
- while ((len = is.read(buffer)) != -1)
- {
- baos.write(buffer, 0, len);
- }
- content = new String(baos.toByteArray(), StandardCharsets.UTF_8);
- }
- return content;
- }
-
- private void publishMapMessage(final Connection senderConnection,
- final Map<String, Object> mapData,
- final Queue testQueue)
- throws JMSException, org.apache.qpid.QpidException
- {
- Session session = senderConnection.createSession(true, Session.SESSION_TRANSACTED);
-
- MessageProducer producer = session.createProducer(testQueue);
- MapMessage sentMessage = session.createMapMessage();
- sentMessage.setStringProperty("bar", "foo");
- for(Map.Entry<String,Object> entry: mapData.entrySet())
- {
- String key = entry.getKey();
- Object value = entry.getValue();
- if (value instanceof String)
- {
- sentMessage.setString(key, (String) value);
- }
- else if (value instanceof Integer)
- {
- sentMessage.setInt(key, (Integer) value);
- }
- else
- {
- throw new RuntimeException("Setting value of type " + value.getClass() + " is not implemented yet");
- }
- }
-
- producer.send(sentMessage);
- session.commit();
- }
-
- private void publishMessage(final Connection senderConnection, final String messageText, final Queue testQueue)
- throws JMSException, org.apache.qpid.QpidException
- {
- Session session = senderConnection.createSession(true, Session.SESSION_TRANSACTED);
-
- MessageProducer producer = session.createProducer(testQueue);
- TextMessage sentMessage = session.createTextMessage(messageText);
- sentMessage.setStringProperty("bar", "foo");
-
- producer.send(sentMessage);
- session.commit();
- }
-
- private String createMessageText()
- {
- StringBuilder stringBuilder = new StringBuilder();
- while(stringBuilder.length() < 2048*1024)
- {
- stringBuilder.append("This should compress easily. ");
- }
- return stringBuilder.toString();
- }
-
- private Connection getConnection(final boolean compress) throws Exception
- {
- Map<String, String> options = new HashMap<>();
- options.put(ConnectionURL.OPTIONS_COMPRESS_MESSAGES,String.valueOf(compress));
- return getConnectionWithOptions(options);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/b603e03f/test-profiles/CPPExcludes
----------------------------------------------------------------------
diff --git a/test-profiles/CPPExcludes b/test-profiles/CPPExcludes
index 2d24142..d8ae4d7 100755
--- a/test-profiles/CPPExcludes
+++ b/test-profiles/CPPExcludes
@@ -81,9 +81,6 @@ org.apache.qpid.systest.rest.*
org.apache.qpid.systest.rest.acl.*
-// QPID-6000 : Tests Qpid Broker-J specific message compression functionality, and uses the REST API to test it
-org.apache.qpid.systest.rest.MessageContentCompressionRestTest#*
-
org.apache.qpid.test.unit.client.AMQSessionTest#testQueueDepthForQueueThatDoesNotExistLegacyBehaviour_08_091
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/b603e03f/test-profiles/Java10Excludes
----------------------------------------------------------------------
diff --git a/test-profiles/Java10Excludes b/test-profiles/Java10Excludes
index 3128524..611c6b9 100644
--- a/test-profiles/Java10Excludes
+++ b/test-profiles/Java10Excludes
@@ -33,9 +33,6 @@ org.apache.qpid.server.logging.ChannelLoggingTest#testChannelClosedOnExclusiveQu
// This test is checking features of the 0-x client specific implementation of Session
org.apache.qpid.test.unit.client.AMQSessionTest#*
-// Message compression not currently supported by the 1.0 client
-org.apache.qpid.systest.rest.MessageContentCompressionRestTest#*
-
// Tests the interaction between the Broker's supported protocols and what the 0-x client agrees to
org.apache.qpid.server.SupportedProtocolVersionsTest#*
---------------------------------------------------------------------
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]
Remove some repetitious tests
Posted by kw...@apache.org.
QPID-8083 [System Tests] [REST/HTTP] Remove some repetitious 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/7601044d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/7601044d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/7601044d
Branch: refs/heads/master
Commit: 7601044d16664383e227011398ae29ebe1b84eeb
Parents: b603e03
Author: Keith Wall <kw...@apache.org>
Authored: Tue Feb 13 18:06:22 2018 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Tue Feb 13 18:11:31 2018 +0000
----------------------------------------------------------------------
.../qpid/server/security/NonJavaKeyStore.java | 3 +
.../qpid/tests/http/rest/model/ReadTest.java | 107 ++++++++
.../qpid/systest/rest/BrokerRestTest.java | 268 -------------------
.../qpid/systest/rest/ExchangeRestTest.java | 122 ---------
.../systest/rest/HttpManagementRestTest.java | 93 -------
.../qpid/systest/rest/KeyStoreRestTest.java | 158 -----------
.../qpid/systest/rest/TrustStoreRestTest.java | 161 -----------
.../apache/qpid/systest/rest/UserRestTest.java | 165 ------------
.../systest/rest/VirtualHostNodeRestTest.java | 234 ----------------
test-profiles/Java010Excludes | 3 -
test-profiles/JavaJsonExcludes | 2 -
11 files changed, 110 insertions(+), 1206 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/7601044d/broker-core/src/main/java/org/apache/qpid/server/security/NonJavaKeyStore.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/security/NonJavaKeyStore.java b/broker-core/src/main/java/org/apache/qpid/server/security/NonJavaKeyStore.java
index d331087..cc7b173 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/security/NonJavaKeyStore.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/security/NonJavaKeyStore.java
@@ -30,6 +30,9 @@ import org.apache.qpid.server.model.ManagedObject;
@ManagedObject( category = false, type = "NonJavaKeyStore" )
public interface NonJavaKeyStore<X extends NonJavaKeyStore<X>> extends KeyStore<X>
{
+ String CERTIFICATE_URL = "certificateUrl";
+ String PRIVATE_KEY_URL = "privateKeyUrl";
+
@Override
@ManagedAttribute(defaultValue = "${this:subjectName}")
String getDescription();
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/7601044d/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/ReadTest.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/ReadTest.java b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/ReadTest.java
index 447f062..43ee305 100644
--- a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/ReadTest.java
+++ b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/ReadTest.java
@@ -31,7 +31,13 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.isOneOf;
+import static org.junit.Assume.assumeThat;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -45,7 +51,15 @@ 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.AbstractConfiguredObject;
import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.User;
+import org.apache.qpid.server.security.NonJavaKeyStore;
+import org.apache.qpid.server.security.NonJavaTrustStore;
+import org.apache.qpid.server.transport.network.security.ssl.SSLUtil;
+import org.apache.qpid.server.transport.network.security.ssl.SSLUtil.KeyCertPair;
+import org.apache.qpid.server.util.DataUrlUtils;
+import org.apache.qpid.server.util.FileUtils;
import org.apache.qpid.tests.http.HttpRequestConfig;
import org.apache.qpid.tests.http.HttpTestBase;
@@ -212,6 +226,89 @@ public class ReadTest extends HttpTestBase
}
}
+ @Test
+ @HttpRequestConfig(useVirtualHostAsHost = false)
+ public void secureAttributes() throws Exception
+ {
+ final String validUsername = getBrokerAdmin().getValidUsername();
+ final Map<String, Object> user = getHelper().getJsonAsMap("user/plain/" + validUsername);
+ assertThat(user.get(User.NAME), is(equalTo(validUsername)));
+ assertThat(user.get(User.PASSWORD), is(equalTo(AbstractConfiguredObject.SECURED_STRING_VALUE)));
+ }
+
+ @Test
+ @HttpRequestConfig(useVirtualHostAsHost = false)
+ public void valueFilteredSecureAttributes() throws Exception
+ {
+ assumeThat(SSLUtil.canGenerateCerts(), is(equalTo(true)));
+
+ final KeyCertPair keyCertPair = generateCertKeyPair();
+ final byte[] privateKey = keyCertPair.getPrivateKey().getEncoded();
+ final byte[] cert = keyCertPair.getCertificate().getEncoded();
+ final String privateKeyUrl = DataUrlUtils.getDataUrlForBytes(privateKey);
+ final String certUrl = DataUrlUtils.getDataUrlForBytes(cert);
+
+ final File privateKeyFile = File.createTempFile("foo" + System.currentTimeMillis(), "key");
+ privateKeyFile.deleteOnExit();
+ FileUtils.copy(new ByteArrayInputStream(privateKey), privateKeyFile);
+
+ Map<String, Object> base = new HashMap<>();
+ base.put(NonJavaKeyStore.TYPE, "NonJavaKeyStore");
+ base.put(NonJavaKeyStore.CERTIFICATE_URL, certUrl);
+
+ try
+ {
+ {
+ final String storeUrl = "keystore/mystoreDataUrl";
+ final Map<String, Object> attrs = new HashMap<>(base);
+ attrs.put(NonJavaKeyStore.PRIVATE_KEY_URL, privateKeyUrl);
+ getHelper().submitRequest(storeUrl, "PUT", attrs, SC_CREATED);
+
+ final Map<String, Object> store = getHelper().getJsonAsMap(storeUrl);
+ assertThat(store.get(NonJavaKeyStore.PRIVATE_KEY_URL),
+ is(equalTo(AbstractConfiguredObject.SECURED_STRING_VALUE)));
+ }
+
+ {
+ final String privateKeyFileUrl = privateKeyFile.toURI().toString();
+ final String storeUrl = "keystore/mystoreFileUrl";
+ final Map<String, Object> attrs = new HashMap<>(base);
+ attrs.put(NonJavaKeyStore.TYPE, "NonJavaKeyStore");
+ attrs.put(NonJavaKeyStore.PRIVATE_KEY_URL, privateKeyFileUrl);
+ getHelper().submitRequest(storeUrl, "PUT", attrs, SC_CREATED);
+
+ final Map<String, Object> store = getHelper().getJsonAsMap(storeUrl);
+ assertThat(store.get(NonJavaKeyStore.PRIVATE_KEY_URL), is(equalTo(privateKeyFileUrl)));
+ }
+ }
+ finally
+ {
+ privateKeyFile.delete();
+ }
+ }
+
+ @Test
+ @HttpRequestConfig(useVirtualHostAsHost = false)
+ public void oversizeAttribute() throws Exception
+ {
+ assumeThat(SSLUtil.canGenerateCerts(), is(equalTo(true)));
+
+ final byte[] encodedCert = generateCertKeyPair().getCertificate().getEncoded();
+ final String dataUrl = DataUrlUtils.getDataUrlForBytes(encodedCert);
+
+ final String storeUrl = "truststore/mystore";
+ final Map<String, Object> attrs = new HashMap<>();
+ attrs.put(NonJavaTrustStore.TYPE, "NonJavaTrustStore");
+ attrs.put(NonJavaTrustStore.CERTIFICATES_URL, dataUrl);
+ getHelper().submitRequest(storeUrl, "PUT", attrs, SC_CREATED);
+
+ final Map<String, Object> store = getHelper().getJsonAsMap(storeUrl);
+ assertThat(store.get(NonJavaTrustStore.CERTIFICATES_URL), is(equalTo(AbstractConfiguredObject.OVER_SIZED_ATTRIBUTE_ALTERNATIVE_TEXT)));
+
+ final Map<String, Object> full = getHelper().getJsonAsMap(storeUrl + String.format("?oversize=%d", dataUrl.length()));
+ assertThat(full.get(NonJavaTrustStore.CERTIFICATES_URL), is(equalTo(dataUrl)));
+ }
+
private String createLoggerAndRule(final String loggerName, final String inclusionRuleName) throws Exception
{
final String parentUrl = String.format("virtualhostlogger/%s", loggerName);
@@ -233,4 +330,14 @@ public class ReadTest extends HttpTestBase
{
return ((String) object.get(ConfiguredObject.ID));
}
+
+ private KeyCertPair generateCertKeyPair() throws Exception
+ {
+ return SSLUtil.generateSelfSignedCertificate("RSA", "SHA256WithRSA",
+ 2048, Instant.now().toEpochMilli(),
+ Duration.of(365, ChronoUnit.DAYS).getSeconds(),
+ "CN=foo",
+ Collections.emptySet(),
+ Collections.emptySet());
+ }
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/7601044d/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestTest.java b/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestTest.java
deleted file mode 100644
index acaeb87..0000000
--- a/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestTest.java
+++ /dev/null
@@ -1,268 +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.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.qpid.server.configuration.CommonProperties;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.BrokerModel;
-import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.LifetimePolicy;
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.State;
-import org.apache.qpid.server.model.VirtualHostNode;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-import org.apache.qpid.util.SystemUtils;
-
-public class BrokerRestTest extends QpidRestTestCase
-{
- private static final String BROKER_AUTHENTICATIONPROVIDERS_ATTRIBUTE = "authenticationproviders";
- private static final String BROKER_PORTS_ATTRIBUTE = "ports";
- private static final String BROKER_VIRTUALHOST_NODES_ATTRIBUTE = "virtualhostnodes";
- private static final String BROKER_STATISTICS_ATTRIBUTE = "statistics";
- private static final String SYSTEM_PROPERTY_NAME = "qpid.rest.test.name";
- private static final String SYSTEM_PROPERTY_ACTUAL_VALUE = "qpid.rest.test.name.value";
- private static final String SYSTEM_PROPERTY2_NAME = "qpid.rest.test.var";
- private static final String SYSTEM_PROPERTY2_ACTUAL_VALUE = "qpid.rest.test.name=${" + SYSTEM_PROPERTY_NAME + "}";
- private static final String SYSTEM_PROPERTY2_EFFECTIVE_VALUE = "qpid.rest.test.name=" + SYSTEM_PROPERTY_ACTUAL_VALUE;
- private static final String SYSTEM_PROPERTY3_NAME = "qpid.rest.test.var2";
- private static final String SYSTEM_PROPERTY3_ACTUAL_VALUE = "${" + SYSTEM_PROPERTY2_NAME + "}2";
- private static final String SYSTEM_PROPERTY3_EFFECTIVE_VALUE = SYSTEM_PROPERTY2_EFFECTIVE_VALUE + "2";
-
- @Override
- public void setUp() throws Exception
- {
- HashMap<String, String> _testSystemContext = new HashMap<>();
- _testSystemContext.put(SYSTEM_PROPERTY_NAME, SYSTEM_PROPERTY_ACTUAL_VALUE);
- _testSystemContext.put(SYSTEM_PROPERTY2_NAME, SYSTEM_PROPERTY2_ACTUAL_VALUE);
- for (Map.Entry<String,String> testContextEntry: _testSystemContext.entrySet())
- {
- setSystemProperty(testContextEntry.getKey(), testContextEntry.getValue());
- }
- super.setUp();
- }
-
- public void testGet() throws Exception
- {
- Map<String, Object> brokerDetails = getRestTestHelper().getJsonAsMap("broker?depth=1");
-
- assertBrokerAttributes(brokerDetails);
-
- @SuppressWarnings("unchecked")
- Map<String, Object> statistics = (Map<String, Object>) brokerDetails.get(BROKER_STATISTICS_ATTRIBUTE);
- Asserts.assertAttributesPresent(statistics, new String[]{ "bytesIn", "messagesOut", "bytesOut", "messagesIn" });
-
- @SuppressWarnings("unchecked")
- List<Map<String, Object>> nodes = (List<Map<String, Object>>) brokerDetails.get(BROKER_VIRTUALHOST_NODES_ATTRIBUTE);
- assertEquals("Unexpected number of virtual hosts", 3, nodes.size());
-
- for (String nodeName: EXPECTED_VIRTUALHOSTS)
- {
- Map<String, Object> nodeAttributes = getRestTestHelper().find(VirtualHostNode.NAME, nodeName, nodes);
- assertNotNull("Node attributes are not found for node with name " + nodeName, nodeAttributes);
- }
-
- @SuppressWarnings("unchecked")
- List<Map<String, Object>> ports = (List<Map<String, Object>>) brokerDetails.get(BROKER_PORTS_ATTRIBUTE);
- assertEquals("Unexpected number of ports", 2, ports.size());
-
- for (Map<String, Object> port : ports)
- {
- Asserts.assertPortAttributes(port);
- }
-
- Map<String, Object> amqpPort = getRestTestHelper().find(Port.NAME, TestBrokerConfiguration.ENTRY_NAME_AMQP_PORT, ports);
- Map<String, Object> httpPort = getRestTestHelper().find(Port.NAME, TestBrokerConfiguration.ENTRY_NAME_HTTP_PORT, ports);
-
- assertEquals("Unexpected binding address", "*", amqpPort.get(Port.BINDING_ADDRESS));
- assertNotNull("Cannot find AMQP port", amqpPort);
- assertNotNull("Cannot find HTTP port", httpPort);
-
- @SuppressWarnings("unchecked")
- Collection<String> port1Protocols = (Collection<String>) amqpPort.get(Port.PROTOCOLS);
- assertFalse("AMQP protocol list cannot contain HTTP", port1Protocols != null && port1Protocols.contains("HTTP"));
-
- @SuppressWarnings("unchecked")
- Collection<String> port2Protocols = (Collection<String>) httpPort.get(Port.PROTOCOLS);
- assertEquals("Unexpected value of attribute " + Port.PROTOCOLS, new HashSet<String>(Arrays.asList("HTTP")),
- new HashSet<String>(port2Protocols));
- }
-
- public void testPutToUpdateWithValidAttributeValues() throws Exception
- {
- Map<String, Object> brokerAttributes = getValidBrokerAttributes();
-
- int response = getRestTestHelper().submitRequest("broker", "PUT", brokerAttributes);
- assertEquals("Unexpected update response", 200, response);
-
- restartDefaultBroker();
- Map<String, Object> brokerDetails = getRestTestHelper().getJsonAsMap("broker");
- assertBrokerAttributes(brokerAttributes, brokerDetails);
- }
-
- public void testPutUpdateWhereNumericAttributesAreSetAsStringValues() throws Exception
- {
- Map<String, Object> validAttributes = getValidBrokerAttributes();
- Map<String, Object> attributes = new HashMap<String, Object>();
-
- for (Map.Entry<String, Object> entry : validAttributes.entrySet())
- {
- Object value = entry.getValue();
- if (value instanceof Number)
- {
- value = String.valueOf(value);
- }
- attributes.put(entry.getKey(), value);
- }
-
- int response = getRestTestHelper().submitRequest("broker", "PUT", attributes);
- assertEquals("Unexpected update response", 200, response);
-
- Map<String, Object> brokerDetails = getRestTestHelper().getJsonAsMap("broker");
- assertBrokerAttributes(validAttributes, brokerDetails);
- }
-
- public void testEffectiveInheritedContext() throws IOException
- {
- Map<String, Object> brokerDetails =
- getRestTestHelper().getJsonAsMap("broker?excludeInheritedContext=false&actuals=false");
- Map<String, String> brokerContext = (Map<String, String>) brokerDetails.get(ConfiguredObject.CONTEXT);
- assertEquals("Unexpected test context variable value",
- SYSTEM_PROPERTY_ACTUAL_VALUE,
- brokerContext.get(SYSTEM_PROPERTY_NAME));
- assertEquals("Unexpected test context expression value",
- SYSTEM_PROPERTY2_EFFECTIVE_VALUE,
- brokerContext.get(SYSTEM_PROPERTY2_NAME));
- }
-
- public void testActualNotInheritedContext() throws IOException
- {
- Map<String, Object> brokerDetails =
- getRestTestHelper().getJsonAsMap("broker?excludeInheritedContext=true&actuals=true");
-
- assertFalse("Unexpected context", brokerDetails.containsKey(ConfiguredObject.CONTEXT));
-
- Map<String, Object> attributes = Collections.<String, Object>singletonMap(
- ConfiguredObject.CONTEXT,
- Collections.singletonMap(SYSTEM_PROPERTY3_NAME, SYSTEM_PROPERTY3_ACTUAL_VALUE));
- getRestTestHelper().submitRequest("broker", "POST", attributes);
-
- brokerDetails =
- getRestTestHelper().getJsonAsMap("broker?excludeInheritedContext=true&actuals=true");
- Map<String, Object> brokerContext =
- new HashMap<>((Map<String, Object>) brokerDetails.get(ConfiguredObject.CONTEXT));
- Map<String, String> expectedContext = new HashMap<>();
- expectedContext.put(SYSTEM_PROPERTY3_NAME, SYSTEM_PROPERTY3_ACTUAL_VALUE);
-
- assertEquals("Unexpected context", expectedContext, brokerContext);
- }
-
- public void testEffectiveNotInheritedContext() throws IOException
- {
- Map<String, Object> brokerDetails =
- getRestTestHelper().getJsonAsMap("broker?excludeInheritedContext=true&actuals=false");
-
- assertFalse("Unexpected context", brokerDetails.containsKey(ConfiguredObject.CONTEXT));
-
- Map<String, Object> attributes = Collections.<String, Object>singletonMap(
- ConfiguredObject.CONTEXT,
- Collections.singletonMap(SYSTEM_PROPERTY3_NAME, SYSTEM_PROPERTY3_ACTUAL_VALUE));
- getRestTestHelper().submitRequest("broker", "POST", attributes);
-
- brokerDetails =
- getRestTestHelper().getJsonAsMap("broker?excludeInheritedContext=true&actuals=false");
-
- Map<String, String> expectedContext = new HashMap<>();
- Map<String, Object> brokerContext =
- new HashMap<>((Map<String, Object>) brokerDetails.get(ConfiguredObject.CONTEXT));
-
- expectedContext.put(SYSTEM_PROPERTY3_NAME, SYSTEM_PROPERTY3_EFFECTIVE_VALUE);
-
- assertEquals("Unexpected context", expectedContext, brokerContext);
- }
-
- private Map<String, Object> getValidBrokerAttributes()
- {
- Map<String, Object> brokerAttributes = new HashMap<>();
- brokerAttributes.put(Broker.STATISTICS_REPORTING_PERIOD, 12000);
- return brokerAttributes;
- }
-
- private void assertBrokerAttributes(Map<String, Object> expectedAttributes, Map<String, Object> actualAttributes)
- {
- for (Map.Entry<String, Object> entry : expectedAttributes.entrySet())
- {
- String attributeName = entry.getKey();
- Object attributeValue = entry.getValue();
-
- Object currentValue = actualAttributes.get(attributeName);
- assertEquals("Unexpected attribute " + attributeName + " value:", attributeValue, currentValue);
- }
- }
-
- protected void assertBrokerAttributes(Map<String, Object> brokerDetails)
- {
- Asserts.assertAttributesPresent(brokerDetails, BrokerModel.getInstance().getTypeRegistry().getAttributeNames(
- Broker.class),
- Broker.PROCESS_PID,
- Broker.CONFIDENTIAL_CONFIGURATION_ENCRYPTION_PROVIDER,
- ConfiguredObject.TYPE,
- ConfiguredObject.CREATED_BY,
- ConfiguredObject.CREATED_TIME,
- ConfiguredObject.LAST_UPDATED_BY,
- ConfiguredObject.LAST_UPDATED_TIME,
- ConfiguredObject.DESCRIPTION,
- ConfiguredObject.CONTEXT,
- ConfiguredObject.DESIRED_STATE,
- Broker.PREFERENCE_STORE_ATTRIBUTES);
-
- assertEquals("Unexpected value of attribute " + Broker.BUILD_VERSION, CommonProperties.getBuildVersion(),
- brokerDetails.get(Broker.BUILD_VERSION));
- assertEquals("Unexpected value of attribute " + Broker.OPERATING_SYSTEM, SystemUtils.getOSString(),
- brokerDetails.get(Broker.OPERATING_SYSTEM));
- assertEquals(
- "Unexpected value of attribute " + Broker.PLATFORM,
- System.getProperty("java.vendor") + " "
- + System.getProperty("java.runtime.version", System.getProperty("java.version")),
- brokerDetails.get(Broker.PLATFORM));
- assertEquals("Unexpected value of attribute " + Broker.DURABLE, Boolean.TRUE, brokerDetails.get(Broker.DURABLE));
- assertEquals("Unexpected value of attribute " + Broker.LIFETIME_POLICY, LifetimePolicy.PERMANENT.name(),
- brokerDetails.get(Broker.LIFETIME_POLICY));
- assertEquals("Unexpected value of attribute " + Broker.NAME, "Broker", brokerDetails.get(Broker.NAME));
- assertEquals("Unexpected value of attribute " + Broker.STATE, State.ACTIVE.name(), brokerDetails.get(Broker.STATE));
-
- assertNotNull("Unexpected value of attribute " + Broker.ID, brokerDetails.get(Broker.ID));
- assertNotNull("Unexpected value of attribute statistics", brokerDetails.get(BROKER_STATISTICS_ATTRIBUTE));
- assertNotNull("Unexpected value of attribute virtual host nodes", brokerDetails.get(BROKER_VIRTUALHOST_NODES_ATTRIBUTE));
- assertNotNull("Unexpected value of attribute ports", brokerDetails.get(BROKER_PORTS_ATTRIBUTE));
- assertNotNull("Unexpected value of attribute authenticationproviders", brokerDetails.get(BROKER_AUTHENTICATIONPROVIDERS_ATTRIBUTE));
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/7601044d/systests/src/test/java/org/apache/qpid/systest/rest/ExchangeRestTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/rest/ExchangeRestTest.java b/systests/src/test/java/org/apache/qpid/systest/rest/ExchangeRestTest.java
deleted file mode 100644
index 25502e8..0000000
--- a/systests/src/test/java/org/apache/qpid/systest/rest/ExchangeRestTest.java
+++ /dev/null
@@ -1,122 +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.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.qpid.server.model.AlternateBinding;
-import org.apache.qpid.server.model.Exchange;
-
-public class ExchangeRestTest extends QpidRestTestCase
-{
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
- getRestTestHelper().createTestQueues();
- }
-
- public void testGet() throws Exception
- {
- List<Map<String, Object>> exchanges = getRestTestHelper().getJsonAsList("exchange");
- assertNotNull("Exchanges cannot be null", exchanges);
- assertTrue("Unexpected number of exchanges", exchanges.size() >= EXPECTED_VIRTUALHOSTS.length * EXPECTED_EXCHANGES.length);
- for (Map<String, Object> exchange : exchanges)
- {
- Asserts.assertExchange((String) exchange.get(Exchange.NAME), (String) exchange.get(Exchange.TYPE), exchange);
- }
- }
-
- public void testGetHostExchanges() throws Exception
- {
- List<Map<String, Object>> exchanges = getRestTestHelper().getJsonAsList("exchange/test");
- assertNotNull("Users cannot be null", exchanges);
- assertEquals("Unexpected number of exchanges", exchanges.size(), EXPECTED_EXCHANGES.length);
- for (String exchangeName : EXPECTED_EXCHANGES)
- {
- Map<String, Object> exchange = getRestTestHelper().find(Exchange.NAME, exchangeName, exchanges);
- assertExchange(exchangeName, exchange);
- }
- }
-
- public void testGetHostExchangeByName() throws Exception
- {
- for (String exchangeName : EXPECTED_EXCHANGES)
- {
- Map<String, Object> exchange = getRestTestHelper().getJsonAsMap("exchange/test/test/"
- + getRestTestHelper().encodeAsUTF(
- exchangeName));
- assertExchange(exchangeName, exchange);
- }
- }
-
- public void testSetExchangeSupported() throws Exception
- {
- String exchangeName = getTestName();
- String exchangeUrl = "exchange/test/test/" + exchangeName;
-
- Map<String, Object> attributes = new HashMap<>();
- attributes.put(Exchange.NAME, exchangeName);
- attributes.put(Exchange.TYPE, "direct");
- getRestTestHelper().submitRequest(exchangeUrl, "PUT", attributes, 201);
-
- Map<String, Object> exchange = getRestTestHelper().getJsonAsMap(exchangeUrl);
- assertNotNull("Exchange not found", exchange);
-
- attributes = new HashMap<>();
- attributes.put(Exchange.NAME, exchangeName);
- attributes.put(Exchange.ALTERNATE_BINDING,
- Collections.singletonMap(AlternateBinding.DESTINATION, "amq.direct"));
-
- getRestTestHelper().submitRequest(exchangeUrl, "PUT", attributes, 200);
- exchange = getRestTestHelper().getJsonAsMap(exchangeUrl);
- assertNotNull("Exchange not found", exchange);
- assertEquals(new HashMap<>(Collections.singletonMap(AlternateBinding.DESTINATION, "amq.direct")),
- new HashMap<>(((Map<String, Object>) exchange.get(Exchange.ALTERNATE_BINDING))));
- }
-
- private void assertExchange(String exchangeName, Map<String, Object> exchange)
- {
- assertNotNull("Exchange with name " + exchangeName + " is not found", exchange);
- String type = (String) exchange.get(Exchange.TYPE);
- Asserts.assertExchange(exchangeName, type, exchange);
- if ("direct".equals(type))
- {
- assertBindings(exchange);
- }
- }
-
- private void assertBindings(Map<String, Object> exchange)
- {
- List<Map<String, Object>> bindings = (List<Map<String, Object>>) exchange.get("bindings");
- assertEquals(RestTestHelper.EXPECTED_QUEUES.length, bindings.size());
- for (Map<String, Object> binding : bindings)
- {
- String destination = (String) binding.get("destination");
- assertTrue(Arrays.asList(RestTestHelper.EXPECTED_QUEUES).contains(destination));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/7601044d/systests/src/test/java/org/apache/qpid/systest/rest/HttpManagementRestTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/rest/HttpManagementRestTest.java b/systests/src/test/java/org/apache/qpid/systest/rest/HttpManagementRestTest.java
deleted file mode 100644
index 298d594..0000000
--- a/systests/src/test/java/org/apache/qpid/systest/rest/HttpManagementRestTest.java
+++ /dev/null
@@ -1,93 +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.util.HashMap;
-import java.util.Map;
-
-import org.apache.qpid.server.management.plugin.HttpManagement;
-import org.apache.qpid.server.management.plugin.servlet.rest.AbstractServlet;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-
-public class HttpManagementRestTest extends QpidRestTestCase
-{
-
- public void testGetHttpManagement() throws Exception
- {
- Map<String, Object> details =
- getRestTestHelper().getJsonAsMap("plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
-
- assertEquals("Unexpected session timeout", HttpManagement.DEFAULT_TIMEOUT_IN_SECONDS,
- details.get(HttpManagement.TIME_OUT));
- assertEquals("Unexpected http basic auth enabled", true,
- details.get(HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED));
- assertEquals("Unexpected https basic auth enabled", true,
- details.get(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED));
- assertEquals("Unexpected http sasl auth enabled", true,
- details.get(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED));
- assertEquals("Unexpected https sasl auth enabled", true,
- details.get(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED));
- }
-
- public void testUpdateAttributes() throws Exception
- {
- Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(HttpManagement.NAME, TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
- attributes.put(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED, false);
- attributes.put(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED, false);
- attributes.put(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED, false);
- attributes.put(HttpManagement.TIME_OUT, 10000);
-
- getRestTestHelper().submitRequest("plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "PUT", attributes);
-
- Map<String, Object> details =
- getRestTestHelper().getJsonAsMap("plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
-
- assertEquals("Unexpected session timeout", 10000, details.get(HttpManagement.TIME_OUT));
- assertEquals("Unexpected http basic auth enabled", true, details.get(HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED));
- assertEquals("Unexpected https basic auth enabled", false, details.get(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED));
- assertEquals("Unexpected http sasl auth enabled", false, details.get(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED));
- assertEquals("Unexpected https sasl auth enabled", false, details.get(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED));
- }
-
- public void testUpdateAttributesWithInvalidValues() throws Exception
- {
- Map<String, Object> invalidAttributes = new HashMap<String, Object>();
- invalidAttributes.put(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED, 1);
- invalidAttributes.put(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED, 2);
- invalidAttributes.put(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED, 3);
- invalidAttributes.put(HttpManagement.TIME_OUT, "undefined");
-
- for (Map.Entry<String, Object> invalidAttribute : invalidAttributes.entrySet())
- {
- Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(invalidAttribute.getKey(), invalidAttribute.getValue());
- int response = getRestTestHelper().submitRequest("plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "PUT", attributes);
- assertEquals("Update should fail for attribute " + invalidAttribute.getKey() + " with value " + invalidAttribute.getValue(),
- AbstractServlet.SC_UNPROCESSABLE_ENTITY, response);
- }
-
- Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(HttpManagement.TIME_OUT, -1l);
- int response = getRestTestHelper().submitRequest("plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "PUT", attributes);
- assertEquals("Update should fail for invalid session timeout", AbstractServlet.SC_UNPROCESSABLE_ENTITY, response);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/7601044d/systests/src/test/java/org/apache/qpid/systest/rest/KeyStoreRestTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/rest/KeyStoreRestTest.java b/systests/src/test/java/org/apache/qpid/systest/rest/KeyStoreRestTest.java
deleted file mode 100644
index 1b34545..0000000
--- a/systests/src/test/java/org/apache/qpid/systest/rest/KeyStoreRestTest.java
+++ /dev/null
@@ -1,158 +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.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletResponse;
-
-
-import org.apache.qpid.server.model.AbstractConfiguredObject;
-import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.KeyStore;
-import org.apache.qpid.server.security.FileKeyStore;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-import org.apache.qpid.test.utils.TestSSLConstants;
-import org.apache.qpid.util.DataUrlUtils;
-import org.apache.qpid.util.FileUtils;
-
-public class KeyStoreRestTest extends QpidRestTestCase
-{
-
- public void testGet() throws Exception
- {
- //verify existence of the default keystore used by the systests
- List<Map<String, Object>> keyStores = assertNumberOfKeyStores(1);
-
- Map<String, Object> keystore = keyStores.get(0);
-
- assertEquals("Unexpected name", TestBrokerConfiguration.ENTRY_NAME_SSL_KEYSTORE, keystore.get(KeyStore.NAME));
- assertEquals("unexpected path to key store", ConfiguredObject.OVER_SIZED_ATTRIBUTE_ALTERNATIVE_TEXT, keystore.get(FileKeyStore.STORE_URL));
- assertEquals("unexpected (dummy) password of default systests key store", AbstractConfiguredObject.SECURED_STRING_VALUE, keystore.get(FileKeyStore.PASSWORD));
- assertEquals("unexpected type of default systests key store", java.security.KeyStore.getDefaultType(), keystore.get(FileKeyStore.KEY_STORE_TYPE));
- assertFalse("should not be a certificateAlias attribute", keystore.containsKey(FileKeyStore.CERTIFICATE_ALIAS));
- }
-
- public void testCreate() throws Exception
- {
- String name = getTestName();
- String certAlias = "app2";
-
- assertNumberOfKeyStores(1);
- createKeyStore(name, certAlias, TestSSLConstants.KEYSTORE, TestSSLConstants.KEYSTORE_PASSWORD);
- assertNumberOfKeyStores(2);
-
- Map<String, Object> keystore = getRestTestHelper().getJsonAsMap("keystore/" + name + "?actuals=true");
-
- assertEquals("Unexpected name", name, keystore.get(KeyStore.NAME));
- assertEquals("unexpected path to key store", TestSSLConstants.KEYSTORE, keystore.get(FileKeyStore.STORE_URL));
- assertEquals("unexpected password", AbstractConfiguredObject.SECURED_STRING_VALUE, keystore.get(FileKeyStore.PASSWORD));
- assertEquals("unexpected alias", certAlias, keystore.get(FileKeyStore.CERTIFICATE_ALIAS));
- }
-
- public void testCreateWithDataUrl() throws Exception
- {
- String name = getTestName();
- byte[] keystoreAsBytes = FileUtils.readFileAsBytes(TestSSLConstants.KEYSTORE);
- String dataUrlForKeyStore = DataUrlUtils.getDataUrlForBytes(keystoreAsBytes);
-
- assertNumberOfKeyStores(1);
- createKeyStore(name, null, dataUrlForKeyStore, TestSSLConstants.KEYSTORE_PASSWORD);
- assertNumberOfKeyStores(2);
-
- Map<String, Object> keystore = getRestTestHelper().getJsonAsMap("keystore/" + name + "?actuals=true");
-
- assertEquals("Unexpected name", name, keystore.get(KeyStore.NAME));
- assertEquals("unexpected data", AbstractConfiguredObject.SECURED_STRING_VALUE, keystore.get(FileKeyStore.STORE_URL));
- assertEquals("unexpected password", AbstractConfiguredObject.SECURED_STRING_VALUE, keystore.get(FileKeyStore.PASSWORD));
- assertEquals("unexpected alias", null, keystore.get(FileKeyStore.CERTIFICATE_ALIAS));
- }
-
- public void testDelete() throws Exception
- {
- String name = getTestName();
- String certAlias = "app2";
-
- assertNumberOfKeyStores(1);
- createKeyStore(name, certAlias, TestSSLConstants.KEYSTORE, TestSSLConstants.KEYSTORE_PASSWORD);
- assertNumberOfKeyStores(2);
-
- getRestTestHelper().submitRequest("keystore/" + name, "DELETE", HttpServletResponse.SC_OK);
- getRestTestHelper().submitRequest("keystore/" + name + "?actuals=true", "GET", HttpServletResponse.SC_NOT_FOUND);
-
- //check only the default systests key store remains
- List<Map<String, Object>> keyStores = assertNumberOfKeyStores(1);
- Map<String, Object> keystore = keyStores.get(0);
- assertEquals("Unexpected name", TestBrokerConfiguration.ENTRY_NAME_SSL_KEYSTORE, keystore.get(KeyStore.NAME));
- assertEquals("unexpected path to key store", ConfiguredObject.OVER_SIZED_ATTRIBUTE_ALTERNATIVE_TEXT, keystore.get(FileKeyStore.STORE_URL));
- assertEquals("unexpected (dummy) password of default systests key store", AbstractConfiguredObject.SECURED_STRING_VALUE, keystore.get(FileKeyStore.PASSWORD));
- assertFalse("should not be a certificateAlias attribute", keystore.containsKey(FileKeyStore.CERTIFICATE_ALIAS));
- }
-
- public void testUpdate() throws Exception
- {
- String name = getTestName();
-
- assertNumberOfKeyStores(1);
- createKeyStore(name, null, TestSSLConstants.KEYSTORE, TestSSLConstants.KEYSTORE_PASSWORD);
- assertNumberOfKeyStores(2);
-
- Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(KeyStore.NAME, name);
- attributes.put(FileKeyStore.STORE_URL, TestSSLConstants.UNTRUSTED_KEYSTORE);
-
- getRestTestHelper().submitRequest("keystore/" + name, "PUT", attributes, HttpServletResponse.SC_OK);
-
- Map<String, Object> keystore = getRestTestHelper().getJsonAsMap("keystore/" + name + "?actuals=true");
-
- assertEquals("Unexpected name", name, keystore.get(KeyStore.NAME));
- assertEquals("unexpected data", TestSSLConstants.UNTRUSTED_KEYSTORE, keystore.get(FileKeyStore.STORE_URL));
- assertEquals("unexpected password", AbstractConfiguredObject.SECURED_STRING_VALUE, keystore.get(FileKeyStore.PASSWORD));
- assertEquals("unexpected alias", null, keystore.get(FileKeyStore.CERTIFICATE_ALIAS));
- }
-
-
- private List<Map<String, Object>> assertNumberOfKeyStores(int numberOfKeystores) throws Exception
- {
- List<Map<String, Object>> keyStores = getRestTestHelper().getJsonAsList("keystore");
- assertNotNull("keystores should not be null", keyStores);
- assertEquals("Unexpected number of keystores", numberOfKeystores, keyStores.size());
-
- return keyStores;
- }
-
- private void createKeyStore(String name, String certAlias, final String keyStorePath, final String keystorePassword) throws Exception
- {
- Map<String, Object> keyStoreAttributes = new HashMap<>();
- keyStoreAttributes.put(KeyStore.NAME, name);
- keyStoreAttributes.put(FileKeyStore.STORE_URL, keyStorePath);
- keyStoreAttributes.put(FileKeyStore.PASSWORD, keystorePassword);
- if (certAlias != null)
- {
- keyStoreAttributes.put(FileKeyStore.CERTIFICATE_ALIAS, certAlias);
- }
-
- getRestTestHelper().submitRequest("keystore/" + name, "PUT", keyStoreAttributes, HttpServletResponse.SC_CREATED);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/7601044d/systests/src/test/java/org/apache/qpid/systest/rest/TrustStoreRestTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/rest/TrustStoreRestTest.java b/systests/src/test/java/org/apache/qpid/systest/rest/TrustStoreRestTest.java
deleted file mode 100644
index 70759f9..0000000
--- a/systests/src/test/java/org/apache/qpid/systest/rest/TrustStoreRestTest.java
+++ /dev/null
@@ -1,161 +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.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.qpid.server.model.AbstractConfiguredObject;
-import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.TrustStore;
-import org.apache.qpid.server.security.FileTrustStore;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-import org.apache.qpid.test.utils.TestSSLConstants;
-import org.apache.qpid.util.DataUrlUtils;
-import org.apache.qpid.util.FileUtils;
-
-public class TrustStoreRestTest extends QpidRestTestCase
-{
-
- public void testGet() throws Exception
- {
- //verify existence of the default trust store used by the systests
- List<Map<String, Object>> trustStores = assertNumberOfTrustStores(1);
-
- Map<String, Object> truststore = trustStores.get(0);
- assertEquals("default systests trust store is missing",
- TestBrokerConfiguration.ENTRY_NAME_SSL_TRUSTSTORE, truststore.get(TrustStore.NAME));
- assertEquals("unexpected store URL", ConfiguredObject.OVER_SIZED_ATTRIBUTE_ALTERNATIVE_TEXT, truststore.get(FileTrustStore.STORE_URL));
- assertEquals("unexpected (dummy) password of default systests trust store",
- AbstractConfiguredObject.SECURED_STRING_VALUE, truststore.get(FileTrustStore.PASSWORD));
- assertEquals("unexpected type of default systests trust store",
- java.security.KeyStore.getDefaultType(), truststore.get(FileTrustStore.TRUST_STORE_TYPE));
- assertEquals("unexpected peersOnly value", false, truststore.get(FileTrustStore.PEERS_ONLY));
- }
-
- public void testCreate() throws Exception
- {
- String name = getTestName();
-
- assertNumberOfTrustStores(1);
- createTrustStore(name, true, TestSSLConstants.TRUSTSTORE, TestSSLConstants.TRUSTSTORE_PASSWORD);
- assertNumberOfTrustStores(2);
-
- Map<String, Object> truststore = getRestTestHelper().getJsonAsMap("truststore/" + name);
-
- assertEquals("unexpected trust store name", name, truststore.get(TrustStore.NAME));
- assertEquals("unexpected store URL", TestSSLConstants.TRUSTSTORE, truststore.get(FileTrustStore.STORE_URL));
- assertEquals("unexpected password value", AbstractConfiguredObject.SECURED_STRING_VALUE, truststore.get(FileTrustStore.PASSWORD));
- assertEquals("unexpected type", java.security.KeyStore.getDefaultType(), truststore.get(FileTrustStore.TRUST_STORE_TYPE));
- assertEquals("unexpected peersOnly value", true, truststore.get(FileTrustStore.PEERS_ONLY));
- }
-
- public void testCreateUsingDataUrl() throws Exception
- {
- String name = getTestName();
- byte[] trustStoreAsBytes = FileUtils.readFileAsBytes(TestSSLConstants.TRUSTSTORE);
- String dataUrlForTruststore = DataUrlUtils.getDataUrlForBytes(trustStoreAsBytes);
-
- assertNumberOfTrustStores(1);
-
- createTrustStore(name, false, dataUrlForTruststore, TestSSLConstants.TRUSTSTORE_PASSWORD);
-
- assertNumberOfTrustStores(2);
-
- Map<String, Object> truststore = getRestTestHelper().getJsonAsMap("truststore/" + name);
-
- assertEquals("nexpected trust store name", name, truststore.get(TrustStore.NAME));
- assertEquals("unexpected store URL value", ConfiguredObject.OVER_SIZED_ATTRIBUTE_ALTERNATIVE_TEXT, truststore.get(FileTrustStore.STORE_URL));
- assertEquals("unexpected password value", AbstractConfiguredObject.SECURED_STRING_VALUE, truststore.get(FileTrustStore.PASSWORD));
- assertEquals("unexpected type of trust store", java.security.KeyStore.getDefaultType(), truststore.get(FileTrustStore.TRUST_STORE_TYPE));
- assertEquals("unexpected peersOnly value", false, truststore.get(FileTrustStore.PEERS_ONLY));
- }
-
- public void testDelete() throws Exception
- {
- String name = getTestName();
-
- assertNumberOfTrustStores(1);
- createTrustStore(name, false, TestSSLConstants.TRUSTSTORE, TestSSLConstants.TRUSTSTORE_PASSWORD);
- assertNumberOfTrustStores(2);
-
- getRestTestHelper().submitRequest("truststore/" + name, "DELETE", HttpServletResponse.SC_OK);
- getRestTestHelper().submitRequest("truststore/" + name, "GET", HttpServletResponse.SC_NOT_FOUND);
-
- //check only the default systests trust store remains
- List<Map<String, Object>> trustStores = assertNumberOfTrustStores(1);
- Map<String, Object> truststore = trustStores.get(0);
- assertEquals("unexpected name", TestBrokerConfiguration.ENTRY_NAME_SSL_TRUSTSTORE, truststore.get(TrustStore.NAME));
- assertEquals("unexpected store URL value", ConfiguredObject.OVER_SIZED_ATTRIBUTE_ALTERNATIVE_TEXT, truststore.get(FileTrustStore.STORE_URL));
- assertEquals("unexpected password value", AbstractConfiguredObject.SECURED_STRING_VALUE, truststore.get(FileTrustStore.PASSWORD));
- assertEquals("unexpected type of trust store", java.security.KeyStore.getDefaultType(), truststore.get(FileTrustStore.TRUST_STORE_TYPE));
- assertEquals("unexpected peersOnly value", false, truststore.get(FileTrustStore.PEERS_ONLY));
- }
-
-
- public void testUpdate() throws Exception
- {
- String name = getTestName();
-
- assertNumberOfTrustStores(1);
- createTrustStore(name, false, TestSSLConstants.TRUSTSTORE, TestSSLConstants.TRUSTSTORE_PASSWORD);
- assertNumberOfTrustStores(2);
-
- Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(TrustStore.NAME, name);
- attributes.put(FileTrustStore.STORE_URL, TestSSLConstants.TRUSTSTORE);
-
- getRestTestHelper().submitRequest("truststore/" + name , "PUT", attributes, HttpServletResponse.SC_OK);
-
- Map<String, Object> trustStore = getRestTestHelper().getJsonAsMap("truststore/" + name);
-
- assertEquals("unexpected name", name, trustStore.get(TrustStore.NAME));
- assertEquals("unexpected path to trust store", TestSSLConstants.TRUSTSTORE, trustStore.get(FileTrustStore.STORE_URL));
- assertEquals("unexpected password", AbstractConfiguredObject.SECURED_STRING_VALUE, trustStore.get(FileTrustStore.PASSWORD));
- assertEquals("unexpected type", java.security.KeyStore.getDefaultType(), trustStore.get(FileTrustStore.TRUST_STORE_TYPE));
- assertEquals("unexpected peersOnly value", false, trustStore.get(FileTrustStore.PEERS_ONLY));
- }
-
- private List<Map<String, Object>> assertNumberOfTrustStores(int numberOfTrustStores) throws Exception
- {
- List<Map<String, Object>> trustStores = getRestTestHelper().getJsonAsList("truststore");
- assertNotNull("trust stores should not be null", trustStores);
- assertEquals("Unexpected number of trust stores", numberOfTrustStores, trustStores.size());
-
- return trustStores;
- }
-
- private void createTrustStore(String name, boolean peersOnly, final String truststorePath, final String truststorePassword) throws Exception
- {
- Map<String, Object> trustStoreAttributes = new HashMap<String, Object>();
- trustStoreAttributes.put(TrustStore.NAME, name);
- //deliberately using the client trust store to differentiate from the one we are already for broker
- trustStoreAttributes.put(FileTrustStore.STORE_URL, truststorePath);
- trustStoreAttributes.put(FileTrustStore.PASSWORD, truststorePassword);
- trustStoreAttributes.put(FileTrustStore.PEERS_ONLY, peersOnly);
-
- getRestTestHelper().submitRequest("truststore/" + name, "PUT", trustStoreAttributes, HttpServletResponse.SC_CREATED);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/7601044d/systests/src/test/java/org/apache/qpid/systest/rest/UserRestTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/rest/UserRestTest.java b/systests/src/test/java/org/apache/qpid/systest/rest/UserRestTest.java
deleted file mode 100644
index cfaffec..0000000
--- a/systests/src/test/java/org/apache/qpid/systest/rest/UserRestTest.java
+++ /dev/null
@@ -1,165 +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.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.qpid.server.model.User;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-
-public class UserRestTest extends QpidRestTestCase
-{
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
- getRestTestHelper().setUsernameAndPassword("user1", "user1");
- }
-
- @Override
- protected void customizeConfiguration() throws Exception
- {
- super.customizeConfiguration();
- final TestBrokerConfiguration defaultBrokerConfiguration = getDefaultBrokerConfiguration();
- defaultBrokerConfiguration.configureTemporaryPasswordFile("user1", "user2");
- }
-
- public void testGet() throws Exception
- {
- List<Map<String, Object>> users = getRestTestHelper().getJsonAsList("user");
- assertNotNull("Users cannot be null", users);
- assertTrue("Unexpected number of users", users.size() > 1);
- for (Map<String, Object> user : users)
- {
- assertUser(user);
- }
- }
-
- public void testGetUserByName() throws Exception
- {
- List<Map<String, Object>> users = getRestTestHelper().getJsonAsList("user");
- assertNotNull("Users cannot be null", users);
- assertTrue("Unexpected number of users", users.size() > 1);
- for (Map<String, Object> user : users)
- {
- assertNotNull("Attribute " + User.ID, user.get(User.ID));
- String userName = (String) user.get(User.NAME);
- assertNotNull("Attribute " + User.NAME, userName);
- Map<String, Object> userDetails = getRestTestHelper().getJsonAsMap("user/"
- + TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER
- + "/"
- + userName);
- assertUser(userDetails);
- assertEquals("Unexpected user name", userName, userDetails.get(User.NAME));
- }
- }
-
- public void testCreateUserByPutUsingUserURI() throws Exception
- {
- String userName = getTestName();
- getRestTestHelper().createOrUpdateUser(userName, "newPassword");
-
- Map<String, Object> userDetails = getRestTestHelper().getJsonAsMap("user/"
- + TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER
- + "/"
- + userName);
- assertUser(userDetails);
- assertEquals("Unexpected user name", userName, userDetails.get(User.NAME));
- }
-
- public void testCreateUserByPostUsingParentURI() throws Exception
- {
- String userName = getTestName();
-
- Map<String,Object> userAttributes = new HashMap<>();
- userAttributes.put("password", "newPassword");
- userAttributes.put("name", userName);
-
- String url = "user/" + TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER;
- getRestTestHelper().submitRequest(url, "POST", userAttributes, HttpServletResponse.SC_CREATED);
-
- Map<String, Object> userDetails = getRestTestHelper().getJsonAsMap(url + "/" + userName);
- assertUser(userDetails);
- assertEquals("Unexpected user name", userName, userDetails.get(User.NAME));
-
- // verify that second create request fails
- getRestTestHelper().submitRequest(url, "POST", userAttributes, HttpServletResponse.SC_CONFLICT);
- }
-
- public void testCreateUserByPutUsingParentURI() throws Exception
- {
- String userName = getTestName();
-
- Map<String,Object> userAttributes = new HashMap<>();
- userAttributes.put("password", "newPassword");
- userAttributes.put("name", userName);
-
- String url = "user/" + TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER;
- getRestTestHelper().submitRequest(url, "PUT", userAttributes, HttpServletResponse.SC_CREATED);
-
- Map<String, Object> userDetails = getRestTestHelper().getJsonAsMap(url + "/" + userName);
- assertUser(userDetails);
- assertEquals("Unexpected user name", userName, userDetails.get(User.NAME));
-
- // verify that second create request fails
- getRestTestHelper().submitRequest(url, "PUT", userAttributes, HttpServletResponse.SC_CONFLICT);
- }
-
- public void testSetPasswordForNonExistingUserByPostFails() throws Exception
- {
- String userName = getTestName();
-
- Map<String,Object> userAttributes = new HashMap<>();
- userAttributes.put("password", "newPassword");
- userAttributes.put("name", userName);
-
- String url = "user/" + TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER + "/" + userName;
- getRestTestHelper().submitRequest(url, "POST", userAttributes, HttpServletResponse.SC_NOT_FOUND);
- getRestTestHelper().submitRequest(url, "GET", HttpServletResponse.SC_NOT_FOUND);
- }
-
- public void testDelete() throws Exception
- {
- String userName = getTestName();
- getRestTestHelper().createOrUpdateUser(userName, "newPassword");
-
- Map<String, Object> userDetails = getRestTestHelper().getJsonAsMap("user/"
- + TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER
- + "/"
- + userName);
- String id = (String) userDetails.get(User.ID);
-
- getRestTestHelper().removeUserById(id);
-
- getRestTestHelper().submitRequest("user/" + TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER
- + "/" + userName, "GET", HttpServletResponse.SC_NOT_FOUND);
- }
-
- private void assertUser(Map<String, Object> user)
- {
- assertNotNull("Attribute " + User.ID, user.get(User.ID));
- assertNotNull("Attribute " + User.NAME, user.get(User.NAME));
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/7601044d/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostNodeRestTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostNodeRestTest.java b/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostNodeRestTest.java
deleted file mode 100644
index b216e86..0000000
--- a/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostNodeRestTest.java
+++ /dev/null
@@ -1,234 +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.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.VirtualHostNode;
-import org.apache.qpid.server.virtualhostnode.JsonVirtualHostNode;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-
-/**
- *
- * TODO: Add test to test the mutation of the storePath. If the store path is mutated
- * whilst active then the store should be deleted next time we stop or close.
- */
-public class VirtualHostNodeRestTest extends QpidRestTestCase
-{
- public void testGet() throws Exception
- {
- List<Map<String, Object>> virtualhostNodes = getRestTestHelper().getJsonAsList("virtualhostnode");
- assertNotNull("Virtualhostnodes data cannot be null", virtualhostNodes);
- assertEquals("Unexpected number of hosts", EXPECTED_VIRTUALHOSTS.length, virtualhostNodes.size());
- for (String nodeName : EXPECTED_VIRTUALHOSTS)
- {
- Map<String, Object> node = getRestTestHelper().find("name", nodeName, virtualhostNodes);
- Asserts.assertVirtualHostNode(nodeName, node);
- }
- }
-
- public void testCreateAndDeleteVirtualHostNode() throws Exception
- {
- String virtualhostNodeType = getTestProfileVirtualHostNodeType();
- String nodeName = "virtualhostnode-" + getTestName();
- File storePathAsFile = new File(getStoreLocation(nodeName));
-
- createAndDeleteVirtualHostNode(virtualhostNodeType, nodeName, storePathAsFile);
- assertFalse("Store should not exist after deletion", storePathAsFile.exists());
- }
-
- public void testCreateVirtualHostNodeWithVirtualHost() throws Exception
- {
- String nodeName = "virtualhostnode-" + getTestName();
-
- Map<String, Object> nodeData = new HashMap<String, Object>();
- nodeData.put(VirtualHostNode.NAME, nodeName);
- nodeData.put(VirtualHostNode.TYPE, getTestProfileVirtualHostNodeType());
-
- nodeData.put("virtualHostInitialConfiguration", "{ \"type\" : \"DERBY\" }");
-
- getRestTestHelper().submitRequest("virtualhostnode/" + nodeName,
- "PUT",
- nodeData,
- HttpServletResponse.SC_CREATED);
-
-
- Map<String, Object> virtualhostNode = getRestTestHelper().getJsonAsMap("virtualhostnode/" + nodeName);
- Asserts.assertVirtualHostNode(nodeName, virtualhostNode);
-
- Map<String, Object> virtualhost = getRestTestHelper().getJsonAsMap("virtualhost/" + nodeName + "/" + nodeName);
- Asserts.assertVirtualHost(nodeName, virtualhost);
- }
-
- public void testCreateVirtualHostNodeWithDefaultStorePath() throws Exception
- {
- String virtualhostNodeType = getTestProfileVirtualHostNodeType();
- String nodeName = "virtualhostnode-" + getTestName();
-
- createVirtualHostNode(nodeName, virtualhostNodeType);
-
- String restUrl = "virtualhostnode/" + nodeName;
- Map<String, Object> virtualhostNode = getRestTestHelper().getJsonAsMap(restUrl);
- Asserts.assertVirtualHostNode(nodeName, virtualhostNode);
- assertNull("Virtualhostnode should not automatically get a virtualhost child",
- virtualhostNode.get("virtualhosts"));
-
- getRestTestHelper().submitRequest(restUrl, "DELETE", HttpServletResponse.SC_OK);
- getRestTestHelper().submitRequest(restUrl, "GET", HttpServletResponse.SC_NOT_FOUND);
- }
-
- public void testRecoverVirtualHostNodeWithDesiredStateStopped() throws Exception
- {
- stopDefaultBroker();
-
- TestBrokerConfiguration config = getDefaultBrokerConfiguration();
- config.setObjectAttribute(VirtualHostNode.class, TEST3_VIRTUALHOST, ConfiguredObject.DESIRED_STATE, "STOPPED");
- config.setSaved(false);
-
- startDefaultBroker();
-
- String restUrl = "virtualhostnode/" + TEST3_VIRTUALHOST;
- assertActualAndDesireStates(restUrl, "STOPPED", "STOPPED");
- }
-
- public void testMutateState() throws Exception
- {
- String restUrl = "virtualhostnode/" + TEST3_VIRTUALHOST;
-
- assertActualAndDesireStates(restUrl, "ACTIVE", "ACTIVE");
-
- mutateVirtualHostNodeDesiredState(restUrl, "STOPPED");
- assertActualAndDesireStates(restUrl, "STOPPED", "STOPPED");
-
- mutateVirtualHostNodeDesiredState(restUrl, "ACTIVE");
- assertActualAndDesireStates(restUrl, "ACTIVE", "ACTIVE");
- }
-
- public void testMutateAttributes() throws Exception
- {
- String restUrl = "virtualhostnode/" + TEST3_VIRTUALHOST;
-
- Map<String, Object> virtualhostNode = getRestTestHelper().getJsonAsMap(restUrl);
- assertNull(virtualhostNode.get(VirtualHostNode.DESCRIPTION));
-
- String newDescription = "My virtualhost node";
- Map<String, Object> newAttributes = new HashMap<String, Object>();
- newAttributes.put(VirtualHostNode.DESCRIPTION, newDescription);
-
- getRestTestHelper().submitRequest(restUrl, "PUT", newAttributes, HttpServletResponse.SC_OK);
-
- virtualhostNode = getRestTestHelper().getJsonAsMap(restUrl);
- assertEquals(newDescription, virtualhostNode.get(VirtualHostNode.DESCRIPTION));
- }
-
- public void testCreateVirtualHostNodeByPostUsingParentURI() throws Exception
- {
- createVirtualHostNodeByUsingParentURI("POST");
- }
-
- public void testCreateVirtualHostNodeByPutUsingParentURI() throws Exception
- {
- createVirtualHostNodeByUsingParentURI("PUT");
- }
-
- private void createVirtualHostNodeByUsingParentURI(final String method) throws IOException
- {
- String nodeName = getTestName();
- Map<String, Object> nodeData = new HashMap<>();
- nodeData.put(VirtualHostNode.NAME, nodeName);
- nodeData.put(VirtualHostNode.TYPE, getTestProfileVirtualHostNodeType());
-
- String url = "virtualhostnode";
- getRestTestHelper().submitRequest(url, method, nodeData, HttpServletResponse.SC_CREATED);
-
- Map<String, Object> virtualhostNode = getRestTestHelper().getJsonAsMap(url + "/" + nodeName);
- Asserts.assertVirtualHostNode(nodeName, virtualhostNode);
- }
-
- private void createAndDeleteVirtualHostNode(final String virtualhostNodeType,
- final String nodeName,
- final File storePathAsFile) throws Exception
- {
- assertFalse("Store should not exist", storePathAsFile.exists());
-
- createVirtualHostNode(nodeName, storePathAsFile.getAbsolutePath(), virtualhostNodeType);
- assertTrue("Store should exist after creation of node", storePathAsFile.exists());
-
- String restUrl = "virtualhostnode/" + nodeName;
- Map<String, Object> virtualhostNode = getRestTestHelper().getJsonAsMap(restUrl);
- Asserts.assertVirtualHostNode(nodeName, virtualhostNode);
- assertNull("Virtualhostnode should not automatically get a virtualhost child",
- virtualhostNode.get("virtualhosts"));
-
- getRestTestHelper().submitRequest(restUrl, "DELETE", HttpServletResponse.SC_OK);
- getRestTestHelper().submitRequest(restUrl, "GET", HttpServletResponse.SC_NOT_FOUND);
- }
-
- private void assertActualAndDesireStates(final String restUrl,
- final String expectedDesiredState,
- final String expectedActualState) throws IOException
- {
- Map<String, Object> virtualhostNode = getRestTestHelper().getJsonAsMap(restUrl);
- Asserts.assertActualAndDesiredState(expectedDesiredState, expectedActualState, virtualhostNode);
- }
-
- private void mutateVirtualHostNodeDesiredState(final String restUrl, final String newState) throws IOException
- {
- Map<String, Object> newAttributes = new HashMap<String, Object>();
- newAttributes.put(VirtualHostNode.DESIRED_STATE, newState);
-
- getRestTestHelper().submitRequest(restUrl, "PUT", newAttributes, HttpServletResponse.SC_OK);
- }
-
- private void createVirtualHostNode(String nodeName, String configStorePath, final String storeType) throws Exception
- {
- Map<String, Object> nodeData = new HashMap<String, Object>();
- nodeData.put(VirtualHostNode.NAME, nodeName);
- nodeData.put(VirtualHostNode.TYPE, storeType);
- if (configStorePath != null)
- {
- nodeData.put(JsonVirtualHostNode.STORE_PATH, configStorePath);
- }
-
- getRestTestHelper().submitRequest("virtualhostnode/" + nodeName,
- "PUT",
- nodeData,
- HttpServletResponse.SC_CREATED);
- }
-
- private void createVirtualHostNode(String nodeName, final String storeType) throws Exception
- {
- createVirtualHostNode(nodeName, null, storeType);
- }
-
- private String getStoreLocation(String hostName)
- {
- return new File(TMP_FOLDER, "store-" + hostName + "-" + System.currentTimeMillis()).getAbsolutePath();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/7601044d/test-profiles/Java010Excludes
----------------------------------------------------------------------
diff --git a/test-profiles/Java010Excludes b/test-profiles/Java010Excludes
index 327c146..3557644 100755
--- a/test-profiles/Java010Excludes
+++ b/test-profiles/Java010Excludes
@@ -17,9 +17,6 @@
// under the License.
//
-// Those tests are testing 0.8..-0-9-1 specific semantics
-org.apache.qpid.systest.rest.BrokerRestTest#testSetCloseOnNoRoute
-
// 0-10 and 0-9 connections dont generate the exact same logging due to protocol differences
org.apache.qpid.server.logging.ChannelLoggingTest#testChannelStartsFlowStopped
org.apache.qpid.server.logging.ChannelLoggingTest#testChannelStartConsumerFlowStarted
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/7601044d/test-profiles/JavaJsonExcludes
----------------------------------------------------------------------
diff --git a/test-profiles/JavaJsonExcludes b/test-profiles/JavaJsonExcludes
index 61f4703..7620403 100644
--- a/test-profiles/JavaJsonExcludes
+++ b/test-profiles/JavaJsonExcludes
@@ -20,6 +20,4 @@
org.apache.qpid.server.store.berkeleydb.*
org.apache.qpid.server.store.berkeleydb.replication.*
org.apache.qpid.systest.rest.acl.VirtualHostACLTest#*
-org.apache.qpid.systest.rest.VirtualHostNodeRestTest#testCreateAndDeleteVirtualHostNode
-org.apache.qpid.systest.rest.VirtualHostRestTest#testPutCreateProvidedVirtualHost
org.apache.qpid.server.BrokerStartupTest#testStartupWithNoConfig
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org