Moving from govendor to dep, updated dependencies (#48)
* Moving from govendor to dep. * Making the pull request template more friendly. * Fixing akward space in PR template. * goimports run on whole project using ` goimports -w $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./gen-go/*")` source of command: https://gist.github.com/bgentry/fd1ffef7dbde01857f66
This commit is contained in:
parent
9631aa3aab
commit
8d445c1c77
2186 changed files with 400410 additions and 352 deletions
3
vendor/git.apache.org/thrift.git/lib/erl/test/Thrift1151.thrift
generated
vendored
Normal file
3
vendor/git.apache.org/thrift.git/lib/erl/test/Thrift1151.thrift
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
struct StructA { 1: i16 x; }
|
||||
struct StructB { 1: i32 x; }
|
||||
struct StructC { 1: StructA x; }
|
34
vendor/git.apache.org/thrift.git/lib/erl/test/Thrift1475.thrift
generated
vendored
Normal file
34
vendor/git.apache.org/thrift.git/lib/erl/test/Thrift1475.thrift
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
struct StructB
|
||||
{
|
||||
1: string x
|
||||
}
|
||||
|
||||
struct StructA
|
||||
{
|
||||
1: string a,
|
||||
2: binary b,
|
||||
3: optional string c,
|
||||
4: optional binary d,
|
||||
5: required string e,
|
||||
6: required binary f,
|
||||
7: string g = "foo",
|
||||
8: i32 h,
|
||||
9: optional i32 i,
|
||||
10: required i32 j,
|
||||
11: required i32 k = 5,
|
||||
12: double l,
|
||||
13: optional double m,
|
||||
14: required double n,
|
||||
15: double o = 3.14159,
|
||||
16: list<string> string_list,
|
||||
17: list<byte> byte_list = [1, 2, 3],
|
||||
18: required list<string> rsl,
|
||||
19: optional list<string> osl,
|
||||
20: set<string> string_set,
|
||||
21: required set<string> rss,
|
||||
22: optional set<string> oss,
|
||||
23: map<string, string> string_map,
|
||||
24: required map<string, string> rsm,
|
||||
25: optional map<string, string> osm,
|
||||
26: StructB structb
|
||||
}
|
33
vendor/git.apache.org/thrift.git/lib/erl/test/flags/LegacyNames.thrift
generated
vendored
Normal file
33
vendor/git.apache.org/thrift.git/lib/erl/test/flags/LegacyNames.thrift
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
enum Numberz
|
||||
{
|
||||
ONE = 1,
|
||||
TWO,
|
||||
THREE,
|
||||
FIVE = 5,
|
||||
SIX,
|
||||
EIGHT = 8
|
||||
}
|
||||
|
||||
const Numberz myNumberz = Numberz.ONE;
|
||||
|
||||
struct CapitalizedStruct
|
||||
{
|
||||
1: i32 Id,
|
||||
2: binary message
|
||||
}
|
||||
|
||||
struct ListCapitalizedStructs
|
||||
{
|
||||
1: list<CapitalizedStruct> structs
|
||||
}
|
||||
|
||||
exception Xception {
|
||||
1: i32 errorCode,
|
||||
2: binary message
|
||||
}
|
||||
|
||||
service LegacyNames
|
||||
{
|
||||
ListCapitalizedStructs Names(1: CapitalizedStruct foo, 2: CapitalizedStruct bar)
|
||||
throws(1: Xception err)
|
||||
}
|
23
vendor/git.apache.org/thrift.git/lib/erl/test/flags/Thrift3214.thrift
generated
vendored
Normal file
23
vendor/git.apache.org/thrift.git/lib/erl/test/flags/Thrift3214.thrift
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
struct StringMap
|
||||
{
|
||||
1: map<i32, string> data = {1: "a", 2: "b"};
|
||||
}
|
69
vendor/git.apache.org/thrift.git/lib/erl/test/legacy_names_test.erl
generated
vendored
Normal file
69
vendor/git.apache.org/thrift.git/lib/erl/test/legacy_names_test.erl
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
%%
|
||||
%% Licensed to the Apache Software Foundation (ASF) under one
|
||||
%% or more contributor license agreements. See the NOTICE file
|
||||
%% distributed with this work for additional information
|
||||
%% regarding copyright ownership. The ASF licenses this file
|
||||
%% to you under the Apache License, Version 2.0 (the
|
||||
%% "License"); you may not use this file except in compliance
|
||||
%% with the License. You may obtain a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing,
|
||||
%% software distributed under the License is distributed on an
|
||||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
%% KIND, either express or implied. See the License for the
|
||||
%% specific language governing permissions and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
|
||||
-module(legacy_names_test).
|
||||
-compile(export_all).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
-include("gen-erl/legacyNames_constants.hrl").
|
||||
|
||||
record_generation_test_() ->
|
||||
[
|
||||
{"capitalizedStruct record", ?_assertMatch(
|
||||
{capitalizedStruct, _, _},
|
||||
#capitalizedStruct{id=null,message=null}
|
||||
)}
|
||||
].
|
||||
|
||||
struct_info_test_() ->
|
||||
[
|
||||
{"capitalizedStruct extended definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, i32, 'id', undefined},
|
||||
{2, undefined, string, 'message', undefined}
|
||||
]},
|
||||
legacyNames_types:struct_info_ext(capitalizedStruct)
|
||||
)},
|
||||
{"listCapitalizedStructs extended definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, {list, {struct, {'legacyNames_types', 'capitalizedStruct'}}}, 'structs', []}
|
||||
]},
|
||||
legacyNames_types:struct_info_ext(listCapitalizedStructs)
|
||||
)}
|
||||
].
|
||||
|
||||
service_info_test_() ->
|
||||
[
|
||||
{"names params", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, {struct, {'legacyNames_types', 'capitalizedStruct'}}},
|
||||
{2, {struct, {'legacyNames_types', 'capitalizedStruct'}}}
|
||||
]},
|
||||
legacyNames_thrift:function_info(names, params_type)
|
||||
)},
|
||||
{"names reply", ?_assertEqual(
|
||||
{struct, {'legacyNames_types', 'listCapitalizedStructs'}},
|
||||
legacyNames_thrift:function_info(names, reply_type)
|
||||
)},
|
||||
{"names exceptions", ?_assertEqual(
|
||||
{struct, [{1, {struct, {'legacyNames_types', 'xception'}}}]},
|
||||
legacyNames_thrift:function_info(names, exceptions)
|
||||
)}
|
||||
].
|
7
vendor/git.apache.org/thrift.git/lib/erl/test/multiplexing.thrift
generated
vendored
Normal file
7
vendor/git.apache.org/thrift.git/lib/erl/test/multiplexing.thrift
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
service Multiplexing_Calculator {
|
||||
i32 add(1: i32 x, 2: i32 y)
|
||||
}
|
||||
|
||||
service Multiplexing_WeatherReport {
|
||||
double getTemperature()
|
||||
}
|
57
vendor/git.apache.org/thrift.git/lib/erl/test/multiplexing_test.erl
generated
vendored
Normal file
57
vendor/git.apache.org/thrift.git/lib/erl/test/multiplexing_test.erl
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
-module(multiplexing_test).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
-export([
|
||||
handle_function/2
|
||||
,handle_error/2
|
||||
]).
|
||||
|
||||
start_multiplexed_server_test() ->
|
||||
|
||||
Port = 9090,
|
||||
Services = [
|
||||
{"Multiplexing_Calculator", multiplexing__calculator_thrift},
|
||||
{"Multiplexing_WeatherReport", multiplexing__weather_report_thrift}
|
||||
],
|
||||
|
||||
{ok, Pid} = thrift_socket_server:start([
|
||||
{ip, "127.0.0.1"},
|
||||
{port, Port},
|
||||
{name, ?MODULE},
|
||||
{service, Services},
|
||||
{handler, [
|
||||
{"error_handler", ?MODULE},
|
||||
{"Multiplexing_Calculator", ?MODULE},
|
||||
{"Multiplexing_WeatherReport", ?MODULE}
|
||||
]}
|
||||
]),
|
||||
|
||||
{ok, [{"Multiplexing_Calculator", CalculatorClient0},
|
||||
{"Multiplexing_WeatherReport", WeatherReportClient0}]} = thrift_client_util:new_multiplexed("127.0.0.1", Port, Services, []),
|
||||
|
||||
?assertMatch({_, {error, {bad_args, _, _}}}, thrift_client:call(WeatherReportClient0, getTemperature, [1])),
|
||||
?assertMatch({_, {error, {bad_args, _, _}}}, thrift_client:call(CalculatorClient0, add, [1])),
|
||||
?assertMatch({_, {error, {bad_args, _, _}}}, thrift_client:call(CalculatorClient0, add, [1,1,1])),
|
||||
|
||||
?assertMatch({_, {error, {no_function, _}}}, thrift_client:call(CalculatorClient0, getTemperature, [])),
|
||||
?assertMatch({_, {error, {no_function, _}}}, thrift_client:call(WeatherReportClient0, add, [41, 1])),
|
||||
|
||||
?assertMatch({_, {ok, 42}}, thrift_client:call(CalculatorClient0, add, [41, 1])),
|
||||
?assertMatch({_, {ok, 42.0}}, thrift_client:call(WeatherReportClient0, getTemperature, [])),
|
||||
|
||||
thrift_socket_server:stop(Pid).
|
||||
|
||||
%% HANDLE FUNCTIONS
|
||||
|
||||
%% Calculator handles
|
||||
handle_function(add, {X, Y}) ->
|
||||
{reply, X + Y};
|
||||
|
||||
%% WeatherReport handles
|
||||
handle_function(getTemperature, {}) ->
|
||||
{reply, 42.0}.
|
||||
|
||||
handle_error(_F, _Reason) ->
|
||||
%% ?debugHere, ?debugVal({_F, _Reason}),
|
||||
ok.
|
299
vendor/git.apache.org/thrift.git/lib/erl/test/name_conflict_test.erl
generated
vendored
Normal file
299
vendor/git.apache.org/thrift.git/lib/erl/test/name_conflict_test.erl
generated
vendored
Normal file
|
@ -0,0 +1,299 @@
|
|||
%%
|
||||
%% Licensed to the Apache Software Foundation (ASF) under one
|
||||
%% or more contributor license agreements. See the NOTICE file
|
||||
%% distributed with this work for additional information
|
||||
%% regarding copyright ownership. The ASF licenses this file
|
||||
%% to you under the Apache License, Version 2.0 (the
|
||||
%% "License"); you may not use this file except in compliance
|
||||
%% with the License. You may obtain a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing,
|
||||
%% software distributed under the License is distributed on an
|
||||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
%% KIND, either express or implied. See the License for the
|
||||
%% specific language governing permissions and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
|
||||
-module(name_conflict_test).
|
||||
-compile(export_all).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
-include("gen-erl/name_conflict_test_constants.hrl").
|
||||
|
||||
record_generation_test_() ->
|
||||
[
|
||||
{"using record", ?_assertMatch(
|
||||
{using, _, _},
|
||||
#using{single=null,integer=null}
|
||||
)},
|
||||
{"delegate record", ?_assertMatch(
|
||||
{delegate, _, _},
|
||||
#delegate{partial=null,delegate=null}
|
||||
)},
|
||||
{"get record", ?_assertMatch(
|
||||
{get, _},
|
||||
#get{sbyte=null}
|
||||
)},
|
||||
{"partial record", ?_assertMatch(
|
||||
{partial, _, _, _},
|
||||
#partial{using=null}
|
||||
)},
|
||||
{"ClassAndProp record", ?_assertMatch(
|
||||
{'ClassAndProp', _, _, _, _},
|
||||
#'ClassAndProp'{
|
||||
'ClassAndProp'=null,
|
||||
'ClassAndProp_'=null,
|
||||
'ClassAndProp__'=null,
|
||||
'ClassAndProper'=null
|
||||
}
|
||||
)},
|
||||
{"second_chance record", ?_assertMatch(
|
||||
{second_chance, _, _, _, _},
|
||||
#second_chance{
|
||||
'SECOND_CHANCE'=null,
|
||||
'SECOND_CHANCE_'=null,
|
||||
'SECOND_CHANCE__'=null,
|
||||
'SECOND_CHANCES'=null
|
||||
}
|
||||
)},
|
||||
{"NOW_EAT_THIS record", ?_assertMatch(
|
||||
{'NOW_EAT_THIS', _, _, _, _},
|
||||
#'NOW_EAT_THIS'{
|
||||
now_eat_this=null,
|
||||
now_eat_this_=null,
|
||||
now_eat_this__=null,
|
||||
now_eat_this_and_this=null
|
||||
}
|
||||
)},
|
||||
{"TheEdgeCase record", ?_assertMatch(
|
||||
{'TheEdgeCase', _, _, _, _, _, _},
|
||||
#'TheEdgeCase'{
|
||||
theEdgeCase=null,
|
||||
theEdgeCase_=null,
|
||||
theEdgeCase__=null,
|
||||
'TheEdgeCase'=null,
|
||||
'TheEdgeCase_'=null,
|
||||
'TheEdgeCase__'=null
|
||||
}
|
||||
)},
|
||||
{"Tricky_ record", ?_assertMatch(
|
||||
{'Tricky_', _, _},
|
||||
#'Tricky_'{tricky=null,'Tricky'=null}
|
||||
)},
|
||||
{"Nested record", ?_assertMatch(
|
||||
{'Nested', _, _, _, _, _, _},
|
||||
#'Nested'{
|
||||
'ClassAndProp'=null,
|
||||
second_chance=null,
|
||||
'NOW_EAT_THIS'=null,
|
||||
'TheEdgeCase'=null,
|
||||
'Tricky_'=null,
|
||||
'Nested'=null
|
||||
}
|
||||
)},
|
||||
{"Problem_ record", ?_assertMatch(
|
||||
{'Problem_', _, _},
|
||||
#'Problem_'{problem=null,'Problem'=null}
|
||||
)}
|
||||
].
|
||||
|
||||
struct_info_test_() ->
|
||||
[
|
||||
{"using definition", ?_assertEqual(
|
||||
{struct, [{1, double},{2, double}]},
|
||||
name_conflict_test_types:struct_info(using)
|
||||
)},
|
||||
{"delegate definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, string},
|
||||
{2, {struct, {name_conflict_test_types, delegate}}}
|
||||
]},
|
||||
name_conflict_test_types:struct_info(delegate)
|
||||
)},
|
||||
{"get definition", ?_assertEqual(
|
||||
{struct, [{1, bool}]},
|
||||
name_conflict_test_types:struct_info(get)
|
||||
)},
|
||||
{"partial definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, {struct, {name_conflict_test_types, using}}},
|
||||
{2, bool},
|
||||
{3, bool}
|
||||
]},
|
||||
name_conflict_test_types:struct_info(partial)
|
||||
)},
|
||||
{"ClassAndProp definition", ?_assertEqual(
|
||||
{struct, [{1, bool},{2, bool},{3, bool},{4, bool}]},
|
||||
name_conflict_test_types:struct_info('ClassAndProp')
|
||||
)},
|
||||
{"second_chance definition", ?_assertEqual(
|
||||
{struct, [{1, bool},{2, bool},{3, bool},{4, bool}]},
|
||||
name_conflict_test_types:struct_info(second_chance)
|
||||
)},
|
||||
{"NOW_EAT_THIS definition", ?_assertEqual(
|
||||
{struct, [{1, bool},{2, bool},{3, bool},{4, bool}]},
|
||||
name_conflict_test_types:struct_info('NOW_EAT_THIS')
|
||||
)},
|
||||
{"TheEdgeCase definition", ?_assertEqual(
|
||||
{struct, [{1, bool},{2, bool},{3, bool},{4, bool},{5, bool},{6, bool}]},
|
||||
name_conflict_test_types:struct_info('TheEdgeCase')
|
||||
)},
|
||||
{"Tricky_ definition", ?_assertEqual(
|
||||
{struct, [{1, bool},{2, bool}]},
|
||||
name_conflict_test_types:struct_info('Tricky_')
|
||||
)},
|
||||
{"Nested definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, {struct, {name_conflict_test_types, 'ClassAndProp'}}},
|
||||
{2, {struct, {name_conflict_test_types, second_chance}}},
|
||||
{3, {struct, {name_conflict_test_types, 'NOW_EAT_THIS'}}},
|
||||
{4, {struct, {name_conflict_test_types, 'TheEdgeCase'}}},
|
||||
{5, {struct, {name_conflict_test_types, 'Tricky_'}}},
|
||||
{6, {struct, {name_conflict_test_types, 'Nested'}}}
|
||||
]},
|
||||
name_conflict_test_types:struct_info('Nested')
|
||||
)},
|
||||
{"Problem_ definition", ?_assertEqual(
|
||||
{struct, [{1, bool},{2, bool}]},
|
||||
name_conflict_test_types:struct_info('Problem_')
|
||||
)},
|
||||
{"using extended definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, double, single, undefined},
|
||||
{2, undefined, double, integer, undefined}
|
||||
]},
|
||||
name_conflict_test_types:struct_info_ext(using)
|
||||
)},
|
||||
{"delegate extended definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, string, partial, undefined},
|
||||
{2, undefined, {struct, {name_conflict_test_types, delegate}}, delegate, undefined}
|
||||
]},
|
||||
name_conflict_test_types:struct_info_ext(delegate)
|
||||
)},
|
||||
{"get extended definition", ?_assertEqual(
|
||||
{struct, [{1, undefined, bool, sbyte, undefined}]},
|
||||
name_conflict_test_types:struct_info_ext(get)
|
||||
)},
|
||||
{"partial extended definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, {struct, {name_conflict_test_types, using}}, using, #using{}},
|
||||
{2, undefined, bool, read, undefined},
|
||||
{3, undefined, bool, write, undefined}
|
||||
]},
|
||||
name_conflict_test_types:struct_info_ext(partial)
|
||||
)},
|
||||
{"ClassAndProp extended definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, bool, 'ClassAndProp', undefined},
|
||||
{2, undefined, bool, 'ClassAndProp_', undefined},
|
||||
{3, undefined, bool, 'ClassAndProp__', undefined},
|
||||
{4, undefined, bool, 'ClassAndProper', undefined}
|
||||
]},
|
||||
name_conflict_test_types:struct_info_ext('ClassAndProp')
|
||||
)},
|
||||
{"second_chance extended definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, bool, 'SECOND_CHANCE', undefined},
|
||||
{2, undefined, bool, 'SECOND_CHANCE_', undefined},
|
||||
{3, undefined, bool, 'SECOND_CHANCE__', undefined},
|
||||
{4, undefined, bool, 'SECOND_CHANCES', undefined}
|
||||
]},
|
||||
name_conflict_test_types:struct_info_ext(second_chance)
|
||||
)},
|
||||
{"NOW_EAT_THIS extended definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, bool, now_eat_this, undefined},
|
||||
{2, undefined, bool, now_eat_this_, undefined},
|
||||
{3, undefined, bool, now_eat_this__, undefined},
|
||||
{4, undefined, bool, now_eat_this_and_this, undefined}
|
||||
]},
|
||||
name_conflict_test_types:struct_info_ext('NOW_EAT_THIS')
|
||||
)},
|
||||
{"TheEdgeCase extended definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, bool, theEdgeCase, undefined},
|
||||
{2, undefined, bool, theEdgeCase_, undefined},
|
||||
{3, undefined, bool, theEdgeCase__, undefined},
|
||||
{4, undefined, bool, 'TheEdgeCase', undefined},
|
||||
{5, undefined, bool, 'TheEdgeCase_', undefined},
|
||||
{6, undefined, bool, 'TheEdgeCase__', undefined}
|
||||
]},
|
||||
name_conflict_test_types:struct_info_ext('TheEdgeCase')
|
||||
)},
|
||||
{"Tricky_ extended definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, bool, tricky, undefined},
|
||||
{2, undefined, bool, 'Tricky', undefined}
|
||||
]},
|
||||
name_conflict_test_types:struct_info_ext('Tricky_')
|
||||
)},
|
||||
{"Nested extended definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, {struct, {
|
||||
name_conflict_test_types,
|
||||
'ClassAndProp'
|
||||
}}, 'ClassAndProp', #'ClassAndProp'{}},
|
||||
{2, undefined, {struct, {
|
||||
name_conflict_test_types,
|
||||
second_chance
|
||||
}}, second_chance, #second_chance{}},
|
||||
{3, undefined, {struct, {
|
||||
name_conflict_test_types,
|
||||
'NOW_EAT_THIS'
|
||||
}}, 'NOW_EAT_THIS', #'NOW_EAT_THIS'{}},
|
||||
{4, undefined, {struct, {
|
||||
name_conflict_test_types,
|
||||
'TheEdgeCase'
|
||||
}}, 'TheEdgeCase', #'TheEdgeCase'{}},
|
||||
{5, undefined, {struct, {
|
||||
name_conflict_test_types,
|
||||
'Tricky_'
|
||||
}}, 'Tricky_', #'Tricky_'{}},
|
||||
{6, undefined, {struct, {
|
||||
name_conflict_test_types,
|
||||
'Nested'
|
||||
}}, 'Nested', undefined}
|
||||
]},
|
||||
name_conflict_test_types:struct_info_ext('Nested')
|
||||
)},
|
||||
{"Problem_ extended definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, bool, problem, undefined},
|
||||
{2, undefined, bool, 'Problem', undefined}
|
||||
]},
|
||||
name_conflict_test_types:struct_info_ext('Problem_')
|
||||
)}
|
||||
].
|
||||
|
||||
service_info_test_() ->
|
||||
[
|
||||
{"event params", ?_assertEqual(
|
||||
{struct, [{1, {struct, {name_conflict_test_types, partial}}}]},
|
||||
extern_thrift:function_info(event, params_type)
|
||||
)},
|
||||
{"event reply", ?_assertEqual(
|
||||
{struct, {name_conflict_test_types, delegate}},
|
||||
extern_thrift:function_info(event, reply_type)
|
||||
)},
|
||||
{"event exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
extern_thrift:function_info(event, exceptions)
|
||||
)},
|
||||
{"Foo params", ?_assertEqual(
|
||||
{struct, [{1, {struct, {name_conflict_test_types, 'Nested'}}}]},
|
||||
extern_thrift:function_info('Foo', params_type)
|
||||
)},
|
||||
{"Foo reply", ?_assertEqual(
|
||||
{struct, []},
|
||||
extern_thrift:function_info('Foo', reply_type)
|
||||
)},
|
||||
{"Foo exceptions", ?_assertEqual(
|
||||
{struct, [{1, {struct, {name_conflict_test_types, 'Problem_'}}}]},
|
||||
extern_thrift:function_info('Foo', exceptions)
|
||||
)}
|
||||
].
|
64
vendor/git.apache.org/thrift.git/lib/erl/test/stress_server.erl
generated
vendored
Normal file
64
vendor/git.apache.org/thrift.git/lib/erl/test/stress_server.erl
generated
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
%%
|
||||
%% Licensed to the Apache Software Foundation (ASF) under one
|
||||
%% or more contributor license agreements. See the NOTICE file
|
||||
%% distributed with this work for additional information
|
||||
%% regarding copyright ownership. The ASF licenses this file
|
||||
%% to you under the Apache License, Version 2.0 (the
|
||||
%% "License"); you may not use this file except in compliance
|
||||
%% with the License. You may obtain a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing,
|
||||
%% software distributed under the License is distributed on an
|
||||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
%% KIND, either express or implied. See the License for the
|
||||
%% specific language governing permissions and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
|
||||
-module(stress_server).
|
||||
|
||||
|
||||
-export([start_link/1,
|
||||
|
||||
handle_function/2,
|
||||
|
||||
echoVoid/0,
|
||||
echoByte/1,
|
||||
echoI32/1,
|
||||
echoI64/1,
|
||||
echoString/1,
|
||||
echoList/1,
|
||||
echoSet/1,
|
||||
echoMap/1
|
||||
]).
|
||||
|
||||
start_link(Port) ->
|
||||
thrift_server:start_link(Port, service_thrift, ?MODULE).
|
||||
|
||||
|
||||
handle_function(Function, Args) ->
|
||||
case apply(?MODULE, Function, tuple_to_list(Args)) of
|
||||
ok ->
|
||||
ok;
|
||||
Else -> {reply, Else}
|
||||
end.
|
||||
|
||||
|
||||
echoVoid() ->
|
||||
ok.
|
||||
echoByte(X) ->
|
||||
X.
|
||||
echoI32(X) ->
|
||||
X.
|
||||
echoI64(X) ->
|
||||
X.
|
||||
echoString(X) ->
|
||||
X.
|
||||
echoList(X) ->
|
||||
X.
|
||||
echoSet(X) ->
|
||||
X.
|
||||
echoMap(X) ->
|
||||
X.
|
99
vendor/git.apache.org/thrift.git/lib/erl/test/test_disklog.erl
generated
vendored
Normal file
99
vendor/git.apache.org/thrift.git/lib/erl/test/test_disklog.erl
generated
vendored
Normal file
|
@ -0,0 +1,99 @@
|
|||
%%
|
||||
%% Licensed to the Apache Software Foundation (ASF) under one
|
||||
%% or more contributor license agreements. See the NOTICE file
|
||||
%% distributed with this work for additional information
|
||||
%% regarding copyright ownership. The ASF licenses this file
|
||||
%% to you under the Apache License, Version 2.0 (the
|
||||
%% "License"); you may not use this file except in compliance
|
||||
%% with the License. You may obtain a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing,
|
||||
%% software distributed under the License is distributed on an
|
||||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
%% KIND, either express or implied. See the License for the
|
||||
%% specific language governing permissions and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
|
||||
-module(test_disklog).
|
||||
|
||||
-ifdef(TEST).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
disklog_test() ->
|
||||
{ok, TransportFactory} =
|
||||
thrift_disk_log_transport:new_transport_factory(
|
||||
test_disklog,
|
||||
[{file, "./test_log"},
|
||||
{size, {1024*1024, 10}}]),
|
||||
{ok, ProtocolFactory} =
|
||||
thrift_binary_protocol:new_protocol_factory( TransportFactory, []),
|
||||
{ok, Proto} = ProtocolFactory(),
|
||||
{ok, Client0} = thrift_client:new(Proto, thrift_test_thrift),
|
||||
|
||||
io:format("Client started~n"),
|
||||
|
||||
% We have to make oneway calls into this client only since otherwise it
|
||||
% will try to read from the disklog and go boom.
|
||||
{Client1, {ok, ok}} = thrift_client:call(Client0, testOneway, [16#deadbeef]),
|
||||
io:format("Call written~n"),
|
||||
|
||||
% Use the send_call method to write a non-oneway call into the log
|
||||
{Client2, ok} =
|
||||
thrift_client:send_call(Client1, testString, [<<"hello world">>]),
|
||||
io:format("Non-oneway call sent~n"),
|
||||
|
||||
{_Client3, ok} = thrift_client:close(Client2),
|
||||
io:format("Client closed~n"),
|
||||
|
||||
lists:foreach(fun(File) -> file:delete(File) end, [
|
||||
"./test_log.1",
|
||||
"./test_log.idx",
|
||||
"./test_log.siz"
|
||||
]),
|
||||
io:format("Cleaning up test files~n"),
|
||||
|
||||
ok.
|
||||
|
||||
disklog_base64_test() ->
|
||||
{ok, TransportFactory} =
|
||||
thrift_disk_log_transport:new_transport_factory(
|
||||
test_disklog,
|
||||
[{file, "./test_b64_log"},
|
||||
{size, {1024*1024, 10}}]),
|
||||
{ok, B64Factory} =
|
||||
thrift_base64_transport:new_transport_factory(TransportFactory),
|
||||
{ok, BufFactory} =
|
||||
thrift_buffered_transport:new_transport_factory(B64Factory),
|
||||
{ok, ProtocolFactory} =
|
||||
thrift_binary_protocol:new_protocol_factory(BufFactory, []),
|
||||
{ok, Proto} = ProtocolFactory(),
|
||||
{ok, Client0} = thrift_client:new(Proto, thrift_test_thrift),
|
||||
|
||||
io:format("Client started~n"),
|
||||
|
||||
% We have to make oneway calls into this client only since otherwise
|
||||
% it will try to read from the disklog and go boom.
|
||||
{Client1, {ok, ok}} = thrift_client:call(Client0, testOneway, [16#deadbeef]),
|
||||
io:format("Call written~n"),
|
||||
|
||||
% Use the send_call method to write a non-oneway call into the log
|
||||
{Client2, ok} =
|
||||
thrift_client:send_call(Client1, testString, [<<"hello world">>]),
|
||||
io:format("Non-oneway call sent~n"),
|
||||
|
||||
{_Client3, ok} = thrift_client:close(Client2),
|
||||
io:format("Client closed~n"),
|
||||
|
||||
lists:foreach(fun(File) -> file:delete(File) end, [
|
||||
"./test_b64_log.1",
|
||||
"./test_b64_log.idx",
|
||||
"./test_b64_log.siz"
|
||||
]),
|
||||
io:format("Cleaning up test files~n"),
|
||||
|
||||
ok.
|
||||
|
||||
-endif.
|
34
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_1151.erl
generated
vendored
Normal file
34
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_1151.erl
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
-module(test_thrift_1151).
|
||||
|
||||
-include("gen-erl/thrift1151_types.hrl").
|
||||
|
||||
-ifdef(TEST).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
unmatched_struct_test() ->
|
||||
S1 = #'StructC'{x=#'StructB'{x=1}},
|
||||
{ok, Transport} = thrift_memory_buffer:new(),
|
||||
{ok, Protocol} = thrift_binary_protocol:new(Transport),
|
||||
?assertException(
|
||||
error,
|
||||
struct_unmatched,
|
||||
thrift_protocol:write(
|
||||
Protocol,
|
||||
{{struct, element(2, thrift1151_types:struct_info('StructC'))}, S1}
|
||||
)
|
||||
).
|
||||
|
||||
badarg_test() ->
|
||||
S2 = #'StructC'{x=#'StructA'{x="1"}},
|
||||
{ok, Transport} = thrift_memory_buffer:new(),
|
||||
{ok, Protocol} = thrift_binary_protocol:new(Transport),
|
||||
?assertException(
|
||||
error,
|
||||
badarg,
|
||||
thrift_protocol:write(
|
||||
Protocol,
|
||||
{{struct, element(2, thrift1151_types:struct_info('StructC'))}, S2}
|
||||
)
|
||||
).
|
||||
|
||||
-endif.
|
60
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_3214.erl
generated
vendored
Normal file
60
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_3214.erl
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
%%
|
||||
%% Licensed to the Apache Software Foundation (ASF) under one
|
||||
%% or more contributor license agreements. See the NOTICE file
|
||||
%% distributed with this work for additional information
|
||||
%% regarding copyright ownership. The ASF licenses this file
|
||||
%% to you under the Apache License, Version 2.0 (the
|
||||
%% "License"); you may not use this file except in compliance
|
||||
%% with the License. You may obtain a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing,
|
||||
%% software distributed under the License is distributed on an
|
||||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
%% KIND, either express or implied. See the License for the
|
||||
%% specific language governing permissions and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
|
||||
-module(test_thrift_3214).
|
||||
-compile(export_all).
|
||||
|
||||
-include("gen-erl/thrift3214_types.hrl").
|
||||
|
||||
-ifdef(TEST).
|
||||
-ifndef(otp16_or_less).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
record_generation_test_() ->
|
||||
[
|
||||
{"StringMap record", ?_assertMatch(
|
||||
{'StringMap', _},
|
||||
#'StringMap'{data=#{50 => "foo"}}
|
||||
)},
|
||||
{"StringMap record defaults", ?_assertEqual(
|
||||
{'StringMap', #{1 => "a", 2 => "b"}},
|
||||
#'StringMap'{}
|
||||
)},
|
||||
{"StringMap record dict from list", ?_assertNotEqual(
|
||||
{'StringMap', dict:from_list([{1, "a"}, {2, "b"}])},
|
||||
#'StringMap'{}
|
||||
)},
|
||||
{"StringMap record map from list", ?_assertEqual(
|
||||
{'StringMap', maps:from_list([{1, "a"}, {2, "b"}])},
|
||||
#'StringMap'{}
|
||||
)}
|
||||
].
|
||||
|
||||
struct_info_test_() ->
|
||||
[
|
||||
{"StringMap extended definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, {map, i32, string}, 'data', #{1 => "a", 2 => "b"}}
|
||||
]},
|
||||
thrift3214_types:struct_info_ext('StringMap')
|
||||
)}
|
||||
].
|
||||
|
||||
-endif.
|
||||
-endif.
|
359
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_buffered_transport.erl
generated
vendored
Normal file
359
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_buffered_transport.erl
generated
vendored
Normal file
|
@ -0,0 +1,359 @@
|
|||
%%
|
||||
%% Licensed to the Apache Software Foundation (ASF) under one
|
||||
%% or more contributor license agreements. See the NOTICE file
|
||||
%% distributed with this work for additional information
|
||||
%% regarding copyright ownership. The ASF licenses this file
|
||||
%% to you under the Apache License, Version 2.0 (the
|
||||
%% "License"); you may not use this file except in compliance
|
||||
%% with the License. You may obtain a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing,
|
||||
%% software distributed under the License is distributed on an
|
||||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
%% KIND, either express or implied. See the License for the
|
||||
%% specific language governing permissions and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
|
||||
-module(test_thrift_buffered_transport).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
|
||||
new(Transport) -> thrift_buffered_transport:new(Transport).
|
||||
|
||||
new_test_() ->
|
||||
[
|
||||
{"new buffered membuffer", ?_assertMatch(
|
||||
{ok, {t_transport, thrift_buffered_transport, {t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, []}},
|
||||
[]
|
||||
}}},
|
||||
new({t_transport, thrift_membuffer_transport, {t_membuffer, []}})
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
read(Frame, Bytes) -> thrift_buffered_transport:read(Frame, Bytes).
|
||||
|
||||
read_test_() ->
|
||||
[
|
||||
{"read zero bytes from an empty buffered membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[]
|
||||
},
|
||||
{ok, <<>>}
|
||||
},
|
||||
read(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[]
|
||||
},
|
||||
0
|
||||
)
|
||||
)},
|
||||
{"read 1 byte from an empty buffered membuffer", ?_assertMatch(
|
||||
{_, {ok, <<>>}},
|
||||
read(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[]
|
||||
},
|
||||
1
|
||||
)
|
||||
)},
|
||||
{"read zero bytes from nonempty buffered membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer,
|
||||
<<"hallo world">>
|
||||
}},
|
||||
[]
|
||||
},
|
||||
{ok, <<>>}
|
||||
},
|
||||
read(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer,
|
||||
<<"hallo world">>
|
||||
}},
|
||||
[]
|
||||
},
|
||||
0
|
||||
)
|
||||
)},
|
||||
{"read 1 byte from nonempty buffered membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<"allo world">>}},
|
||||
[]
|
||||
},
|
||||
{ok, <<"h">>}
|
||||
},
|
||||
read(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}},
|
||||
[]
|
||||
},
|
||||
1
|
||||
)
|
||||
)},
|
||||
{"read 1 byte from nonempty buffer", ?_assertMatch(
|
||||
{
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<"allo world">>}},
|
||||
[]
|
||||
},
|
||||
{ok, <<"h">>}
|
||||
},
|
||||
read(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}},
|
||||
[]
|
||||
},
|
||||
1
|
||||
)
|
||||
)},
|
||||
{"read a zillion bytes from nonempty buffered membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[]
|
||||
},
|
||||
{ok, <<"hallo world">>}
|
||||
},
|
||||
read(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}},
|
||||
[]
|
||||
},
|
||||
65536
|
||||
)
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
read_exact(Frame, Bytes) -> thrift_buffered_transport:read_exact(Frame, Bytes).
|
||||
|
||||
read_exact_test_() ->
|
||||
[
|
||||
{"read exactly zero bytes from an empty buffered membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[]
|
||||
},
|
||||
{ok, <<>>}
|
||||
},
|
||||
read_exact(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[]
|
||||
},
|
||||
0
|
||||
)
|
||||
)},
|
||||
{"read exactly 1 byte from an empty buffered membuffer", ?_assertMatch(
|
||||
{_, {error, eof}},
|
||||
read_exact(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[]
|
||||
},
|
||||
1
|
||||
)
|
||||
)},
|
||||
{"read exactly zero bytes from nonempty buffered membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}},
|
||||
[]
|
||||
},
|
||||
{ok, <<>>}
|
||||
},
|
||||
read_exact(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}},
|
||||
[]
|
||||
},
|
||||
0
|
||||
)
|
||||
)},
|
||||
{"read exactly 1 byte from nonempty buffered membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<"allo world">>}},
|
||||
[]
|
||||
},
|
||||
{ok, <<"h">>}
|
||||
},
|
||||
read_exact(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer,
|
||||
<<"hallo world">>
|
||||
}},
|
||||
[]
|
||||
},
|
||||
1
|
||||
)
|
||||
)},
|
||||
{"read exactly 1 byte from nonempty buffer", ?_assertMatch(
|
||||
{
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<"allo world">>}},
|
||||
[]
|
||||
},
|
||||
{ok, <<"h">>}
|
||||
},
|
||||
read_exact(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}},
|
||||
[]
|
||||
},
|
||||
1
|
||||
)
|
||||
)},
|
||||
{"read exactly a zillion bytes from nonempty buffered membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}},
|
||||
[]
|
||||
},
|
||||
{error, eof}
|
||||
},
|
||||
read_exact(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer,
|
||||
<<"hallo world">>
|
||||
}},
|
||||
[]
|
||||
},
|
||||
65536
|
||||
)
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
write(Framed, Data) -> thrift_buffered_transport:write(Framed, Data).
|
||||
|
||||
write_test_() ->
|
||||
[
|
||||
{"write empty list to empty buffered membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[[], []]
|
||||
},
|
||||
ok
|
||||
},
|
||||
write(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[]
|
||||
},
|
||||
[]
|
||||
)
|
||||
)},
|
||||
{"write empty list to nonempty buffered membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[["hallo world"], []]
|
||||
},
|
||||
ok
|
||||
},
|
||||
write(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
["hallo world"]
|
||||
},
|
||||
[]
|
||||
)
|
||||
)},
|
||||
{"write empty binary to empty buffered membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[[], <<>>]
|
||||
},
|
||||
ok
|
||||
},
|
||||
write(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[]
|
||||
},
|
||||
<<>>
|
||||
)
|
||||
)},
|
||||
{"write empty binary to nonempty buffered membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[["hallo world"], <<>>]
|
||||
},
|
||||
ok
|
||||
},
|
||||
write(
|
||||
{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
["hallo world"]
|
||||
},
|
||||
<<>>
|
||||
)
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
flush(Transport) -> thrift_buffered_transport:flush(Transport).
|
||||
|
||||
flush_test_() ->
|
||||
[
|
||||
{"flush empty buffered membuffer", ?_assertMatch(
|
||||
{{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[]
|
||||
},
|
||||
ok
|
||||
},
|
||||
flush({t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[]
|
||||
})
|
||||
)},
|
||||
{"flush nonempty buffered membuffer", ?_assertMatch(
|
||||
{{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer,
|
||||
[<<>>, <<"hallo world">>]
|
||||
}},
|
||||
[]
|
||||
},
|
||||
ok
|
||||
},
|
||||
flush({t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
<<"hallo world">>
|
||||
})
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
close(Transport) -> thrift_buffered_transport:close(Transport).
|
||||
|
||||
close_test_() ->
|
||||
{"close buffered membuffer", ?_assertMatch(
|
||||
{{t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[]
|
||||
},
|
||||
ok
|
||||
},
|
||||
close({t_buffered,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[]
|
||||
})
|
||||
)}.
|
||||
|
219
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_compact_protocol.erl
generated
vendored
Normal file
219
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_compact_protocol.erl
generated
vendored
Normal file
|
@ -0,0 +1,219 @@
|
|||
%%
|
||||
%% Licensed to the Apache Software Foundation (ASF) under one
|
||||
%% or more contributor license agreements. See the NOTICE file
|
||||
%% distributed with this work for additional information
|
||||
%% regarding copyright ownership. The ASF licenses this file
|
||||
%% to you under the Apache License, Version 2.0 (the
|
||||
%% "License"); you may not use this file except in compliance
|
||||
%% with the License. You may obtain a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing,
|
||||
%% software distributed under the License is distributed on an
|
||||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
%% KIND, either express or implied. See the License for the
|
||||
%% specific language governing permissions and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
|
||||
-module(test_thrift_compact_protocol).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
-include("thrift_constants.hrl").
|
||||
-include("thrift_protocol.hrl").
|
||||
|
||||
|
||||
new(Transport) -> thrift_compact_protocol:new(Transport).
|
||||
new() ->
|
||||
{ok, Transport} = thrift_membuffer_transport:new(),
|
||||
thrift_compact_protocol:new(Transport).
|
||||
|
||||
new_test() ->
|
||||
new(thrift_membuffer_transport:new()).
|
||||
|
||||
write(This, Value) -> thrift_protocol:write(This, Value).
|
||||
read(This, Type) -> thrift_protocol:read(This, Type).
|
||||
|
||||
str(This0, Value0) ->
|
||||
{This1, ok} = write(This0, {string, Value0}),
|
||||
{This2, {ok, Value1}} = read(This1, string),
|
||||
?assertEqual(Value0, binary_to_list(Value1)),
|
||||
{This2, ok}.
|
||||
string_test() ->
|
||||
{ok, This0} = new(),
|
||||
{This1, ok} = str(This0, "aaa"),
|
||||
{This2, ok} = str(This1, ""),
|
||||
{This2, ok}.
|
||||
|
||||
round_trip(This0, Type, Value0) ->
|
||||
{This1, ok} = write(This0, {Type, Value0}),
|
||||
{This2, {ok, Value1}} = read(This1, Type),
|
||||
?assertEqual(Value0, Value1),
|
||||
{This2, ok}.
|
||||
|
||||
bool_test() ->
|
||||
{ok, This0} = new(),
|
||||
{This1, ok} = round_trip(This0, bool, true),
|
||||
{This2, ok} = round_trip(This1, bool, false),
|
||||
{This2, ok}.
|
||||
|
||||
byte(This0, Value0) -> round_trip(This0, byte, Value0).
|
||||
byte_test() ->
|
||||
{ok, This0} = new(),
|
||||
{This1, ok} = byte(This0, 0),
|
||||
{This2, ok} = byte(This1, 42),
|
||||
{This3, ok} = byte(This2, -1),
|
||||
{This4, ok} = byte(This3, -128),
|
||||
{This4, ok}.
|
||||
|
||||
i16(This0, Value0) -> round_trip(This0, i16, Value0).
|
||||
i16_test() ->
|
||||
{ok, This0} = new(),
|
||||
{This1, ok} = i16(This0, 0),
|
||||
{This2, ok} = i16(This1, 42),
|
||||
{This3, ok} = i16(This2, 30000),
|
||||
{This4, ok} = i16(This3, -1),
|
||||
{This5, ok} = i16(This4, -128),
|
||||
{This6, ok} = i16(This5, -30000),
|
||||
{This6, ok}.
|
||||
|
||||
i32(This0, Value0) -> round_trip(This0, i32, Value0).
|
||||
i32_test() ->
|
||||
{ok, This0} = new(),
|
||||
{This1, ok} = i32(This0, 0),
|
||||
{This2, ok} = i32(This1, 42),
|
||||
{This3, ok} = i32(This2, 30000),
|
||||
{This4, ok} = i32(This3, 2000000002),
|
||||
{This5, ok} = i32(This4, -1),
|
||||
{This6, ok} = i32(This5, -128),
|
||||
{This7, ok} = i32(This6, -30000),
|
||||
{This8, ok} = i32(This7, -2000000002),
|
||||
{This8, ok}.
|
||||
|
||||
i64(This0, Value0) -> round_trip(This0, i64, Value0).
|
||||
i64_test() ->
|
||||
{ok, This0} = new(),
|
||||
{This1, ok} = i64(This0, 0),
|
||||
{This2, ok} = i64(This1, 42),
|
||||
{This3, ok} = i64(This2, 30000),
|
||||
{This4, ok} = i64(This3, 2000000002),
|
||||
{This5, ok} = i64(This4, 100000000000000064),
|
||||
{This6, ok} = i64(This5, -1),
|
||||
{This7, ok} = i64(This6, -128),
|
||||
{This8, ok} = i64(This7, -30000),
|
||||
{This9, ok} = i64(This8, -2000000002),
|
||||
{This10, ok} = i64(This9, -100000000000000064),
|
||||
{This10, ok}.
|
||||
|
||||
struct_test() ->
|
||||
{ok, P0} = new(),
|
||||
{P1, ok} = write(P0, #protocol_message_begin{ name = "Message1", type = ?tType_I8, seqid = 3}),
|
||||
{P2, ok} = write(P1, #protocol_struct_begin{}),
|
||||
{P3, ok} = write(P2, #protocol_field_begin{ name = "field1", type = ?tType_I8, id = 1}),
|
||||
{P4, ok} = write(P3, {byte, 42}),
|
||||
{P5, ok} = write(P4, field_end),
|
||||
{P6, ok} = write(P5, #protocol_field_begin{ name = "field2", type = ?tType_I8, id = 14}),
|
||||
{P7, ok} = write(P6, {byte, 3}),
|
||||
{P8, ok} = write(P7, field_end),
|
||||
{P9, ok} = write(P8, #protocol_field_begin{ name = "field3", type = ?tType_I8, id = 42}),
|
||||
{P10, ok} = write(P9, {byte, 8}),
|
||||
{P11, ok} = write(P10, field_end),
|
||||
{P12, ok} = write(P11, field_stop),
|
||||
{P13, ok} = write(P12, struct_end),
|
||||
{P14, ok} = write(P13, message_end),
|
||||
|
||||
{P15, #protocol_message_begin{ name = "Message1", type = ?tType_I8, seqid = 3}} = read(P14, message_begin),
|
||||
{P16, ok} = read(P15, struct_begin),
|
||||
{P17, #protocol_field_begin{ type = ?tType_I8, id = 1 }} = read(P16, field_begin),
|
||||
{P18, {ok, 42}} = read(P17, byte),
|
||||
{P19, ok} = read(P18, field_end),
|
||||
{P20, #protocol_field_begin{ type = ?tType_I8, id = 14 }} = read(P19, field_begin),
|
||||
{P21, {ok, 3}} = read(P20, byte),
|
||||
{P22, ok} = read(P21, field_end),
|
||||
{P23, #protocol_field_begin{ type = ?tType_I8, id = 42 }} = read(P22, field_begin),
|
||||
{P24, {ok, 8}} = read(P23, byte),
|
||||
{P25, ok} = read(P24, field_end),
|
||||
{P26, #protocol_field_begin{ type = ?tType_STOP}} = read(P25, field_begin),
|
||||
{P27, ok} = read(P26, struct_end),
|
||||
{P28, ok} = read(P27, message_end),
|
||||
{P28, ok}.
|
||||
|
||||
bool_field_test() ->
|
||||
{ok, P0} = new(),
|
||||
{P1, ok} = write(P0, #protocol_message_begin{ name = "Message1", type = ?tType_I8, seqid = 3}),
|
||||
{P2, ok} = write(P1, #protocol_struct_begin{}),
|
||||
{P3, ok} = write(P2, #protocol_field_begin{ name = "field1", type = ?tType_BOOL, id = 1}),
|
||||
{P4, ok} = write(P3, {bool, true}),
|
||||
{P5, ok} = write(P4, field_end),
|
||||
{P6, ok} = write(P5, #protocol_field_begin{ name = "field2", type = ?tType_BOOL, id = 14}),
|
||||
{P7, ok} = write(P6, {bool, false}),
|
||||
{P8, ok} = write(P7, field_end),
|
||||
{P9, ok} = write(P8, #protocol_field_begin{ name = "field3", type = ?tType_BOOL, id = 42}),
|
||||
{P10, ok} = write(P9, {bool, true}),
|
||||
{P11, ok} = write(P10, field_end),
|
||||
{P12, ok} = write(P11, field_stop),
|
||||
{P13, ok} = write(P12, struct_end),
|
||||
{P14, ok} = write(P13, message_end),
|
||||
|
||||
{P15, #protocol_message_begin{ name = "Message1", type = ?tType_I8, seqid = 3}} = read(P14, message_begin),
|
||||
{P16, ok} = read(P15, struct_begin),
|
||||
{P17, #protocol_field_begin{ type = ?tType_BOOL, id = 1 }} = read(P16, field_begin),
|
||||
{P18, {ok, true}} = read(P17, bool),
|
||||
{P19, ok} = read(P18, field_end),
|
||||
{P20, #protocol_field_begin{ type = ?tType_BOOL, id = 14 }} = read(P19, field_begin),
|
||||
{P21, {ok, false}} = read(P20, bool),
|
||||
{P22, ok} = read(P21, field_end),
|
||||
{P23, #protocol_field_begin{ type = ?tType_BOOL, id = 42 }} = read(P22, field_begin),
|
||||
{P24, {ok, true}} = read(P23, bool),
|
||||
{P25, ok} = read(P24, field_end),
|
||||
{P26, #protocol_field_begin{ type = ?tType_STOP}} = read(P25, field_begin),
|
||||
{P27, ok} = read(P26, struct_end),
|
||||
{P28, ok} = read(P27, message_end),
|
||||
{P28, ok}.
|
||||
|
||||
nesting_test() ->
|
||||
{ok, P0} = new(),
|
||||
{P1, ok} = write(P0, #protocol_message_begin{ name = "Message1", type = ?tType_I8, seqid = 3}),
|
||||
{P2, ok} = write(P1, #protocol_struct_begin{}),
|
||||
{P3, ok} = write(P2, #protocol_field_begin{ name = "field1", type = ?tType_BOOL, id = 14}),
|
||||
{P4, ok} = write(P3, {bool, true}),
|
||||
{P5, ok} = write(P4, field_end),
|
||||
|
||||
{P6, ok} = write(P5, #protocol_field_begin{ name = "field2", type = ?tType_STRUCT, id = 28}),
|
||||
{P7, ok} = write(P6, #protocol_struct_begin{}),
|
||||
{P8, ok} = write(P7, #protocol_field_begin{ name = "field2_1", type = ?tType_BOOL, id = 30000}),
|
||||
{P9, ok} = write(P8, {bool, false}),
|
||||
{P10, ok} = write(P9, field_end),
|
||||
{P11, ok} = write(P10, field_stop),
|
||||
{P12, ok} = write(P11, struct_end),
|
||||
{P13, ok} = write(P12, field_end),
|
||||
|
||||
{P14, ok} = write(P13, #protocol_field_begin{ name = "field3", type = ?tType_BOOL, id = 42}),
|
||||
{P15, ok} = write(P14, {bool, true}),
|
||||
{P16, ok} = write(P15, field_end),
|
||||
{P17, ok} = write(P16, field_stop),
|
||||
{P18, ok} = write(P17, struct_end),
|
||||
{P19, ok} = write(P18, message_end),
|
||||
|
||||
{P20, #protocol_message_begin{ name = "Message1", type = ?tType_I8, seqid = 3}} = read(P19, message_begin),
|
||||
{P21, ok} = read(P20, struct_begin),
|
||||
{P22, #protocol_field_begin{ type = ?tType_BOOL, id = 14 }} = read(P21, field_begin),
|
||||
{P23, {ok, true}} = read(P22, bool),
|
||||
{P24, ok} = read(P23, field_end),
|
||||
|
||||
{P25, #protocol_field_begin{ type = ?tType_STRUCT, id = 28 }} = read(P24, field_begin),
|
||||
{P26, ok} = read(P25, struct_begin),
|
||||
{P27, #protocol_field_begin{ type = ?tType_BOOL, id = 30000 }} = read(P26, field_begin),
|
||||
{P28, {ok, false}} = read(P27, bool),
|
||||
{P29, ok} = read(P28, field_end),
|
||||
{P30, #protocol_field_begin{ type = ?tType_STOP }} = read(P29, field_begin),
|
||||
{P31, ok} = read(P30, struct_end),
|
||||
{P32, ok} = read(P31, field_end),
|
||||
|
||||
{P33, #protocol_field_begin{ type = ?tType_BOOL, id = 42 }} = read(P32, field_begin),
|
||||
{P34, {ok, true}} = read(P33, bool),
|
||||
{P35, ok} = read(P34, field_end),
|
||||
{P36, #protocol_field_begin{ type = ?tType_STOP }} = read(P35, field_begin),
|
||||
{P37, ok} = read(P36, struct_end),
|
||||
{P38, ok} = read(P37, message_end),
|
||||
{P38, ok}.
|
213
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_file_transport.erl
generated
vendored
Normal file
213
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_file_transport.erl
generated
vendored
Normal file
|
@ -0,0 +1,213 @@
|
|||
%%
|
||||
%% Licensed to the Apache Software Foundation (ASF) under one
|
||||
%% or more contributor license agreements. See the NOTICE file
|
||||
%% distributed with this work for additional information
|
||||
%% regarding copyright ownership. The ASF licenses this file
|
||||
%% to you under the Apache License, Version 2.0 (the
|
||||
%% "License"); you may not use this file except in compliance
|
||||
%% with the License. You may obtain a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing,
|
||||
%% software distributed under the License is distributed on an
|
||||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
%% KIND, either express or implied. See the License for the
|
||||
%% specific language governing permissions and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
|
||||
-module(test_thrift_file_transport).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
|
||||
new(File) -> thrift_file_transport:new(File).
|
||||
new(File, Opts) -> thrift_file_transport:new(File, Opts).
|
||||
|
||||
new_test_() ->
|
||||
[
|
||||
{"new file", ?_assertMatch(
|
||||
{ok, {_, thrift_file_transport, {t_file, a_fake_file, true, write}}},
|
||||
new(a_fake_file)
|
||||
)},
|
||||
{"new file in read mode", ?_assertMatch(
|
||||
{ok, {_, thrift_file_transport, {t_file, a_fake_file, true, read}}},
|
||||
new(a_fake_file, [{mode, read}])
|
||||
)},
|
||||
{"new file in write mode", ?_assertMatch(
|
||||
{ok, {_, thrift_file_transport, {t_file, a_fake_file, true, write}}},
|
||||
new(a_fake_file, [{mode, write}])
|
||||
)},
|
||||
{"new file in should_close true mode", ?_assertMatch(
|
||||
{ok, {_, thrift_file_transport, {t_file, a_fake_file, true, write}}},
|
||||
new(a_fake_file, [{should_close, true}])
|
||||
)},
|
||||
{"new file in should_close false mode", ?_assertMatch(
|
||||
{ok, {_, thrift_file_transport, {t_file, a_fake_file, false, write}}},
|
||||
new(a_fake_file, [{should_close, false}])
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
read(File, Bytes) -> thrift_file_transport:read(File, Bytes).
|
||||
|
||||
read_test_() ->
|
||||
{setup,
|
||||
fun() ->
|
||||
meck:new(file, [unstick, passthrough]),
|
||||
meck:expect(file, read, fun(Bin, N) ->
|
||||
{Result, _} = split_binary(Bin, min(iolist_size(Bin), N)),
|
||||
{ok, Result}
|
||||
end)
|
||||
end,
|
||||
fun(_) -> meck:unload(file) end,
|
||||
[
|
||||
{"read zero bytes from empty file", ?_assertMatch(
|
||||
{_, {ok, <<>>}},
|
||||
read({t_file, <<>>, true, read}, 0)
|
||||
)},
|
||||
{"read 1 byte from empty file", ?_assertMatch(
|
||||
{_, {ok, <<>>}},
|
||||
read({t_file, <<>>, true, read}, 1)
|
||||
)},
|
||||
{"read zero bytes from nonempty file", ?_assertMatch(
|
||||
{_, {ok, <<>>}},
|
||||
read({t_file, <<"hallo world">>, true, read}, 0)
|
||||
)},
|
||||
{"read 1 byte from nonempty file", ?_assertMatch(
|
||||
{_, {ok, <<"h">>}},
|
||||
read({t_file, <<"hallo world">>, true, read}, 1)
|
||||
)},
|
||||
{"read a zillion bytes from nonempty file", ?_assertMatch(
|
||||
{_, {ok, <<"hallo world">>}},
|
||||
read({t_file, <<"hallo world">>, true, read}, 65536)
|
||||
)},
|
||||
{"read 0 byte from file in write mode", ?_assertMatch(
|
||||
{_, {error, write_mode}},
|
||||
read({t_file, <<>>, true, write}, 0)
|
||||
)},
|
||||
{"read 1 byte from file in write mode", ?_assertMatch(
|
||||
{_, {error, write_mode}},
|
||||
read({t_file, <<>>, true, write}, 1)
|
||||
)}
|
||||
]
|
||||
}.
|
||||
|
||||
|
||||
read_exact(File, Bytes) -> thrift_file_transport:read_exact(File, Bytes).
|
||||
|
||||
read_exact_test_() ->
|
||||
{setup,
|
||||
fun() ->
|
||||
meck:new(file, [unstick, passthrough]),
|
||||
meck:expect(file, read, fun(Bin, N) ->
|
||||
{Result, _} = split_binary(Bin, min(iolist_size(Bin), N)),
|
||||
{ok, Result}
|
||||
end)
|
||||
end,
|
||||
fun(_) -> meck:unload(file) end,
|
||||
[
|
||||
{"read exactly zero bytes from empty file", ?_assertMatch(
|
||||
{_, {ok, <<>>}},
|
||||
read_exact({t_file, <<>>, true, read}, 0)
|
||||
)},
|
||||
{"read exactly 1 byte from empty file", ?_assertMatch(
|
||||
{_, {error, eof}},
|
||||
read_exact({t_file, <<>>, true, read}, 1)
|
||||
)},
|
||||
{"read exactly zero bytes from nonempty file", ?_assertMatch(
|
||||
{_, {ok, <<>>}},
|
||||
read_exact({t_file, <<"hallo world">>, true, read}, 0)
|
||||
)},
|
||||
{"read exactly 1 byte from nonempty file", ?_assertMatch(
|
||||
{_, {ok, <<"h">>}},
|
||||
read_exact({t_file, <<"hallo world">>, true, read}, 1)
|
||||
)},
|
||||
{"read exactly a zillion bytes from nonempty file", ?_assertMatch(
|
||||
{_, {error, eof}},
|
||||
read_exact({t_file, <<"hallo world">>, true, read}, 65536)
|
||||
)},
|
||||
{"read exactly 0 byte from file in write mode", ?_assertMatch(
|
||||
{_, {error, write_mode}},
|
||||
read_exact({t_file, <<>>, true, write}, 0)
|
||||
)},
|
||||
{"read exactly 1 byte from file in write mode", ?_assertMatch(
|
||||
{_, {error, write_mode}},
|
||||
read_exact({t_file, <<>>, true, write}, 1)
|
||||
)}
|
||||
]
|
||||
}.
|
||||
|
||||
|
||||
write(File, Data) -> thrift_file_transport:write(File, Data).
|
||||
|
||||
write_test_() ->
|
||||
{setup,
|
||||
fun() ->
|
||||
meck:new(file, [unstick, passthrough]),
|
||||
meck:expect(file, write, fun(_, _) -> ok end)
|
||||
end,
|
||||
fun(_) -> meck:unload(file) end,
|
||||
[
|
||||
{"write empty list to file", ?_assertMatch(
|
||||
{{t_file, a_fake_file, true, write}, ok},
|
||||
write({t_file, a_fake_file, true, write}, [])
|
||||
)},
|
||||
{"write empty binary to file", ?_assertMatch(
|
||||
{{t_file, a_fake_file, true, write}, ok},
|
||||
write({t_file, a_fake_file, true, write}, <<>>)
|
||||
)},
|
||||
{"write a list to file", ?_assertMatch(
|
||||
{{t_file, a_fake_file, true, write}, ok},
|
||||
write({t_file, a_fake_file, true, write}, "hallo world")
|
||||
)},
|
||||
{"write a binary to file", ?_assertMatch(
|
||||
{{t_file, a_fake_file, true, write}, ok},
|
||||
write({t_file, a_fake_file, true, write}, <<"hallo world">>)
|
||||
)},
|
||||
{"write a binary to file in read mode", ?_assertMatch(
|
||||
{_, {error, read_mode}},
|
||||
write({t_file, a_fake_file, true, read}, <<"hallo world">>)
|
||||
)},
|
||||
{"write a list to file in read mode", ?_assertMatch(
|
||||
{_, {error, read_mode}},
|
||||
write({t_file, a_fake_file, true, read}, "hallo world")
|
||||
)}
|
||||
]
|
||||
}.
|
||||
|
||||
|
||||
flush(Transport) -> thrift_file_transport:flush(Transport).
|
||||
|
||||
flush_test_() ->
|
||||
{setup,
|
||||
fun() ->
|
||||
meck:new(file, [unstick, passthrough]),
|
||||
meck:expect(file, sync, fun(_File) -> ok end)
|
||||
end,
|
||||
fun(_) -> meck:unload(file) end,
|
||||
[
|
||||
{"flush file", ?_assertMatch(
|
||||
{{t_file, a_fake_file, true, write}, ok},
|
||||
flush({t_file, a_fake_file, true, write})
|
||||
)}
|
||||
]
|
||||
}.
|
||||
|
||||
|
||||
close(Transport) -> thrift_file_transport:close(Transport).
|
||||
|
||||
close_test_() ->
|
||||
{setup,
|
||||
fun() ->
|
||||
meck:new(file, [unstick, passthrough]),
|
||||
meck:expect(file, close, fun(_) -> ok end)
|
||||
end,
|
||||
fun(_) -> meck:unload(file) end,
|
||||
[
|
||||
{"close file", ?_assertMatch(
|
||||
{{t_file, a_fake_file, true, write}, ok},
|
||||
close({t_file, a_fake_file, true, write})
|
||||
)}
|
||||
]
|
||||
}.
|
404
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_framed_transport.erl
generated
vendored
Normal file
404
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_framed_transport.erl
generated
vendored
Normal file
|
@ -0,0 +1,404 @@
|
|||
%%
|
||||
%% Licensed to the Apache Software Foundation (ASF) under one
|
||||
%% or more contributor license agreements. See the NOTICE file
|
||||
%% distributed with this work for additional information
|
||||
%% regarding copyright ownership. The ASF licenses this file
|
||||
%% to you under the Apache License, Version 2.0 (the
|
||||
%% "License"); you may not use this file except in compliance
|
||||
%% with the License. You may obtain a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing,
|
||||
%% software distributed under the License is distributed on an
|
||||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
%% KIND, either express or implied. See the License for the
|
||||
%% specific language governing permissions and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
|
||||
-module(test_thrift_framed_transport).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
|
||||
new(Transport) -> thrift_framed_transport:new(Transport).
|
||||
|
||||
new_test_() ->
|
||||
[
|
||||
{"new framed membuffer", ?_assertMatch(
|
||||
{ok, {t_transport, thrift_framed_transport, {t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, []}},
|
||||
[],
|
||||
[]
|
||||
}}},
|
||||
new({t_transport, thrift_membuffer_transport, {t_membuffer, []}})
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
read(Frame, Bytes) -> thrift_framed_transport:read(Frame, Bytes).
|
||||
|
||||
read_test_() ->
|
||||
[
|
||||
{"read zero bytes from an empty framed membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
{ok, <<>>}
|
||||
},
|
||||
read(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
0
|
||||
)
|
||||
)},
|
||||
{"read 1 byte from an empty framed membuffer", ?_assertMatch(
|
||||
{_, {error, eof}},
|
||||
read(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
1
|
||||
)
|
||||
)},
|
||||
{"read zero bytes from nonempty framed membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer,
|
||||
<<0, 0, 0, 11, "hallo world">>
|
||||
}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
{ok, <<>>}
|
||||
},
|
||||
read(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer,
|
||||
<<0, 0, 0, 11, "hallo world">>
|
||||
}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
0
|
||||
)
|
||||
)},
|
||||
{"read 1 byte from nonempty framed membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
<<"allo world">>,
|
||||
[]
|
||||
},
|
||||
{ok, <<"h">>}
|
||||
},
|
||||
read(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer,
|
||||
<<0, 0, 0, 11, "hallo world">>
|
||||
}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
1
|
||||
)
|
||||
)},
|
||||
{"read 1 byte from nonempty buffer", ?_assertMatch(
|
||||
{
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
<<"allo world">>,
|
||||
[]
|
||||
},
|
||||
{ok, <<"h">>}
|
||||
},
|
||||
read(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
<<"hallo world">>,
|
||||
[]
|
||||
},
|
||||
1
|
||||
)
|
||||
)},
|
||||
{"read a zillion bytes from nonempty framed membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
<<>>,
|
||||
[]
|
||||
},
|
||||
{ok, <<"hallo world">>}
|
||||
},
|
||||
read(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer,
|
||||
<<0, 0, 0, 11, "hallo world">>
|
||||
}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
65536
|
||||
)
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
read_exact(Frame, Bytes) -> thrift_framed_transport:read_exact(Frame, Bytes).
|
||||
|
||||
read_exact_test_() ->
|
||||
[
|
||||
{"read exactly zero bytes from an empty framed membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
<<>>,
|
||||
[]
|
||||
},
|
||||
{ok, <<>>}
|
||||
},
|
||||
read_exact(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
0
|
||||
)
|
||||
)},
|
||||
{"read exactly 1 byte from an empty framed membuffer", ?_assertMatch(
|
||||
{_, {error, eof}},
|
||||
read_exact(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
1
|
||||
)
|
||||
)},
|
||||
{"read exactly zero bytes from nonempty framed membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer,
|
||||
<<0, 0, 0, 11, "hallo world">>
|
||||
}},
|
||||
<<>>,
|
||||
[]
|
||||
},
|
||||
{ok, <<>>}
|
||||
},
|
||||
read_exact(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer,
|
||||
<<0, 0, 0, 11, "hallo world">>
|
||||
}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
0
|
||||
)
|
||||
)},
|
||||
{"read exactly 1 byte from nonempty framed membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
<<"allo world">>,
|
||||
[]
|
||||
},
|
||||
{ok, <<"h">>}
|
||||
},
|
||||
read_exact(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer,
|
||||
<<0, 0, 0, 11, "hallo world">>
|
||||
}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
1
|
||||
)
|
||||
)},
|
||||
{"read exactly 1 byte from nonempty buffer", ?_assertMatch(
|
||||
{
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
<<"allo world">>,
|
||||
[]
|
||||
},
|
||||
{ok, <<"h">>}
|
||||
},
|
||||
read_exact(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
<<"hallo world">>,
|
||||
[]
|
||||
},
|
||||
1
|
||||
)
|
||||
)},
|
||||
{"read exactly a zillion bytes from nonempty framed membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[[],<<"hallo world">>],
|
||||
[]
|
||||
},
|
||||
{error, eof}
|
||||
},
|
||||
read_exact(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer,
|
||||
<<0, 0, 0, 11, "hallo world">>
|
||||
}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
65536
|
||||
)
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
write(Framed, Data) -> thrift_framed_transport:write(Framed, Data).
|
||||
|
||||
write_test_() ->
|
||||
[
|
||||
{"write empty list to empty framed membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
[[], []]
|
||||
},
|
||||
ok
|
||||
},
|
||||
write(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
[]
|
||||
)
|
||||
)},
|
||||
{"write empty list to nonempty framed membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
[["hallo world"], []]
|
||||
},
|
||||
ok
|
||||
},
|
||||
write(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
["hallo world"]
|
||||
},
|
||||
[]
|
||||
)
|
||||
)},
|
||||
{"write empty binary to empty framed membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
[[], <<>>]
|
||||
},
|
||||
ok
|
||||
},
|
||||
write(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
<<>>
|
||||
)
|
||||
)},
|
||||
{"write empty binary to nonempty framed membuffer", ?_assertMatch(
|
||||
{
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
[["hallo world"], <<>>]
|
||||
},
|
||||
ok
|
||||
},
|
||||
write(
|
||||
{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
["hallo world"]
|
||||
},
|
||||
<<>>
|
||||
)
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
flush(Transport) -> thrift_framed_transport:flush(Transport).
|
||||
|
||||
flush_test_() ->
|
||||
[
|
||||
{"flush empty framed membuffer", ?_assertMatch(
|
||||
{{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
ok
|
||||
},
|
||||
flush({t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
[]
|
||||
})
|
||||
)},
|
||||
{"flush nonempty framed membuffer", ?_assertMatch(
|
||||
{{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer,
|
||||
[<<>>, [<<0, 0, 0, 11>>, <<"hallo world">>]]
|
||||
}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
ok
|
||||
},
|
||||
flush({t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
<<"hallo world">>
|
||||
})
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
close(Transport) -> thrift_framed_transport:close(Transport).
|
||||
|
||||
close_test_() ->
|
||||
{"close framed membuffer", ?_assertMatch(
|
||||
{{t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
[]
|
||||
},
|
||||
ok
|
||||
},
|
||||
close({t_framed,
|
||||
{t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}},
|
||||
[],
|
||||
[]
|
||||
})
|
||||
)}.
|
||||
|
167
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_membuffer_transport.erl
generated
vendored
Normal file
167
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_membuffer_transport.erl
generated
vendored
Normal file
|
@ -0,0 +1,167 @@
|
|||
%%
|
||||
%% Licensed to the Apache Software Foundation (ASF) under one
|
||||
%% or more contributor license agreements. See the NOTICE file
|
||||
%% distributed with this work for additional information
|
||||
%% regarding copyright ownership. The ASF licenses this file
|
||||
%% to you under the Apache License, Version 2.0 (the
|
||||
%% "License"); you may not use this file except in compliance
|
||||
%% with the License. You may obtain a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing,
|
||||
%% software distributed under the License is distributed on an
|
||||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
%% KIND, either express or implied. See the License for the
|
||||
%% specific language governing permissions and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
|
||||
-module(test_thrift_membuffer_transport).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
|
||||
new() -> thrift_membuffer_transport:new().
|
||||
new(Data) -> thrift_membuffer_transport:new(Data).
|
||||
|
||||
new_test_() ->
|
||||
[
|
||||
{"new empty membuffer", ?_assertMatch(
|
||||
{ok, {_, _, {t_membuffer, []}}},
|
||||
new()
|
||||
)},
|
||||
{"new membuffer with <<>>", ?_assertMatch(
|
||||
{ok, {_, _, {t_membuffer, [<<>>]}}},
|
||||
new(<<>>)
|
||||
)},
|
||||
{"new membuffer with []", ?_assertMatch(
|
||||
{ok, {_, _, {t_membuffer, []}}},
|
||||
new([])
|
||||
)},
|
||||
{"new membuffer with <<\"hallo world\">>", ?_assertMatch(
|
||||
{ok, {_, _, {t_membuffer, [<<"hallo world">>]}}},
|
||||
new(<<"hallo world">>)
|
||||
)},
|
||||
{"new membuffer with \"hallo world\"", ?_assertMatch(
|
||||
{ok, {_, _, {t_membuffer, "hallo world"}}},
|
||||
new("hallo world")
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
read(Membuffer, Bytes) -> thrift_membuffer_transport:read(Membuffer, Bytes).
|
||||
|
||||
read_test_() ->
|
||||
[
|
||||
{"read zero bytes from an empty membuffer", ?_assertMatch(
|
||||
{_, {ok, <<>>}},
|
||||
read({t_membuffer, []}, 0)
|
||||
)},
|
||||
{"read 1 byte from an empty membuffer", ?_assertMatch(
|
||||
{_, {ok, <<>>}},
|
||||
read({t_membuffer, []}, 1)
|
||||
)},
|
||||
{"read zero bytes from nonempty membuffer", ?_assertMatch(
|
||||
{{t_membuffer, <<"hallo world">>}, {ok, <<>>}},
|
||||
read({t_membuffer, [["hallo", " "], "world"]}, 0)
|
||||
)},
|
||||
{"read 1 byte from nonempty membuffer", ?_assertMatch(
|
||||
{{t_membuffer, <<"allo world">>}, {ok, <<"h">>}},
|
||||
read({t_membuffer, [["hallo", " "], "world"]}, 1)
|
||||
)},
|
||||
{"read a zillion bytes from nonempty buffer", ?_assertMatch(
|
||||
{{t_membuffer, <<>>}, {ok, <<"hallo world">>}},
|
||||
read({t_membuffer, [["hallo", " "], "world"]}, 65536)
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
read_exact(Membuffer, Bytes) ->
|
||||
thrift_membuffer_transport:read_exact(Membuffer, Bytes).
|
||||
|
||||
read_exact_test_() ->
|
||||
[
|
||||
{"read exactly zero bytes from an empty membuffer", ?_assertMatch(
|
||||
{_, {ok, <<>>}},
|
||||
read_exact({t_membuffer, []}, 0)
|
||||
)},
|
||||
{"read exactly 1 byte from an empty membuffer", ?_assertMatch(
|
||||
{_, {error, eof}},
|
||||
read_exact({t_membuffer, []}, 1)
|
||||
)},
|
||||
{"read exactly zero bytes from nonempty membuffer", ?_assertMatch(
|
||||
{{t_membuffer, <<"hallo world">>}, {ok, <<>>}},
|
||||
read_exact({t_membuffer, [["hallo", " "], "world"]}, 0)
|
||||
)},
|
||||
{"read exactly 1 byte from nonempty membuffer", ?_assertMatch(
|
||||
{{t_membuffer, <<"allo world">>}, {ok, <<"h">>}},
|
||||
read_exact({t_membuffer, [["hallo", " "], "world"]}, 1)
|
||||
)},
|
||||
{"read exactly a zillion bytes from nonempty buffer", ?_assertMatch(
|
||||
{{t_membuffer, [["hallo", " "], "world"]}, {error, eof}},
|
||||
read_exact({t_membuffer, [["hallo", " "], "world"]}, 65536)
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
write(Membuffer, Data) -> thrift_membuffer_transport:write(Membuffer, Data).
|
||||
|
||||
write_test_() ->
|
||||
[
|
||||
{"write empty list to empty membuffer", ?_assertMatch(
|
||||
{{t_membuffer, [[], []]}, ok},
|
||||
write({t_membuffer, []}, [])
|
||||
)},
|
||||
{"write empty list to nonempty membuffer", ?_assertMatch(
|
||||
{{t_membuffer, ["hallo world", []]}, ok},
|
||||
write({t_membuffer, "hallo world"}, [])
|
||||
)},
|
||||
{"write empty binary to empty membuffer", ?_assertMatch(
|
||||
{{t_membuffer, [[], <<>>]}, ok},
|
||||
write({t_membuffer, []}, <<>>)
|
||||
)},
|
||||
{"write empty binary to nonempty membuffer", ?_assertMatch(
|
||||
{{t_membuffer, ["hallo world", <<>>]}, ok},
|
||||
write({t_membuffer, "hallo world"}, <<>>)
|
||||
)},
|
||||
{"write a list to empty membuffer", ?_assertMatch(
|
||||
{{t_membuffer, [[], "hallo world"]}, ok},
|
||||
write({t_membuffer, []}, "hallo world")
|
||||
)},
|
||||
{"write a list to nonempty membuffer", ?_assertMatch(
|
||||
{{t_membuffer, [["hallo", " "], "world"]}, ok},
|
||||
write({t_membuffer, ["hallo", " "]}, "world")
|
||||
)},
|
||||
{"write a binary to empty membuffer", ?_assertMatch(
|
||||
{{t_membuffer, [[], <<"hallo world">>]}, ok},
|
||||
write({t_membuffer, []}, <<"hallo world">>)
|
||||
)},
|
||||
{"write a binary to nonempty membuffer", ?_assertMatch(
|
||||
{{t_membuffer, [["hallo", " "], <<"world">>]}, ok},
|
||||
write({t_membuffer, ["hallo", " "]}, <<"world">>)
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
flush(Transport) -> thrift_membuffer_transport:flush(Transport).
|
||||
|
||||
flush_test_() ->
|
||||
[
|
||||
{"flush empty membuffer", ?_assertMatch(
|
||||
{{t_membuffer, []}, ok},
|
||||
flush({t_membuffer, []})
|
||||
)},
|
||||
{"flush nonempty membuffer", ?_assertMatch(
|
||||
{{t_membuffer, [<<"hallo world">>]}, ok},
|
||||
flush({t_membuffer, [<<"hallo world">>]})
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
close(Transport) -> thrift_membuffer_transport:close(Transport).
|
||||
|
||||
close_test_() ->
|
||||
{"close membuffer", ?_assertMatch(
|
||||
{{t_membuffer, _}, ok},
|
||||
close({t_membuffer, []})
|
||||
)}.
|
199
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_socket_transport.erl
generated
vendored
Normal file
199
vendor/git.apache.org/thrift.git/lib/erl/test/test_thrift_socket_transport.erl
generated
vendored
Normal file
|
@ -0,0 +1,199 @@
|
|||
%%
|
||||
%% Licensed to the Apache Software Foundation (ASF) under one
|
||||
%% or more contributor license agreements. See the NOTICE file
|
||||
%% distributed with this work for additional information
|
||||
%% regarding copyright ownership. The ASF licenses this file
|
||||
%% to you under the Apache License, Version 2.0 (the
|
||||
%% "License"); you may not use this file except in compliance
|
||||
%% with the License. You may obtain a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing,
|
||||
%% software distributed under the License is distributed on an
|
||||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
%% KIND, either express or implied. See the License for the
|
||||
%% specific language governing permissions and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
|
||||
-module(test_thrift_socket_transport).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
|
||||
new(Socket) -> thrift_socket_transport:new(Socket).
|
||||
new(Socket, Opts) -> thrift_socket_transport:new(Socket, Opts).
|
||||
|
||||
new_test_() ->
|
||||
[
|
||||
{"new socket", ?_assertMatch(
|
||||
{ok, {_, thrift_socket_transport, {t_socket, a_fake_socket, 60000, []}}},
|
||||
new(a_fake_socket)
|
||||
)},
|
||||
{"new socket with no options", ?_assertMatch(
|
||||
{ok, {_, thrift_socket_transport, {t_socket, a_fake_socket, 60000, []}}},
|
||||
new(a_fake_socket, [])
|
||||
)},
|
||||
{"new socket with integer timeout", ?_assertMatch(
|
||||
{ok, {_, thrift_socket_transport, {t_socket, a_fake_socket, 5000, []}}},
|
||||
new(a_fake_socket, [{recv_timeout, 5000}])
|
||||
)},
|
||||
{"new socket with infinity timeout", ?_assertMatch(
|
||||
{ok, {_, thrift_socket_transport, {t_socket, a_fake_socket, infinity, []}}},
|
||||
new(a_fake_socket, [{recv_timeout, infinity}])
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
read(Socket, Bytes) -> thrift_socket_transport:read(Socket, Bytes).
|
||||
|
||||
read_test_() ->
|
||||
{setup,
|
||||
fun() ->
|
||||
meck:new(gen_tcp, [unstick, passthrough]),
|
||||
meck:expect(gen_tcp, recv, fun(Bin, 0, _) -> {ok, Bin} end)
|
||||
end,
|
||||
fun(_) -> meck:unload(gen_tcp) end,
|
||||
[
|
||||
{"read zero bytes from empty socket", ?_assertMatch(
|
||||
{_, {ok, <<>>}},
|
||||
read({t_socket, <<>>, 60000, []}, 0)
|
||||
)},
|
||||
{"read 1 byte from empty socket", ?_assertMatch(
|
||||
{_, {ok, <<>>}},
|
||||
read({t_socket, <<>>, 60000, []}, 1)
|
||||
)},
|
||||
{"read zero bytes from nonempty socket", ?_assertMatch(
|
||||
{{t_socket, _, _, _}, {ok, <<>>}},
|
||||
read({t_socket, <<"hallo world">>, 60000, []}, 0)
|
||||
)},
|
||||
{"read 1 byte from nonempty socket", ?_assertMatch(
|
||||
{{t_socket, _, _, <<"allo world">>}, {ok, <<"h">>}},
|
||||
read({t_socket, <<"hallo world">>, 60000, []}, 1)
|
||||
)},
|
||||
{"read a zillion bytes from nonempty socket", ?_assertMatch(
|
||||
{{t_socket, _, _, <<>>}, {ok, <<"hallo world">>}},
|
||||
read({t_socket, <<"hallo world">>, 60000, []}, 65536)
|
||||
)},
|
||||
{"read 1 byte from previously buffered socket", ?_assertMatch(
|
||||
{{t_socket, _, _, <<"allo">>}, {ok, <<"h">>}},
|
||||
read({t_socket, <<" world">>, 60000, <<"hallo">>}, 1)
|
||||
)},
|
||||
{"read 6 byte from previously buffered socket", ?_assertMatch(
|
||||
{{t_socket, _, _, <<"world">>}, {ok, <<"hallo ">>}},
|
||||
read({t_socket, <<" world">>, 60000, <<"hallo">>}, 6)
|
||||
)},
|
||||
{"read a zillion bytes from previously buffered socket", ?_assertMatch(
|
||||
{{t_socket, _, _, <<>>}, {ok, <<"hallo world">>}},
|
||||
read({t_socket, <<" world">>, 60000, <<"hallo">>}, 65536)
|
||||
)}
|
||||
]
|
||||
}.
|
||||
|
||||
|
||||
read_exact(Socket, Bytes) -> thrift_socket_transport:read_exact(Socket, Bytes).
|
||||
|
||||
read_exact_test_() ->
|
||||
{setup,
|
||||
fun() ->
|
||||
meck:new(gen_tcp, [unstick, passthrough]),
|
||||
meck:expect(gen_tcp, recv, fun(Bin, N, _) ->
|
||||
case N of
|
||||
0 -> {ok, Bin};
|
||||
1 -> {ok, <<"h">>};
|
||||
N when N > 2 -> {error, timeout}
|
||||
end
|
||||
end),
|
||||
meck:expect(gen_tcp, close, fun(_) -> ok end)
|
||||
end,
|
||||
fun(_) -> meck:unload(gen_tcp) end,
|
||||
[
|
||||
{"read_exact zero bytes from empty socket", ?_assertMatch(
|
||||
{_, {ok, <<>>}},
|
||||
read_exact({t_socket, <<>>, 60000, []}, 0)
|
||||
)},
|
||||
{"read_exact zero bytes from nonempty socket", ?_assertMatch(
|
||||
{{t_socket, _, _, _}, {ok, <<>>}},
|
||||
read_exact({t_socket, <<"hallo world">>, 60000, []}, 0)
|
||||
)},
|
||||
{"read_exact 1 byte from nonempty socket", ?_assertMatch(
|
||||
{{t_socket, _, _, []}, {ok, <<"h">>}},
|
||||
read_exact({t_socket, <<"hallo world">>, 60000, []}, 1)
|
||||
)},
|
||||
{"read_exact a zillion bytes from nonempty socket", ?_assertMatch(
|
||||
{{t_socket, _, _, []}, {error, timeout}},
|
||||
read_exact({t_socket, <<"hallo world">>, 60000, []}, 65536)
|
||||
)},
|
||||
{"read_exact 1 byte from previously buffered socket", ?_assertMatch(
|
||||
{{t_socket, _, _, <<"allo">>}, {ok, <<"h">>}},
|
||||
read_exact({t_socket, <<" world">>, 60000, <<"hallo">>}, 1)
|
||||
)},
|
||||
{"read_exact 6 byte from previously buffered socket", ?_assertMatch(
|
||||
{{t_socket, _, _, []}, {ok, <<"more h">>}},
|
||||
read_exact({t_socket, <<"hallo">>, 60000, <<"more ">>}, 6)
|
||||
)},
|
||||
{"read_exact a zillion bytes from previously buffered socket", ?_assertMatch(
|
||||
{{t_socket, _, _, <<"hallo">>}, {error, timeout}},
|
||||
read_exact({t_socket, <<" world">>, 60000, <<"hallo">>}, 65536)
|
||||
)}
|
||||
]
|
||||
}.
|
||||
|
||||
|
||||
write(Socket, Data) -> thrift_socket_transport:write(Socket, Data).
|
||||
|
||||
write_test_() ->
|
||||
{setup,
|
||||
fun() ->
|
||||
meck:new(gen_tcp, [unstick, passthrough]),
|
||||
meck:expect(gen_tcp, send, fun(_, _) -> ok end)
|
||||
end,
|
||||
fun(_) -> meck:unload(gen_tcp) end,
|
||||
[
|
||||
{"write empty list to socket", ?_assertMatch(
|
||||
{{t_socket, a_fake_socket, 60000, []}, ok},
|
||||
write({t_socket, a_fake_socket, 60000, []}, [])
|
||||
)},
|
||||
{"write empty binary to socket", ?_assertMatch(
|
||||
{{t_socket, a_fake_socket, 60000, []}, ok},
|
||||
write({t_socket, a_fake_socket, 60000, []}, <<>>)
|
||||
)},
|
||||
{"write a list to socket", ?_assertMatch(
|
||||
{{t_socket, a_fake_socket, 60000, []}, ok},
|
||||
write({t_socket, a_fake_socket, 60000, []}, "hallo world")
|
||||
)},
|
||||
{"write a binary to socket", ?_assertMatch(
|
||||
{{t_socket, a_fake_socket, 60000, []}, ok},
|
||||
write({t_socket, a_fake_socket, 60000, []}, <<"hallo world">>)
|
||||
)}
|
||||
]
|
||||
}.
|
||||
|
||||
|
||||
flush(Transport) -> thrift_socket_transport:flush(Transport).
|
||||
|
||||
flush_test_() ->
|
||||
[
|
||||
{"flush socket", ?_assertMatch(
|
||||
{{t_socket, a_fake_socket, 60000, []}, ok},
|
||||
flush({t_socket, a_fake_socket, 60000, []})
|
||||
)}
|
||||
].
|
||||
|
||||
|
||||
close(Transport) -> thrift_socket_transport:close(Transport).
|
||||
|
||||
close_test_() ->
|
||||
{setup,
|
||||
fun() ->
|
||||
meck:new(gen_tcp, [unstick, passthrough]),
|
||||
meck:expect(gen_tcp, close, fun(_) -> ok end)
|
||||
end,
|
||||
fun(_) -> meck:unload(gen_tcp) end,
|
||||
[
|
||||
{"close membuffer", ?_assertMatch(
|
||||
{{t_socket, a_fake_socket, 60000, []}, ok},
|
||||
close({t_socket, a_fake_socket, 60000, []})
|
||||
)}
|
||||
]
|
||||
}.
|
49
vendor/git.apache.org/thrift.git/lib/erl/test/thrift_socket_server_test.erl
generated
vendored
Normal file
49
vendor/git.apache.org/thrift.git/lib/erl/test/thrift_socket_server_test.erl
generated
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
-module (thrift_socket_server_test).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
-include ("thrift_constants.hrl").
|
||||
|
||||
parse_handler_options_test_() ->
|
||||
CorrectServiceHandlerOptionList = [{?MULTIPLEXED_ERROR_HANDLER_KEY, ?MODULE}, {"Service1", ?MODULE}, {"Service2", ?MODULE}],
|
||||
MissingErrorHandlerOptionList = [{"Service1", ?MODULE}, {"Service2", ?MODULE}],
|
||||
WrongService2HandlerOptionList = [{?MULTIPLEXED_ERROR_HANDLER_KEY, ?MODULE}, {"Service1", ?MODULE}, {"Service2", "Module"}],
|
||||
WrongServiceKeyOptionList = [{?MULTIPLEXED_ERROR_HANDLER_KEY, ?MODULE}, {'service1', ?MODULE}, {"Service2", ?MODULE}],
|
||||
CorrectHandlerTestFunction = fun() ->
|
||||
?assertMatch({thrift_socket_server,_,_,_,_,_,_,_,_,_,_,_,_,_}, thrift_socket_server:parse_options([{handler, CorrectServiceHandlerOptionList}])),
|
||||
{thrift_socket_server,_,_, HandlerList,_,_,_,_,_,_,_,_,_,_} = thrift_socket_server:parse_options([{handler, CorrectServiceHandlerOptionList}]),
|
||||
lists:foreach(fun
|
||||
({ServiceName, HandlerModule}) ->
|
||||
?assertMatch({ok, HandlerModule} when is_atom(HandlerModule), thrift_multiplexed_map_wrapper:find(ServiceName, HandlerList))
|
||||
end, CorrectServiceHandlerOptionList)
|
||||
end,
|
||||
[
|
||||
{"Bad argument for the handler option", ?_assertThrow(_, thrift_socket_server:parse_options([{handler, []}]))},
|
||||
{"Try to parse the handler option twice", ?_assertThrow(_, thrift_socket_server:parse_options([{handler, ?MODULE}, {handler, CorrectServiceHandlerOptionList}]))},
|
||||
{"Parse the handler option as a non multiplexed service handler", ?_assertMatch({thrift_socket_server,_,_,?MODULE,_,_,_,_,_,_,_,_,_,_}, thrift_socket_server:parse_options([{handler, ?MODULE}]))},
|
||||
{"No error handler was defined", ?_assertThrow(_, thrift_socket_server:parse_options([{handler, MissingErrorHandlerOptionList}]))},
|
||||
{"Bad handler module for Service2", ?_assertThrow(_, thrift_socket_server:parse_options([{handler, WrongService2HandlerOptionList}]))},
|
||||
{"Bad service key for Service1", ?_assertThrow(_, thrift_socket_server:parse_options([{handler, WrongServiceKeyOptionList}]))},
|
||||
{"Try to parse a correct handler option list", CorrectHandlerTestFunction}
|
||||
].
|
||||
|
||||
parse_service_options_test_() ->
|
||||
CorrectServiceModuleOptionList = [{"Service1", ?MODULE}, {"Service2", ?MODULE}],
|
||||
WrongService2ModuleOptionList = [{"Service1", ?MODULE}, {"Service2", "thrift_service_module"}],
|
||||
WrongServiceKeyOptionList = [{'service1', ?MODULE}, {"Service2", ?MODULE}],
|
||||
CorrectServiceModuleTestFunction = fun() ->
|
||||
?assertMatch({thrift_socket_server,_,_,_,_,_,_,_,_,_,_,_,_,_}, thrift_socket_server:parse_options([{service, CorrectServiceModuleOptionList}])),
|
||||
{thrift_socket_server,_, ServiceModuleList,_,_,_,_,_,_,_,_,_,_,_} = thrift_socket_server:parse_options([{service, CorrectServiceModuleOptionList}]),
|
||||
lists:foreach(fun
|
||||
({ServiceName, ServiceModule}) ->
|
||||
?assertMatch({ok, ServiceModule} when is_atom(ServiceModule), thrift_multiplexed_map_wrapper:find(ServiceName, ServiceModuleList))
|
||||
end, CorrectServiceModuleOptionList)
|
||||
end,
|
||||
[
|
||||
{"Bad argument for the service option", ?_assertThrow(_, thrift_socket_server:parse_options([{service, []}]))},
|
||||
{"Try to parse the service option twice", ?_assertThrow(_, thrift_socket_server:parse_options([{service, ?MODULE}, {service, CorrectServiceModuleOptionList}]))},
|
||||
{"Parse a service module for a non multiplexed service", ?_assertMatch({thrift_socket_server,_,?MODULE,_,_,_,_,_,_,_,_,_,_,_}, thrift_socket_server:parse_options([{service, ?MODULE}]))},
|
||||
{"Bad service module for Service2", ?_assertThrow(_, thrift_socket_server:parse_options([{service, WrongService2ModuleOptionList}]))},
|
||||
{"Bad service key for Service1", ?_assertThrow(_, thrift_socket_server:parse_options([{service, WrongServiceKeyOptionList}]))},
|
||||
{"Try to parse a correct service option list", CorrectServiceModuleTestFunction}
|
||||
].
|
655
vendor/git.apache.org/thrift.git/lib/erl/test/thrift_test_test.erl
generated
vendored
Normal file
655
vendor/git.apache.org/thrift.git/lib/erl/test/thrift_test_test.erl
generated
vendored
Normal file
|
@ -0,0 +1,655 @@
|
|||
%%
|
||||
%% Licensed to the Apache Software Foundation (ASF) under one
|
||||
%% or more contributor license agreements. See the NOTICE file
|
||||
%% distributed with this work for additional information
|
||||
%% regarding copyright ownership. The ASF licenses this file
|
||||
%% to you under the Apache License, Version 2.0 (the
|
||||
%% "License"); you may not use this file except in compliance
|
||||
%% with the License. You may obtain a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing,
|
||||
%% software distributed under the License is distributed on an
|
||||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
%% KIND, either express or implied. See the License for the
|
||||
%% specific language governing permissions and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
|
||||
% don't rename this thrift_test, it clobbers generated files
|
||||
-module(thrift_test_test).
|
||||
-compile(export_all).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
-include("gen-erl/thrift_test_constants.hrl").
|
||||
|
||||
constant_test_() ->
|
||||
[
|
||||
{"myNumberz equals 1", ?_assertEqual(1, ?THRIFT_TEST_MYNUMBERZ)}
|
||||
].
|
||||
|
||||
record_generation_test_() ->
|
||||
[
|
||||
{"Bonk record", ?_assertMatch(
|
||||
{'thrift.test.Bonk', _, _},
|
||||
#'thrift.test.Bonk'{message=null,type=null}
|
||||
)},
|
||||
{"Bools record", ?_assertMatch(
|
||||
{'thrift.test.Bools', _, _},
|
||||
#'thrift.test.Bools'{im_true=null,im_false=null}
|
||||
)},
|
||||
{"Xtruct record", ?_assertMatch(
|
||||
{'thrift.test.Xtruct', _, _, _, _},
|
||||
#'thrift.test.Xtruct'{string_thing=null,byte_thing=null,i32_thing=null,i64_thing=null}
|
||||
)},
|
||||
{"Xtruct2 record", ?_assertMatch(
|
||||
{'thrift.test.Xtruct2', _, _, _},
|
||||
#'thrift.test.Xtruct2'{byte_thing=null,struct_thing=null,i32_thing=null}
|
||||
)},
|
||||
{"Xtruct3 record", ?_assertMatch(
|
||||
{'thrift.test.Xtruct3', _, _, _, _},
|
||||
#'thrift.test.Xtruct3'{string_thing=null,changed=null,i32_thing=null,i64_thing=null}
|
||||
)},
|
||||
{"Insanity record", ?_assertMatch(
|
||||
{'thrift.test.Insanity', _, _},
|
||||
#'thrift.test.Insanity'{userMap=null,xtructs=null}
|
||||
)},
|
||||
{"CrazyNesting record", ?_assertMatch(
|
||||
{'thrift.test.CrazyNesting', _, _, _, _},
|
||||
#'thrift.test.CrazyNesting'{
|
||||
string_field=null,
|
||||
set_field=null,
|
||||
list_field=null,
|
||||
binary_field=null
|
||||
}
|
||||
)},
|
||||
{"Xception record", ?_assertMatch(
|
||||
{'thrift.test.Xception', _, _},
|
||||
#'thrift.test.Xception'{errorCode=null,message=null}
|
||||
)},
|
||||
{"Xception2 record", ?_assertMatch(
|
||||
{'thrift.test.Xception2', _, _},
|
||||
#'thrift.test.Xception2'{errorCode=null,struct_thing=null}
|
||||
)},
|
||||
{"EmptyStruct record", ?_assertMatch({'thrift.test.EmptyStruct'}, #'thrift.test.EmptyStruct'{})},
|
||||
{"OneField record", ?_assertMatch({'thrift.test.OneField', _}, #'thrift.test.OneField'{field=null})},
|
||||
{"VersioningTestV1 record", ?_assertMatch(
|
||||
{'thrift.test.VersioningTestV1', _, _, _},
|
||||
#'thrift.test.VersioningTestV1'{begin_in_both=null,old_string=null,end_in_both=null}
|
||||
)},
|
||||
{"VersioningTestV2 record", ?_assertMatch(
|
||||
{'thrift.test.VersioningTestV2', _, _, _, _, _, _, _, _, _, _, _, _},
|
||||
#'thrift.test.VersioningTestV2'{
|
||||
begin_in_both=null,
|
||||
newint=null,
|
||||
newbyte=null,
|
||||
newshort=null,
|
||||
newlong=null,
|
||||
newdouble=null,
|
||||
newstruct=null,
|
||||
newlist=null,
|
||||
newset=null,
|
||||
newmap=null,
|
||||
newstring=null,
|
||||
end_in_both=null
|
||||
}
|
||||
)},
|
||||
{"ListTypeVersioningV1 record", ?_assertMatch(
|
||||
{'thrift.test.ListTypeVersioningV1', _, _},
|
||||
#'thrift.test.ListTypeVersioningV1'{myints=null,hello=null}
|
||||
)},
|
||||
{"ListTypeVersioningV2 record", ?_assertMatch(
|
||||
{'thrift.test.ListTypeVersioningV2', _, _},
|
||||
#'thrift.test.ListTypeVersioningV2'{strings=null,hello=null}
|
||||
)},
|
||||
{"GuessProtocolStruct record", ?_assertMatch(
|
||||
{'thrift.test.GuessProtocolStruct', _},
|
||||
#'thrift.test.GuessProtocolStruct'{map_field=null}
|
||||
)},
|
||||
{"LargeDeltas record", ?_assertMatch(
|
||||
{'thrift.test.LargeDeltas', _, _, _, _, _, _, _, _, _, _},
|
||||
#'thrift.test.LargeDeltas'{
|
||||
b1=null,
|
||||
b10=null,
|
||||
b100=null,
|
||||
check_true=null,
|
||||
b1000=null,
|
||||
check_false=null,
|
||||
vertwo2000=null,
|
||||
a_set2500=null,
|
||||
vertwo3000=null,
|
||||
big_numbers=null
|
||||
}
|
||||
)},
|
||||
{"NestedListsI32x2 record", ?_assertMatch(
|
||||
{'thrift.test.NestedListsI32x2', _},
|
||||
#'thrift.test.NestedListsI32x2'{integerlist=null}
|
||||
)},
|
||||
{"NestedListsI32x3 record", ?_assertMatch(
|
||||
{'thrift.test.NestedListsI32x3', _},
|
||||
#'thrift.test.NestedListsI32x3'{integerlist=null}
|
||||
)},
|
||||
{"NestedMixedx2 record", ?_assertMatch(
|
||||
{'thrift.test.NestedMixedx2', _, _, _},
|
||||
#'thrift.test.NestedMixedx2'{
|
||||
int_set_list=null,
|
||||
map_int_strset=null,
|
||||
map_int_strset_list=null
|
||||
}
|
||||
)},
|
||||
{"ListBonks record", ?_assertMatch({'thrift.test.ListBonks', _}, #'thrift.test.ListBonks'{bonk=null})},
|
||||
{"NestedListsBonk record", ?_assertMatch(
|
||||
{'thrift.test.NestedListsBonk', _},
|
||||
#'thrift.test.NestedListsBonk'{bonk=null}
|
||||
)},
|
||||
{"BoolTest record", ?_assertMatch(
|
||||
{'thrift.test.BoolTest', _, _},
|
||||
#'thrift.test.BoolTest'{b=null,s=null}
|
||||
)},
|
||||
{"StructA record", ?_assertMatch({'thrift.test.StructA', _}, #'thrift.test.StructA'{s=null})},
|
||||
{"StructB record", ?_assertMatch(
|
||||
{'thrift.test.StructB', _, _},
|
||||
#'thrift.test.StructB'{aa=null,ab=null}
|
||||
)}
|
||||
].
|
||||
|
||||
struct_info_test_() ->
|
||||
[
|
||||
{"Bonk definition (short version)", ?_assertEqual(
|
||||
{struct, [{1, string}, {2, i32}]},
|
||||
thrift_test_types:struct_info('thrift.test.Bonk')
|
||||
)},
|
||||
{"Bonk definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, string, message, undefined},
|
||||
{2, undefined, i32, type, undefined}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.Bonk')
|
||||
)},
|
||||
{"Bools definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, bool, im_true, undefined},
|
||||
{2, undefined, bool, im_false, undefined}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.Bools')
|
||||
)},
|
||||
{"Xtruct definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, string, string_thing, undefined},
|
||||
{4, undefined, byte, byte_thing, undefined},
|
||||
{9, undefined, i32, i32_thing, undefined},
|
||||
{11, undefined, i64, i64_thing, undefined}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.Xtruct')
|
||||
)},
|
||||
{"Xtruct2 definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, byte, byte_thing, undefined},
|
||||
{2, undefined, {struct, {'thrift_test_types', 'thrift.test.Xtruct'}}, struct_thing, #'thrift.test.Xtruct'{}},
|
||||
{3, undefined, i32, i32_thing, undefined}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.Xtruct2')
|
||||
)},
|
||||
{"Xtruct3 definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, string, string_thing, undefined},
|
||||
{4, undefined, i32, changed, undefined},
|
||||
{9, undefined, i32, i32_thing, undefined},
|
||||
{11, undefined, i64, i64_thing, undefined}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.Xtruct3')
|
||||
)},
|
||||
{"Insanity definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, {map, i32, i64}, userMap, dict:new()},
|
||||
{2, undefined, {list, {struct, {'thrift_test_types', 'thrift.test.Xtruct'}}}, xtructs, []}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.Insanity')
|
||||
)},
|
||||
{"CrazyNesting definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, string, string_field, undefined},
|
||||
{2, optional, {set, {struct, {'thrift_test_types', 'thrift.test.Insanity'}}}, set_field, sets:new()},
|
||||
{3, required, {list, {map,
|
||||
{set, i32},
|
||||
{map, i32, {set, {list, {map, {struct, {'thrift_test_types', 'thrift.test.Insanity'}}, string}}}}
|
||||
}}, list_field, []},
|
||||
{4, undefined, string, binary_field, undefined}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.CrazyNesting')
|
||||
)},
|
||||
{"Xception definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, i32, errorCode, undefined},
|
||||
{2, undefined, string, message, undefined}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.Xception')
|
||||
)},
|
||||
{"Xception2 definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, i32, errorCode, undefined},
|
||||
{2, undefined, {struct, {'thrift_test_types', 'thrift.test.Xtruct'}}, struct_thing, #'thrift.test.Xtruct'{}}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.Xception2')
|
||||
)},
|
||||
{"EmptyStruct definition", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_types:struct_info_ext('thrift.test.EmptyStruct')
|
||||
)},
|
||||
{"OneField definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, {struct, {'thrift_test_types', 'thrift.test.EmptyStruct'}}, field, #'thrift.test.EmptyStruct'{}}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.OneField')
|
||||
)},
|
||||
{"VersioningTestV1 definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, i32, begin_in_both, undefined},
|
||||
{3, undefined, string, old_string, undefined},
|
||||
{12, undefined, i32, end_in_both, undefined}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.VersioningTestV1')
|
||||
)},
|
||||
{"VersioningTestV2 definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, i32, begin_in_both, undefined},
|
||||
{2, undefined, i32, newint, undefined},
|
||||
{3, undefined, byte, newbyte, undefined},
|
||||
{4, undefined, i16, newshort, undefined},
|
||||
{5, undefined, i64, newlong, undefined},
|
||||
{6, undefined, double, newdouble, undefined},
|
||||
{7, undefined, {struct, {thrift_test_types, 'thrift.test.Bonk'}}, newstruct, #'thrift.test.Bonk'{}},
|
||||
{8, undefined, {list, i32}, newlist, []},
|
||||
{9, undefined, {set, i32}, newset, sets:new()},
|
||||
{10, undefined, {map, i32, i32}, newmap, dict:new()},
|
||||
{11, undefined, string, newstring, undefined},
|
||||
{12, undefined, i32, end_in_both, undefined}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.VersioningTestV2')
|
||||
)},
|
||||
{"ListTypeVersioningV1 definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, {list, i32}, myints, []},
|
||||
{2, undefined, string, hello, undefined}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.ListTypeVersioningV1')
|
||||
)},
|
||||
{"ListTypeVersioningV2 definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, {list, string}, strings, []},
|
||||
{2, undefined, string, hello, undefined}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.ListTypeVersioningV2')
|
||||
)},
|
||||
{"GuessProtocolStruct definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{7, undefined, {map, string, string}, map_field, dict:new()}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.GuessProtocolStruct')
|
||||
)},
|
||||
{"LargeDeltas definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b1, #'thrift.test.Bools'{}},
|
||||
{10, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b10, #'thrift.test.Bools'{}},
|
||||
{100, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b100, #'thrift.test.Bools'{}},
|
||||
{500, undefined, bool, check_true, undefined},
|
||||
{1000, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b1000, #'thrift.test.Bools'{}},
|
||||
{1500, undefined, bool, check_false, undefined},
|
||||
{2000, undefined, {struct, {thrift_test_types, 'thrift.test.VersioningTestV2'}}, vertwo2000, #'thrift.test.VersioningTestV2'{}},
|
||||
{2500, undefined, {set, string}, a_set2500, sets:new()},
|
||||
{3000, undefined, {struct, {thrift_test_types, 'thrift.test.VersioningTestV2'}}, vertwo3000, #'thrift.test.VersioningTestV2'{}},
|
||||
{4000, undefined, {list, i32}, big_numbers, []}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.LargeDeltas')
|
||||
)},
|
||||
{"NestedListsI32x2 definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, {list, {list, i32}}, integerlist, []}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.NestedListsI32x2')
|
||||
)},
|
||||
{"NestedListsI32x3 definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, {list, {list, {list, i32}}}, integerlist, []}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.NestedListsI32x3')
|
||||
)},
|
||||
{"NestedMixedx2 definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, {list, {set, i32}}, int_set_list, []},
|
||||
{2, undefined, {map, i32, {set, string}}, map_int_strset, dict:new()},
|
||||
{3, undefined, {list, {map, i32, {set, string}}}, map_int_strset_list, []}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.NestedMixedx2')
|
||||
)},
|
||||
{"ListBonks definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, {list, {struct, {thrift_test_types, 'thrift.test.Bonk'}}}, bonk, []}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.ListBonks')
|
||||
)},
|
||||
{"NestedListsBonk definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, undefined, {list, {list, {list, {struct, {thrift_test_types, 'thrift.test.Bonk'}}}}}, bonk, []}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.NestedListsBonk')
|
||||
)},
|
||||
{"BoolTest definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, optional, bool, b, true},
|
||||
{2, optional, string, s, "true"}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.BoolTest')
|
||||
)},
|
||||
{"StructA definition", ?_assertEqual(
|
||||
{struct, [{1, required, string, s, undefined}]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.StructA')
|
||||
)},
|
||||
{"StructB definition", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, optional, {struct, {thrift_test_types, 'thrift.test.StructA'}}, aa, #'thrift.test.StructA'{}},
|
||||
{2, required, {struct, {thrift_test_types, 'thrift.test.StructA'}}, ab, #'thrift.test.StructA'{}}
|
||||
]},
|
||||
thrift_test_types:struct_info_ext('thrift.test.StructB')
|
||||
)}
|
||||
].
|
||||
|
||||
service_info_test_() ->
|
||||
[
|
||||
{"testVoid params", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testVoid, params_type)
|
||||
)},
|
||||
{"testVoid reply", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testVoid, reply_type)
|
||||
)},
|
||||
{"testVoid exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testVoid, exceptions)
|
||||
)},
|
||||
{"testString params", ?_assertEqual(
|
||||
{struct, [{1, string}]},
|
||||
thrift_test_thrift:function_info(testString, params_type)
|
||||
)},
|
||||
{"testString reply", ?_assertEqual(
|
||||
string,
|
||||
thrift_test_thrift:function_info(testString, reply_type)
|
||||
)},
|
||||
{"testString exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testString, exceptions)
|
||||
)},
|
||||
{"testByte params", ?_assertEqual(
|
||||
{struct, [{1, byte}]},
|
||||
thrift_test_thrift:function_info(testByte, params_type)
|
||||
)},
|
||||
{"testByte reply", ?_assertEqual(
|
||||
byte,
|
||||
thrift_test_thrift:function_info(testByte, reply_type)
|
||||
)},
|
||||
{"testByte exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testByte, exceptions)
|
||||
)},
|
||||
{"testI32 params", ?_assertEqual(
|
||||
{struct, [{1, i32}]},
|
||||
thrift_test_thrift:function_info(testI32, params_type)
|
||||
)},
|
||||
{"testI32 reply", ?_assertEqual(
|
||||
i32,
|
||||
thrift_test_thrift:function_info(testI32, reply_type)
|
||||
)},
|
||||
{"testI32 exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testI32, exceptions)
|
||||
)},
|
||||
{"testI64 params", ?_assertEqual(
|
||||
{struct, [{1, i64}]},
|
||||
thrift_test_thrift:function_info(testI64, params_type)
|
||||
)},
|
||||
{"testI64 reply", ?_assertEqual(
|
||||
i64,
|
||||
thrift_test_thrift:function_info(testI64, reply_type)
|
||||
)},
|
||||
{"testI64 exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testI64, exceptions)
|
||||
)},
|
||||
{"testDouble params", ?_assertEqual(
|
||||
{struct, [{1, double}]},
|
||||
thrift_test_thrift:function_info(testDouble, params_type)
|
||||
)},
|
||||
{"testDouble reply", ?_assertEqual(
|
||||
double,
|
||||
thrift_test_thrift:function_info(testDouble, reply_type)
|
||||
)},
|
||||
{"testDouble exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testDouble, exceptions)
|
||||
)},
|
||||
{"testStruct params", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, {struct, {thrift_test_types, 'thrift.test.Xtruct'}}}
|
||||
]},
|
||||
thrift_test_thrift:function_info(testStruct, params_type)
|
||||
)},
|
||||
{"testStruct reply", ?_assertEqual(
|
||||
{struct, {thrift_test_types, 'thrift.test.Xtruct'}},
|
||||
thrift_test_thrift:function_info(testStruct, reply_type)
|
||||
)},
|
||||
{"testStruct exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testStruct, exceptions)
|
||||
)},
|
||||
{"testNest params", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, {struct, {thrift_test_types, 'thrift.test.Xtruct2'}}}
|
||||
]},
|
||||
thrift_test_thrift:function_info(testNest, params_type)
|
||||
)},
|
||||
{"testNest reply", ?_assertEqual(
|
||||
{struct, {thrift_test_types, 'thrift.test.Xtruct2'}},
|
||||
thrift_test_thrift:function_info(testNest, reply_type)
|
||||
)},
|
||||
{"testNest exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testNest, exceptions)
|
||||
)},
|
||||
{"testMap params", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, {map, i32, i32}}
|
||||
]},
|
||||
thrift_test_thrift:function_info(testMap, params_type)
|
||||
)},
|
||||
{"testMap reply", ?_assertEqual(
|
||||
{map, i32, i32},
|
||||
thrift_test_thrift:function_info(testMap, reply_type)
|
||||
)},
|
||||
{"testMap exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testMap, exceptions)
|
||||
)},
|
||||
{"testStringMap params", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, {map, string, string}}
|
||||
]},
|
||||
thrift_test_thrift:function_info(testStringMap, params_type)
|
||||
)},
|
||||
{"testStringMap reply", ?_assertEqual(
|
||||
{map, string, string},
|
||||
thrift_test_thrift:function_info(testStringMap, reply_type)
|
||||
)},
|
||||
{"testStringMap exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testStringMap, exceptions)
|
||||
)},
|
||||
{"testSet params", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, {set, i32}}
|
||||
]},
|
||||
thrift_test_thrift:function_info(testSet, params_type)
|
||||
)},
|
||||
{"testSet reply", ?_assertEqual(
|
||||
{set, i32},
|
||||
thrift_test_thrift:function_info(testSet, reply_type)
|
||||
)},
|
||||
{"testSet exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testSet, exceptions)
|
||||
)},
|
||||
{"testList params", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, {list, i32}}
|
||||
]},
|
||||
thrift_test_thrift:function_info(testList, params_type)
|
||||
)},
|
||||
{"testList reply", ?_assertEqual(
|
||||
{list, i32},
|
||||
thrift_test_thrift:function_info(testList, reply_type)
|
||||
)},
|
||||
{"testList exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testList, exceptions)
|
||||
)},
|
||||
{"testEnum params", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, i32}
|
||||
]},
|
||||
thrift_test_thrift:function_info(testEnum, params_type)
|
||||
)},
|
||||
{"testEnum reply", ?_assertEqual(
|
||||
i32,
|
||||
thrift_test_thrift:function_info(testEnum, reply_type)
|
||||
)},
|
||||
{"testEnum exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testEnum, exceptions)
|
||||
)},
|
||||
{"testTypedef params", ?_assertEqual(
|
||||
{struct, [{1, i64}]},
|
||||
thrift_test_thrift:function_info(testTypedef, params_type)
|
||||
)},
|
||||
{"testTypedef reply", ?_assertEqual(
|
||||
i64,
|
||||
thrift_test_thrift:function_info(testTypedef, reply_type)
|
||||
)},
|
||||
{"testTypedef exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testTypedef, exceptions)
|
||||
)},
|
||||
{"testMapMap params", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, i32}
|
||||
]},
|
||||
thrift_test_thrift:function_info(testMapMap, params_type)
|
||||
)},
|
||||
{"testMapMap reply", ?_assertEqual(
|
||||
{map, i32, {map, i32,i32}},
|
||||
thrift_test_thrift:function_info(testMapMap, reply_type)
|
||||
)},
|
||||
{"testMapMap exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testMapMap, exceptions)
|
||||
)},
|
||||
{"testInsanity params", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, {struct, {thrift_test_types, 'thrift.test.Insanity'}}}
|
||||
]},
|
||||
thrift_test_thrift:function_info(testInsanity, params_type)
|
||||
)},
|
||||
{"testInsanity reply", ?_assertEqual(
|
||||
{map, i64, {map, i32, {struct, {'thrift_test_types', 'thrift.test.Insanity'}}}},
|
||||
thrift_test_thrift:function_info(testInsanity, reply_type)
|
||||
)},
|
||||
{"testInsanity exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testInsanity, exceptions)
|
||||
)},
|
||||
{"testMulti params", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, byte},
|
||||
{2, i32},
|
||||
{3, i64},
|
||||
{4, {map, i16, string}},
|
||||
{5, i32},
|
||||
{6, i64}
|
||||
]},
|
||||
thrift_test_thrift:function_info(testMulti, params_type)
|
||||
)},
|
||||
{"testMulti reply", ?_assertEqual(
|
||||
{struct, {thrift_test_types, 'thrift.test.Xtruct'}},
|
||||
thrift_test_thrift:function_info(testMulti, reply_type)
|
||||
)},
|
||||
{"testMulti exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testMulti, exceptions)
|
||||
)},
|
||||
{"testException params", ?_assertEqual(
|
||||
{struct, [{1, string}]},
|
||||
thrift_test_thrift:function_info(testException, params_type)
|
||||
)},
|
||||
{"testException reply", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testException, reply_type)
|
||||
)},
|
||||
{"testException exceptions", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, {struct, {thrift_test_types, 'thrift.test.Xception'}}}
|
||||
]},
|
||||
thrift_test_thrift:function_info(testException, exceptions)
|
||||
)},
|
||||
{"testMultiException params", ?_assertEqual(
|
||||
{struct, [{1, string}, {2, string}]},
|
||||
thrift_test_thrift:function_info(testMultiException, params_type)
|
||||
)},
|
||||
{"testMultiException reply", ?_assertEqual(
|
||||
{struct, {thrift_test_types, 'thrift.test.Xtruct'}},
|
||||
thrift_test_thrift:function_info(testMultiException, reply_type)
|
||||
)},
|
||||
{"testMultiException exceptions", ?_assertEqual(
|
||||
{struct, [
|
||||
{1, {struct, {thrift_test_types, 'thrift.test.Xception'}}},
|
||||
{2, {struct, {thrift_test_types, 'thrift.test.Xception2'}}}
|
||||
]},
|
||||
thrift_test_thrift:function_info(testMultiException, exceptions)
|
||||
)},
|
||||
{"testOneway params", ?_assertEqual(
|
||||
{struct, [{1, i32}]},
|
||||
thrift_test_thrift:function_info(testOneway, params_type)
|
||||
)},
|
||||
{"testOneway reply", ?_assertEqual(
|
||||
oneway_void,
|
||||
thrift_test_thrift:function_info(testOneway, reply_type)
|
||||
)},
|
||||
{"testOneway exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
thrift_test_thrift:function_info(testOneway, exceptions)
|
||||
)},
|
||||
{"blahBlah params", ?_assertEqual(
|
||||
{struct, []},
|
||||
second_service_thrift:function_info(blahBlah, params_type)
|
||||
)},
|
||||
{"blahBlah reply", ?_assertEqual(
|
||||
{struct, []},
|
||||
second_service_thrift:function_info(blahBlah, reply_type)
|
||||
)},
|
||||
{"blahBlah exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
second_service_thrift:function_info(blahBlah, exceptions)
|
||||
)},
|
||||
{"secondtestString params", ?_assertEqual(
|
||||
{struct, [{1, string}]},
|
||||
second_service_thrift:function_info(secondtestString, params_type)
|
||||
)},
|
||||
{"secondtestString reply", ?_assertEqual(
|
||||
string,
|
||||
second_service_thrift:function_info(secondtestString, reply_type)
|
||||
)},
|
||||
{"secondtestString exceptions", ?_assertEqual(
|
||||
{struct, []},
|
||||
second_service_thrift:function_info(secondtestString, exceptions)
|
||||
)}
|
||||
].
|
Loading…
Add table
Add a link
Reference in a new issue