From 571f269ffa7248088e2a9f5ab4e5ce50a00957dd Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Sun, 17 Aug 2014 15:04:18 +0000 Subject: 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 --- .../store/ManagementModeStoreHandler.java | 12 ++++- .../apache/qpid/server/model/port/PortFactory.java | 25 +++++++---- qpid/java/pom.xml | 34 +++++++-------- qpid/java/systests/etc/config-systests.json | 3 +- .../apache/qpid/test/utils/QpidBrokerTestCase.java | 4 ++ .../qpid/server/SupportedProtocolVersionsTest.java | 51 ++++++++++++++++++---- 6 files changed, 92 insertions(+), 37 deletions(-) (limited to 'qpid/java') diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java index 2a39cfa642..44b76cd5c8 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java @@ -34,6 +34,9 @@ import org.apache.qpid.server.BrokerOptions; import org.apache.qpid.server.configuration.IllegalConfigurationException; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectAttribute; +import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry; +import org.apache.qpid.server.model.Model; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.Protocol; import org.apache.qpid.server.model.State; @@ -44,7 +47,6 @@ import org.apache.qpid.server.store.ConfiguredObjectRecordImpl; import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler; -import org.apache.qpid.server.util.MapValueConverter; public class ManagementModeStoreHandler implements DurableConfigurationStore { @@ -455,7 +457,13 @@ public class ManagementModeStoreHandler implements DurableConfigurationStore { return null; } - return MapValueConverter.getEnumSetAttribute(Port.PROTOCOLS, attributes, Protocol.class); + Model model = _parent.getModel(); + ConfiguredObjectTypeRegistry typeRegistry = model.getTypeRegistry(); + Map> attributeTypes = + typeRegistry.getAttributeTypes(Port.class); + ConfiguredObjectAttribute protocolsAttribute = attributeTypes.get(Port.PROTOCOLS); + return (Set) protocolsAttribute.convert(object,_parent); + } private ConfiguredObjectRecord createEntryWithState(ConfiguredObjectRecord entry, Object state) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java index 99ec4b79cb..870621f292 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java @@ -24,8 +24,12 @@ import java.util.Map; import java.util.Set; import org.apache.qpid.server.configuration.IllegalConfigurationException; +import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectAttribute; import org.apache.qpid.server.model.ConfiguredObjectFactory; +import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry; +import org.apache.qpid.server.model.Model; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.Protocol; import org.apache.qpid.server.model.Protocol.ProtocolType; @@ -34,7 +38,6 @@ import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory; import org.apache.qpid.server.plugin.PluggableService; import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.store.UnresolvedConfiguredObject; -import org.apache.qpid.server.util.MapValueConverter; @PluggableService public class PortFactory> implements ConfiguredObjectTypeFactory @@ -52,11 +55,14 @@ public class PortFactory> implements ConfiguredObjectTypeFacto { } - private ProtocolType getProtocolType(Map portAttributes) + private ProtocolType getProtocolType(Map portAttributes, Broker broker) { - - Set protocols = MapValueConverter.getEnumSetAttribute(Port.PROTOCOLS, portAttributes, Protocol.class); - + Model model = broker.getModel(); + ConfiguredObjectTypeRegistry typeRegistry = model.getTypeRegistry(); + Map> attributeTypes = + typeRegistry.getAttributeTypes(Port.class); + ConfiguredObjectAttribute protocolsAttribute = attributeTypes.get(Port.PROTOCOLS); + Set protocols = (Set) protocolsAttribute.convert(portAttributes.get(Port.PROTOCOLS),broker); ProtocolType protocolType = null; if(protocols == null || protocols.isEmpty()) @@ -98,7 +104,7 @@ public class PortFactory> implements ConfiguredObjectTypeFacto final Map attributes, final ConfiguredObject... parents) { - return getPortFactory(factory, attributes).create(factory, attributes,parents); + return getPortFactory(factory, attributes, (Broker)parents[0]).create(factory, attributes,parents); } @Override @@ -106,11 +112,12 @@ public class PortFactory> implements ConfiguredObjectTypeFacto final ConfiguredObjectRecord record, final ConfiguredObject... parents) { - return getPortFactory(factory, record.getAttributes()).recover(factory, record, parents); + return getPortFactory(factory, record.getAttributes(), (Broker)parents[0]).recover(factory, record, parents); } public ConfiguredObjectTypeFactory getPortFactory(final ConfiguredObjectFactory factory, - Map attributes) + Map attributes, + Broker broker) { String type; @@ -120,7 +127,7 @@ public class PortFactory> implements ConfiguredObjectTypeFacto } else { - type = getProtocolType(attributes).name(); + type = getProtocolType(attributes, broker).name(); } return factory.getConfiguredObjectTypeFactory(Port.class.getSimpleName(), type); diff --git a/qpid/java/pom.xml b/qpid/java/pom.xml index 05bf17af9f..d535b4c60a 100644 --- a/qpid/java/pom.xml +++ b/qpid/java/pom.xml @@ -65,7 +65,7 @@ Excludes JavaExcludes ${profile}.excludes ${profile.specific.excludes} JavaTransientExcludes Java010Excludes v0_10 - AMQP_1_0 + ["AMQP_0_8","AMQP_0_9","AMQP_0_9_1","AMQP_0_10"] false Memory true @@ -174,7 +174,7 @@ [profile.specific.excludes] ${profile.specific.excludes} [profile.test.excludes] ${profile.test.excludes} [profile.broker.version] ${profile.broker.version} - [profile.qpid.broker_default_amqp_protocol_excludes] ${profile.qpid.broker_default_amqp_protocol_excludes} + [profile.test.amqp_port_protocols] ${profile.test.amqp_port_protocols} [profile.broker.persistent] ${profile.broker.persistent} [profile.virtualhostnode.type] ${profile.virtualhostnode.type} [profile.virtualhostnode.context.blueprint] ${profile.virtualhostnode.context.blueprint} @@ -241,7 +241,7 @@ ${profile.broker.command.windows} ${profile.test.excludes} ${profile.broker.version} - ${profile.qpid.broker_default_amqp_protocol_excludes} + ${profile.test.amqp_port_protocols} ${profile.broker.persistent} ${profile.virtualhostnode.type} ${profile.virtualhostnode.context.blueprint} @@ -400,7 +400,7 @@ java-mms.0-10 JavaTransientExcludes Java010Excludes v0_10 - AMQP_1_0 + ["AMQP_0_8","AMQP_0_9","AMQP_0_9_1","AMQP_0_10"] false Memory {"type":"ProvidedStore"} @@ -419,7 +419,7 @@ java-mms.0-9-1 JavaTransientExcludes XAExcludes JavaPre010Excludes v0_9_1 - AMQP_1_0,AMQP_0_10 + ["AMQP_0_8","AMQP_0_9","AMQP_0_9_1"] false Memory {"type":"ProvidedStore"} @@ -438,7 +438,7 @@ java-mms.0-9 JavaTransientExcludes XAExcludes JavaPre010Excludes v0_9 - AMQP_1_0,AMQP_0_10,AMQP_0_9_1 + ["AMQP_0_8","AMQP_0_9"] false Memory {"type":"ProvidedStore"} @@ -457,7 +457,7 @@ java-bdb.0-10 JavaPersistentExcludes Java010Excludes JavaBDBExcludes v0_10 - AMQP_1_0 + ["AMQP_0_8","AMQP_0_9","AMQP_0_9_1","AMQP_0_10"] true BDB {"type":"ProvidedStore"} @@ -476,7 +476,7 @@ java-bdb.0-9-1 JavaPersistentExcludes XAExcludes JavaPre010Excludes JavaBDBExcludes v0_9_1 - AMQP_1_0,AMQP_0_10 + ["AMQP_0_8","AMQP_0_9","AMQP_0_9_1"] true BDB {"type":"ProvidedStore"} @@ -495,7 +495,7 @@ java-bdb.0-9 JavaPersistentExcludes XAExcludes JavaPre010Excludes JavaBDBExcludes v0_9 - AMQP_1_0,AMQP_0_10,AMQP_0_9_1 + ["AMQP_0_8","AMQP_0_9"] true BDB {"type":"ProvidedStore"} @@ -514,7 +514,7 @@ java-dby-mem.0-10 JavaPersistentExcludes JavaDerbyExcludes Java010Excludes v0_10 - AMQP_1_0 + ["AMQP_0_8","AMQP_0_9","AMQP_0_9_1","AMQP_0_10"] true DERBY {"type":"ProvidedStore"} @@ -533,7 +533,7 @@ java-dby-mem.0-9-1 JavaPersistentExcludes JavaDerbyExcludes XAExcludes JavaPre010Excludes v0_9_1 - AMQP_1_0,AMQP_0_10 + ["AMQP_0_8","AMQP_0_9","AMQP_0_9_1"] true DERBY {"type":"ProvidedStore"} @@ -552,7 +552,7 @@ java-dby-mem.0-9 JavaPersistentExcludes JavaDerbyExcludes XAExcludes JavaPre010Excludes v0_9 - AMQP_1_0,AMQP_0_10,AMQP_0_9_1 + ["AMQP_0_8","AMQP_0_9"] true DERBY {"type":"ProvidedStore"} @@ -571,7 +571,7 @@ java-dby.0-10 JavaPersistentExcludes JavaDerbyExcludes Java010Excludes v0_10 - AMQP_1_0 + ["AMQP_0_8","AMQP_0_9","AMQP_0_9_1","AMQP_0_10"] true DERBY {"type":"ProvidedStore"} @@ -590,7 +590,7 @@ java-dby.0-9-1 JavaPersistentExcludes JavaDerbyExcludes XAExcludes JavaPre010Excludes v0_9_1 - AMQP_1_0,AMQP_0_10 + ["AMQP_0_8","AMQP_0_9","AMQP_0_9_1"] true DERBY {"type":"ProvidedStore"} @@ -609,7 +609,7 @@ java-dby.0-9 JavaPersistentExcludes JavaDerbyExcludes XAExcludes JavaPre010Excludes v0_9 - AMQP_1_0,AMQP_0_10,AMQP_0_9_1 + ["AMQP_0_8","AMQP_0_9"] true DERBY {"type":"ProvidedStore"} @@ -633,7 +633,7 @@ java-json.0-9-1 JavaPersistentExcludes JavaJsonExcludes XAExcludes JavaPre010Excludes v0_9_1 - AMQP_1_0,AMQP_0_10 + ["AMQP_0_8","AMQP_0_9","AMQP_0_9_1"] true JSON {"type":"DERBY","storePath":"${dollar.sign}{json:QPID_WORK}${dollar.sign}{json:file.separator}${dollar.sign}{this:name}${dollar.sign}{json:file.separator}derby"} @@ -652,7 +652,7 @@ java-json.0-10 JavaPersistentExcludes JavaJsonExcludes XAExcludes Java010Excludes v0_10 - AMQP_1_0 + ["AMQP_0_8","AMQP_0_9","AMQP_0_9_1","AMQP_0_10"] true JSON {"type":"DERBY","storePath":"${dollar.sign}{QPID_WORK}/${dollar.sign}{this:name}/derby"} diff --git a/qpid/java/systests/etc/config-systests.json b/qpid/java/systests/etc/config-systests.json index 4375f258e8..4ec402c292 100644 --- a/qpid/java/systests/etc/config-systests.json +++ b/qpid/java/systests/etc/config-systests.json @@ -41,7 +41,8 @@ "ports" : [ { "name" : "amqp", "authenticationProvider" : "plain", - "port" : "${test.port}" + "port" : "${test.port}", + "protocols" : "${test.amqp_port_protocols}" }, { "name" : "http", "authenticationProvider" : "plain", 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 getAllAmqpProtocols() throws Exception + { + Collection 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 protocols = new HashSet<>(getAllAmqpProtocols()); + protocols.removeAll(Arrays.asList(excludes)); + return getProtocolsAsString(protocols); + } + + private String getProtocolsAsString(final Collection 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(); -- cgit v1.2.1