@Test public void testWriteObjectWithIllegalTypeThrowsMFE() throws Exception { JmsStreamMessage streamMessage = factory.createStreamMessage(); try { streamMessage.writeObject(BigInteger.ONE); fail("Expected exception to be thrown"); } catch (MessageFormatException mfe) { } }
@Override public void writeObject(Object value) throws JMSException { checkReadOnlyBody(); if (value == null) { facade.put(null); } else if (value instanceof String) { facade.put(value); } else if (value instanceof Character) { facade.put(value); } else if (value instanceof Boolean) { facade.put(value); } else if (value instanceof Byte) { facade.put(value); } else if (value instanceof Short) { facade.put(value); } else if (value instanceof Integer) { facade.put(value); } else if (value instanceof Long) { facade.put(value); } else if (value instanceof Float) { facade.put(value); } else if (value instanceof Double) { facade.put(value); } else if (value instanceof byte[]) { writeBytes((byte[]) value); } else { throw new MessageFormatException("Unsupported Object type: " + value.getClass().getSimpleName()); } }
JmsStreamMessage extends JmsMessage implements StreamMessage { @Override public void writeObject(Object value) throws JMSException { checkReadOnlyBody(); if (value == null) { facade.put(null); } else if (value instanceof String) { facade.put(value); } else if (value instanceof Character) { facade.put(value); } else if (value instanceof Boolean) { facade.put(value); } else if (value instanceof Byte) { facade.put(value); } else if (value instanceof Short) { facade.put(value); } else if (value instanceof Integer) { facade.put(value); } else if (value instanceof Long) { facade.put(value); } else if (value instanceof Float) { facade.put(value); } else if (value instanceof Double) { facade.put(value); } else if (value instanceof byte[]) { writeBytes((byte[]) value); } else { throw new MessageFormatException("Unsupported Object type: " + value.getClass().getSimpleName()); } } }
JmsStreamMessage extends JmsMessage implements StreamMessage { @Override public void writeObject(Object value) throws JMSException { checkReadOnlyBody(); if (value == null) { facade.put(null); } else if (value instanceof String) { facade.put(value); } else if (value instanceof Character) { facade.put(value); } else if (value instanceof Boolean) { facade.put(value); } else if (value instanceof Byte) { facade.put(value); } else if (value instanceof Short) { facade.put(value); } else if (value instanceof Integer) { facade.put(value); } else if (value instanceof Long) { facade.put(value); } else if (value instanceof Float) { facade.put(value); } else if (value instanceof Double) { facade.put(value); } else if (value instanceof byte[]) { writeBytes((byte[]) value); } else { throw new MessageFormatException("Unsupported Object type: " + value.getClass().getSimpleName()); } } JmsStreamMessage(JmsStreamMessageFacade facade); }
JmsStreamMessage extends JmsMessage implements StreamMessage { @Override public void writeObject(Object value) throws JMSException { checkReadOnlyBody(); if (value == null) { facade.put(null); } else if (value instanceof String) { facade.put(value); } else if (value instanceof Character) { facade.put(value); } else if (value instanceof Boolean) { facade.put(value); } else if (value instanceof Byte) { facade.put(value); } else if (value instanceof Short) { facade.put(value); } else if (value instanceof Integer) { facade.put(value); } else if (value instanceof Long) { facade.put(value); } else if (value instanceof Float) { facade.put(value); } else if (value instanceof Double) { facade.put(value); } else if (value instanceof byte[]) { writeBytes((byte[]) value); } else { throw new MessageFormatException("Unsupported Object type: " + value.getClass().getSimpleName()); } } JmsStreamMessage(JmsStreamMessageFacade facade); @Override JmsStreamMessage copy(); @Override void onSend(long producerTtl); @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[] target); @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(); @Override boolean isBodyAssignableTo(@SuppressWarnings("rawtypes") Class target); }
JmsStreamMessage extends JmsMessage implements StreamMessage { @Override public void writeObject(Object value) throws JMSException { checkReadOnlyBody(); if (value == null) { facade.put(null); } else if (value instanceof String) { facade.put(value); } else if (value instanceof Character) { facade.put(value); } else if (value instanceof Boolean) { facade.put(value); } else if (value instanceof Byte) { facade.put(value); } else if (value instanceof Short) { facade.put(value); } else if (value instanceof Integer) { facade.put(value); } else if (value instanceof Long) { facade.put(value); } else if (value instanceof Float) { facade.put(value); } else if (value instanceof Double) { facade.put(value); } else if (value instanceof byte[]) { writeBytes((byte[]) value); } else { throw new MessageFormatException("Unsupported Object type: " + value.getClass().getSimpleName()); } } JmsStreamMessage(JmsStreamMessageFacade facade); @Override JmsStreamMessage copy(); @Override void onSend(long producerTtl); @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[] target); @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(); @Override boolean isBodyAssignableTo(@SuppressWarnings("rawtypes") Class target);  }