Examples of StreamMessageImpl


Examples of com.caucho.jms.message.StreamMessageImpl

   * Reads a stream message.
   */
  private StreamMessageImpl readStreamMessage(InputStream is)
    throws IOException, JMSException
  {
    StreamMessageImpl stream = new StreamMessageImpl();

    if (is == null)
      return stream;

    ObjectInputStream in = new ContextLoaderObjectInputStream(is);

    try {
      while (true) {
        Object obj = in.readObject();

        stream.writeObject(obj);
      }
    } catch (EOFException e) {
    } catch (Exception e) {
      throw new JmsExceptionWrapper(e);
    }

    in.close();

    stream.reset();
   
    return stream;
  }
View Full Code Here

Examples of com.caucho.jms.message.StreamMessageImpl

  public StreamMessage createStreamMessage()
    throws JMSException
  {
    checkOpen();
   
    return new StreamMessageImpl();
  }
View Full Code Here

Examples of com.caucho.jms.message.StreamMessageImpl

  public StreamMessage createStreamMessage()
    throws JMSException
  {
    checkOpen();
   
    return new StreamMessageImpl();
  }
View Full Code Here

Examples of com.caucho.jms.message.StreamMessageImpl

   * Reads a stream message.
   */
  private StreamMessageImpl readStreamMessage(InputStream is)
    throws IOException, JMSException
  {
    StreamMessageImpl stream = new StreamMessageImpl();

    if (is == null)
      return stream;

    ObjectInputStream in = new ContextLoaderObjectInputStream(is);

    try {
      while (true) {
  Object obj = in.readObject();

  stream.writeObject(obj);
      }
    } catch (EOFException e) {
    } catch (Exception e) {
      throw new JmsExceptionWrapper(e);
    }

    in.close();

    stream.reset();
   
    return stream;
  }
View Full Code Here

Examples of net.timewalker.ffmq3.common.message.StreamMessageImpl

        return msg;
    }
   
    public static StreamMessageImpl createStreamMessage( int size ) throws JMSException
    {
        StreamMessageImpl msg = new StreamMessageImpl();
        setDummyProperties(msg);
       
        msg.writeBoolean(true);
        msg.writeString("foobar");
        msg.writeChar('c');
        msg.writeByte((byte)1);
        msg.writeShort((short)2);
        msg.writeInt(3);
        msg.writeLong(4);
        msg.writeFloat(1.23f);
        msg.writeDouble(4.56);
        msg.writeBytes(createDummyByteArray(size));
       
        return msg;
    }
View Full Code Here

Examples of net.timewalker.ffmq3.common.message.StreamMessageImpl

    /* (non-Javadoc)
     * @see javax.jms.Session#createStreamMessage()
     */
    public final StreamMessage createStreamMessage() throws JMSException
    {
        return new StreamMessageImpl();
    }
View Full Code Here

Examples of net.timewalker.ffmq3.common.message.StreamMessageImpl

*/
public class StreamMessageImplTest extends TestCase
{
  public void testBooleanConversion() throws Exception
  {
    StreamMessageImpl msg;
   
    // Boolean
    msg = new StreamMessageImpl();
    msg.writeBoolean(true);
    msg.markAsReadOnly();
    assertTrue(msg.readBoolean());
   
    // Byte
    msg = new StreamMessageImpl();
    msg.writeBoolean(true);
    msg.markAsReadOnly();
    try { msg.readByte(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertTrue(msg.readBoolean());
   
    // Short
    msg = new StreamMessageImpl();
    msg.writeBoolean(true);
    msg.markAsReadOnly();
    try { msg.readShort(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertTrue(msg.readBoolean());

    // Char
    msg = new StreamMessageImpl();
    msg.writeBoolean(true);
    msg.markAsReadOnly();
    try { msg.readChar(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertTrue(msg.readBoolean());
   
    // Int
    msg = new StreamMessageImpl();
    msg.writeBoolean(true);
    msg.markAsReadOnly();
    try { msg.readInt(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertTrue(msg.readBoolean());
   
    // Long
    msg = new StreamMessageImpl();
    msg.writeBoolean(true);
    msg.markAsReadOnly();
    try { msg.readLong(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertTrue(msg.readBoolean());
   
    // Float
    msg = new StreamMessageImpl();
    msg.writeBoolean(true);
    msg.markAsReadOnly();
    try { msg.readFloat(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertTrue(msg.readBoolean());
   
    // Double
    msg = new StreamMessageImpl();
    msg.writeBoolean(true);
    msg.markAsReadOnly();
    try { msg.readDouble(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertTrue(msg.readBoolean());
   
    // String
    msg = new StreamMessageImpl();
    msg.writeBoolean(true);
    msg.markAsReadOnly();
    assertEquals("true",msg.readString());
   
    // Bytes
    msg = new StreamMessageImpl();
    msg.writeBoolean(true);
    msg.markAsReadOnly();
    try { msg.readBytes(new byte[1]); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertTrue(msg.readBoolean());
  }
 
View Full Code Here

Examples of net.timewalker.ffmq3.common.message.StreamMessageImpl

    assertEquals(123,msg.readLong());
  }
 
  public void testFloatConversion() throws Exception
  {
    StreamMessageImpl msg;
   
    // Boolean
    msg = new StreamMessageImpl();
    msg.writeFloat(1.23f);
    msg.markAsReadOnly();
    try { msg.readBoolean(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(1.23f,msg.readFloat(),0);
   
    // Byte
    msg = new StreamMessageImpl();
    msg.writeFloat(1.23f);
    msg.markAsReadOnly();
    try { msg.readByte(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(1.23f,msg.readFloat(),0);
   
    // Short
    msg = new StreamMessageImpl();
    msg.writeFloat(1.23f);
    msg.markAsReadOnly();
    try { msg.readShort(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(1.23f,msg.readFloat(),0);
   
    // Char
    msg = new StreamMessageImpl();
    msg.writeFloat(1.23f);
    msg.markAsReadOnly();
    try { msg.readChar(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(1.23f,msg.readFloat(),0);
   
    // Int
    msg = new StreamMessageImpl();
    msg.writeFloat(1.23f);
    msg.markAsReadOnly();
    try { msg.readInt(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertEquals(1.23f,msg.readFloat(),0);
   
    // Long
    msg = new StreamMessageImpl();
    msg.writeFloat(1.23f);
    msg.markAsReadOnly();
    try { msg.readLong(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertEquals(1.23f,msg.readFloat(),0);
   
    // Float
    msg = new StreamMessageImpl();
    msg.writeFloat(1.23f);
    msg.markAsReadOnly();
    assertEquals(1.23f,msg.readFloat(),0);
   
    // Double
    msg = new StreamMessageImpl();
    msg.writeFloat(1.23f);
    msg.markAsReadOnly();
    assertEquals(1.23,msg.readDouble(),0.0000001);
   
    // String
    msg = new StreamMessageImpl();
    msg.writeFloat(1.23f);
    msg.markAsReadOnly();
    assertEquals("1.23",msg.readString());
   
    // Bytes
    msg = new StreamMessageImpl();
    msg.writeFloat(1.23f);
    msg.markAsReadOnly();
    try { msg.readBytes(new byte[1]); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(1.23f,msg.readFloat(),0);
  }
 
View Full Code Here

Examples of net.timewalker.ffmq3.common.message.StreamMessageImpl

    assertEquals(1.23f,msg.readFloat(),0);
  }
 
  public void testDoubleConversion() throws Exception
  {
    StreamMessageImpl msg;
   
    // Boolean
    msg = new StreamMessageImpl();
    msg.writeDouble(1.23);
    msg.markAsReadOnly();
    try { msg.readBoolean(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(1.23,msg.readDouble(),0);
   
    // Byte
    msg = new StreamMessageImpl();
    msg.writeDouble(1.23);
    msg.markAsReadOnly();
    try { msg.readByte(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(1.23,msg.readDouble(),0);
   
    // Short
    msg = new StreamMessageImpl();
    msg.writeDouble(1.23);
    msg.markAsReadOnly();
    try { msg.readShort(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(1.23,msg.readDouble(),0);
   
    // Char
    msg = new StreamMessageImpl();
    msg.writeDouble(1.23);
    msg.markAsReadOnly();
    try { msg.readChar(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(1.23,msg.readDouble(),0);
   
    // Int
    msg = new StreamMessageImpl();
    msg.writeDouble(1.23);
    msg.markAsReadOnly();
    try { msg.readInt(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertEquals(1.23,msg.readDouble(),0);
   
    // Long
    msg = new StreamMessageImpl();
    msg.writeDouble(1.23);
    msg.markAsReadOnly();
    try { msg.readLong(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertEquals(1.23,msg.readDouble(),0);
   
    // Float
    msg = new StreamMessageImpl();
    msg.writeDouble(1.23);
    msg.markAsReadOnly();
    try { msg.readFloat(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertEquals(1.23,msg.readDouble(),0);
   
    // Double
    msg = new StreamMessageImpl();
    msg.writeDouble(1.23);
    msg.markAsReadOnly();
    assertEquals(1.23,msg.readDouble(),0.0000001);
   
    // String
    msg = new StreamMessageImpl();
    msg.writeDouble(1.23);
    msg.markAsReadOnly();
    assertEquals("1.23",msg.readString());
   
    // Bytes
    msg = new StreamMessageImpl();
    msg.writeDouble(1.23);
    msg.markAsReadOnly();
    try { msg.readBytes(new byte[1]); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(1.23,msg.readDouble(),0);
  }
 
View Full Code Here

Examples of net.timewalker.ffmq3.common.message.StreamMessageImpl

    assertEquals(1.23,msg.readDouble(),0);
  }
 
  public void testStringConversion() throws Exception
  {
    StreamMessageImpl msg;
   
    // Boolean
    msg = new StreamMessageImpl();
    msg.writeString("foobar");
    msg.markAsReadOnly();
    assertFalse(msg.readBoolean());
   
    // Byte
    msg = new StreamMessageImpl();
    msg.writeString("foobar");
    msg.markAsReadOnly();
    try { msg.readByte(); fail("Should have failed"); } catch (NumberFormatException e) { /* OK */  }
    assertEquals("foobar",msg.readString());
   
    // Short
    msg = new StreamMessageImpl();
    msg.writeString("foobar");
    msg.markAsReadOnly();
    try { msg.readShort(); fail("Should have failed"); } catch (NumberFormatException e) { /* OK */  }
    assertEquals("foobar",msg.readString());
   
    // Char
    msg = new StreamMessageImpl();
    msg.writeString("foobar");
    msg.markAsReadOnly();
    try { msg.readChar(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals("foobar",msg.readString());
   
    // Int
    msg = new StreamMessageImpl();
    msg.writeString("foobar");
    msg.markAsReadOnly();
    try { msg.readInt(); fail("Should have failed"); } catch (NumberFormatException e) { /* OK */ }
    assertEquals("foobar",msg.readString());
   
    // Long
    msg = new StreamMessageImpl();
    msg.writeString("foobar");
    msg.markAsReadOnly();
    try { msg.readLong(); fail("Should have failed"); } catch (NumberFormatException e) { /* OK */ }
    assertEquals("foobar",msg.readString());
   
    // Float
    msg = new StreamMessageImpl();
    msg.writeString("foobar");
    msg.markAsReadOnly();
    try { msg.readFloat(); fail("Should have failed"); } catch (NumberFormatException e) { /* OK */ }
    assertEquals("foobar",msg.readString());
   
    // Double
    msg = new StreamMessageImpl();
    msg.writeString("foobar");
    msg.markAsReadOnly();
    try { msg.readDouble(); fail("Should have failed"); } catch (NumberFormatException e) { /* OK */ }
    assertEquals("foobar",msg.readString());
   
    // String
    msg = new StreamMessageImpl();
    msg.writeString("foobar");
    msg.markAsReadOnly();
    assertEquals("foobar",msg.readString());
   
    // Bytes
    msg = new StreamMessageImpl();
    msg.writeString("foobar");
    msg.markAsReadOnly();
    try { msg.readBytes(new byte[1]); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals("foobar",msg.readString());
  }
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.