I have test env.: [REST API]-->[RabbitMQ] and trying to send the file (with multipart) to REST API and read from RabbitMQ directly:
* bytes expectedPayload = read('flask.png')
And multipart file file = { read: 'flask.png', contentType: 'application/json' }
And multipart field message = { messageFlowName: 'TestMSGFlow', moduleInstanceId: 5 }
When method POST
Then status 200
...
* bytes receivedPayload = amqpConnection.getMessagePayload('test.rabbitmq.queue', 'testChannel')
And match receivedPayload == read('flask.png')
amqpConnection.getMessagePayload method:
public byte[] getMessagePayload(String queueName, Channel channel) {
byte[] message = null;
try {
GetResponse response = channel.basicGet(queueName, true);
if (response == null) {
System.out.println("DEBUG: No message found.");
} else {
AMQP.BasicProperties props = response.getProps();
return response.getBody();
}
} catch (IOException e) {
e.printStackTrace();
}
return message;
}
I'm getting the result:
actual: [B@64b70919, expected: [B@4e31c3ec, reason: actual and expected byte-arrays are not equal
I've tried to use *.json instead of *.png (as test file) and it works well. How to make it works with *.png too?