Skip to content

Commit

Permalink
Restructure message-identification related test-cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ayeshLK committed Sep 5, 2024
1 parent 92073a1 commit 9eb87b4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ballerina/tests/queue_producer_consumer_tests.bal
Original file line number Diff line number Diff line change
Expand Up @@ -542,13 +542,22 @@ function produceMessagesWithIdentification() returns error? {

byte[]? payload = message?.payload;
test:assertEquals(message?.userId, userId, "Invalid userId");
test:assertEquals((string:fromBytes(check message?.accountingToken.ensureType())), accountingToken, "Invalid accounting token");
byte[] retrievedAccountingToken = trimTrailingZeros(check message?.accountingToken.ensureType());
test:assertEquals(retrievedAccountingToken, accountingToken.toBytes(), "Invalid accounting token");
test:assertEquals(string:fromBytes(check payload.ensureType()), messageContent, "Invalid message content");

check queue->close();
check queueManager.disconnect();
}

function trimTrailingZeros(byte[] bytes) returns byte[] {
int i = bytes.length() - 1;
while (i >= 0 && bytes[i] == 0) {
i -= 1;
}
return bytes.slice(0, i + 1);
}

@test:Config {
groups: ["ibmmqQueue", "charset"]
}
Expand Down

0 comments on commit 9eb87b4

Please sign in to comment.