### Question:
IOMessageListener implements MessageListener { @Override public void onMessage(javax.jms.Message msg) { LoggingService.logDebug(MODULE_NAME, "Start acknowledging message onMessage"); try { TextMessage textMessage = (TextMessage) msg; textMessage.acknowledge(); JsonReader jsonReader = Json.createReader(new StringReader(textMessage.getText())); JsonObject json = jsonReader.readObject(); jsonReader.close(); Message message = new Message(json); callback.sendRealtimeMessage(message); } catch (Exception exp) { LoggingService.logError(MODULE_NAME, "Error acknowledging message", new AgentSystemException("Error acknowledging message", exp)); } LoggingService.logDebug(MODULE_NAME, "Finish acknowledging message onMessage"); } IOMessageListener(MessageCallback callback); @Override void onMessage(javax.jms.Message msg);  }### Answer:
@Test public void testOnMessage() { try { ioMessageListener.onMessage(textMessage); verify(textMessage).acknowledge(); verify(messageCallback).sendRealtimeMessage(any()); verifyStatic(LoggingService.class); LoggingService.logDebug(MODULE_NAME, "Start acknowledging message onMessage"); verifyStatic(LoggingService.class); LoggingService.logDebug(MODULE_NAME, "Finish acknowledging message onMessage"); } catch (Exception e) { fail("This should not happen"); } }
@Test public void throwsExceptionOnMessage() { try { PowerMockito.doThrow(mock(JMSException.class)).when(textMessage).acknowledge(); ioMessageListener.onMessage(textMessage); LoggingService.logError(eq(MODULE_NAME), eq("Error acknowledging message"), any()); } catch (Exception e) { fail("This should not happen"); } }