Program: 41157
Project: 41157
Buggy source:
/** 
 * Test that a message received from the test peer with an AmqpValue section containing a map which holds entries of the various supported entry types is returned as a  {@link MapMessage}, and verify the values can all be retrieved as expected.
 */
@Test(timeout=5000) public void testReceiveBasicMapMessage() throws Exception {
  try (TestAmqpPeer testPeer=new TestAmqpPeer(IntegrationTestFixture.PORT)){
    Connection connection=testFixture.establishConnecton(testPeer);
    connection.start();
    testPeer.expectBegin(true);
    Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
    Queue queue=session.createQueue("String_Node_Str");
    String myBoolKey="String_Node_Str";
    boolean myBool=true;
    String myByteKey="String_Node_Str";
    byte myByte=4;
    String myBytesKey="String_Node_Str";
    byte[] myBytes=myBytesKey.getBytes();
    String myCharKey="String_Node_Str";
    char myChar='d';
    String myDoubleKey="String_Node_Str";
    double myDouble=1234567890123456789.1234;
    String myFloatKey="String_Node_Str";
    float myFloat=1.1F;
    String myIntKey="String_Node_Str";
    int myInt=Integer.MAX_VALUE;
    String myLongKey="String_Node_Str";
    long myLong=Long.MAX_VALUE;
    String myShortKey="String_Node_Str";
    short myShort=25;
    String myStringKey="String_Node_Str";
    String myString=myStringKey;
    Map<String,Object> map=new LinkedHashMap<String,Object>();
    map.put(myBoolKey,myBool);
    map.put(myByteKey,myByte);
    map.put(myBytesKey,new Binary(myBytes));
    map.put(myCharKey,myChar);
    map.put(myDoubleKey,myDouble);
    map.put(myFloatKey,myFloat);
    map.put(myIntKey,myInt);
    map.put(myLongKey,myLong);
    map.put(myShortKey,myShort);
    map.put(myStringKey,myString);
    MessageAnnotationsDescribedType msgAnnotations=new MessageAnnotationsDescribedType();
    msgAnnotations.setSymbolKeyedAnnotation(AmqpMessageSupport.JMS_MSG_TYPE,AmqpMessageSupport.JMS_MAP_MESSAGE);
    DescribedType amqpValueSectionContent=new AmqpValueDescribedType(map);
    testPeer.expectReceiverAttach();
    testPeer.expectLinkFlowRespondWithTransfer(null,msgAnnotations,null,null,amqpValueSectionContent);
    testPeer.expectDispositionThatIsAcceptedAndSettled();
    MessageConsumer messageConsumer=session.createConsumer(queue);
    Message receivedMessage=messageConsumer.receive(1000);
    testPeer.waitForAllHandlersToComplete(3000);
    assertNotNull("String_Node_Str",receivedMessage);
    assertTrue("String_Node_Str",receivedMessage instanceof MapMessage);
    MapMessage receivedMapMessage=(MapMessage)receivedMessage;
    assertEquals("String_Node_Str",myBool,receivedMapMessage.getBoolean(myBoolKey));
    assertEquals("String_Node_Str",myByte,receivedMapMessage.getByte(myByteKey));
    byte[] readBytes=receivedMapMessage.getBytes(myBytesKey);
    assertTrue("String_Node_Str" + Arrays.toString(readBytes),Arrays.equals(myBytes,readBytes));
    assertEquals("String_Node_Str",myChar,receivedMapMessage.getChar(myCharKey));
    assertEquals("String_Node_Str",myDouble,receivedMapMessage.getDouble(myDoubleKey),0.0);
    assertEquals("String_Node_Str",myFloat,receivedMapMessage.getFloat(myFloatKey),0.0);
    assertEquals("String_Node_Str",myInt,receivedMapMessage.getInt(myIntKey));
    assertEquals("String_Node_Str",myLong,receivedMapMessage.getLong(myLongKey));
    assertEquals("String_Node_Str",myShort,receivedMapMessage.getShort(myShortKey));
    assertEquals("String_Node_Str",myString,receivedMapMessage.getString(myStringKey));
  }
 }

