Initial implementation of HTTP RESPONSE EXPECTATIONS.
Added a class to test http client with httpbin.org and expectations
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
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
|
||||
@@ -0,0 +1,27 @@
|
||||
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
|
||||
@@ -0,0 +1,42 @@
|
||||
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
|
||||
Reference in New Issue
Block a user