} catch (MessageNotWriteableException mnwe) {
}
}
public void testReadOnlyBody() throws JMSException {
ActiveMQStreamMessage message = new ActiveMQStreamMessage();
try {
message.writeBoolean(true);
message.writeByte((byte) 1);
message.writeBytes(new byte[1]);
message.writeBytes(new byte[3], 0, 2);
message.writeChar('a');
message.writeDouble(1.5);
message.writeFloat((float) 1.5);
message.writeInt(1);
message.writeLong(1);
message.writeObject("stringobj");
message.writeShort((short) 1);
message.writeString("string");
} catch (MessageNotWriteableException mnwe) {
fail("Should be writeable");
}
message.reset();
try {
message.readBoolean();
message.readByte();
assertEquals(1, message.readBytes(new byte[10]));
assertEquals(-1, message.readBytes(new byte[10]));
assertEquals(2, message.readBytes(new byte[10]));
assertEquals(-1, message.readBytes(new byte[10]));
message.readChar();
message.readDouble();
message.readFloat();
message.readInt();
message.readLong();
message.readString();
message.readShort();
message.readString();
} catch (MessageNotReadableException mnwe) {
fail("Should be readable");
}
try {
message.writeBoolean(true);
fail("Should have thrown exception");
} catch (MessageNotWriteableException mnwe) {
}
try {
message.writeByte((byte) 1);
fail("Should have thrown exception");
} catch (MessageNotWriteableException mnwe) {
}
try {
message.writeBytes(new byte[1]);
fail("Should have thrown exception");
} catch (MessageNotWriteableException mnwe) {
}
try {
message.writeBytes(new byte[3], 0, 2);
fail("Should have thrown exception");
} catch (MessageNotWriteableException mnwe) {
}
try {
message.writeChar('a');
fail("Should have thrown exception");
} catch (MessageNotWriteableException mnwe) {
}
try {
message.writeDouble(1.5);
fail("Should have thrown exception");
} catch (MessageNotWriteableException mnwe) {
}
try {
message.writeFloat((float) 1.5);
fail("Should have thrown exception");
} catch (MessageNotWriteableException mnwe) {
}
try {
message.writeInt(1);
fail("Should have thrown exception");
} catch (MessageNotWriteableException mnwe) {
}
try {
message.writeLong(1);
fail("Should have thrown exception");
} catch (MessageNotWriteableException mnwe) {
}
try {
message.writeObject("stringobj");
fail("Should have thrown exception");
} catch (MessageNotWriteableException mnwe) {
}
try {
message.writeShort((short) 1);
fail("Should have thrown exception");
} catch (MessageNotWriteableException mnwe) {
}
try {
message.writeString("string");
fail("Should have thrown exception");
} catch (MessageNotWriteableException mnwe) {
}
}