Karate 如何将*.png文件与空手道中Java方法调用的结果进行比较

Karate 如何将*.png文件与空手道中Java方法调用的结果进行比较,karate,Karate,我有test env.:[REST API]-->[RabbitMQ],正在尝试将文件(带有多部分)发送到REST API并直接从RabbitMQ读取: * bytes expectedPayload = read('flask.png') And multipart file file = { read: 'flask.png', contentType: 'application/json' } And multipart field message = { messageFlowName:

我有test env.:[REST API]-->[RabbitMQ],正在尝试将文件(带有多部分)发送到REST API并直接从RabbitMQ读取:

* 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方法:

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;
}
我得到的结果是:

actual: [B@64b70919, expected: [B@4e31c3ec, reason: actual and expected byte-arrays are not equal

我尝试使用*.json而不是*.png(作为测试文件),效果很好。如何使它也能与*.png一起工作?

它应该能工作,因此从通道/消息中提取字节数组的例程中似乎有错误

可能涉及一些编码/解码

您可以做一个简单的测试:

* bytes temp = read('flask.png')
* match temp == read('flask.png')

你说得对,彼得,经过详细审查,我发现了一个错误。