~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to lib/inets/test/httpc_test.erl

  • Committer: Bazaar Package Importer
  • Author(s): Erlang Packagers, Sergei Golovan
  • Date: 2006-12-03 17:07:44 UTC
  • mfrom: (2.1.11 feisty)
  • Revision ID: james.westby@ubuntu.com-20061203170744-rghjwupacqlzs6kv
Tags: 1:11.b.2-4
[ Sergei Golovan ]
Fixed erlang-base and erlang-base-hipe prerm scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%% ``The contents of this file are subject to the Erlang Public License,
2
 
%% Version 1.1, (the "License"); you may not use this file except in
3
 
%% compliance with the License. You should have received a copy of the
4
 
%% Erlang Public License along with this software. If not, it can be
5
 
%% retrieved via the world wide web at http://www.erlang.org/.
6
 
%% 
7
 
%% Software distributed under the License is distributed on an "AS IS"
8
 
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
 
%% the License for the specific language governing rights and limitations
10
 
%% under the License.
11
 
%% 
12
 
%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
 
%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
 
%% AB. All Rights Reserved.''
15
 
%% 
16
 
%%     $Id$
17
 
%%
18
 
%%----------------------------------------------------------------------
19
 
%% Purpose: Verify the application specifics of the inets application
20
 
%%----------------------------------------------------------------------
21
 
-module(httpc_test).
22
 
 
23
 
-compile(export_all).
24
 
 
25
 
-include("inets_test_lib.hrl").
26
 
 
27
 
 
28
 
%% These are JUST temporary
29
 
-ifndef(NOPROXY_HOST).
30
 
-define(NOPROXY_HOST, "otp.ericsson.se").
31
 
-define(NOPROXY_PORT, "8000").
32
 
-endif.
33
 
 
34
 
-ifndef(PROXY_HOST).
35
 
-define(PROXY_HOST, "www.erlang.org").
36
 
-define(PROXY_PORT, undefined).
37
 
-endif.
38
 
 
39
 
 
40
 
% t()     -> megaco_test_lib:t(?MODULE).
41
 
% t(Case) -> megaco_test_lib:t({?MODULE, Case}).
42
 
 
43
 
 
44
 
%% Test server callbacks
45
 
init_per_testcase(Case, Config) ->
46
 
    Timeout = inets_test_lib:get_config(tc_timeout, Config, ?SECS(10)),
47
 
    Pid = ?WD_START(Timeout),
48
 
    [{watchdog, Pid}|Config].
49
 
 
50
 
fin_per_testcase(Case, Config) ->
51
 
    case ?CONFIG(watchdog, Config) of
52
 
        Pid when pid(Pid) ->
53
 
            ?WD_STOP(Pid);
54
 
        _ ->
55
 
            ok
56
 
    end,
57
 
    Config.
58
 
 
59
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60
 
 
61
 
all(suite) ->
62
 
    [
63
 
     ip_comm, ssl
64
 
    ].
65
 
 
66
 
 
67
 
ip_comm(suite) ->
68
 
    Cases = 
69
 
        [
70
 
         ip_noproxy,
71
 
         ip_proxy
72
 
        ].
73
 
 
74
 
ip_noproxy(suite) ->
75
 
    Cases = 
76
 
        [
77
 
         ip_noproxy_simple_op,
78
 
         ip_noproxy_get,
79
 
         ip_noproxy_head,
80
 
         ip_noproxy_post
81
 
        ],
82
 
    ?EXPANDABLE(init_noproxy_ip, Cases, stop_noproxy_ip).
83
 
 
84
 
ip_proxy(suite) ->
85
 
    Cases = 
86
 
        [
87
 
         ip_proxy_simple_op,
88
 
         ip_proxy_get,
89
 
         ip_proxy_head,
90
 
         ip_proxy_post
91
 
        ],
92
 
    ?EXPANDABLE(init_proxy_ip, Cases, stop_proxy_ip).
93
 
 
94
 
 
95
 
init_noproxy_ip(suite) -> [];
96
 
init_noproxy_ip(doc) -> [];
97
 
init_noproxy_ip(Config) when list(Config) ->
98
 
    %% Here we should propably start the server...
99
 
    [{type, ip_comm}, {host, ?NOPROXY_HOST}, {port, ?NOPROXY_PORT}|Config].
100
 
 
101
 
stop_noproxy_ip(suite) -> [];
102
 
stop_noproxy_ip(doc) -> [];
103
 
stop_noproxy_ip(Config) when list(Config) ->
104
 
    Config.
105
 
 
106
 
ip_noproxy_simple_op(suite) -> [];
107
 
