1 -module(multiplexing_test).
3 -include_lib("eunit/include/eunit.hrl").
10 start_multiplexed_server_test() ->
14 {"Multiplexing_Calculator", multiplexing__calculator_thrift},
15 {"Multiplexing_WeatherReport", multiplexing__weather_report_thrift}
18 {ok, Pid} = thrift_socket_server:start([
24 {"error_handler", ?MODULE},
25 {"Multiplexing_Calculator", ?MODULE},
26 {"Multiplexing_WeatherReport", ?MODULE}
30 {ok, [{"Multiplexing_Calculator", CalculatorClient0},
31 {"Multiplexing_WeatherReport", WeatherReportClient0}]} = thrift_client_util:new_multiplexed("127.0.0.1", Port, Services, []),
33 ?assertMatch({_, {error, {bad_args, _, _}}}, thrift_client:call(WeatherReportClient0, getTemperature, [1])),
34 ?assertMatch({_, {error, {bad_args, _, _}}}, thrift_client:call(CalculatorClient0, add, [1])),
35 ?assertMatch({_, {error, {bad_args, _, _}}}, thrift_client:call(CalculatorClient0, add, [1,1,1])),
37 ?assertMatch({_, {error, {no_function, _}}}, thrift_client:call(CalculatorClient0, getTemperature, [])),
38 ?assertMatch({_, {error, {no_function, _}}}, thrift_client:call(WeatherReportClient0, add, [41, 1])),
40 ?assertMatch({_, {ok, 42}}, thrift_client:call(CalculatorClient0, add, [41, 1])),
41 ?assertMatch({_, {ok, 42.0}}, thrift_client:call(WeatherReportClient0, getTemperature, [])),
43 thrift_socket_server:stop(Pid).
48 handle_function(add, {X, Y}) ->
51 %% WeatherReport handles
52 handle_function(getTemperature, {}) ->
55 handle_error(_F, _Reason) ->
56 %% ?debugHere, ?debugVal({_F, _Reason}),