Better code to test similar functions but with chunked input
This commit is contained in:
@@ -161,7 +161,7 @@ feature {NONE} -- Events
|
||||
do
|
||||
get_http_session
|
||||
if attached http_session as sess then
|
||||
if attached sess.get (a_url, ctx) as res and then not res.error_occurred and then attached res.body as l_body then
|
||||
if attached sess.get (a_url, adapted_context (ctx)) as res and then not res.error_occurred and then attached res.body as l_body then
|
||||
assert ("Good answer got=%""+l_body+"%" expected=%""+a_expected_body+"%"", l_body.same_string (a_expected_body))
|
||||
else
|
||||
assert ("Request %""+a_url+"%" failed", False)
|
||||
@@ -173,7 +173,7 @@ feature {NONE} -- Events
|
||||
do
|
||||
get_http_session
|
||||
if attached http_session as sess then
|
||||
if attached sess.post (a_url, ctx, Void) as res and then not res.error_occurred and then attached res.body as l_body then
|
||||
if attached sess.post (a_url, adapted_context (ctx), Void) as res and then not res.error_occurred and then attached res.body as l_body then
|
||||
assert ("Good answer got=%""+l_body+"%" expected=%""+a_expected_body+"%"", l_body.same_string (a_expected_body))
|
||||
else
|
||||
assert ("Request %""+a_url+"%" failed", False)
|
||||
@@ -181,6 +181,16 @@ feature {NONE} -- Events
|
||||
end
|
||||
end
|
||||
|
||||
adapted_context (ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT): HTTP_CLIENT_REQUEST_CONTEXT
|
||||
do
|
||||
if ctx /= Void then
|
||||
Result := ctx
|
||||
else
|
||||
create Result.make
|
||||
end
|
||||
-- Result.set_proxy ("127.0.0.1", 8888) --| inspect traffic with http://www.fiddler2.com/
|
||||
end
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_get_request_01
|
||||
|
||||
@@ -13,50 +13,30 @@ class
|
||||
inherit
|
||||
TEST_WSF_REQUEST
|
||||
redefine
|
||||
adapted_context,
|
||||
test_get_request_01,
|
||||
test_post_request_01
|
||||
end
|
||||
|
||||
feature {NONE} -- Helpers
|
||||
|
||||
adapted_context (ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT): HTTP_CLIENT_REQUEST_CONTEXT
|
||||
do
|
||||
Result := Precursor (ctx)
|
||||
Result.headers.extend ("chunked", "Transfer-Encoding")
|
||||
-- Result.set_proxy ("127.0.0.1", 8888) --| inspect traffic with http://www.fiddler2.com/
|
||||
end
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_get_request_01
|
||||
-- New test routine
|
||||
local
|
||||
ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT
|
||||
do
|
||||
get_http_session
|
||||
if attached http_session as sess then
|
||||
-- create ctx.make
|
||||
-- ctx.set_proxy ("127.0.0.1", 8888) --| debugging with http://www.fiddler2.com/
|
||||
|
||||
test_get_request ("get/01", ctx, "get-01")
|
||||
test_get_request ("get/01/?foo=bar", ctx, "get-01(foo=bar)")
|
||||
test_get_request ("get/01/?foo=bar&abc=def", ctx, "get-01(foo=bar&abc=def)")
|
||||
test_get_request ("get/01/?lst=a&lst=b", ctx, "get-01(lst=[a,b])")
|
||||
else
|
||||
assert ("not_implemented", False)
|
||||
end
|
||||
Precursor
|
||||
end
|
||||
|
||||
test_post_request_01
|
||||
-- New test routine
|
||||
local
|
||||
ctx: HTTP_CLIENT_REQUEST_CONTEXT
|
||||
do
|
||||
get_http_session
|
||||
if attached http_session as sess then
|
||||
create ctx.make
|
||||
ctx.add_form_parameter ("id", "123")
|
||||
ctx.headers.extend ("chunked", "Transfer-Encoding")
|
||||
-- ctx.set_proxy ("127.0.0.1", 8888) --| debugging with http://www.fiddler2.com/
|
||||
|
||||
test_post_request ("post/01", ctx, "post-01 : id=123")
|
||||
test_post_request ("post/01/?foo=bar", ctx, "post-01(foo=bar) : id=123")
|
||||
test_post_request ("post/01/?foo=bar&abc=def", ctx, "post-01(foo=bar&abc=def) : id=123")
|
||||
test_post_request ("post/01/?lst=a&lst=b", ctx, "post-01(lst=[a,b]) : id=123")
|
||||
else
|
||||
assert ("not_implemented", False)
|
||||
end
|
||||
Precursor
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user