diff options
author | Andrew MacBean <macbean@apache.org> | 2014-06-19 15:08:16 +0000 |
---|---|---|
committer | Andrew MacBean <macbean@apache.org> | 2014-06-19 15:08:16 +0000 |
commit | 6071a5f23ae85eb7a3fb469f43250c7e5a37fda7 (patch) | |
tree | 5b7d2697d800759d756dd705f78e2f71b823ae91 | |
parent | 7f33591e615d1e7969d3df2b959244ed28d00e03 (diff) | |
download | qpid-python-6071a5f23ae85eb7a3fb469f43250c7e5a37fda7.tar.gz |
QPID-5825: Changes to address some review comments for initial commit
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1603914 13f79535-47bb-0310-9956-ffa450edef68
6 files changed, 163 insertions, 54 deletions
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapper.java b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapper.java index 9947a8fac0..766d6fbcd3 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapper.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapper.java @@ -1,3 +1,23 @@ +/* + * + * 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.plugin; import org.apache.commons.lang.StringUtils; @@ -5,11 +25,11 @@ import org.apache.qpid.server.model.Protocol; public class AMQPProtocolVersionWrapper { - private static final char DELIMITER = '_'; + static final char DELIMITER = '_'; - private int major; - private int minor; - private int patch; + private int _major; + private int _minor; + private int _patch; public AMQPProtocolVersionWrapper(Protocol amqpProtocol) { @@ -23,51 +43,29 @@ public class AMQPProtocolVersionWrapper { switch (i) { - case 1: this.major = Integer.parseInt(parts[i]); + case 1: this._major = Integer.parseInt(parts[i]); break; - case 2: this.minor = Integer.parseInt(parts[i]); + case 2: this._minor = Integer.parseInt(parts[i]); break; - case 3: this.patch = Integer.parseInt(parts[i]); + case 3: this._patch = Integer.parseInt(parts[i]); break; } } } - public AMQPProtocolVersionWrapper(int major, int minor, int patch) - { - this.major = major; - this.minor = minor; - this.patch = patch; - } - public int getMajor() { - return major; - } - - public void setMajor(int major) - { - this.major = major; + return _major; } public int getMinor() { - return minor; - } - - public void setMinor(int minor) - { - this.minor = minor; + return _minor; } public int getPatch() { - return patch; - } - - public void setPatch(int patch) - { - this.patch = patch; + return _patch; } public Protocol getProtocol() @@ -89,15 +87,15 @@ public class AMQPProtocolVersionWrapper final AMQPProtocolVersionWrapper number = (AMQPProtocolVersionWrapper) o; - if (this.major != number.major) + if (this._major != number._major) { return false; } - else if (this.minor != number.minor) + else if (this._minor != number._minor) { return false; } - else if (this.patch != number.patch) + else if (this._patch != number._patch) { return false; } @@ -110,9 +108,9 @@ public class AMQPProtocolVersionWrapper @Override public int hashCode() { - int result = major; - result = 31 * result + minor; - result = 31 * result + patch; + int result = _major; + result = 31 * result + _minor; + result = 31 * result + _patch; return result; } @@ -120,11 +118,11 @@ public class AMQPProtocolVersionWrapper public String toString() { final StringBuilder sb = new StringBuilder(Protocol.ProtocolType.AMQP.name()).append(DELIMITER) - .append(major).append(DELIMITER) - .append(minor); - if (patch != 0) + .append(_major).append(DELIMITER) + .append(_minor); + if (_patch != 0) { - sb.append(DELIMITER).append(patch); + sb.append(DELIMITER).append(_patch); } return sb.toString(); } diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ProtocolEngineCreatorComparator.java b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ProtocolEngineCreatorComparator.java index 3619d7000e..a8913617af 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ProtocolEngineCreatorComparator.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ProtocolEngineCreatorComparator.java @@ -1,3 +1,23 @@ +/* + * + * 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.plugin; import java.util.Comparator; diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapperTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapperTest.java index 4d57c6c7e7..c493391b78 100644 --- a/java/broker-core/src/test/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapperTest.java +++ b/java/broker-core/src/test/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapperTest.java @@ -1,3 +1,23 @@ +/* + * + * 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.plugin; import org.apache.qpid.server.model.Protocol; @@ -7,14 +27,30 @@ public class AMQPProtocolVersionWrapperTest extends QpidTestCase { public void testAMQPProtocolVersionWrapper() throws Exception { - assertEquals(new AMQPProtocolVersionWrapper(0,8,0), new AMQPProtocolVersionWrapper(Protocol.AMQP_0_8)); - assertEquals(new AMQPProtocolVersionWrapper(0,9,0), new AMQPProtocolVersionWrapper(Protocol.AMQP_0_9)); - assertEquals(new AMQPProtocolVersionWrapper(0,9,1), new AMQPProtocolVersionWrapper(Protocol.AMQP_0_9_1)); - assertEquals(new AMQPProtocolVersionWrapper(0,10,0),new AMQPProtocolVersionWrapper(Protocol.AMQP_0_10)); - assertEquals(new AMQPProtocolVersionWrapper(1,0,0), new AMQPProtocolVersionWrapper(Protocol.AMQP_1_0)); - - assertNotSame(new AMQPProtocolVersionWrapper(0, 9, 1), new AMQPProtocolVersionWrapper(Protocol.AMQP_0_9)); - assertNotSame(new AMQPProtocolVersionWrapper(0, 10, 0), new AMQPProtocolVersionWrapper(Protocol.AMQP_1_0)); + final AMQPProtocolVersionWrapper wrapper0_8 = new AMQPProtocolVersionWrapper(Protocol.AMQP_0_8); + assertEquals(0 ,wrapper0_8.getMajor()); + assertEquals(8 ,wrapper0_8.getMinor()); + assertEquals(0 ,wrapper0_8.getPatch()); + + final AMQPProtocolVersionWrapper wrapper0_9 = new AMQPProtocolVersionWrapper(Protocol.AMQP_0_9); + assertEquals(0 ,wrapper0_9.getMajor()); + assertEquals(9 ,wrapper0_9.getMinor()); + assertEquals(0 ,wrapper0_9.getPatch()); + + final AMQPProtocolVersionWrapper wrapper0_9_1 = new AMQPProtocolVersionWrapper(Protocol.AMQP_0_9_1); + assertEquals(0 ,wrapper0_9_1.getMajor()); + assertEquals(9 ,wrapper0_9_1.getMinor()); + assertEquals(1 ,wrapper0_9_1.getPatch()); + + final AMQPProtocolVersionWrapper wrapper0_10 = new AMQPProtocolVersionWrapper(Protocol.AMQP_0_10); + assertEquals(0 ,wrapper0_10.getMajor()); + assertEquals(10 ,wrapper0_10.getMinor()); + assertEquals(0 ,wrapper0_10.getPatch()); + + final AMQPProtocolVersionWrapper wrapper1_0 = new AMQPProtocolVersionWrapper(Protocol.AMQP_1_0); + assertEquals(1 ,wrapper1_0.getMajor()); + assertEquals(0 ,wrapper1_0.getMinor()); + assertEquals(0 ,wrapper1_0.getPatch()); } public void testAMQPProtocolVersionWrapperGetProtocol() throws Exception @@ -40,4 +76,5 @@ public class AMQPProtocolVersionWrapperTest extends QpidTestCase // pass } } + } diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/plugin/ProtocolEngineCreatorComparatorTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/plugin/ProtocolEngineCreatorComparatorTest.java index 6eceab13c4..bee39058ac 100644 --- a/java/broker-core/src/test/java/org/apache/qpid/server/plugin/ProtocolEngineCreatorComparatorTest.java +++ b/java/broker-core/src/test/java/org/apache/qpid/server/plugin/ProtocolEngineCreatorComparatorTest.java @@ -1,3 +1,23 @@ +/* + * + * 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.plugin; import org.apache.qpid.server.model.Protocol; diff --git a/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java b/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java index 23a00431d1..42f3854d32 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java @@ -26,6 +26,7 @@ import org.apache.qpid.framing.ProtocolVersion; import org.apache.qpid.server.configuration.BrokerProperties; import org.apache.qpid.server.model.Protocol; import org.apache.qpid.server.model.adapter.PortFactoryTest; +import org.apache.qpid.server.plugin.AMQPProtocolVersionWrapper; import org.apache.qpid.test.utils.QpidBrokerTestCase; /** @@ -130,5 +131,33 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase connection.close(); } + public void testProtocolIsExpectedBasedOnTestProfile() throws Exception + { + super.setUp(); + final AMQConnection connection = (AMQConnection) getConnection(); + final Protocol expectedBrokerProtocol = getBrokerProtocol(); + final AMQPProtocolVersionWrapper amqpProtocolVersionWrapper = new AMQPProtocolVersionWrapper(expectedBrokerProtocol); + final ProtocolVersion protocolVersion = connection.getProtocolVersion(); + assertTrue("Connection AMQP protocol " + expectedBrokerProtocol + "is not the same as the test specified protocol " + protocolVersion, + areEquivalent(amqpProtocolVersionWrapper, protocolVersion)); + connection.close(); + } -}
\ No newline at end of file + private boolean areEquivalent(AMQPProtocolVersionWrapper amqpProtocolVersionWrapper, ProtocolVersion protocolVersion) + { + byte byteMajor = (byte)amqpProtocolVersionWrapper.getMajor(); + byte byteMinor; + if (amqpProtocolVersionWrapper.getPatch() == 0) + { + byteMinor = (byte)amqpProtocolVersionWrapper.getMinor(); + } + else + { + final StringBuilder sb = new StringBuilder(); + sb.append(amqpProtocolVersionWrapper.getMinor()); + sb.append(amqpProtocolVersionWrapper.getPatch()); + byteMinor = Byte.valueOf(sb.toString()).byteValue(); + } + return (protocolVersion.getMajorVersion() == byteMajor && protocolVersion.getMinorVersion() == byteMinor); + } +} diff --git a/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java index 88e7ee20c8..9b6abb1447 100755 --- a/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java +++ b/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java @@ -164,7 +164,7 @@ public class QpidBrokerTestCase extends QpidTestCase protected BrokerCommandHelper _brokerCommandHelper = new BrokerCommandHelper(BROKER_COMMAND_TEMPLATE); private Boolean _brokerCleanBetweenTests = Boolean.getBoolean(BROKER_CLEAN_BETWEEN_TESTS); - private final Protocol _brokerVersion = Protocol.valueOf("AMQP_" + System.getProperty(BROKER_VERSION, " ").substring(1)); + private final Protocol _brokerProtocol = Protocol.valueOf("AMQP_" + System.getProperty(BROKER_VERSION, " ").substring(1)); protected String _output = System.getProperty(TEST_OUTPUT, System.getProperty("java.io.tmpdir")); protected Boolean _brokerPersistent = Boolean.getBoolean(BROKER_PERSITENT); @@ -993,12 +993,17 @@ public class QpidBrokerTestCase extends QpidTestCase */ public boolean isBroker08() { - return _brokerVersion.equals(Protocol.AMQP_0_8); + return _brokerProtocol.equals(Protocol.AMQP_0_8); } public boolean isBroker010() { - return _brokerVersion.equals(Protocol.AMQP_0_10); + return _brokerProtocol.equals(Protocol.AMQP_0_10); + } + + public Protocol getBrokerProtocol() + { + return _brokerProtocol; } protected boolean isJavaBroker() |