### Question:
JmsStreamMessage extends JmsMessage implements StreamMessage { @Override public void writeObject(Object value) throws JMSException { initializeWriting(); if (value == null) { stream.add(null); } else if (value instanceof String) { writeString(value.toString()); } else if (value instanceof Character) { writeChar(((Character) value).charValue()); } else if (value instanceof Boolean) { writeBoolean(((Boolean) value).booleanValue()); } else if (value instanceof Byte) { writeByte(((Byte) value).byteValue()); } else if (value instanceof Short) { writeShort(((Short) value).shortValue()); } else if (value instanceof Integer) { writeInt(((Integer) value).intValue()); } else if (value instanceof Float) { writeFloat(((Float) value).floatValue()); } else if (value instanceof Double) { writeDouble(((Double) value).doubleValue()); } else if (value instanceof byte[]) { writeBytes((byte[]) value); } else if (value instanceof Long) { writeLong(((Long) value).longValue()); } else { throw new MessageFormatException("Unsupported Object type: " + value.getClass()); } } 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 testWriteObject() { try { JmsStreamMessage message = factory.createStreamMessage(); message.clearBody(); message.writeObject("test"); message.writeObject(new Character('a')); message.writeObject(new Boolean(false)); message.writeObject(new Byte((byte) 2)); message.writeObject(new Short((short) 2)); message.writeObject(new Integer(2)); message.writeObject(new Long(2l)); message.writeObject(new Float(2.0f)); message.writeObject(new Double(2.0d)); } catch (Exception e) { fail(e.getMessage()); } try { JmsStreamMessage message = factory.createStreamMessage(); message.clearBody(); message.writeObject(new Object()); fail("should throw an exception"); } catch (MessageFormatException e) { } catch (Exception e) { fail(e.getMessage()); } }