### Question:
JmsStreamMessage extends JmsMessage implements StreamMessage { @Override public Object readObject() throws JMSException { initializeReading(); try { checkEndOfStream(); Object value = stream.get(index++); if (value == null) { return null; } if (value instanceof String) { return value; } if (value instanceof Double) { return value; } if (value instanceof Float) { return value; } if (value instanceof Long) { return value; } if (value instanceof Integer) { return value; } if (value instanceof Short) { return value; } if (value instanceof Byte) { return value; } if (value instanceof Character) { return value; } if (value instanceof Boolean) { return value; } if (value instanceof Buffer) { return ((Buffer) value).toByteArray(); } else { index--; throw new MessageFormatException("Unknown type found in stream"); } } catch (Exception ex) { index--; throw JmsExceptionSupport.create(ex); } } JmsStreamMessage(JmsMessageFacade facade); @Override JmsMessage copy(); @Override void onSend(); @Override void clearBody(); @Override boolean readBoolean(); @Override byte readByte(); @Override short readShort(); @Override char readChar(); @Override int readInt(); @Override long readLong(); @Override float readFloat(); @Override double readDouble(); @Override String readString(); @Override int readBytes(byte[] value); @Override Object readObject(); @Override void writeBoolean(boolean value); @Override void writeByte(byte value); @Override void writeShort(short value); @Override void writeChar(char value); @Override void writeInt(int value); @Override void writeLong(long value); @Override void writeFloat(float value); @Override void writeDouble(double value); @Override void writeString(String value); @Override void writeBytes(byte[] value); @Override void writeBytes(byte[] value, int offset, int length); @Override void writeObject(Object value); @Override void reset(); @Override String toString();  }### Answer:
@Test public void testReadObject() { JmsStreamMessage msg = factory.createStreamMessage(); try { byte testByte = (byte) 2; msg.writeByte(testByte); msg.reset(); assertTrue(((Byte) msg.readObject()).byteValue() == testByte); msg.clearBody(); short testShort = 3; msg.writeShort(testShort); msg.reset(); assertTrue(((Short) msg.readObject()).shortValue() == testShort); msg.clearBody(); int testInt = 4; msg.writeInt(testInt); msg.reset(); assertTrue(((Integer) msg.readObject()).intValue() == testInt); msg.clearBody(); long testLong = 6L; msg.writeLong(testLong); msg.reset(); assertTrue(((Long) msg.readObject()).longValue() == testLong); msg.clearBody(); float testFloat = 6.6f; msg.writeFloat(testFloat); msg.reset(); assertTrue(((Float) msg.readObject()).floatValue() == testFloat); msg.clearBody(); double testDouble = 7.7d; msg.writeDouble(testDouble); msg.reset(); assertTrue(((Double) msg.readObject()).doubleValue() == testDouble); msg.clearBody(); char testChar = 'z'; msg.writeChar(testChar); msg.reset(); assertTrue(((Character) msg.readObject()).charValue() == testChar); msg.clearBody(); byte[] data = new byte[50]; for (int i = 0; i < data.length; i++) { data[i] = (byte) i; } msg.writeBytes(data); msg.reset(); byte[] valid = (byte[]) msg.readObject(); assertTrue(valid.length == data.length); for (int i = 0; i < valid.length; i++) { assertTrue(valid[i] == data[i]); } msg.clearBody(); msg.writeBoolean(true); msg.reset(); assertTrue(((Boolean) msg.readObject()).booleanValue()); } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } }