Source:
<code>public void sendAndReceiveMessage() throws Exception { Connection connection = null; Session session = null; Message receivedMessage = null; try { END A MESSAGE on the source queue connection = factory.createConnection(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(sourceQueue); String text = MESSAGE_TEXT + " " + UUID.randomUUID().toString(); Message message = session.createTextMessage(text); message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); producer.send(message); connection.start(); connection.close(); connection = factory.createConnection(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer(targetQueue); connection.start(); receivedMessage = consumer.receive(5000); assertNotNull("did not receive expected message", receivedMessage); assertTrue(receivedMessage instanceof TextMessage); assertEquals(text, ((TextMessage) receivedMessage).getText()); assertNotNull("did not get header set by the JMS bridge", receivedMessage.getStringProperty(ActiveMQJMSConstants.AMQ_MESSAGING_BRIDGE_MESSAGE_ID_LIST)); <START> assertEquals("bridge metrics are not correct", 5000L,readMetrics()); <END> } catch (Exception e) { e.printStackTrace(); } finally { if (session != null) { session.close(); } if (connection != null) { connection.close(); } } }</code><technical_language>please edit message slightly more explaining? is obvious, assert fails, is correct/expected..</technical_language>

Target:
public void sendAndReceiveMessage() throws Exception { Connection connection = null; Session session = null; Message receivedMessage = null; try { assertEquals("Message count bridge metric is not correct", 0L, readMetric("message-count")); assertEquals("Aborted message count bridge metric is not correct", 0L, readMetric("aborted-message-count")); END A MESSAGE on the source queue connection = factory.createConnection(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(sourceQueue); String text = MESSAGE_TEXT + " " + UUID.randomUUID().toString(); Message message = session.createTextMessage(text); message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); producer.send(message); connection.start(); connection.close(); connection = factory.createConnection(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer(targetQueue); connection.start(); receivedMessage = consumer.receive(5000); assertNotNull("did not receive expected message", receivedMessage); assertTrue(receivedMessage instanceof TextMessage); assertEquals(text, ((TextMessage) receivedMessage).getText()); assertNotNull("did not get header set by the JMS bridge", receivedMessage.getStringProperty(ActiveMQJMSConstants.AMQ_MESSAGING_BRIDGE_MESSAGE_ID_LIST)); assertEquals("Message count bridge metric is not correct", 1L, readMetric("message-count")); assertEquals("Aborted message count bridge metric is not correct", 0L, readMetric("aborted-message-count")); } catch (Exception e) { e.printStackTrace(); throw e; } finally { if (session != null) { session.close(); } if (connection != null) { connection.close(); } } }