diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2014-08-17 15:04:18 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2014-08-17 15:04:18 +0000 |
| commit | 571f269ffa7248088e2a9f5ab4e5ce50a00957dd (patch) | |
| tree | 954e70e3c6e0aa681a6b91e58bec5bc37d22b247 /qpid/java/systests/src | |
| parent | 3bb54b2bcac8b7602d865de45e92376b4c5332ba (diff) | |
| download | qpid-python-571f269ffa7248088e2a9f5ab4e5ce50a00957dd.tar.gz | |
QPID-6010 : [Java Tests] Use context defaulting to select protocols in use
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1618478 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/systests/src')
| -rwxr-xr-x | qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java | 4 | ||||
| -rw-r--r-- | qpid/java/systests/src/test/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java | 51 |
2 files changed, 47 insertions, 8 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java index 0f558f3abe..0345485167 100755 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java @@ -142,6 +142,8 @@ public class QpidBrokerTestCase extends QpidTestCase public static final int DEFAULT_HTTP_MANAGEMENT_PORT_VALUE = 8080; public static final int DEFAULT_HTTPS_MANAGEMENT_PORT_VALUE = 8443; + public static final String TEST_AMQP_PORT_PROTOCOLS_PROPERTY="test.amqp_port_protocols"; + // values protected static final String JAVA = "java"; protected static final String CPP = "cpp"; @@ -559,6 +561,8 @@ public class QpidBrokerTestCase extends QpidTestCase setSystemProperty("test.port.ssl"); setSystemProperty("test.port.alt"); setSystemProperty("test.port.alt.ssl"); + setSystemProperty("test.amqp_port_protocols"); + setSystemProperty("virtualhostnode.type"); setSystemProperty("virtualhostnode.context.blueprint"); diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java index 42f3854d32..b94827f249 100644 --- a/qpid/java/systests/src/test/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java +++ b/qpid/java/systests/src/test/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java @@ -20,6 +20,15 @@ */ package org.apache.qpid.server; +import java.io.IOException; +import java.io.StringWriter; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.codehaus.jackson.map.ObjectMapper; + import org.apache.qpid.client.AMQConnection; import org.apache.qpid.configuration.ClientProperties; import org.apache.qpid.framing.ProtocolVersion; @@ -43,11 +52,41 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase // No-op, we call super.setUp() from test methods after appropriate config overrides } - private void clearProtocolSupportManipulations() + private void clearProtocolSupportManipulations() throws Exception { //Remove the QBTC provided protocol manipulations, giving only the protocols which default to enabled setSystemProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_EXCLUDES, null); setSystemProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_INCLUDES, null); + setSystemProperty(QpidBrokerTestCase.TEST_AMQP_PORT_PROTOCOLS_PROPERTY, getProtocolsAsString(getAllAmqpProtocols())); + } + + private Collection<Protocol> getAllAmqpProtocols() throws Exception + { + Collection<Protocol> protocols = new HashSet<>(); + for(Protocol p : Protocol.values()) + { + if(p.getProtocolType() == Protocol.ProtocolType.AMQP) + { + protocols.add(p); + } + } + + return protocols; + } + + private String getProtocolsWithExclusions(Protocol... excludes) throws Exception + { + Set<Protocol> protocols = new HashSet<>(getAllAmqpProtocols()); + protocols.removeAll(Arrays.asList(excludes)); + return getProtocolsAsString(protocols); + } + + private String getProtocolsAsString(final Collection<Protocol> protocols) throws IOException + { + ObjectMapper mapper = new ObjectMapper(); + StringWriter stringWriter = new StringWriter(); + mapper.writeValue(stringWriter, protocols); + return stringWriter.toString(); } /** @@ -89,11 +128,7 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase public void testDisabling010and10() throws Exception { - clearProtocolSupportManipulations(); - - //disable 0-10 and 1-0 support - setSystemProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_EXCLUDES, - Protocol.AMQP_1_0 + "," + Protocol.AMQP_0_10); + setSystemProperty(QpidBrokerTestCase.TEST_AMQP_PORT_PROTOCOLS_PROPERTY, getProtocolsWithExclusions(Protocol.AMQP_1_0, Protocol.AMQP_0_10)); super.setUp(); @@ -110,8 +145,8 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase clearProtocolSupportManipulations(); //disable 0-10 support, and set the default unsupported protocol initiation reply to 0-9 - setSystemProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_EXCLUDES, - Protocol.AMQP_1_0 + "," + Protocol.AMQP_0_10); + setSystemProperty(QpidBrokerTestCase.TEST_AMQP_PORT_PROTOCOLS_PROPERTY, getProtocolsWithExclusions(Protocol.AMQP_1_0, Protocol.AMQP_0_10)); + setSystemProperty(BrokerProperties.PROPERTY_DEFAULT_SUPPORTED_PROTOCOL_REPLY, "v0_9"); super.setUp(); |
