2525import com .tencent .trpc .core .common .config .AdminConfig ;
2626import com .tencent .trpc .core .utils .JsonUtils ;
2727import java .util .List ;
28- import org .junit .Assert ;
29- import org .junit .Before ;
30- import org .junit .Test ;
31- import org .junit .runner . RunWith ;
28+ import org .junit .jupiter . api . Assertions ;
29+ import org .junit .jupiter . api . BeforeEach ;
30+ import org .junit .jupiter . api . Test ;
31+ import org .junit .jupiter . api . extension . ExtendWith ;
3232import org .springframework .boot .test .context .SpringBootTest ;
3333import org .springframework .test .context .ActiveProfiles ;
34- import org .springframework .test .context .junit4 . SpringRunner ;
34+ import org .springframework .test .context .junit . jupiter . SpringExtension ;
3535
36- @ RunWith ( SpringRunner .class )
36+ @ ExtendWith ( SpringExtension .class )
3737@ ActiveProfiles ("admin" )
3838@ SpringBootTest (classes = TrpcServerApplication .class )
3939public class AdminIntegrationTest {
4040
4141 private String adminAddress ;
4242
43- @ Before
43+ @ BeforeEach
4444 public void before () {
4545 final AdminConfig adminConfig = ConfigManager .getInstance ().getServerConfig ().getAdminConfig ();
4646 adminAddress = new StringBuffer (adminConfig .getAdminIp ()).append (":" ).append (adminConfig .getAdminPort ())
4747 .toString ();
48+ System .out .println ("adminAddress:" + adminAddress );
4849 }
4950
5051 @ Test
5152 public void testVersion () {
5253 String [] cmd = {"curl" , "http://" + adminAddress + "/version" };
5354 String versionInfo = ShellUtils .execute (cmd );
5455 VersionDto versionDto = JsonUtils .fromJson (versionInfo , VersionDto .class );
55- Assert .assertEquals (Version .version (), versionDto .getVersion ());
56+ Assertions .assertEquals (Version .version (), versionDto .getVersion ());
5657 }
5758
5859 @ Test
@@ -61,19 +62,19 @@ public void testUpdateLoglevel() {
6162 String [] set2DebugCmd = {"curl" , "-XPUT" , "http://" + adminAddress + "/cmds/loglevel/ROOT" , "-d" ,
6263 "value=DEBUG" };
6364 String set2DebugResult = ShellUtils .execute (set2DebugCmd );
64- System .out .println (set2DebugResult );
65+ System .out .println ("set2DebugResult: " + set2DebugResult );
6566 final LoggerLevelRevisedDto levelDebugRevisedDto = JsonUtils .fromJson (set2DebugResult ,
6667 LoggerLevelRevisedDto .class );
6768
68- Assert .assertEquals (CommonDto .SUCCESS , levelDebugRevisedDto .getErrorcode ());
69- Assert .assertEquals ("DEBUG" , (levelDebugRevisedDto .getLevel ()));
69+ Assertions .assertEquals (CommonDto .SUCCESS , levelDebugRevisedDto .getErrorcode ());
70+ Assertions .assertEquals ("DEBUG" , (levelDebugRevisedDto .getLevel ()));
7071
7172 //查看修改后的结果
7273 String [] logLevelCmd = {"curl" , "http://" + adminAddress + "/cmds/loglevel" };
7374 String logLevelInfo = ShellUtils .execute (logLevelCmd );
7475 LoggerLevelDto dto = JsonUtils .fromJson (logLevelInfo , LoggerLevelDto .class );
75- Assert .assertEquals (CommonDto .SUCCESS , dto .getErrorcode ());
76- Assert .assertTrue (dto .getLogger ().stream ()
76+ Assertions .assertEquals (CommonDto .SUCCESS , dto .getErrorcode ());
77+ Assertions .assertTrue (dto .getLogger ().stream ()
7778 .anyMatch (log -> "ROOT" .equals (log .getLoggerName ()) && "DEBUG" .equals (log .getLevel ())));
7879
7980 //修改
@@ -82,63 +83,64 @@ public void testUpdateLoglevel() {
8283 LoggerLevelRevisedDto levelInfoRevisedDto = JsonUtils .fromJson (set2InfoResult ,
8384 LoggerLevelRevisedDto .class );
8485
85- Assert .assertEquals (CommonDto .SUCCESS , levelInfoRevisedDto .getErrorcode ());
86- Assert .assertEquals ("INFO" , levelInfoRevisedDto .getLevel ());
86+ Assertions .assertEquals (CommonDto .SUCCESS , levelInfoRevisedDto .getErrorcode ());
87+ Assertions .assertEquals ("INFO" , levelInfoRevisedDto .getLevel ());
8788 }
8889
8990 @ Test
9091 public void testLogLevel () {
9192 String [] cmd = {"curl" , "http://" + adminAddress + "/cmds/loglevel" };
9293 String logLevelInfo = ShellUtils .execute (cmd );
94+ System .out .println (logLevelInfo );
9395 LoggerLevelDto dto = JsonUtils .fromJson (logLevelInfo , LoggerLevelDto .class );
94- Assert .assertEquals (CommonDto .SUCCESS , dto .getErrorcode ());
95- Assert .assertTrue (dto .getLogger ().stream ()
96+ Assertions .assertEquals (CommonDto .SUCCESS , dto .getErrorcode ());
97+ Assertions .assertTrue (dto .getLogger ().stream ()
9698 .anyMatch (log -> "ROOT" .equals (log .getLoggerName ()) && "INFO" .equals (log .getLevel ())));
9799 }
98100
99101 @ Test
100102 public void testWorkerPool () {
101103 String [] cmd = {"curl" , "http://" + adminAddress + "/cmds/workerpool/info" };
102104 String workPoolInfo = ShellUtils .execute (cmd );
103- Assert .assertTrue ("{\" errorcode\" :\" 0\" ,\" message\" :\" \" ,\" workerPoolInfo\" :{}}" .equals (workPoolInfo ));
105+ Assertions .assertTrue ("{\" errorcode\" :\" 0\" ,\" message\" :\" \" ,\" workerPoolInfo\" :{}}" .equals (workPoolInfo ));
104106 }
105107
106108 @ Test
107109 public void testConfig () {
108110 String [] cmd = {"curl" , "http://" + adminAddress + "/cmds/config" };
109111 String configInfo = ShellUtils .execute (cmd );
110112 ConfigOverviewDto configOverviewDto = JsonUtils .fromJson (configInfo , ConfigOverviewDto .class );
111- Assert .assertEquals (CommonDto .SUCCESS , configOverviewDto .getErrorcode ());
112- Assert .assertEquals ("integration-test-admin" , configOverviewDto .getContent ().getServer ().getApp ());
113+ Assertions .assertEquals (CommonDto .SUCCESS , configOverviewDto .getErrorcode ());
114+ Assertions .assertEquals ("integration-test-admin" , configOverviewDto .getContent ().getServer ().getApp ());
113115 }
114116
115117 @ Test
116118 public void testStatRpc () {
117119 String [] cmd = {"curl" , "http://" + adminAddress + "/cmds/stats/rpc" };
118120 String rpcStats = ShellUtils .execute (cmd );
119121 RpcStatsDto rpcStatsDto = JsonUtils .fromJson (rpcStats , RpcStatsDto .class );
120- Assert .assertEquals (CommonDto .SUCCESS , rpcStatsDto .getErrorcode ());
121- Assert .assertEquals (Version .version (), rpcStatsDto .getRpcVersion ());
122- Assert .assertEquals (0 , rpcStatsDto .getRpcServiceCount ().intValue ());
122+ Assertions .assertEquals (CommonDto .SUCCESS , rpcStatsDto .getErrorcode ());
123+ Assertions .assertEquals (Version .version (), rpcStatsDto .getRpcVersion ());
124+ Assertions .assertEquals (0 , rpcStatsDto .getRpcServiceCount ().intValue ());
123125 }
124126
125127 @ Test
126128 public void testCustomAdmin () {
127129 String [] cmd = {"curl" , "http://" + adminAddress + "/cmds/test" };
128130 String testInfo = ShellUtils .execute (cmd );
129131 TestDto rpcStatsDto = JsonUtils .fromJson (testInfo , TestDto .class );
130- Assert .assertEquals (CommonDto .SUCCESS , rpcStatsDto .getErrorcode ());
131- Assert .assertEquals ("hello world!" , rpcStatsDto .getTestResult ());
132+ Assertions .assertEquals (CommonDto .SUCCESS , rpcStatsDto .getErrorcode ());
133+ Assertions .assertEquals ("hello world!" , rpcStatsDto .getTestResult ());
132134 }
133135
134136 @ Test
135137 public void testCmds () {
136138 String [] cmd = {"curl" , "http://" + adminAddress + "/cmds" };
137139 String cmdResult = ShellUtils .execute (cmd );
138140 CommandDto commandDto = JsonUtils .fromJson (cmdResult , CommandDto .class );
139- Assert .assertEquals (CommonDto .SUCCESS , commandDto .getErrorcode ());
141+ Assertions .assertEquals (CommonDto .SUCCESS , commandDto .getErrorcode ());
140142 List <String > commands = commandDto .getCmds ();
141- Assert .assertTrue (commands .contains ("/cmds/loglevel" ) && commands .contains ("/cmds/loglevel/{logname}" )
143+ Assertions .assertTrue (commands .contains ("/cmds/loglevel" ) && commands .contains ("/cmds/loglevel/{logname}" )
142144 && commands .contains ("/version" ) && commands .contains ("/cmds" ) && commands .contains ("/cmds/config" )
143145 && commands .contains ("/cmds/stats/rpc" ) && commands .contains ("/cmds/workerpool/info" )
144146 && commands .contains ("/cmds/test" ));
0 commit comments