ip_noproxy_simple_op(doc) ->
108
 
    ["Perform the operations GET, POST, ... "
109
 
     "with only the needed options (simple)"];
110
 
ip_noproxy_simple_op(Config) -> 
111
 
    simple_op(Config).
112
 
 
113
 
ip_noproxy_get(suite) -> [];
114
 
ip_noproxy_get(doc) ->
115
 
    ["Perform the GET operation, excercising all the options"];
116
 
ip_noproxy_get(Config) -> 
117
 
    ?SKIP(not_yet_implemented).
118
 
 
119
 
ip_noproxy_head(suite) -> [];
120
 
ip_noproxy_head(doc) ->
121
 
    ["Perform the HEAD operation, excercising all the options"];
122
 
ip_noproxy_head(Config) -> 
123
 
    ?SKIP(not_yet_implemented).
124
 
 
125
 
ip_noproxy_post(suite) -> [];
126
 
ip_noproxy_post(doc) ->
127
 
    ["Perform the POST operation, excercising all the options"];
128
 
ip_noproxy_post(Config) -> 
129
 
    ?SKIP(not_yet_implemented).
130
 
 
131
 
 
132
 
init_proxy_ip(suite) -> [];
133
 
init_proxy_ip(doc) -> [];
134
 
init_proxy_ip(Config) when list(Config) ->
135
 
    %% Here we should propably start the server...
136
 
    [{type, ip_comm}, {host, ?PROXY_HOST}, {port, ?PROXY_PORT},
137
 
     {settings, [{http_useproxy,true},{http_proxy,{"proxy",82}}]}|Config].
138
 
 
139
 
stop_proxy_ip(suite) -> [];
140
 
stop_proxy_ip(doc) -> [];
141
 
stop_proxy_ip(Config) when list(Config) ->
142
 
    Config.
143
 
 
144
 
ip_proxy_simple_op(suite) -> [];
145
 
ip_proxy_simple_op(doc) ->
146
 
    ["Perform the operations GET, POST, ... "
147
 
     "with only the needed options (simple)"];
148
 
ip_proxy_simple_op(Config) -> 
149
 
    simple_op(Config).
150
 
 
151
 
ip_proxy_get(suite) -> [];
152
 
ip_proxy_get(doc) ->
153
 
    ["Perform the GET operation, excercising all the options"];
154
 
ip_proxy_get(Config) -> 
155
 
    ?SKIP(not_yet_implemented).
156
 
 
157
 
ip_proxy_head(suite) -> [];
158
 
ip_proxy_head(doc) ->
159
 
    ["Perform the HEAD operation, excercising all the options"];
160
 
ip_proxy_head(Config) -> 
161
 
    ?SKIP(not_yet_implemented).
162
 
 
163
 
ip_proxy_post(suite) -> [];
164
 
ip_proxy_post(doc) ->
165
 
    ["Perform the POST operation, excercising all the options"];
166
 
ip_proxy_post(Config) -> 
167
 
    ?SKIP(not_yet_implemented).
168
 
 
169
 
 
170
 
 
171
 
ssl(suite) ->
172
 
    Cases = 
173
 
        [
174
 
         ssl_noproxy,
175
 
         ssl_proxy
176
 
        ].
177
 
 
178
 
ssl_noproxy(suite) ->
179
 
    Cases = 
180
 
        [
181
 
         ssl_noproxy_simple_op,
182
 
         ssl_noproxy_get,
183
 
         ssl_noproxy_head,
184
 
         ssl_noproxy_post
185
 
        ],
186
 
    ?EXPANDABLE(init_noproxy_ssl, Cases, stop_noproxy_ssl).
187
 
 
188
 
ssl_proxy(suite) ->
189
 
    Cases = 
190
 
        [
191
 
         ssl_proxy_simple_op,
192
 
         ssl_proxy_get,
193
 
         ssl_proxy_head,
194
 
         ssl_proxy_post
195
 
        ],
196
 
    ?EXPANDABLE(init_proxy_ssl, Cases, stop_proxy_ssl).
197
 
 
198
 
 
199
 
init_noproxy_ssl(suite) -> [];
200
 
init_noproxy_ssl(doc) -> [];
201
 
init_noproxy_ssl(Config) when list(Config) ->
202
 
    %% Here we should propably start the server...
203
 
    [{type, ssl}, {host, ?NOPROXY_HOST}, {port, ?NOPROXY_PORT}|Config].
204
 
 
205
 
stop_noproxy_ssl(suite) -> [];
206
 
stop_noproxy_ssl(doc) -> [];
207
 
