Example usage for javax.jms MapMessage getDouble

List of usage examples for javax.jms MapMessage getDouble

Introduction

In this page you can find the example usage for javax.jms MapMessage getDouble.

Prototype


double getDouble(String name) throws JMSException;

Source Link

Document

Returns the double value with the specified name.

Usage

From source file:org.mule.transport.jms.JmsMessageUtilsTestCase.java

/**
 * Tests that is able to convert a Map which only contains simple values into a
 * MapMessage.//from  ww  w.ja va2  s . c  om
 */
@Test
public void testConvertsValidMapWithSimpleValuesToMapMessage() throws JMSException {
    Session session = mock(Session.class);
    when(session.createMapMessage()).thenReturn(new ActiveMQMapMessage());

    // Creates a test Map with data
    Map data = new HashMap();
    data.put("value1", new Float(4));
    data.put("value2", new byte[] { 1, 2, 3 });
    data.put("value3", "value3");
    data.put("value4", new Double(67.9));
    data.put("value5", true);
    data.put("value6", null);

    Message message = JmsMessageUtils.toMessage(data, session);
    assertTrue(message instanceof MapMessage);

    MapMessage mapMessage = (MapMessage) message;
    assertEquals(new Float(4), mapMessage.getFloat("value1"), 0);
    assertTrue(Arrays.equals(new byte[] { 1, 2, 3 }, mapMessage.getBytes("value2")));
    assertEquals("value3", mapMessage.getString("value3"));
    assertEquals(new Double(67.9), mapMessage.getDouble("value4"), 0);
    assertTrue(mapMessage.getBoolean("value5"));
    assertNull(mapMessage.getObject("value6"));
}