Skip to content

Commit

Permalink
Add test case to validate mime requests without action
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuvindu committed Dec 1, 2023
1 parent 56d25d9 commit c396b2c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions ballerina/modules/soap12/tests/soap12_client_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Body>
<quer:Add xmlns:quer="http://tempuri.org/">
<quer:intA>2</quer:intA>
<quer:intB>3</quer:intB>
</quer:Add>
</soap:Body>
</soap:Envelope>`;

mime:Entity[] mtomMessage = [];
mime:Entity envelope = new;
check envelope.setContentType("application/xop+xml");
envelope.setContentId("<soap@envelope>");
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("<image1>");
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"]
}
Expand Down

0 comments on commit c396b2c

Please sign in to comment.