diff options
| author | Robert Gemmell <robbie@apache.org> | 2012-05-29 22:50:35 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2012-05-29 22:50:35 +0000 |
| commit | 4e82caaece6d7b1626edc0b0913d45cad8771596 (patch) | |
| tree | a08c7faba239fcc8bd9ab73c9ccd9ca7a7ca02ce /qpid/java/systests | |
| parent | 3f64f140c95f54adfd5d698765f01d04670a0af0 (diff) | |
| download | qpid-python-4e82caaece6d7b1626edc0b0913d45cad8771596.tar.gz | |
QPID-4029: add ability to selectively include a protocol version on a given port, overriding an exclusion on the same port or it being disabled on all ports.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1344040 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/systests')
| -rw-r--r-- | qpid/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java | 102 | ||||
| -rw-r--r-- | qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java | 44 |
2 files changed, 131 insertions, 15 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java index 0e3a658e32..e8d72c13bd 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java @@ -38,6 +38,13 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase // No-op, we call super.setUp() from test methods after appropriate config overrides } + private void clearProtocolSupportManipulations() + { + //Remove the QBTC provided protocol manipulations, giving only the protocols which default to enabled + setTestSystemProperty(QpidBrokerTestCase.BROKER_PROTOCOL_EXCLUDES, null); + setTestSystemProperty(QpidBrokerTestCase.BROKER_PROTOCOL_INCLUDES, null); + } + /** * Test that 0-10, 0-9-1, 0-9, and 0-8 support is present when no * attempt has yet been made to disable them, and forcing the client @@ -46,7 +53,8 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase */ public void testDefaultProtocolSupport() throws Exception { - //Start the broker without modifying its supported protocols + clearProtocolSupportManipulations(); + super.setUp(); //Verify requesting a 0-10 connection works @@ -74,11 +82,13 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase connection.close(); } - public void testDisabling010() throws Exception + public void testDisabling010and10() throws Exception { - //disable 0-10 support - setConfigurationProperty("connector.amqp10enabled", "false"); - setConfigurationProperty("connector.amqp010enabled", "false"); + clearProtocolSupportManipulations(); + + //disable 0-10 and 1-0 support + setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP010ENABLED, "false"); + setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP10ENABLED, "false"); super.setUp(); @@ -90,9 +100,11 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase connection.close(); } - public void testDisabling091and010() throws Exception + public void testDisabling091and010and10() throws Exception { - //disable 0-91 and 0-10 support + clearProtocolSupportManipulations(); + + //disable 0-91 and 0-10 and 1-0 support setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP10ENABLED, "false"); setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP010ENABLED, "false"); setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP091ENABLED, "false"); @@ -107,9 +119,11 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase connection.close(); } - public void testDisabling09and091and010() throws Exception + public void testDisabling09and091and010and10() throws Exception { - //disable 0-9, 0-91 and 0-10 support + clearProtocolSupportManipulations(); + + //disable 0-9, 0-91, 0-10 and 1-0 support setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP09ENABLED, "false"); setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP091ENABLED, "false"); setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP010ENABLED, "false"); @@ -127,6 +141,8 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase public void testConfiguringReplyingToUnsupported010ProtocolInitiationWith09insteadOf091() throws Exception { + clearProtocolSupportManipulations(); + //disable 0-10 support, and set the default unsupported protocol initiation reply to 0-9 setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP010ENABLED, "false"); setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP_SUPPORTED_REPLY, "v0_9"); @@ -147,4 +163,72 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_91, connection.getProtocolVersion()); connection.close(); } + + public void testProtocolInclusionThroughQBTCSystemPropertiesOverridesProtocolExclusion() throws Exception + { + testProtocolInclusionOverridesProtocolExclusion(false); + } + + public void testProtocolInclusionThroughConfigOverridesProtocolExclusion() throws Exception + { + testProtocolInclusionOverridesProtocolExclusion(true); + } + + private void testProtocolInclusionOverridesProtocolExclusion(boolean useConfig) throws Exception + { + clearProtocolSupportManipulations(); + + //selectively exclude 0-10 and 1-0 on the test port + setTestSystemProperty(QpidBrokerTestCase.BROKER_PROTOCOL_EXCLUDES,"--exclude-0-10 @PORT --exclude-1-0 @PORT"); + + super.setUp(); + + //Verify initially requesting a 0-10 connection negotiates a 0-9-1 connection + setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-10"); + AMQConnection connection = (AMQConnection) getConnection(); + assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_91, connection.getProtocolVersion()); + connection.close(); + + stopBroker(); + + if(useConfig) + { + //selectively include 0-10 support again on the test port through config + setConfigurationProperty(ServerConfiguration.CONNECTOR_INCLUDE_010, String.valueOf(getPort())); + } + else + { + //selectively include 0-10 support again on the test port through QBTC sys props + setTestSystemProperty(QpidBrokerTestCase.BROKER_PROTOCOL_INCLUDES,"--include-0-10 @PORT"); + } + + startBroker(); + + //Verify requesting a 0-10 connection now returns one + setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-10"); + connection = (AMQConnection) getConnection(); + assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_10, connection.getProtocolVersion()); + connection.close(); + } + + public void testProtocolInclusionOverridesProtocolDisabling() throws Exception + { + clearProtocolSupportManipulations(); + + //disable 0-10 and 1-0 + setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP010ENABLED, "false"); + setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP10ENABLED, "false"); + + //selectively include 0-10 support again on the test port + setConfigurationProperty(ServerConfiguration.CONNECTOR_INCLUDE_010, String.valueOf(getPort())); + + super.setUp(); + + //Verify initially requesting a 0-10 connection still works + setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-10"); + AMQConnection connection = (AMQConnection) getConnection(); + assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_10, connection.getProtocolVersion()); + connection.close(); + } + }
\ No newline at end of file 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 9f019443f5..238d3d5229 100644 --- 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 @@ -61,6 +61,7 @@ import org.apache.qpid.management.common.mbeans.ConfigurationManagement; import org.apache.qpid.server.Broker; import org.apache.qpid.server.BrokerOptions; import org.apache.qpid.server.ProtocolExclusion; +import org.apache.qpid.server.ProtocolInclusion; import org.apache.qpid.server.configuration.ServerConfiguration; import org.apache.qpid.server.protocol.AmqpProtocolVersion; import org.apache.qpid.server.store.MessageStoreConstants; @@ -123,7 +124,8 @@ public class QpidBrokerTestCase extends QpidTestCase private static final String BROKER_LOG_INTERLEAVE = "broker.log.interleave"; private static final String BROKER_LOG_PREFIX = "broker.log.prefix"; private static final String BROKER_PERSITENT = "broker.persistent"; - private static final String BROKER_PROTOCOL_EXCLUDES = "broker.protocol.excludes"; + public static final String BROKER_PROTOCOL_EXCLUDES = "broker.protocol.excludes"; + public static final String BROKER_PROTOCOL_INCLUDES = "broker.protocol.includes"; // values protected static final String JAVA = "java"; @@ -144,7 +146,6 @@ public class QpidBrokerTestCase extends QpidTestCase private final AmqpProtocolVersion _brokerVersion = AmqpProtocolVersion.valueOf(System.getProperty(BROKER_VERSION, "")); protected String _output = System.getProperty(TEST_OUTPUT, System.getProperty("java.io.tmpdir")); protected Boolean _brokerPersistent = Boolean.getBoolean(BROKER_PERSITENT); - private String _brokerProtocolExcludes = System.getProperty(BROKER_PROTOCOL_EXCLUDES); protected static String _brokerLogPrefix = System.getProperty(BROKER_LOG_PREFIX,"BROKER: "); protected static boolean _interleaveBrokerLog = Boolean.getBoolean(BROKER_LOG_INTERLEAVE); @@ -332,12 +333,15 @@ public class QpidBrokerTestCase extends QpidTestCase { final int sslPort = port-1; final String protocolExcludesList = getProtocolExcludesList(port, sslPort); + final String protocolIncludesList = getProtocolIncludesList(port, sslPort); + return _brokerCommand .replace("@PORT", "" + port) .replace("@SSL_PORT", "" + sslPort) .replace("@MPORT", "" + getManagementPort(port)) .replace("@CONFIG_FILE", _configFile.toString()) - .replace("@EXCLUDES", protocolExcludesList); + .replace("@EXCLUDES", protocolExcludesList) + .replace("@INCLUDES", protocolIncludesList); } public void startBroker() throws Exception @@ -377,6 +381,7 @@ public class QpidBrokerTestCase extends QpidTestCase options.addPort(port); addExcludedPorts(port, DEFAULT_SSL_PORT, options); + addIncludedPorts(port, DEFAULT_SSL_PORT, options); options.setJmxPortRegistryServer(getManagementPort(port)); @@ -525,9 +530,36 @@ public class QpidBrokerTestCase extends QpidTestCase protected String getProtocolExcludesList(int port, int sslPort) { - final String protocolExcludesList = - _brokerProtocolExcludes.replace("@PORT", "" + port).replace("@SSL_PORT", "" + sslPort); - return protocolExcludesList; + return System.getProperty(BROKER_PROTOCOL_EXCLUDES,"").replace("@PORT", "" + port).replace("@SSL_PORT", "" + sslPort); + } + + private String getProtocolIncludesList(int port, int sslPort) + { + return System.getProperty(BROKER_PROTOCOL_INCLUDES, "").replace("@PORT", "" + port).replace("@SSL_PORT", "" + sslPort); + } + + private void addIncludedPorts(int port, int sslPort, BrokerOptions options) + { + final String protocolIncludesList = getProtocolIncludesList(port, sslPort); + + if (protocolIncludesList.equals("")) + { + return; + } + final String[] toks = protocolIncludesList.split("\\s"); + + if(toks.length % 2 != 0) + { + throw new IllegalArgumentException("Must be an even number of tokens in '" + protocolIncludesList + "'"); + } + for (int i = 0; i < toks.length; i=i+2) + { + String includeArg = toks[i]; + final int includedPort = Integer.parseInt(toks[i+1]); + options.addIncludedPort(ProtocolInclusion.lookup(includeArg), includedPort); + + _logger.info("Adding protocol inclusion " + includeArg + " " + includedPort); + } } private boolean existingInternalBroker() |
