Skip to content
Permalink
Browse files
test: add common test lib
  • Loading branch information
DLive committed May 2, 2019
1 parent 45a6668 commit 834dc65dc413c8210846e205adc3956d1f663948
Showing 9 changed files with 390 additions and 6 deletions.
@@ -6,7 +6,7 @@
{<<"com.ifcoder.demo.facade.User">>,[]}
]},
{provider,[
{user_impl,user_behaviour,<<"com.ifcoder.demo.facade.User">>,[]}
% {user_impl,user_behaviour,<<"com.ifcoder.demo.facade.User">>,[]}
]}

]}
@@ -148,7 +148,7 @@ handle_info(_Info, State) ->
%%--------------------------------------------------------------------
%% @private
%% @doc
%% This function is called by a gen_se rver when it is about to
%% This function is called by a gen_server when it is about to
%% terminate. It should be the opposite of Module:init/1 and do any
%% necessary cleaning up. When it returns, the gen_server terminates
%% with Reason. The return value is ignored.
@@ -270,7 +270,6 @@ clean_invalid_provider([HostFlag | DeleteProverList])->
[]->
ok;
ProviderNodeList->
io:format("ConnectionList ~p~n",[ProviderNodeList]),
ProviderNodeList1 = lists_util:del_duplicate(ProviderNodeList),
clean_connection_info(ProviderNodeList1)
end,
@@ -5,7 +5,7 @@
{mod, { dubboerl_app, []}},
{applications,
[kernel,
stdlib,xmerl,eunit,erlzk,logger,poolboy,inets
stdlib,xmerl,eunit,erlzk,poolboy,inets
]},
{env,[]},
{modules, []},
@@ -16,8 +16,8 @@
-export([init/0,start_consumer/0,start_provider/0]).

init()->
start_consumer(),
start_provider(),
ok=start_consumer(),
ok=start_provider(),
ok.


@@ -0,0 +1,126 @@
%%%-------------------------------------------------------------------
%%% @author dlive
%%% @copyright (C) 2019, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 02. May 2019 17:10
%%%-------------------------------------------------------------------
-module(consumer_SUITE).
-author("dlive").

%% API
-export([]).

-compile(export_all).

-include_lib("common_test/include/ct.hrl").

%%--------------------------------------------------------------------
%% Function: suite() -> Info
%% Info = [tuple()]
%%--------------------------------------------------------------------
suite() ->
[{timetrap,{seconds,50}}].

%%--------------------------------------------------------------------
%% Function: init_per_suite(Config0) ->
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
%% Config0 = Config1 = [tuple()]
%% Reason = term()
%%--------------------------------------------------------------------
init_per_suite(Config) ->
application:ensure_all_started(dubboerl),
Config.

%%--------------------------------------------------------------------
%% Function: end_per_suite(Config0) -> term() | {save_config,Config1}
%% Config0 = Config1 = [tuple()]
%%--------------------------------------------------------------------
end_per_suite(_Config) ->
ok.

%%--------------------------------------------------------------------
%% Function: init_per_group(GroupName, Config0) ->
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
%% GroupName = atom()
%% Config0 = Config1 = [tuple()]
%% Reason = term()
%%--------------------------------------------------------------------
init_per_group(_GroupName, Config) ->
Config.

%%--------------------------------------------------------------------
%% Function: end_per_group(GroupName, Config0) ->
%% term() | {save_config,Config1}
%% GroupName = atom()
%% Config0 = Config1 = [tuple()]
%%--------------------------------------------------------------------
end_per_group(_GroupName, _Config) ->
ok.

%%--------------------------------------------------------------------
%% Function: init_per_testcase(TestCase, Config0) ->
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
%% TestCase = atom()
%% Config0 = Config1 = [tuple()]
%% Reason = term()
%%--------------------------------------------------------------------
init_per_testcase(_TestCase, Config) ->
Config.

%%--------------------------------------------------------------------
%% Function: end_per_testcase(TestCase, Config0) ->
%% term() | {save_config,Config1} | {fail,Reason}
%% TestCase = atom()
%% Config0 = Config1 = [tuple()]
%% Reason = term()
%%--------------------------------------------------------------------
end_per_testcase(_TestCase, _Config) ->
ok.

%%--------------------------------------------------------------------
%% Function: groups() -> [Group]
%% Group = {GroupName,Properties,GroupsAndTestCases}
%% GroupName = atom()
%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]
%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]
%% TestCase = atom()
%% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}}
%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |
%% repeat_until_any_ok | repeat_until_any_fail
%% N = integer() | forever
%%--------------------------------------------------------------------
groups() ->
[
{consumer1,[sequence],[lib_type_register]}
].

%%--------------------------------------------------------------------
%% Function: all() -> GroupsAndTestCases | {skip,Reason}
%% GroupsAndTestCases = [{group,GroupName} | TestCase]
%% GroupName = atom()
%% TestCase = atom()
%% Reason = term()
%%--------------------------------------------------------------------
all() ->
[{group,consumer1}].

%%--------------------------------------------------------------------
%% Function: TestCase() -> Info
%% Info = [tuple()]
%%--------------------------------------------------------------------
lib_type_register() ->
[].

%%--------------------------------------------------------------------
%% Function: TestCase(Config0) ->
%% ok | exit() | {skip,Reason} | {comment,Comment} |
%% {save_config,Config1} | {skip_and_save,Reason,Config1}
%% Config0 = Config1 = [tuple()]
%% Reason = term()
%% Comment = term()
%%--------------------------------------------------------------------
lib_type_register(_Config) ->
ok = dubbo_service_app:register_type_list(),
ok.
@@ -0,0 +1,14 @@

-record(userInfoRequest,{
username ::list(),
requestId ::list()}).


-record(userInfo,{
userName ::list(),
userId ::list(),
userAge ::integer()}).

-record(userRes,{
userlist ::[]}).

@@ -0,0 +1,40 @@
%%%-------------------------------------------------------------------
%% @doc dubbo_service public API
%% @end
%%%-------------------------------------------------------------------

-module(dubbo_service_app).

-behaviour(application).

%% Application callbacks
-export([start/2, stop/1]).
-export([register_type_list/0]).

-include("dubbo_service.hrl").


%%====================================================================
%% API
%%====================================================================

start(_StartType, _StartArgs) ->
register_type_list(),
dubbo_service_sup:start_link().

%%--------------------------------------------------------------------
stop(_State) ->
ok.

%%====================================================================
%% Internal functions
%%====================================================================


register_type_list()->
List = dubbo_service_type_list:get_list(),
lists:map(
fun({NativeType,ForeignType,Fields}) ->
de_type_transfer:pre_process_typedef(NativeType,ForeignType,Fields)
end,List),
ok.
@@ -0,0 +1,15 @@
-module(dubbo_service_type_list).

%% API
-export([register_type_list/0,get_list/0]).

-include("dubbo_service.hrl").

get_list()->
[
{userInfoRequest,<<"com.ifcoder.demo.bean.UserInfoRequest">>,record_info(fields,userInfoRequest)},
{userInfo,<<"com.ifcoder.demo.bean.UserInfo">>,record_info(fields,userInfo)},
{userRes,<<"com.ifcoder.demo.bean.UserRes">>,record_info(fields,userRes)} ].

register_type_list()->
ok.

0 comments on commit 834dc65

Please sign in to comment.