stop_noproxy_ssl(Config) when list(Config) ->
208
 
    Config.
209
 
 
210
 
ssl_noproxy_simple_op(suite) -> [];
211
 
ssl_noproxy_simple_op(doc) ->
212
 
    ["Perform the operations GET, POST, ... "
213
 
     "with only the needed options (simple)"];
214
 
ssl_noproxy_simple_op(Config) -> 
215
 
    simple_op(Config).
216
 
 
217
 
ssl_noproxy_get(suite) -> [];
218
 
ssl_noproxy_get(doc) ->
219
 
    ["Perform the GET operation, excercising all the options"];
220
 
ssl_noproxy_get(Config) -> 
221
 
    ?SKIP(not_yet_implemented).
222
 
 
223
 
ssl_noproxy_head(suite) -> [];
224
 
ssl_noproxy_head(doc) ->
225
 
    ["Perform the HEAD operation, excercising all the options"];
226
 
ssl_noproxy_head(Config) -> 
227
 
    ?SKIP(not_yet_implemented).
228
 
 
229
 
ssl_noproxy_post(suite) -> [];
230
 
ssl_noproxy_post(doc) ->
231
 
    ["Perform the POST operation, excercising all the options"];
232
 
ssl_noproxy_post(Config) -> 
233
 
    ?SKIP(not_yet_implemented).
234
 
 
235
 
 
236
 
init_proxy_ssl(suite) -> [];
237
 
init_proxy_ssl(doc) -> [];
238
 
init_proxy_ssl(Config) when list(Config) ->
239
 
    %% Here we should propably start the server...
240
 
    [{type, ssl}, {host, ?PROXY_HOST}, {port, ?PROXY_PORT},
241
 
     {settings, [{http_useproxy,true},{http_proxy,{"proxy",82}}]}|Config].
242
 
 
243
 
stop_proxy_ssl(suite) -> [];
244
 
stop_proxy_ssl(doc) -> [];
245
 
stop_proxy_ssl(Config) when list(Config) ->
246
 
    Config.
247
 
 
248
 
ssl_proxy_simple_op(suite) -> [];
249
 
ssl_proxy_simple_op(doc) ->
250
 
    ["Perform the operations GET, POST, ... "
251
 
     "with only the needed options (simple)"];
252
 
ssl_proxy_simple_op(Config) -> 
253
 
    simple_op(Config).
254
 
 
255
 
ssl_proxy_get(suite) -> [];
256
 
ssl_proxy_get(doc) ->
257
 
    ["Perform the GET operation, excercising all the options"];
258
 
ssl_proxy_get(Config) -> 
259
 
    ?SKIP(not_yet_implemented).
260
 
 
261
 
ssl_proxy_head(suite) -> [];
262
 
ssl_proxy_head(doc) ->
263
 
    ["Perform the HEAD operation, excercising all the options"];
264
 
ssl_proxy_head(Config) -> 
265
 
    ?SKIP(not_yet_implemented).
266
 
 
267
 
ssl_proxy_post(suite) -> [];
268
 
ssl_proxy_post(doc) ->
269
 
    ["Perform the POST operation, excercising all the options"];
270
 
ssl_proxy_post(Config) -> 
271
 
    ?SKIP(not_yet_implemented).
272
 
 
273
 
 
274
 
 
275
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
276
 
 
277
 
simple_op(suite) -> [];
278
 
simple_op(doc) -> [];
279
 
simple_op(Config) -> 
280
 
    ?SKIP(not_yet_implemented),
281
 
    URL = url("/", Config),
282
 
    Settings = inets_test_lib:get_config(settings, Config, []),
283
 
    io:format("simple_op -> "
284
 
              "~nURL:      ~p"
285
 
              "~nSettings: ~p~n", [URL, Settings]),
286
 
    http:request_sync(get, {URL, []}, Settings).
287
 
 
288
 
 
289
 
url(Uri, Config) ->
290
 
    Host = ?CONFIG(host, Config),
291
 
    case inets_test_lib:get_config(type, Config, ip_comm) of
292
 
        ip_comm ->
293
 
            url1("http://", Host, Uri, Config);
294
 
        ssl ->
295
 
            url1("https://", Host, Uri, Config)
296
 
    end.
297
 
    
298
 
url1(Prot, Host, Uri, Config) ->
299
 
    case ?CONFIG(port, Config) of
300
 
        undefined ->
301
 
            Prot ++ Host ++ Uri;
302
 
        Port when list(Port) ->
303
 
            Prot ++ Host ++ ":" ++ Port ++ Uri
304
 
    end.
305
 
    
306
 
 
307