### Question:
Producer { public void send(String text) throws JMSException { TextMessage message = session.createTextMessage(text); producer.send(message); LOGGER.info("{} sent with default priority(=4)", text); }  void openConnection(); void closeConnection(); void createProducer(String queue); void send(String text); void send(String text, int priority);  }### Answer:
@Test public void testSend() throws JMSException, InterruptedException { producer.send("message1"); producer.send("message2"); producer.send("message3"); Thread.sleep(1000); assertEquals("message1", consumer.receive(5000)); assertEquals("message2", consumer.receive(5000)); assertEquals("message3", consumer.receive(5000)); }
@Test public void testSendWithPriority() throws JMSException, InterruptedException { producer.send("message1", 1); producer.send("message2", 2); producer.send("message3", 3); Thread.sleep(1000); assertEquals("message3", consumer.receive(5000)); assertEquals("message2", consumer.receive(5000)); assertEquals("message1", consumer.receive(5000)); }
@Test public void testSend() throws JMSException, InterruptedException { producer.send("message1"); producer.send("message2"); producer.send("message3"); Thread.sleep(10000); assertEquals("message1", consumer.receive(5000)); assertEquals("message2", consumer.receive(5000)); assertEquals("message3", consumer.receive(5000)); }
@Test public void testSendWithPriority() throws JMSException, InterruptedException { producer.send("message1", 1); producer.send("message2", 2); producer.send("message3", 3); Thread.sleep(10000); assertEquals("message3", consumer.receive(5000)); assertEquals("message2", consumer.receive(5000)); assertEquals("message1", consumer.receive(5000)); }