Fixed version (ground truth):
/** 
 * Test that a message received from the test peer with an AmqpValue section containing a map which holds entries of the various supported entry types is returned as a  {@link MapMessage}, and verify the values can all be retrieved as expected.
 */
@Test(timeout=5000) public void testReceiveBasicMapMessage() throws Exception {
  try (TestAmqpPeer testPeer=new TestAmqpPeer(testFixture.getAvailablePort())){
    Connection connection=testFixture.establishConnecton(testPeer);
    connection.start();
    testPeer.expectBegin(true);
    Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
    Queue queue=session.createQueue("String_Node_Str");
    String myBoolKey="String_Node_Str";
    boolean myBool=true;
    String myByteKey="String_Node_Str";
    byte myByte=4;
    String myBytesKey="String_Node_Str";
    byte[] myBytes=myBytesKey.getBytes();
    String myCharKey="String_Node_Str";
    char myChar='d';
    String myDoubleKey="String_Node_Str";
    double myDouble=1234567890123456789.1234;
    String myFloatKey="String_Node_Str";
    float myFloat=1.1F;
    String myIntKey="String_Node_Str";
    int myInt=Integer.MAX_VALUE;
    String myLongKey="String_Node_Str";
    long myLong=Long.MAX_VALUE;
    String myShortKey="String_Node_Str";
    short myShort=25;
    String myStringKey="String_Node_Str";
    String myString=myStringKey;
    Map<String,Object> map=new LinkedHashMap<String,Object>();
    map.put(myBoolKey,myBool);
    map.put(myByteKey,myByte);
    map.put(myBytesKey,new Binary(myBytes));
    map.put(myCharKey,myChar);
    map.put(myDoubleKey,myDouble);
    map.put(myFloatKey,myFloat);
    map.put(myIntKey,myInt);
    map.put(myLongKey,myLong);
    map.put(myShortKey,myShort);
    map.put(myStringKey,myString);
    MessageAnnotationsDescribedType msgAnnotations=new MessageAnnotationsDescribedType();
    msgAnnotations.setSymbolKeyedAnnotation(AmqpMessageSupport.JMS_MSG_TYPE,AmqpMessageSupport.JMS_MAP_MESSAGE);
    DescribedType amqpValueSectionContent=new AmqpValueDescribedType(map);
    testPeer.expectReceiverAttach();
    testPeer.expectLinkFlowRespondWithTransfer(null,msgAnnotations,null,null,amqpValueSectionContent);
    testPeer.expectDispositionThatIsAcceptedAndSettled();
    MessageConsumer messageConsumer=session.createConsumer(queue);
    Message receivedMessage=messageConsumer.receive(1000);
    testPeer.waitForAllHandlersToComplete(3000);
    assertNotNull("String_Node_Str",receivedMessage);
    assertTrue("String_Node_Str",receivedMessage instanceof MapMessage);
    MapMessage receivedMapMessage=(MapMessage)receivedMessage;
    assertEquals("String_Node_Str",myBool,receivedMapMessage.getBoolean(myBoolKey));
    assertEquals("String_Node_Str",myByte,receivedMapMessage.getByte(myByteKey));
    byte[] readBytes=receivedMapMessage.getBytes(myBytesKey);
    assertTrue("String_Node_Str" + Arrays.toString(readBytes),Arrays.equals(myBytes,readBytes));
    assertEquals("String_Node_Str",myChar,receivedMapMessage.getChar(myCharKey));
    assertEquals("String_Node_Str",myDouble,receivedMapMessage.getDouble(myDoubleKey),0.0);
    assertEquals("String_Node_Str",myFloat,receivedMapMessage.getFloat(myFloatKey),0.0);
    assertEquals("String_Node_Str",myInt,receivedMapMessage.getInt(myIntKey));
    assertEquals("String_Node_Str",myLong,receivedMapMessage.getLong(myLongKey));
    assertEquals("String_Node_Str",myShort,receivedMapMessage.getShort(myShortKey));
    assertEquals("String_Node_Str",myString,receivedMapMessage.getString(myStringKey));
  }
 }