summaryrefslogtreecommitdiff
path: root/test/erl
diff options
context:
space:
mode:
authorSteve Cohen <steve@pinterest.com>2016-06-14 00:32:48 +0200
committerJens Geyer <jensg@apache.org>2016-06-14 21:57:24 +0200
commit7ea4a87fc5c03c072a8d52cc499f1b83cfaa927b (patch)
treedcea1f2c9de439357f21805a75a12263a5517bde /test/erl
parent61b170845f256b1977c6d8a8a5906ba998560a53 (diff)
downloadthrift-7ea4a87fc5c03c072a8d52cc499f1b83cfaa927b.tar.gz
THRIFT-3834 Erlang namespacing and exception metadata
Client: Erlang Patch: Steve Cohen <steve@pinterest.com> This closes #1027
Diffstat (limited to 'test/erl')
-rw-r--r--test/erl/src/test_client.erl32
-rw-r--r--test/erl/src/test_thrift_server.erl58
2 files changed, 45 insertions, 45 deletions
diff --git a/test/erl/src/test_client.erl b/test/erl/src/test_client.erl
index f97bc8aaa..50ffc64fb 100644
--- a/test/erl/src/test_client.erl
+++ b/test/erl/src/test_client.erl
@@ -68,13 +68,13 @@ start(Args) ->
{ok, Client0} = thrift_client_util:new(
"127.0.0.1", Port, thrift_test_thrift, ClientOpts),
- DemoXtruct = #'Xtruct'{
- string_thing = <<"Zero">>,
- byte_thing = 1,
- i32_thing = 9128361,
- i64_thing = 9223372036854775807},
+ DemoXtruct = #'thrift.test.Xtruct'{
+ string_thing = <<"Zero">>,
+ byte_thing = 1,
+ i32_thing = 9128361,
+ i64_thing = 9223372036854775807},
- DemoNest = #'Xtruct2'{
+ DemoNest = #'thrift.test.Xtruct2'{
byte_thing = 7,
struct_thing = DemoXtruct,
% Note that we don't set i32_thing, it will come back as undefined
@@ -86,9 +86,9 @@ start(Args) ->
DemoDict = dict:from_list([ {Key, Key-10} || Key <- lists:seq(0,10) ]),
DemoSet = sets:from_list([ Key || Key <- lists:seq(-3,3) ]),
- DemoInsane = #'Insanity'{
+ DemoInsane = #'thrift.test.Insanity'{
userMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_FIVE, 5000}]),
- xtructs = [#'Xtruct'{ string_thing = <<"Truck">>, byte_thing = 8, i32_thing = 8, i64_thing = 8}]},
+ xtructs = [#'thrift.test.Xtruct'{ string_thing = <<"Truck">>, byte_thing = 8, i32_thing = 8, i64_thing = 8}]},
error_logger:info_msg("testVoid"),
{Client01, {ok, ok}} = thrift_client:call(Client0, testVoid, []),
@@ -126,7 +126,7 @@ start(Args) ->
{Client16, {ok, InsaneResult}} = thrift_client:call(Client15, testInsanity, [DemoInsane]),
io:format("~p~n", [InsaneResult]),
- {Client17, {ok, #'Xtruct'{string_thing = <<"Message">>}}} =
+ {Client17, {ok, #'thrift.test.Xtruct'{string_thing = <<"Message">>}}} =
thrift_client:call(Client16, testMultiException, ["Safe", "Message"]),
Client18 =
@@ -135,10 +135,10 @@ start(Args) ->
io:format("Unexpected return! ~p~n", [Result1]),
ClientS1
catch
- throw:{ClientS2, {exception, ExnS1 = #'Xception'{}}} ->
- #'Xception'{errorCode = 1001, message = <<"This is an Xception">>} = ExnS1,
+ throw:{ClientS2, {exception, ExnS1 = #'thrift.test.Xception'{}}} ->
+ #'thrift.test.Xception'{errorCode = 1001, message = <<"This is an Xception">>} = ExnS1,
ClientS2;
- throw:{ClientS2, {exception, _ExnS1 = #'Xception2'{}}} ->
+ throw:{ClientS2, {exception, _ExnS1 = #'thrift.test.Xception2'{}}} ->
io:format("Wrong exception type!~n", []),
ClientS2
end,
@@ -149,12 +149,12 @@ start(Args) ->
io:format("Unexpected return! ~p~n", [Result2]),
ClientS3
catch
- throw:{ClientS4, {exception, _ExnS2 = #'Xception'{}}} ->
+ throw:{ClientS4, {exception, _ExnS2 = #'thrift.test.Xception'{}}} ->
io:format("Wrong exception type!~n", []),
ClientS4;
- throw:{ClientS4, {exception, ExnS2 = #'Xception2'{}}} ->
- #'Xception2'{errorCode = 2002,
- struct_thing = #'Xtruct'{
+ throw:{ClientS4, {exception, ExnS2 = #'thrift.test.Xception2'{}}} ->
+ #'thrift.test.Xception2'{errorCode = 2002,
+ struct_thing = #'thrift.test.Xtruct'{
string_thing = <<"This is an Xception2">>}} = ExnS2,
ClientS4
end,
diff --git a/test/erl/src/test_thrift_server.erl b/test/erl/src/test_thrift_server.erl
index f504c734a..f3ed2f7b0 100644
--- a/test/erl/src/test_thrift_server.erl
+++ b/test/erl/src/test_thrift_server.erl
@@ -107,10 +107,10 @@ handle_function(testBinary, {S}) when is_binary(S) ->
{reply, S};
handle_function(testStruct,
- {Struct = #'Xtruct'{string_thing = String,
- byte_thing = Byte,
- i32_thing = I32,
- i64_thing = I64}})
+ {Struct = #'thrift.test.Xtruct'{string_thing = String,
+ byte_thing = Byte,
+ i32_thing = I32,
+ i64_thing = I64}})
when is_binary(String),
is_integer(Byte),
is_integer(I32),
@@ -119,8 +119,8 @@ when is_binary(String),
{reply, Struct};
handle_function(testNest,
- {Nest}) when is_record(Nest, 'Xtruct2'),
- is_record(Nest#'Xtruct2'.struct_thing, 'Xtruct') ->
+ {Nest}) when is_record(Nest, 'thrift.test.Xtruct2'),
+ is_record(Nest#'thrift.test.Xtruct2'.struct_thing, 'thrift.test.Xtruct') ->
io:format("testNest: ~p~n", [Nest]),
{reply, Nest};
@@ -159,22 +159,22 @@ handle_function(testMapMap, {Hello}) ->
{-4, dict:from_list(NegList)}]),
{reply, MapMap};
-handle_function(testInsanity, {Insanity}) when is_record(Insanity, 'Insanity') ->
- Hello = #'Xtruct'{string_thing = <<"Hello2">>,
- byte_thing = 2,
- i32_thing = 2,
- i64_thing = 2},
+handle_function(testInsanity, {Insanity}) when is_record(Insanity, 'thrift.test.Insanity') ->
+ Hello = #'thrift.test.Xtruct'{string_thing = <<"Hello2">>,
+ byte_thing = 2,
+ i32_thing = 2,
+ i64_thing = 2},
- Goodbye = #'Xtruct'{string_thing = <<"Goodbye4">>,
- byte_thing = 4,
- i32_thing = 4,
- i64_thing = 4},
- Crazy = #'Insanity'{
- userMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_EIGHT, 8}]),
- xtructs = [Goodbye]
- },
+ Goodbye = #'thrift.test.Xtruct'{string_thing = <<"Goodbye4">>,
+ byte_thing = 4,
+ i32_thing = 4,
+ i64_thing = 4},
+ Crazy = #'thrift.test.Insanity'{
+ userMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_EIGHT, 8}]),
+ xtructs = [Goodbye]
+ },
- Looney = #'Insanity'{},
+ Looney = #'thrift.test.Insanity'{},
FirstMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_TWO, Insanity},
{?THRIFT_TEST_NUMBERZ_THREE, Insanity}]),
@@ -196,16 +196,16 @@ handle_function(testMulti, Args = {Arg0, Arg1, Arg2, _Arg3, Arg4, Arg5})
is_integer(Arg5) ->
io:format("testMulti(~p)~n", [Args]),
- {reply, #'Xtruct'{string_thing = <<"Hello2">>,
- byte_thing = Arg0,
- i32_thing = Arg1,
- i64_thing = Arg2}};
+ {reply, #'thrift.test.Xtruct'{string_thing = <<"Hello2">>,
+ byte_thing = Arg0,
+ i32_thing = Arg1,
+ i64_thing = Arg2}};
handle_function(testException, {String}) when is_binary(String) ->
io:format("testException(~p)~n", [String]),
case String of
<<"Xception">> ->
- throw(#'Xception'{errorCode = 1001,
+ throw(#'thrift.test.Xception'{errorCode = 1001,
message = String});
<<"TException">> ->
throw({?TApplicationException_Structure});
@@ -217,14 +217,14 @@ handle_function(testMultiException, {Arg0, Arg1}) ->
io:format("testMultiException(~p, ~p)~n", [Arg0, Arg1]),
case Arg0 of
<<"Xception">> ->
- throw(#'Xception'{errorCode = 1001,
+ throw(#'thrift.test.Xception'{errorCode = 1001,
message = <<"This is an Xception">>});
<<"Xception2">> ->
- throw(#'Xception2'{errorCode = 2002,
+ throw(#'thrift.test.Xception2'{errorCode = 2002,
struct_thing =
- #'Xtruct'{string_thing = <<"This is an Xception2">>}});
+ #'thrift.test.Xtruct'{string_thing = <<"This is an Xception2">>}});
_ ->
- {reply, #'Xtruct'{string_thing = Arg1}}
+ {reply, #'thrift.test.Xtruct'{string_thing = Arg1}}
end;
handle_function(testOneway, {Seconds}) ->