mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@707064 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
537b1b0284
commit
58b8d19a97
|
@ -1089,6 +1089,8 @@ public class ActiveMQStreamMessage extends ActiveMQMessage implements StreamMess
|
|||
writeBytes((byte[])value);
|
||||
}else if (value instanceof Long) {
|
||||
writeLong(((Long)value).longValue());
|
||||
}else {
|
||||
throw new MessageFormatException("Unsupported Object type: " + value.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -754,14 +754,10 @@ public class ActiveMQStreamMessageTest extends TestCase {
|
|||
public void testClearBody() throws JMSException {
|
||||
ActiveMQStreamMessage streamMessage = new ActiveMQStreamMessage();
|
||||
try {
|
||||
streamMessage.writeObject(new Serializable() {
|
||||
private static final long serialVersionUID = -5181896809607968727L;
|
||||
});
|
||||
streamMessage.writeObject(new Long(2));
|
||||
streamMessage.clearBody();
|
||||
assertFalse(streamMessage.isReadOnlyBody());
|
||||
streamMessage.writeObject(new Serializable() {
|
||||
private static final long serialVersionUID = 5074177640797561141L;
|
||||
});
|
||||
streamMessage.writeObject(new Long(2));
|
||||
streamMessage.readObject();
|
||||
fail("should throw exception");
|
||||
} catch (MessageNotReadableException mnwe) {
|
||||
|
@ -973,4 +969,32 @@ public class ActiveMQStreamMessageTest extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testWriteObject() {
|
||||
try {
|
||||
ActiveMQStreamMessage message = new ActiveMQStreamMessage();
|
||||
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 {
|
||||
ActiveMQStreamMessage message = new ActiveMQStreamMessage();
|
||||
message.clearBody();
|
||||
message.writeObject(new Object());
|
||||
fail("should throw an exception");
|
||||
}catch(MessageFormatException e) {
|
||||
|
||||
}catch(Exception e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue