gemmellr commented on code in PR #1303: URL: https://github.com/apache/activemq/pull/1303#discussion_r1760972384
########## activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2ContextTest.java: ########## @@ -296,24 +296,57 @@ public void testProducerDeliveryDelaySet() throws JMSException { messageProducer.setDeliveryDelay(1000l); } - @Test(expected = UnsupportedOperationException.class) + @Test public void testProducerSendMessageCompletionListener() throws JMSException { - messageProducer.send(session.createQueue(methodNameDestinationName), null, (CompletionListener)null); + messageProducer.send(session.createQueue(methodNameDestinationName), session.createTextMessage("test message"), null); } - @Test(expected = UnsupportedOperationException.class) + @Test public void testProducerSendMessageQoSParamsCompletionListener() throws JMSException { - messageProducer.send(null, 1, 4, 0l, null); + messageProducer.send(session.createTextMessage("test message"), 1, 4, 0l, null); } - @Test(expected = UnsupportedOperationException.class) + @Test public void testProducerSendDestinationMessageCompletionListener() throws JMSException { - messageProducer.send(session.createQueue(methodNameDestinationName), null, null); + messageProducer.send(session.createQueue(methodNameDestinationName), session.createTextMessage("test message"), null); } - @Test(expected = UnsupportedOperationException.class) + @Test public void testProducerSendDestinationMessageQosParamsCompletionListener() throws JMSException { - messageProducer.send(session.createQueue(methodNameDestinationName), null, 1, 4, 0l, null); + messageProducer.send(session.createQueue(methodNameDestinationName), session.createTextMessage("test message"), 1, 4, 0l, null); + } + + @Test + public void testProducerSendMessageWithNonNullCompletionListener() throws JMSException { + final String testTextMessageBody = "this is a test message"; + final CompletionListener completionListener = new CompletionListener() { + @Override + public void onCompletion(Message message) { + TextMessage textMessage = (TextMessage) message; + try { + assertEquals(textMessage.getText(), testTextMessageBody); Review Comment: This also simply doesnt work as a verification. The test thread is usually the only one an assert check failing will directly cause a test failure, and this isnt done in the test thread (or at least shouldnt be, since CompletionListeners are not allowed to be fired by the thread calling send \[1\]). The client is likely just going to swallow this assertion failure if it happens, and the test pass regardless of any problem here. You would need to retain the result of the callback and coordinate the checking across the threads. \[1\] "A Jakarta Messaging provider must not invoke the CompletionListener from the thread that is calling the asynchronous send method." -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For additional commands, e-mail: gitbox-h...@activemq.apache.org For further information, visit: https://activemq.apache.org/contact