git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@707064 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2008-10-22 13:02:31 +00:00
parent 537b1b0284
commit 58b8d19a97
2 changed files with 33 additions and 7 deletions

View File

@ -1089,7 +1089,9 @@ public class ActiveMQStreamMessage extends ActiveMQMessage implements StreamMess
writeBytes((byte[])value); writeBytes((byte[])value);
}else if (value instanceof Long) { }else if (value instanceof Long) {
writeLong(((Long)value).longValue()); writeLong(((Long)value).longValue());
} }else {
throw new MessageFormatException("Unsupported Object type: " + value.getClass());
}
} }
/** /**

View File

@ -754,14 +754,10 @@ public class ActiveMQStreamMessageTest extends TestCase {
public void testClearBody() throws JMSException { public void testClearBody() throws JMSException {
ActiveMQStreamMessage streamMessage = new ActiveMQStreamMessage(); ActiveMQStreamMessage streamMessage = new ActiveMQStreamMessage();
try { try {
streamMessage.writeObject(new Serializable() { streamMessage.writeObject(new Long(2));
private static final long serialVersionUID = -5181896809607968727L;
});
streamMessage.clearBody(); streamMessage.clearBody();
assertFalse(streamMessage.isReadOnlyBody()); assertFalse(streamMessage.isReadOnlyBody());
streamMessage.writeObject(new Serializable() { streamMessage.writeObject(new Long(2));
private static final long serialVersionUID = 5074177640797561141L;
});
streamMessage.readObject(); streamMessage.readObject();
fail("should throw exception"); fail("should throw exception");
} catch (MessageNotReadableException mnwe) { } catch (MessageNotReadableException mnwe) {
@ -972,5 +968,33 @@ public class ActiveMQStreamMessageTest extends TestCase {
} catch (MessageNotReadableException e) { } catch (MessageNotReadableException e) {
} }
} }
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());
}
}
} }