diff options
author | Loïc Hoguin <[email protected]> | 2013-04-22 15:55:22 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2013-04-22 17:03:54 +0200 |
commit | 2e916777233d8d82b93cbca9b754a023a6ca63c2 (patch) | |
tree | bc3de082804c1c9f220cdbba542e545082b2e793 /test | |
parent | cf0e00589409eb8caf423e3efa6777540951d424 (diff) | |
download | cowboy-2e916777233d8d82b93cbca9b754a023a6ca63c2.tar.gz cowboy-2e916777233d8d82b93cbca9b754a023a6ca63c2.tar.bz2 cowboy-2e916777233d8d82b93cbca9b754a023a6ca63c2.zip |
Reorganize the websocket test suite
We now have the suite specific modules in the data folder.
Compilation is performed by the Makefile instead of ct_run.
Diffstat (limited to 'test')
-rw-r--r-- | test/autobahn_SUITE.erl | 2 | ||||
-rw-r--r-- | test/autobahn_SUITE_data/autobahn_echo.erl | 26 | ||||
-rw-r--r-- | test/ws_SUITE.erl | 28 | ||||
-rw-r--r-- | test/ws_SUITE_data/ws_echo.erl (renamed from test/websocket_echo_handler.erl) | 2 | ||||
-rw-r--r-- | test/ws_SUITE_data/ws_echo_timer.erl (renamed from test/websocket_handler.erl) | 2 | ||||
-rw-r--r-- | test/ws_SUITE_data/ws_init_shutdown.erl (renamed from test/websocket_handler_init_shutdown.erl) | 2 | ||||
-rw-r--r-- | test/ws_SUITE_data/ws_send_many.erl (renamed from test/ws_send_many_handler.erl) | 2 | ||||
-rw-r--r-- | test/ws_SUITE_data/ws_timeout_cancel.erl (renamed from test/ws_timeout_cancel_handler.erl) | 2 | ||||
-rw-r--r-- | test/ws_SUITE_data/ws_timeout_hibernate.erl (renamed from test/ws_timeout_hibernate_handler.erl) | 2 | ||||
-rw-r--r-- | test/ws_SUITE_data/ws_upgrade_with_opts.erl (renamed from test/ws_upgrade_with_opts_handler.erl) | 2 |
10 files changed, 48 insertions, 22 deletions
diff --git a/test/autobahn_SUITE.erl b/test/autobahn_SUITE.erl index 61cf631..68a9221 100644 --- a/test/autobahn_SUITE.erl +++ b/test/autobahn_SUITE.erl @@ -76,7 +76,7 @@ end_per_group(Listener, _Config) -> init_dispatch() -> cowboy_router:compile([{"localhost", [ - {"/echo", websocket_echo_handler, []}]}]). + {"/echo", autobahn_echo, []}]}]). %% autobahn cases diff --git a/test/autobahn_SUITE_data/autobahn_echo.erl b/test/autobahn_SUITE_data/autobahn_echo.erl new file mode 100644 index 0000000..07f7fd9 --- /dev/null +++ b/test/autobahn_SUITE_data/autobahn_echo.erl @@ -0,0 +1,26 @@ +%% Feel free to use, reuse and abuse the code in this file. + +-module(autobahn_echo). +-behaviour(cowboy_websocket_handler). +-export([init/3]). +-export([websocket_init/3, websocket_handle/3, + websocket_info/3, websocket_terminate/3]). + +init(_Any, _Req, _Opts) -> + {upgrade, protocol, cowboy_websocket}. + +websocket_init(_TransportName, Req, _Opts) -> + {ok, Req, undefined}. + +websocket_handle({text, Data}, Req, State) -> + {reply, {text, Data}, Req, State}; +websocket_handle({binary, Data}, Req, State) -> + {reply, {binary, Data}, Req, State}; +websocket_handle(_Frame, Req, State) -> + {ok, Req, State}. + +websocket_info(_Info, Req, State) -> + {ok, Req, State}. + +websocket_terminate(_Reason, _Req, _State) -> + ok. diff --git a/test/ws_SUITE.erl b/test/ws_SUITE.erl index b6709ca..fbef41a 100644 --- a/test/ws_SUITE.erl +++ b/test/ws_SUITE.erl @@ -90,30 +90,30 @@ end_per_group(Listener, _Config) -> init_dispatch() -> cowboy_router:compile([ {"localhost", [ - {"/websocket", websocket_handler, []}, - {"/ws_echo_handler", websocket_echo_handler, []}, - {"/ws_init_shutdown", websocket_handler_init_shutdown, []}, - {"/ws_send_many", ws_send_many_handler, [ + {"/ws_echo_timer", ws_echo_timer, []}, + {"/ws_echo", ws_echo, []}, + {"/ws_init_shutdown", ws_init_shutdown, []}, + {"/ws_send_many", ws_send_many, [ {sequence, [ {text, <<"one">>}, {text, <<"two">>}, {text, <<"seven!">>}]} ]}, - {"/ws_send_close", ws_send_many_handler, [ + {"/ws_send_close", ws_send_many, [ {sequence, [ {text, <<"send">>}, close, {text, <<"won't be received">>}]} ]}, - {"/ws_send_close_payload", ws_send_many_handler, [ + {"/ws_send_close_payload", ws_send_many, [ {sequence, [ {text, <<"send">>}, {close, 1001, <<"some text!">>}, {text, <<"won't be received">>}]} ]}, - {"/ws_timeout_hibernate", ws_timeout_hibernate_handler, []}, - {"/ws_timeout_cancel", ws_timeout_cancel_handler, []}, - {"/ws_upgrade_with_opts", ws_upgrade_with_opts_handler, + {"/ws_timeout_hibernate", ws_timeout_hibernate, []}, + {"/ws_timeout_cancel", ws_timeout_cancel, []}, + {"/ws_upgrade_with_opts", ws_upgrade_with_opts, <<"failure">>} ]} ]). @@ -126,7 +126,7 @@ ws0(Config) -> {ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}, {packet, raw}]), ok = gen_tcp:send(Socket, - "GET /websocket HTTP/1.1\r\n" + "GET /ws_echo_timer HTTP/1.1\r\n" "Host: localhost\r\n" "Connection: Upgrade\r\n" "Upgrade: WebSocket\r\n" @@ -143,7 +143,7 @@ ws8(Config) -> {ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}, {packet, raw}]), ok = gen_tcp:send(Socket, [ - "GET /websocket HTTP/1.1\r\n" + "GET /ws_echo_timer HTTP/1.1\r\n" "Host: localhost\r\n" "Connection: Upgrade\r\n" "Upgrade: websocket\r\n" @@ -203,7 +203,7 @@ ws8_single_bytes(Config) -> {ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}, {packet, raw}]), ok = gen_tcp:send(Socket, [ - "GET /websocket HTTP/1.1\r\n" + "GET /ws_echo_timer HTTP/1.1\r\n" "Host: localhost\r\n" "Connection: Upgrade\r\n" "Upgrade: websocket\r\n" @@ -263,7 +263,7 @@ ws13(Config) -> {ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}, {packet, raw}]), ok = gen_tcp:send(Socket, [ - "GET /websocket HTTP/1.1\r\n" + "GET /ws_echo_timer HTTP/1.1\r\n" "Host: localhost\r\n" "Connection: Upgrade\r\n" "Origin: http://localhost\r\n" @@ -404,7 +404,7 @@ ws_text_fragments(Config) -> {ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}, {packet, raw}]), ok = gen_tcp:send(Socket, [ - "GET /ws_echo_handler HTTP/1.1\r\n" + "GET /ws_echo HTTP/1.1\r\n" "Host: localhost\r\n" "Connection: Upgrade\r\n" "Upgrade: websocket\r\n" diff --git a/test/websocket_echo_handler.erl b/test/ws_SUITE_data/ws_echo.erl index 21b0116..d4a5f07 100644 --- a/test/websocket_echo_handler.erl +++ b/test/ws_SUITE_data/ws_echo.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(websocket_echo_handler). +-module(ws_echo). -behaviour(cowboy_websocket_handler). -export([init/3]). -export([websocket_init/3, websocket_handle/3, diff --git a/test/websocket_handler.erl b/test/ws_SUITE_data/ws_echo_timer.erl index a9863ae..666a26d 100644 --- a/test/websocket_handler.erl +++ b/test/ws_SUITE_data/ws_echo_timer.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(websocket_handler). +-module(ws_echo_timer). -behaviour(cowboy_websocket_handler). -export([init/3]). -export([websocket_init/3, websocket_handle/3, diff --git a/test/websocket_handler_init_shutdown.erl b/test/ws_SUITE_data/ws_init_shutdown.erl index 7ccea05..2b1dd99 100644 --- a/test/websocket_handler_init_shutdown.erl +++ b/test/ws_SUITE_data/ws_init_shutdown.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(websocket_handler_init_shutdown). +-module(ws_init_shutdown). -behaviour(cowboy_websocket_handler). -export([init/3]). -export([websocket_init/3, websocket_handle/3, diff --git a/test/ws_send_many_handler.erl b/test/ws_SUITE_data/ws_send_many.erl index bd67814..2ed4772 100644 --- a/test/ws_send_many_handler.erl +++ b/test/ws_SUITE_data/ws_send_many.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(ws_send_many_handler). +-module(ws_send_many). -behaviour(cowboy_websocket_handler). -export([init/3]). diff --git a/test/ws_timeout_cancel_handler.erl b/test/ws_SUITE_data/ws_timeout_cancel.erl index 68b0468..9c7b72b 100644 --- a/test/ws_timeout_cancel_handler.erl +++ b/test/ws_SUITE_data/ws_timeout_cancel.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(ws_timeout_cancel_handler). +-module(ws_timeout_cancel). -behaviour(cowboy_websocket_handler). -export([init/3]). -export([websocket_init/3, websocket_handle/3, diff --git a/test/ws_timeout_hibernate_handler.erl b/test/ws_SUITE_data/ws_timeout_hibernate.erl index 41b9edd..cc91e26 100644 --- a/test/ws_timeout_hibernate_handler.erl +++ b/test/ws_SUITE_data/ws_timeout_hibernate.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(ws_timeout_hibernate_handler). +-module(ws_timeout_hibernate). -behaviour(cowboy_websocket_handler). -export([init/3]). -export([websocket_init/3, websocket_handle/3, diff --git a/test/ws_upgrade_with_opts_handler.erl b/test/ws_SUITE_data/ws_upgrade_with_opts.erl index 02d755e..b4f82fa 100644 --- a/test/ws_upgrade_with_opts_handler.erl +++ b/test/ws_SUITE_data/ws_upgrade_with_opts.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(ws_upgrade_with_opts_handler). +-module(ws_upgrade_with_opts). -behaviour(cowboy_websocket_handler). -export([init/3]). |