Shaun Ren : webservices/tests: Add a fault reading test for WsReadBody.
Alexandre Julliard
julliard at winehq.org
Fri Aug 5 14:42:32 CDT 2022
Module: wine
Branch: master
Commit: e4ff5f1ef8700aea563dc083ea3e08a845697507
URL: https://gitlab.winehq.org/wine/wine/-/commit/e4ff5f1ef8700aea563dc083ea3e08a845697507
Author: Shaun Ren <sren at codeweavers.com>
Date: Wed Aug 3 19:22:25 2022 -0400
webservices/tests: Add a fault reading test for WsReadBody.
Signed-off-by: Shaun Ren <sren at codeweavers.com>
---
dlls/webservices/tests/msg.c | 47 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 45 insertions(+), 2 deletions(-)
diff --git a/dlls/webservices/tests/msg.c b/dlls/webservices/tests/msg.c
index feeedc940d5..b1c0237dc3f 100644
--- a/dlls/webservices/tests/msg.c
+++ b/dlls/webservices/tests/msg.c
@@ -1202,19 +1202,27 @@ static void test_WsReadBody(void)
static const char xml[] =
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body>"
"<u xmlns=\"ns\"><val>1</val></u></s:Body></s:Envelope>";
+ static const char faultxml[] =
+ "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body>"
+ "<s:Fault><faultcode>s:Client</faultcode><faultstring>OLS Exception</faultstring></s:Fault>"
+ "</s:Body></s:Envelope>";
+ static const WS_XML_STRING faultcode = { 6, (BYTE *)"Client" };
+ static const WS_STRING faultstring = { 13, (WCHAR *)L"OLS Exception" };
WS_HEAP *heap;
- WS_MESSAGE *msg, *msg2;
+ WS_MESSAGE *msg, *msg2, *msg3;
WS_XML_READER *reader;
WS_MESSAGE_STATE state;
+ BOOL isfault;
WS_XML_STRING localname = {1, (BYTE *)"t"}, localname2 = {1, (BYTE *)"u"};
WS_XML_STRING val = {3, (BYTE *)"val"}, ns = {2, (BYTE *)"ns"};
- WS_ELEMENT_DESCRIPTION desc;
+ WS_ELEMENT_DESCRIPTION desc, faultdesc;
WS_STRUCT_DESCRIPTION s;
WS_FIELD_DESCRIPTION f, *fields[1];
struct test
{
UINT32 val;
} test;
+ WS_FAULT fault;
HRESULT hr;
hr = WsCreateHeap( 1 << 16, 0, NULL, 0, &heap, NULL );
@@ -1280,8 +1288,43 @@ static void test_WsReadBody(void)
hr = WsReadEnvelopeEnd( msg2, NULL );
ok( hr == S_OK, "got %#lx\n", hr );
+ hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1, WS_ADDRESSING_VERSION_0_9, NULL, 0, &msg3, NULL );
+ ok( hr == S_OK, "got %#lx\n", hr );
+
+ hr = set_input( reader, faultxml, strlen(faultxml) );
+ ok( hr == S_OK, "got %#lx\n", hr );
+
+ hr = WsReadEnvelopeStart( msg3, reader, NULL, NULL, NULL );
+ ok( hr == S_OK, "got %#lx\n", hr );
+
+ isfault = FALSE;
+ hr = WsGetMessageProperty( msg3, WS_MESSAGE_PROPERTY_IS_FAULT, &isfault, sizeof(isfault), NULL );
+ ok( hr == S_OK, "got %#lx\n", hr );
+ ok( isfault, "isfault == FALSE\n" );
+
+ faultdesc.elementLocalName = NULL;
+ faultdesc.elementNs = NULL;
+ faultdesc.type = WS_FAULT_TYPE;
+ faultdesc.typeDescription = NULL;
+
+ memset( &fault, 0, sizeof(fault) );
+ hr = WsReadBody( msg3, &faultdesc, WS_READ_REQUIRED_VALUE, heap, &fault, sizeof(fault), NULL );
+ ok( hr == S_OK, "got %#lx\n", hr );
+ ok( fault.code->value.localName.length == faultcode.length, "got %lu\n", fault.code->value.localName.length );
+ ok( !memcmp( fault.code->value.localName.bytes, faultcode.bytes, faultcode.length ), "wrong fault code\n" );
+ ok( !fault.code->subCode, "subcode is not NULL\n" );
+ ok( fault.reasonCount == 1, "got %lu\n", fault.reasonCount );
+ ok( fault.reasons[0].text.length == faultstring.length, "got %lu\n", fault.reasons[0].text.length );
+ ok( !memcmp( fault.reasons[0].text.chars, faultstring.chars, faultstring.length * sizeof(WCHAR) ),
+ "wrong fault string\n" );
+
+ hr = WsReadEnvelopeEnd( msg3, NULL );
+ ok( hr == S_OK, "got %#lx\n", hr );
+
+
WsFreeMessage( msg );
WsFreeMessage( msg2 );
+ WsFreeMessage( msg3 );
WsFreeReader( reader );
WsFreeHeap( heap );
}
More information about the wine-cvs
mailing list