mirror of
https://github.com/apache/activemq.git
synced 2025-02-16 15:08:10 +00:00
AMQ-7291 - allow setting properties after clearProperties for BytesMessage, closes #420
This commit is contained in:
parent
f3b2efcbcb
commit
503416a001
@ -912,12 +912,6 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObjectProperty(String name, Object value) throws JMSException {
|
||||
initializeWriting();
|
||||
super.setObjectProperty(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " ActiveMQBytesMessage{ " + "bytesOut = " + bytesOut + ", dataOut = " + dataOut + ", dataIn = " + dataIn + " }";
|
||||
|
@ -269,6 +269,30 @@ public class ActiveMQBytesMessageTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testClearProperties() throws Exception {
|
||||
ActiveMQBytesMessage bytesMessage = new ActiveMQBytesMessage();
|
||||
bytesMessage.setIntProperty("one", 1);
|
||||
// simulate send
|
||||
bytesMessage.onSend();
|
||||
|
||||
assertEquals(1, bytesMessage.getIntProperty("one"));
|
||||
assertTrue(bytesMessage.isReadOnlyProperties());
|
||||
|
||||
try {
|
||||
bytesMessage.setIntProperty("two", 2);
|
||||
fail("should have thrown b/c readonly");
|
||||
} catch (MessageNotWriteableException expected) {
|
||||
}
|
||||
|
||||
// allow writing new properties
|
||||
bytesMessage.clearProperties();
|
||||
assertFalse(bytesMessage.propertyExists("one"));
|
||||
assertFalse(bytesMessage.isReadOnlyProperties());
|
||||
|
||||
bytesMessage.setIntProperty("two", 2);
|
||||
assertEquals(2, bytesMessage.getIntProperty("two"));
|
||||
}
|
||||
|
||||
public void testReset() throws JMSException {
|
||||
ActiveMQBytesMessage message = new ActiveMQBytesMessage();
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user