MultiVersionProtocolEngineFactory factory =
new MultiVersionProtocolEngineFactory("localhost", versions);
//create a dummy to retrieve the 'current' ID number
long previousId = factory.newProtocolEngine(new TestNetworkConnection()).getConnectionId();
//create a protocol engine and send the AMQP header for all supported AMQP verisons,
//ensuring the ID assigned increases as expected
for(AmqpProtocolVersion version : versions)
{
long expectedID = previousId + 1;
byte[] header = getAmqpHeader(version);
assertNotNull("protocol header should not be null", header);
ServerProtocolEngine engine = factory.newProtocolEngine(new TestNetworkConnection());
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
engine.received(ByteBuffer.wrap(header));
assertEquals("ID was not as expected following receipt of the AMQP version header", expectedID, engine.getConnectionId());