### Question:
Consumer { public String getGreeting(int timeout, boolean acknowledge) throws JMSException { String greeting = NO_GREETING; Message message = messageConsumer.receive(timeout); if (message != null) { TextMessage textMessage = (TextMessage) message; String text = textMessage.getText(); LOGGER.debug(clientId + ": received message with text='{}'", text); if (acknowledge) { message.acknowledge(); LOGGER.debug(clientId + ": message acknowledged"); } else { LOGGER.debug(clientId + ": message not acknowledged"); } greeting = "Hello " + text + "!"; } else { LOGGER.debug(clientId + ": no message received"); } LOGGER.info("greeting={}", greeting); return greeting; }  void create(String clientId, String queueName); void closeConnection(); String getGreeting(int timeout, boolean acknowledge);  }### Answer:
@Test public void testGetGreeting() { try { producerPointToPoint.sendName("Frodo", "Baggins"); String greeting = consumerPointToPoint.getGreeting(1000, true); assertEquals("Hello Frodo Baggins!", greeting); } catch (JMSException e) { fail("a JMS Exception occurred"); } }
@Test public void testOnlyOneConsumer() throws InterruptedException { try { producerOnlyOneConsumer.sendName("Legolas", "Greenleaf"); String greeting1 = consumer1OnlyOneConsumer.getGreeting(1000, true); assertEquals("Hello Legolas Greenleaf!", greeting1); Thread.sleep(1000); String greeting2 = consumer2OnlyOneConsumer.getGreeting(1000, true); assertEquals("no greeting", greeting2); } catch (JMSException e) { fail("a JMS Exception occurred"); } }