diff options
author | Filipe David Borba Manana <fdmanana@apache.org> | 2011-09-29 23:34:40 +0000 |
---|---|---|
committer | Filipe David Borba Manana <fdmanana@apache.org> | 2011-09-29 23:34:40 +0000 |
commit | 1285cd95c8fe351991218f886bbfe28d9a9a3b09 (patch) | |
tree | a62af53acc1fb9be4e943ab1935e6fa92889863f /test/etap/113-replication-attachment-comp.t | |
parent | 89a5c28775f24f2706f443c76afa3edf9df78ce4 (diff) |
Remove usage of http module from etap tests
This module is deprecated in OTP R15, which is going to
be released by the end of this year.
The etap tests now use ibrowse instead.
This is a backport of revision 1177459 from trunk.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1177463 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/etap/113-replication-attachment-comp.t')
-rwxr-xr-x | test/etap/113-replication-attachment-comp.t | 77 |
1 files changed, 33 insertions, 44 deletions
diff --git a/test/etap/113-replication-attachment-comp.t b/test/etap/113-replication-attachment-comp.t index e30a96bc..bc98ca18 100755 --- a/test/etap/113-replication-attachment-comp.t +++ b/test/etap/113-replication-attachment-comp.t @@ -41,8 +41,6 @@ test() -> couch_server_sup:start_link(test_util:config_files()), put(addr, couch_config:get("httpd", "bind_address", "127.0.0.1")), put(port, integer_to_list(mochiweb_socket_server:get(couch_httpd, port))), - application:start(inets), - ibrowse:start(), timer:sleep(1000), % @@ -133,12 +131,11 @@ test() -> ok. put_text_att(DbName) -> - {ok, {{_, Code, _}, _Headers, _Body}} = http:request( + {ok, Code, _Headers, Body} = test_util:request( + db_url(DbName) ++ "/testdoc1/readme.txt", + [{"Content-Type", "text/plain"}], put, - {db_url(DbName) ++ "/testdoc1/readme.txt", [], - "text/plain", test_text_data()}, - [], - [{sync, true}]), + test_text_data()), etap:is(Code, 201, "Created text attachment"), ok. @@ -147,12 +144,11 @@ do_pull_replication(SourceDbName, TargetDbName) -> {<<"source">>, list_to_binary(db_url(SourceDbName))}, {<<"target">>, TargetDbName} ]}, - {ok, {{_, Code, _}, _Headers, Body}} = http:request( + {ok, Code, _Headers, Body} = test_util:request( + rep_url(), + [{"Content-Type", "application/json"}], post, - {rep_url(), [], - "application/json", list_to_binary(couch_util:json_encode(RepObj))}, - [], - [{sync, true}]), + iolist_to_binary(couch_util:json_encode(RepObj))), etap:is(Code, 200, "Pull replication successfully triggered"), Json = couch_util:json_decode(Body), RepOk = couch_util:get_nested_json_value(Json, [<<"ok">>]), @@ -164,12 +160,11 @@ do_push_replication(SourceDbName, TargetDbName) -> {<<"source">>, SourceDbName}, {<<"target">>, list_to_binary(db_url(TargetDbName))} ]}, - {ok, {{_, Code, _}, _Headers, Body}} = http:request( + {ok, Code, _Headers, Body} = test_util:request( + rep_url(), + [{"Content-Type", "application/json"}], post, - {rep_url(), [], - "application/json", list_to_binary(couch_util:json_encode(RepObj))}, - [], - [{sync, true}]), + iolist_to_binary(couch_util:json_encode(RepObj))), etap:is(Code, 200, "Push replication successfully triggered"), Json = couch_util:json_decode(Body), RepOk = couch_util:get_nested_json_value(Json, [<<"ok">>]), @@ -181,12 +176,11 @@ do_local_replication(SourceDbName, TargetDbName) -> {<<"source">>, SourceDbName}, {<<"target">>, TargetDbName} ]}, - {ok, {{_, Code, _}, _Headers, Body}} = http:request( + {ok, Code, _Headers, Body} = test_util:request( + rep_url(), + [{"Content-Type", "application/json"}], post, - {rep_url(), [], - "application/json", list_to_binary(couch_util:json_encode(RepObj))}, - [], - [{sync, true}]), + iolist_to_binary(couch_util:json_encode(RepObj))), etap:is(Code, 200, "Local replication successfully triggered"), Json = couch_util:json_decode(Body), RepOk = couch_util:get_nested_json_value(Json, [<<"ok">>]), @@ -194,16 +188,14 @@ do_local_replication(SourceDbName, TargetDbName) -> ok. check_att_is_compressed(DbName) -> - {ok, {{_, Code, _}, Headers, Body}} = http:request( - get, - {db_url(DbName) ++ "/testdoc1/readme.txt", - [{"Accept-Encoding", "gzip"}]}, - [], - [{sync, true}]), + {ok, Code, Headers, Body} = test_util:request( + db_url(DbName) ++ "/testdoc1/readme.txt", + [{"Accept-Encoding", "gzip"}], + get), etap:is(Code, 200, "HTTP response code for the attachment request is 200"), - Gziped = lists:member({"content-encoding", "gzip"}, Headers), + Gziped = lists:member({"Content-Encoding", "gzip"}, Headers), etap:is(Gziped, true, "The attachment was received in compressed form"), - Uncompressed = binary_to_list(zlib:gunzip(list_to_binary(Body))), + Uncompressed = zlib:gunzip(Body), etap:is( Uncompressed, test_text_data(), @@ -212,13 +204,12 @@ check_att_is_compressed(DbName) -> ok. check_server_can_decompress_att(DbName) -> - {ok, {{_, Code, _}, Headers, Body}} = http:request( - get, - {db_url(DbName) ++ "/testdoc1/readme.txt", []}, + {ok, Code, Headers, Body} = test_util:request( + db_url(DbName) ++ "/testdoc1/readme.txt", [], - [{sync, true}]), + get), etap:is(Code, 200, "HTTP response code for the attachment request is 200"), - Gziped = lists:member({"content-encoding", "gzip"}, Headers), + Gziped = lists:member({"Content-Encoding", "gzip"}, Headers), etap:is( Gziped, false, "The attachment was not received in compressed form" ), @@ -230,11 +221,10 @@ check_server_can_decompress_att(DbName) -> ok. check_att_stubs(SourceDbName, TargetDbName) -> - {ok, {{_, Code1, _}, _Headers1, Body1}} = http:request( - get, - {db_url(SourceDbName) ++ "/testdoc1?att_encoding_info=true", []}, + {ok, Code1, _Headers1, Body1} = test_util:request( + db_url(SourceDbName) ++ "/testdoc1?att_encoding_info=true", [], - [{sync, true}]), + get), etap:is( Code1, 200, @@ -245,11 +235,10 @@ check_att_stubs(SourceDbName, TargetDbName) -> Json1, [<<"_attachments">>, <<"readme.txt">>] ), - {ok, {{_, Code2, _}, _Headers2, Body2}} = http:request( - get, - {db_url(TargetDbName) ++ "/testdoc1?att_encoding_info=true", []}, + {ok, Code2, _Headers2, Body2} = test_util:request( + db_url(SourceDbName) ++ "/testdoc1?att_encoding_info=true", [], - [{sync, true}]), + get), etap:is( Code2, 200, @@ -311,4 +300,4 @@ rep_url() -> test_text_data() -> {ok, Data} = file:read_file(test_util:source_file("README")), - binary_to_list(Data). + Data. |