Skip to content
Permalink
Browse files
test: add test
  • Loading branch information
DLive committed May 8, 2019
1 parent ae9bb5f commit f083d37e5d0134f8287e1fdb0911fd078228c49a
Showing 6 changed files with 87 additions and 8 deletions.
@@ -1,13 +1,32 @@
[
{kernel,
[
{logger,
[
{handler, file, logger_std_h,
#{
config => #{
type=> file,
file => "./log/common.log"
},
level => all
}
}
]
}
]
},
{dubboerl,[
{zookeeper_list,[{"127.0.0.1",2181}]},
{application,<<"testdubboerl">>},
{registry,true},
{protocol,hessian},
{port,20881},
{consumer,[
{<<"com.ifcoder.demo.facade.User">>,[]}
]},
{provider,[
% {user_impl,user_behaviour,<<"com.ifcoder.demo.facade.User">>,[]}
{dubbo_service_user_impl,user2,<<"com.ifcoder.demo.facade.User">>,[]}
]}

]}
@@ -4,7 +4,7 @@
{base_dir, "_build"}.
{root_dir, "."}.
{project_app_dirs, ["."]}.
{extra_src_dirs, ["test"]}.

{plugins, [
rebar3_hex,
{rebar3_codecov, "0.1.0"}
@@ -26,3 +26,11 @@
{jiffy, "0.15.1"}
]}.


{profiles,[
{test,
[
{extra_src_dirs, ["test"]}
]
}
]}.
@@ -5,7 +5,7 @@
{mod, { dubboerl_app, []}},
{applications,
[kernel,
stdlib,xmerl,eunit,erlzk,poolboy,inets
stdlib,xmerl,ranch,erlzk,poolboy,inets
]},
{env,[]},
{modules, []},
@@ -21,7 +21,7 @@
%% Info = [tuple()]
%%--------------------------------------------------------------------
suite() ->
[{timetrap,{seconds,50}}].
[{timetrap,{seconds,60}}].

%%--------------------------------------------------------------------
%% Function: init_per_suite(Config0) ->
@@ -30,9 +30,19 @@ suite() ->
%% Reason = term()
%%--------------------------------------------------------------------
init_per_suite(Config) ->
%% logger:add_handler(testttt,logger_std_h,#{
%% config => #{
%% type=> file,
%% file => "/tmp/common.log"
%% },
%% level => debug
%% }),
Start = application:ensure_all_started(dubboerl),
dubboerl:init(),
dubbo_service_app:start(a,b),
timer:sleep(5000),
io:format(user,"test case start info ~p~n",[Start]),
Config.
[{appid,1}].

%%--------------------------------------------------------------------
%% Function: end_per_suite(Config0) -> term() | {save_config,Config1}
@@ -94,7 +104,7 @@ end_per_testcase(_TestCase, _Config) ->
%%--------------------------------------------------------------------
groups() ->
[
{consumer1,[sequence],[lib_type_register]}
{consumer1,[sequence],[lib_type_register,user_sync_invoker]}
].

%%--------------------------------------------------------------------
@@ -123,5 +133,13 @@ lib_type_register() ->
%% Comment = term()
%%--------------------------------------------------------------------
lib_type_register(_Config) ->
ok = dubbo_service_app:register_type_list(),

ok.

user_sync_invoker(_Config)->
%% dubbo_service_app:register_type_list(),
io:format(user,"table info ~p~n",[ets:info(provider_impl_table)]),
Result = user2:genUserId(),

io:format(user,"result ~p ~n",[Result]),
ok.
@@ -0,0 +1,34 @@
%%%-------------------------------------------------------------------
%%% @author dlive
%%% @copyright (C) 2019, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 08. May 2019 11:06
%%%-------------------------------------------------------------------
-module(dubbo_service_user_impl).
-author("dlive").

-behaviour(user2).

-include_lib("dubbo_service.hrl").
-include_lib("dubboerl/include/hessian.hrl").
-include_lib("dubboerl/include/dubbo.hrl").
%% API
-export([getUserInfo/1,queryUserList/1,genUserId/0]).

genUserId()->
"newid".

getUserInfo(Args) ->
io:format(user,"do invokeWs ~p",[Args]),
#userInfo{userAge = 88,userName = "one", userId = "id123"}.

queryUserList(Args)->
User = #userInfo{userAge = 88,userName = "two", userId = "id123"},
List = #list{len=1,type="java.util.ArrayList",values=[User]},

Res = #userRes{
userlist = List
},
Res.
@@ -1,4 +1,4 @@
-module(user).
-module(user2).

-include_lib("dubboerl/include/dubbo.hrl").
-include_lib("dubboerl/include/hessian.hrl").

0 comments on commit f083d37

Please sign in to comment.