Example usage for javax.jms StreamMessage writeString

List of usage examples for javax.jms StreamMessage writeString

Introduction

In this page you can find the example usage for javax.jms StreamMessage writeString.

Prototype


void writeString(String value) throws JMSException;

Source Link

Document

Writes a String to the stream message.

Usage

From source file:org.mule.transport.jms.integration.JmsTransformersTestCase.java

@Test
public void testTransformStreamMessage() throws Exception {
    RequestContext.setEvent(getTestEvent("test"));

    String text = "Test Text";
    int i = 97823;
    double d = 0923.2143E124;
    List list = new ArrayList();
    list.add(new Integer(i));
    list.add(new Double(d));
    list.add(text);/* w w w.  j a  v  a 2 s.  c o m*/

    StreamMessage message = session.createStreamMessage();
    message.writeString(text);
    message.writeInt(i);
    message.writeDouble(d);
    message.reset();

    AbstractJmsTransformer trans = createObject(JMSMessageToObject.class);
    Object transformedObject = trans.transform(message);
    assertTrue("Transformed object should be a List", transformedObject instanceof List);

    final List result = (List) transformedObject;
    String newText = (String) result.get(0);
    Integer newI = (Integer) result.get(1);
    Double newD = (Double) result.get(2);
    assertEquals(i, newI.intValue());
    assertEquals(new Double(d), newD);
    assertEquals(text, newText);
}