2 * Copyright 2016 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "webservices.h"
22 #include "wine/test.h"
24 static void test_WsCreateChannel(void)
28 WS_CHANNEL_STATE state
;
31 hr
= WsCreateChannel( WS_CHANNEL_TYPE_REQUEST
, WS_HTTP_CHANNEL_BINDING
, NULL
, 0, NULL
, NULL
, NULL
);
32 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
35 hr
= WsCreateChannel( WS_CHANNEL_TYPE_REQUEST
, WS_HTTP_CHANNEL_BINDING
, NULL
, 0, NULL
, &channel
, NULL
);
36 ok( hr
== S_OK
, "got %08x\n", hr
);
37 ok( channel
!= NULL
, "channel not set\n" );
41 hr
= WsGetChannelProperty( channel
, WS_CHANNEL_PROPERTY_MAX_BUFFERED_MESSAGE_SIZE
, &value
, size
, NULL
);
42 ok( hr
== S_OK
, "got %08x\n", hr
);
43 ok( value
== 65536, "got %u\n", value
);
45 /* read-only property */
48 hr
= WsGetChannelProperty( channel
, WS_CHANNEL_PROPERTY_STATE
, &state
, size
, NULL
);
49 ok( hr
== S_OK
, "got %08x\n", hr
);
50 ok( state
== WS_CHANNEL_STATE_CREATED
, "got %u\n", state
);
52 state
= WS_CHANNEL_STATE_CREATED
;
54 hr
= WsSetChannelProperty( channel
, WS_CHANNEL_PROPERTY_STATE
, &state
, size
, NULL
);
55 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
57 WsFreeChannel( channel
);
60 static void test_WsOpenChannel(void)
62 WCHAR url
[] = {'h','t','t','p',':','/','/','l','o','c','a','l','h','o','s','t'};
65 WS_ENDPOINT_ADDRESS addr
;
67 hr
= WsCreateChannel( WS_CHANNEL_TYPE_REQUEST
, WS_HTTP_CHANNEL_BINDING
, NULL
, 0, NULL
, &channel
, NULL
);
68 ok( hr
== S_OK
, "got %08x\n", hr
);
70 hr
= WsCloseChannel( channel
, NULL
, NULL
);
71 ok( hr
== S_OK
, "got %08x\n", hr
);
72 WsFreeChannel( channel
);
74 hr
= WsCreateChannel( WS_CHANNEL_TYPE_REQUEST
, WS_HTTP_CHANNEL_BINDING
, NULL
, 0, NULL
, &channel
, NULL
);
75 ok( hr
== S_OK
, "got %08x\n", hr
);
77 hr
= WsOpenChannel( channel
, NULL
, NULL
, NULL
);
78 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
80 addr
.url
.length
= sizeof(url
)/sizeof(url
[0]);
83 addr
.extensions
= NULL
;
85 hr
= WsOpenChannel( NULL
, &addr
, NULL
, NULL
);
86 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
88 hr
= WsOpenChannel( channel
, &addr
, NULL
, NULL
);
89 ok( hr
== S_OK
, "got %08x\n", hr
);
91 hr
= WsOpenChannel( channel
, &addr
, NULL
, NULL
);
92 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
94 hr
= WsCloseChannel( channel
, NULL
, NULL
);
95 ok( hr
== S_OK
, "got %08x\n", hr
);
97 hr
= WsCloseChannel( channel
, NULL
, NULL
);
98 ok( hr
== S_OK
, "got %08x\n", hr
);
100 hr
= WsCloseChannel( NULL
, NULL
, NULL
);
101 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
103 WsFreeChannel( channel
);
106 static void test_WsResetChannel(void)
108 WCHAR url
[] = {'h','t','t','p',':','/','/','l','o','c','a','l','h','o','s','t'};
111 WS_CHANNEL_STATE state
;
112 WS_CHANNEL_TYPE type
;
113 WS_ENDPOINT_ADDRESS addr
;
116 hr
= WsCreateChannel( WS_CHANNEL_TYPE_REQUEST
, WS_HTTP_CHANNEL_BINDING
, NULL
, 0, NULL
, &channel
, NULL
);
117 ok( hr
== S_OK
, "got %08x\n", hr
);
119 hr
= WsResetChannel( channel
, NULL
);
120 ok( hr
== S_OK
, "got %08x\n", hr
);
123 size
= sizeof(timeout
);
124 hr
= WsSetChannelProperty( channel
, WS_CHANNEL_PROPERTY_RESOLVE_TIMEOUT
, &timeout
, size
, NULL
);
125 ok( hr
== S_OK
, "got %08x\n", hr
);
127 addr
.url
.length
= sizeof(url
)/sizeof(url
[0]);
128 addr
.url
.chars
= url
;
130 addr
.extensions
= NULL
;
131 addr
.identity
= NULL
;
132 hr
= WsOpenChannel( channel
, &addr
, NULL
, NULL
);
133 ok( hr
== S_OK
, "got %08x\n", hr
);
135 hr
= WsResetChannel( channel
, NULL
);
136 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
138 hr
= WsCloseChannel( channel
, NULL
, NULL
);
139 ok( hr
== S_OK
, "got %08x\n", hr
);
141 hr
= WsResetChannel( channel
, NULL
);
142 ok( hr
== S_OK
, "got %08x\n", hr
);
145 size
= sizeof(state
);
146 hr
= WsGetChannelProperty( channel
, WS_CHANNEL_PROPERTY_STATE
, &state
, size
, NULL
);
147 ok( hr
== S_OK
, "got %08x\n", hr
);
148 ok( state
== WS_CHANNEL_STATE_CREATED
, "got %u\n", state
);
152 hr
= WsGetChannelProperty( channel
, WS_CHANNEL_PROPERTY_CHANNEL_TYPE
, &type
, size
, NULL
);
153 ok( hr
== S_OK
, "got %08x\n", hr
);
154 ok( type
== WS_CHANNEL_TYPE_REQUEST
, "got %u\n", type
);
156 timeout
= 0xdeadbeef;
157 size
= sizeof(timeout
);
158 hr
= WsGetChannelProperty( channel
, WS_CHANNEL_PROPERTY_RESOLVE_TIMEOUT
, &timeout
, size
, NULL
);
159 ok( hr
== S_OK
, "got %08x\n", hr
);
160 ok( timeout
== 5000, "got %u\n", timeout
);
162 WsFreeChannel( channel
);
167 test_WsCreateChannel();
168 test_WsOpenChannel();
169 test_WsResetChannel();