@Test public void testNewMessageIsWriteOnlyThrowsMNRE() throws Exception { JmsStreamMessage streamMessage = factory.createStreamMessage(); try { streamMessage.readBoolean(); fail("Expected exception to be thrown as message is not readable"); } catch (MessageNotReadableException mnre) { } }
@Override public boolean readBoolean() throws JMSException { checkWriteOnlyBody(); checkBytesInFlight(); Boolean result = null; Object value; value = facade.peek(); if (value instanceof Boolean) { result = (Boolean) value; } else if (value instanceof String || value == null) { result = Boolean.valueOf((String) value); } else { throw new MessageFormatException( "stream value: " + value.getClass().getSimpleName() + " cannot be converted to a boolean."); } facade.pop(); return result; }
JmsStreamMessage extends JmsMessage implements StreamMessage { @Override public boolean readBoolean() throws JMSException { checkWriteOnlyBody(); checkBytesInFlight(); Boolean result = null; Object value; value = facade.peek(); if (value instanceof Boolean) { result = (Boolean) value; } else if (value instanceof String || value == null) { result = Boolean.valueOf((String) value); } else { throw new MessageFormatException( "stream value: " + value.getClass().getSimpleName() + " cannot be converted to a boolean."); } facade.pop(); return result; } }
JmsStreamMessage extends JmsMessage implements StreamMessage { @Override public boolean readBoolean() throws JMSException { checkWriteOnlyBody(); checkBytesInFlight(); Boolean result = null; Object value; value = facade.peek(); if (value instanceof Boolean) { result = (Boolean) value; } else if (value instanceof String || value == null) { result = Boolean.valueOf((String) value); } else { throw new MessageFormatException( "stream value: " + value.getClass().getSimpleName() + " cannot be converted to a boolean."); } facade.pop(); return result; } JmsStreamMessage(JmsStreamMessageFacade facade); }
JmsStreamMessage extends JmsMessage implements StreamMessage { @Override public boolean readBoolean() throws JMSException { checkWriteOnlyBody(); checkBytesInFlight(); Boolean result = null; Object value; value = facade.peek(); if (value instanceof Boolean) { result = (Boolean) value; } else if (value instanceof String || value == null) { result = Boolean.valueOf((String) value); } else { throw new MessageFormatException( "stream value: " + value.getClass().getSimpleName() + " cannot be converted to a boolean."); } facade.pop(); return result; } 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 boolean readBoolean() throws JMSException { checkWriteOnlyBody(); checkBytesInFlight(); Boolean result = null; Object value; value = facade.peek(); if (value instanceof Boolean) { result = (Boolean) value; } else if (value instanceof String || value == null) { result = Boolean.valueOf((String) value); } else { throw new MessageFormatException( "stream value: " + value.getClass().getSimpleName() + " cannot be converted to a boolean."); } facade.pop(); return result; } 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);  }