Permalink
Browse files

Add "Crash" button to example program.

  • Loading branch information...
1 parent f471b41 commit 51f5aa37238b175757fbd2b13ed6dcb9673b3ce8 @tonyg committed Mar 16, 2012
Showing with 12 additions and 2 deletions.
  1. +4 −0 test/server_root/htdocs/index.html
  2. +1 −0 test/server_root/htdocs/test-client.js
  3. +7 −2 test/test_jsonrpc_inets.erl
@@ -12,6 +12,10 @@
Expect to see: "Starting" and "ErlangServer: Hello, world!", followed by false.
</p>
<pre id="testOutput"></pre>
+ <p>
+ Click the following button to crash the server process:
+ </p>
+ <button id="crashButton">Crash</button>
<script>Event.observe(window, 'load', testMain);</script>
</body>
</html>
@@ -11,4 +11,5 @@ function testMain() {
function onReady() {
testService.test_proc("Hello, world!").addCallback(log);
}
+ Event.observe($("crashButton"), "click", function () { testService.crash() });
}
@@ -43,7 +43,10 @@ start() ->
[#service_proc{name = <<"test_proc">>,
idempotent = true,
params = [#service_proc_param{name = <<"value">>,
- type = <<"str">>}]}])).
+ type = <<"str">>}]},
+ #service_proc{name = <<"crash">>,
+ idempotent = false,
+ params = []}])).
start_httpd() ->
ok = case rfc4627_jsonrpc:start() of
@@ -66,7 +69,9 @@ code_change(_OldVsn, State, _Extra) ->
State.
handle_call({jsonrpc, <<"test_proc">>, _ModData, [Value]}, _From, State) ->
- {reply, {result, <<"ErlangServer: ", Value/binary>>}, State}.
+ {reply, {result, <<"ErlangServer: ", Value/binary>>}, State};
+handle_call({jsonrpc, <<"crash">>, _ModData, []}, _From, _State) ->
+ exit(deliberate_crash).
handle_cast(Request, State) ->
error_logger:error_msg("Unhandled cast in test_jsonrpc: ~p", [Request]),

0 comments on commit 51f5aa3

Please sign in to comment.