ARTEMIS-3137 Fixing Test with wrong message type on Xpath and Core

This commit is contained in:
Clebert Suconic 2021-03-10 21:44:07 -05:00
parent 202601645b
commit f49a163427
5 changed files with 10 additions and 4 deletions

View File

@ -73,8 +73,8 @@ public interface ICoreMessage extends Message {
boolean isServerMessage();
/**
* The body used for this message.
*
* The buffer to write the body.
* Warning: If you just want to read the content of a message, use getDataBuffer() or getReadOnlyBuffer();
* @return
*/
@Override

View File

@ -223,6 +223,8 @@ public interface Message {
/**
* @deprecated do not use this, use through ICoreMessage or ClientMessage
* Warning: if you need to read the content of a message use getDataBuffer(). This method is intended for when you
* want to make changes.
*/
@Deprecated
default ActiveMQBuffer getBodyBuffer() {

View File

@ -132,6 +132,7 @@ public interface ClientMessage extends ICoreMessage {
/**
* The buffer to write the body.
* Warning: If you just want to read the content of a message, use getDataBuffer() or getReadOnlyBuffer();
* @return
*/
@Override

View File

@ -1283,7 +1283,7 @@ public class CoreMessage extends RefCountMessage implements ICoreMessage {
body = simpleBody.toString();
}
} catch (Exception e) {
// ignore
e.printStackTrace();
}
}

View File

@ -1286,15 +1286,18 @@ public class ConsumerTest extends ActiveMQTestBase {
ClientProducer producer = session.createProducer(QUEUE);
ClientMessage message = session.createMessage(false);
message.setType(Message.TEXT_TYPE);
message.getBodyBuffer().writeNullableSimpleString(SimpleString.toSimpleString("wrong"));
producer.send(message);
message = session.createMessage(false);
message.setType(Message.TEXT_TYPE);
message.getBodyBuffer().writeNullableSimpleString(BODY);
producer.send(message);
ClientConsumer consumer = session.createConsumer(QUEUE.toString(), "XPATH 'root/a'");
session.start();
ClientMessage message2 = consumer.receive(1000);
ClientMessage message2 = consumer.receive(5000);
Assert.assertNotNull(message2);
Assert.assertEquals(BODY, message2.getBodyBuffer().readNullableSimpleString());
Assert.assertEquals(1, getMessageCount(((Queue) server.getPostOffice().getBinding(QUEUE).getBindable())));