diff options
author | Robert Godfrey <rgodfrey@apache.org> | 2012-03-10 19:22:10 +0000 |
---|---|---|
committer | Robert Godfrey <rgodfrey@apache.org> | 2012-03-10 19:22:10 +0000 |
commit | 4eaa4e42093e5524d9552d8fa312c214524b6bb4 (patch) | |
tree | a251d57ee92d9c779fe4455c583be0ed90e69a43 /qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java | |
parent | 92be7e8f3163c048a8642d2deeaa921bbb65dc9c (diff) | |
download | qpid-python-rg-amqp-1-0-sandbox.tar.gz |
NO-JIRA : AMQP-1-0 sandbox updates - merge from trunkrg-amqp-1-0-sandbox
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/rg-amqp-1-0-sandbox@1299257 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java')
-rw-r--r-- | qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java index 9d76d5efca..d8b5cd02cf 100644 --- a/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java +++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java @@ -20,11 +20,8 @@ */ package org.apache.qpid.server.protocol; -import java.nio.ByteBuffer; -import java.util.EnumSet; -import java.util.Set; - import org.apache.commons.configuration.XMLConfiguration; + import org.apache.qpid.protocol.ServerProtocolEngine; import org.apache.qpid.server.configuration.ServerConfiguration; import org.apache.qpid.server.registry.ApplicationRegistry; @@ -32,6 +29,10 @@ import org.apache.qpid.server.util.TestApplicationRegistry; import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.transport.TestNetworkConnection; +import java.nio.ByteBuffer; +import java.util.EnumSet; +import java.util.Set; + public class MultiVersionProtocolEngineFactoryTest extends QpidTestCase { protected void setUp() throws Exception @@ -120,10 +121,10 @@ public class MultiVersionProtocolEngineFactoryTest extends QpidTestCase Set<AmqpProtocolVersion> versions = EnumSet.allOf(AmqpProtocolVersion.class); MultiVersionProtocolEngineFactory factory = - new MultiVersionProtocolEngineFactory("localhost", versions); + new MultiVersionProtocolEngineFactory(versions, null); //create a dummy to retrieve the 'current' ID number - long previousId = factory.newProtocolEngine(new TestNetworkConnection()).getConnectionId(); + long previousId = factory.newProtocolEngine().getConnectionId(); //create a protocol engine and send the AMQP header for all supported AMQP verisons, //ensuring the ID assigned increases as expected @@ -133,7 +134,9 @@ public class MultiVersionProtocolEngineFactoryTest extends QpidTestCase byte[] header = getAmqpHeader(version); assertNotNull("protocol header should not be null", header); - ServerProtocolEngine engine = factory.newProtocolEngine(new TestNetworkConnection()); + ServerProtocolEngine engine = factory.newProtocolEngine(); + TestNetworkConnection conn = new TestNetworkConnection(); + engine.setNetworkConnection(conn, conn.getSender()); assertEquals("ID did not increment as expected", expectedID, engine.getConnectionId()); //actually feed in the AMQP header for this protocol version, and ensure the ID remains consistent @@ -143,4 +146,24 @@ public class MultiVersionProtocolEngineFactoryTest extends QpidTestCase previousId = expectedID; } } + + /** + * Test to verify that when requesting a ProtocolEngineFactory to produce engines having a default reply to unsupported + * version initiations, there is enforcement that the default reply is itself a supported protocol version. + */ + public void testUnsupportedDefaultReplyCausesIllegalArgumentException() + { + Set<AmqpProtocolVersion> versions = EnumSet.allOf(AmqpProtocolVersion.class); + versions.remove(AmqpProtocolVersion.v0_9); + + try + { + new MultiVersionProtocolEngineFactory(versions, AmqpProtocolVersion.v0_9); + fail("should not have been allowed to create the factory"); + } + catch(IllegalArgumentException iae) + { + //expected + } + } } |