From c396b2c18eb486eccda35da5873b8b42d750bf53 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Fri, 1 Dec 2023 11:59:43 +0530 Subject: [PATCH] Add test case to validate mime requests without action --- .../soap12/tests/soap12_client_test.bal | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/ballerina/modules/soap12/tests/soap12_client_test.bal b/ballerina/modules/soap12/tests/soap12_client_test.bal index a3443ac..42334b7 100644 --- a/ballerina/modules/soap12/tests/soap12_client_test.bal +++ b/ballerina/modules/soap12/tests/soap12_client_test.bal @@ -198,6 +198,45 @@ function testSendReceive12WithMime2() returns error? { test:assertEquals(response, body); } +@test:Config { + groups: ["soap12", "send_receive", "mime", "h"] +} +function testSendReceive12MimeWithoutAction() returns error? { + Client soapClient = check new ("http://localhost:9090"); + xml body = xml ` + + + 2 + 3 + + + `; + + mime:Entity[] mtomMessage = []; + mime:Entity envelope = new; + check envelope.setContentType("application/xop+xml"); + envelope.setContentId(""); + envelope.setBody(body); + mtomMessage.push(envelope); + + mime:Entity bytesPart = new; + string readContent = check io:fileReadString(FILE_PATH); + bytesPart.setFileAsEntityBody(FILE_PATH); + string|byte[]|io:ReadableByteChannel|mime:EncodeError bytes = mime:base64Encode(readContent.toBytes()); + if bytes !is byte[] { + return error("error"); + } + bytesPart.setBody(bytes); + check bytesPart.setContentType("image/jpeg"); + bytesPart.setContentId(""); + mtomMessage.push(bytesPart); + + mime:Entity[] response = check soapClient->sendReceive(mtomMessage, path = "/getMimePayload"); + test:assertEquals(response[0].getXml(), check mtomMessage[0].getXml()); +} + @test:Config { groups: ["soap12", "send_receive"] }