Removed http classes related to http expectations.

Updated code based on the code review.
Still work in progress
This commit is contained in:
jvelilla
2013-09-19 13:44:03 -03:00
parent a1245b77fd
commit 2d964b1137
21 changed files with 161 additions and 466 deletions

View File

@@ -1,51 +0,0 @@
note
description: "Summary description for {HTTP_CLIENT_HEADER_EXPECTATION}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
HTTP_CLIENT_HEADER_EXPECTATION
inherit
HTTP_CLIENT_RESPONSE_EXPECTATION
create
make
feature {NONE} -- Initializtion
make (a_header: STRING_32; a_value : STRING)
-- Create and Initialize a header expectation
do
header := a_header
value := a_value
ensure
header_set : header ~ a_header
value_set : value ~ a_value
end
feature -- Result expected
expected (resp: HTTP_CLIENT_RESPONSE): BOOLEAN
-- is `header name and value expected' equals to resp.header(name)?
do
if attached {READABLE_STRING_8} resp.header (header) as l_value then
if l_value.same_string (l_value) then
Result := true
end
end
end
feature -- Access
header : STRING
-- header name
value : STRING
-- header value
;note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,48 +0,0 @@
note
description: "Summary description for {HTTP_CLIENT_RESPONSE_BODY_EXPECTATION}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
HTTP_CLIENT_RESPONSE_BODY_EXPECTATION
inherit
HTTP_CLIENT_RESPONSE_EXPECTATION
create
make
feature {NONE} -- Initializtion
make (a_body : detachable STRING_32)
-- Create and Initialize a body expectation
do
body := a_body
ensure
body_set : body ~ a_body
end
feature -- Result expected
expected (resp: HTTP_CLIENT_RESPONSE): BOOLEAN
-- is `body expected' equals to resp.body?
do
if body = Void and then resp.body = Void then
Result := True
elseif attached resp.body as l_body and then attached body as c_body then
Result := l_body.is_case_insensitive_equal (c_body)
end
end
feature -- Access
body : detachable STRING_32
-- expected body
;note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,27 +0,0 @@
note
description: "Summary description for {HTTP_CLIENT_RESPONSE_EXPECTATION}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
HTTP_CLIENT_RESPONSE_EXPECTATION
feature
expected (resp: HTTP_CLIENT_RESPONSE): BOOLEAN
deferred
end
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,42 +0,0 @@
note
description: "Summary description for {HTTP_CLIENT_RESPONSE_STATUS_CODE_EXPECTATION}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
HTTP_CLIENT_RESPONSE_STATUS_CODE_EXPECTATION
inherit
HTTP_CLIENT_RESPONSE_EXPECTATION
create make
feature {NONE} -- Initialization
make (a_status : INTEGER_32)
do
status := a_status
ensure
status_set : status = a_status
end
feature -- Result Expected
expected (resp: HTTP_CLIENT_RESPONSE): BOOLEAN
-- is `status' expected equals to resp.status?
do
Result := status = resp.status
end
feature -- Access
status : INTEGER_32
-- status expected
;note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,121 +0,0 @@
note
description: "Summary description for {TEST_HTTP_CLIENT_WITH_HTTPBIN}."
author: ""
date: "$Date$"
revision: "$Revision$"
EIS: "name=HTTP TESTING", "protocol=uri", "src=http://httpbin.org/"
class
TEST_HTTP_CLIENT_WITH_HTTPBIN
inherit
EQA_TEST_SET
feature
test_origin_ip
local
h: LIBCURL_HTTP_CLIENT
sess: HTTP_CLIENT_SESSION
resp : detachable HTTP_CLIENT_RESPONSE
l_location : detachable READABLE_STRING_8
body : STRING
context : HTTP_CLIENT_REQUEST_CONTEXT
s: READABLE_STRING_8
do
create h.make
sess := h.new_session ("http://httpbin.org/")
resp := sess.get ("",void)
assert ("Expected Status 200 ok", resp.status = 200)
end
test_status_code
local
h: LIBCURL_HTTP_CLIENT
sess: HTTP_CLIENT_SESSION
resp : detachable HTTP_CLIENT_RESPONSE
l_location : detachable READABLE_STRING_8
body : STRING
context : HTTP_CLIENT_REQUEST_CONTEXT
s: READABLE_STRING_8
do
create h.make
sess := h.new_session ("http://httpbin.org/")
assert ("Expected Status 200 ok", (create {HTTP_CLIENT_RESPONSE_STATUS_CODE_EXPECTATION}.make(200)).expected(sess.get ("",void)) )
end
test_body
local
h: LIBCURL_HTTP_CLIENT
sess: HTTP_CLIENT_SESSION
resp : detachable HTTP_CLIENT_RESPONSE
l_location : detachable READABLE_STRING_8
body : STRING
context : HTTP_CLIENT_REQUEST_CONTEXT
s: READABLE_STRING_8
do
create h.make
sess := h.new_session ("http://httpbin.org/")
assert ("Expected no body", (create {HTTP_CLIENT_RESPONSE_BODY_EXPECTATION}.make(expected_body_get)).expected(sess.get ("get",void)) )
end
test_body_status
local
h: LIBCURL_HTTP_CLIENT
sess: HTTP_CLIENT_SESSION
resp : detachable HTTP_CLIENT_RESPONSE
l_location : detachable READABLE_STRING_8
body : STRING
context : HTTP_CLIENT_REQUEST_CONTEXT
s: READABLE_STRING_8
do
create h.make
sess := h.new_session ("http://httpbin.org/")
--assert ("Expected no body", (create {HTTP_CLIENT_RESPONSE_STATUS_CODE_EXPECTATION}.make(200) + create {HTTP_CLIENT_RESPONSE_BODY_EXPECTATION}.make(expected_body_get)).expected(sess.get ("get",void)) )
end
test_after_post_should_continue_working
local
h: LIBCURL_HTTP_CLIENT
sess: HTTP_CLIENT_SESSION
resp : detachable HTTP_CLIENT_RESPONSE
l_location : detachable READABLE_STRING_8
body : STRING
context : HTTP_CLIENT_REQUEST_CONTEXT
s: READABLE_STRING_8
do
create h.make
sess := h.new_session ("http://httpbin.org/")
resp := sess.get ("",void)
assert ("Expected Status 200 ok", resp.status = 200)
create context.make
context.headers.put ("text/plain;charset=UTF-8", "Content-Type")
resp := sess.post ("post", context, "testing post")
assert ("Expected Status 200 ok", resp.status = 200)
sess := h.new_session ("http://httpbin.org/")
resp := sess.get ("",void)
assert ("Expected Status 200 ok", resp.status = 200)
sess := h.new_session ("http://httpbin.org/")
resp := sess.get ("redirect/1",void)
assert ("Expected Status 200 ok", resp.status = 200)
end
expected_body_get : STRING_32 = "[
{
"url": "http://httpbin.org/get",
"args": {},
"headers": {
"Host": "httpbin.org",
"Connection": "close",
"Accept": "*/*"
},
"origin": "190.177.106.187"
}
]"
end