/** * Test that the <code>JMSDeliveryMode</code> header field value is ignored * when the message is sent and that it holds the value specified by the sending * method (i.e. <code>Message.DEFAULT_DELIVERY_MODE</code> in this test when the message is received. */ public void testJMSDeliveryMode() { try { // sender has been created with the DEFAULT_DELIVERY_MODE which is PERSISTENT assertEquals(DeliveryMode.PERSISTENT, sender.getDeliveryMode()); Message message = senderSession.createMessage(); // send a message specfiying NON_PERSISTENT for the JMSDeliveryMode header field message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); sender.send(message); assertTrue("3.4.2 When a message is sent this value is ignored", message.getJMSDeliveryMode() != DeliveryMode.NON_PERSISTENT); assertEquals("3.4.2 After completion of the send it holds the delivery mode specified " + "by the sending method (persistent by default).\n", Message.DEFAULT_DELIVERY_MODE, message .getJMSDeliveryMode()); receiver.receive(TestConfig.TIMEOUT); } catch (JMSException e) { fail(e); } }
/** * Test that the <code>JMSDeliveryMode</code> header field value is ignored * when the message is sent and that it holds the value specified by the sending * method (i.e. <code>Message.DEFAULT_ROUTING_TYPE</code> in this test when the message is received. */ @Test public void testJMSDeliveryMode() { try { // sender has been created with the DEFAULT_ROUTING_TYPE which is PERSISTENT Assert.assertEquals(DeliveryMode.PERSISTENT, sender.getDeliveryMode()); Message message = senderSession.createMessage(); // send a message specfiying NON_PERSISTENT for the JMSDeliveryMode header field message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); sender.send(message); Assert.assertTrue("sec. 3.4.2 When a message is sent this value is ignored", message.getJMSDeliveryMode() != DeliveryMode.NON_PERSISTENT); Assert.assertEquals("sec. 3.4.2 After completion of the send it holds the delivery mode specified " + "by the sending method (persistent by default).\n", Message.DEFAULT_DELIVERY_MODE, message.getJMSDeliveryMode()); receiver.receive(TestConfig.TIMEOUT); } catch (JMSException e) { fail(e); } }