Program: 41162
Project: 41162
Buggy source:
/** 
 * Tests that the   {@link AmqpMessageSupport#LEGACY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME} set on a message toindicate its 'to' address represents a Topic results in the JMSDestination object being a Topic. Ensure the consumers destination is not used by consuming from a Queue.
 */
@Test(timeout=2000) public void testReceivedMessageFromQueueWithToLegacyTypeAnnotationForTopic() 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");
    MessageAnnotationsDescribedType msgAnnotations=new MessageAnnotationsDescribedType();
    msgAnnotations.setSymbolKeyedAnnotation(AmqpMessageSupport.LEGACY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,AmqpMessageSupport.LEGACY_TOPIC_ATTRIBUTE);
    PropertiesDescribedType props=new PropertiesDescribedType();
    String myTopicAddress="String_Node_Str";
    props.setTo(myTopicAddress);
    props.setMessageId("String_Node_Str");
    DescribedType amqpValueNullContent=new AmqpValueDescribedType(null);
    testPeer.expectReceiverAttach();
    testPeer.expectLinkFlowRespondWithTransfer(null,msgAnnotations,props,null,amqpValueNullContent);
    testPeer.expectDispositionThatIsAcceptedAndSettled();
    MessageConsumer messageConsumer=session.createConsumer(queue);
    Message receivedMessage=messageConsumer.receive(1000);
    testPeer.waitForAllHandlersToComplete(3000);
    assertNotNull(receivedMessage);
    Destination dest=receivedMessage.getJMSDestination();
    assertNotNull("String_Node_Str",dest);
    assertTrue("String_Node_Str" + dest.getClass().getName(),dest instanceof Topic);
    assertEquals(myTopicAddress,((Topic)dest).getTopicName());
  }
 }

Fixed version (ground truth):
/** 
 * Tests that the   {@link AmqpMessageSupport#LEGACY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME} set on a message toindicate its 'to' address represents a Topic results in the JMSDestination object being a Topic. Ensure the consumers destination is not used by consuming from a Queue.
 */
@Test(timeout=2000) public void testReceivedMessageFromQueueWithToLegacyTypeAnnotationForTopic() 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");
    MessageAnnotationsDescribedType msgAnnotations=new MessageAnnotationsDescribedType();
    msgAnnotations.setSymbolKeyedAnnotation(AmqpMessageSupport.LEGACY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,AmqpMessageSupport.LEGACY_TOPIC_ATTRIBUTE);
    PropertiesDescribedType props=new PropertiesDescribedType();
    String myTopicAddress="String_Node_Str";
    props.setTo(myTopicAddress);
    props.setMessageId("String_Node_Str");
    DescribedType amqpValueNullContent=new AmqpValueDescribedType(null);
    testPeer.expectReceiverAttach();
    testPeer.expectLinkFlowRespondWithTransfer(null,msgAnnotations,props,null,amqpValueNullContent);
    testPeer.expectDispositionThatIsAcceptedAndSettled();
    MessageConsumer messageConsumer=session.createConsumer(queue);
    Message receivedMessage=messageConsumer.receive(1000);
    testPeer.waitForAllHandlersToComplete(3000);
    assertNotNull(receivedMessage);
    Destination dest=receivedMessage.getJMSDestination();
    assertNotNull("String_Node_Str",dest);
    assertTrue("String_Node_Str" + dest.getClass().getName(),dest instanceof Topic);
    assertEquals(myTopicAddress,((Topic)dest).getTopicName());
  }
 }