3030import java .util .HashMap ;
3131import java .util .Map ;
3232import org .apache .commons .lang3 .StringUtils ;
33- import org .junit .AfterClass ;
34- import org .junit .Assert ;
35- import org .junit .BeforeClass ;
36- import org .junit .Test ;
33+ import org .junit .jupiter . api . AfterAll ;
34+ import org .junit .jupiter . api . Assertions ;
35+ import org .junit .jupiter . api . BeforeAll ;
36+ import org .junit .jupiter . api . Test ;
3737import tests .service .GreeterJsonService ;
3838import tests .service .GreeterService ;
3939import tests .service .HelloRequestProtocol .HelloRequest ;
@@ -53,7 +53,7 @@ public class Http2RpcClientTest {
5353
5454 private static Map <String , Object > extMap = new HashMap <>();
5555
56- @ BeforeClass
56+ @ BeforeAll
5757 public static void startHttpServer () {
5858
5959 String path = Http2RpcServerTest .class .getClassLoader ().getResource ("keystore.jks" )
@@ -130,7 +130,7 @@ private static ServiceConfig getServiceConfig(ProviderConfig gspc, String name,
130130 return serviceConfig ;
131131 }
132132
133- @ AfterClass
133+ @ AfterAll
134134 public static void stopHttpServer () {
135135 ConfigManager .stopTest ();
136136 if (serverConfig != null ) {
@@ -154,7 +154,7 @@ public void testHttpRpcClient() {
154154 backendConfig .setRequestTimeout (10000 );
155155 consumerConfig .setServiceInterface (GreeterService .class );
156156 consumerConfig .setBackendConfig (backendConfig );
157- backendConfig .setNamingUrl ("ip://127.0.0.1 :18084" );
157+ backendConfig .setNamingUrl ("ip://localhost :18084" );
158158 backendConfig .setKeepAlive (false );
159159 backendConfig .setConnsPerAddr (4 );
160160 backendConfig .setProtocol (HTTP2_SCHEME );
@@ -166,10 +166,10 @@ public void testHttpRpcClient() {
166166 for (int i = 0 ; i < 20 ; i ++) {
167167 RpcClientContext context = new RpcClientContext ();
168168 HelloResponse helloResponse = proxy .sayHello (context , createPbRequest (TEST_MESSAGE ));
169- Assert .assertNotNull (helloResponse );
169+ Assertions .assertNotNull (helloResponse );
170170 String rspMessage = helloResponse .getMessage ();
171171 logger .info ("http rpc client request result: {}" , rspMessage );
172- Assert .assertTrue (rspMessage .contains (TEST_MESSAGE ));
172+ Assertions .assertTrue (rspMessage .contains (TEST_MESSAGE ));
173173 }
174174 } finally {
175175 backendConfig .stop ();
@@ -185,7 +185,7 @@ public void testHttpRpcClientWithOneWay() {
185185 backendConfig .setRequestTimeout (10000 );
186186 consumerConfig .setServiceInterface (GreeterService .class );
187187 consumerConfig .setBackendConfig (backendConfig );
188- backendConfig .setNamingUrl ("ip://127.0.0.1 :18084" );
188+ backendConfig .setNamingUrl ("ip://localhost :18084" );
189189 backendConfig .setKeepAlive (false );
190190 backendConfig .setConnsPerAddr (4 );
191191 backendConfig .setProtocol (HTTP2_SCHEME );
@@ -198,7 +198,7 @@ public void testHttpRpcClientWithOneWay() {
198198 RpcClientContext context = new RpcClientContext ();
199199 context .setOneWay (true );
200200 HelloResponse helloResponse = proxy .sayHello (context , createPbRequest (TEST_MESSAGE ));
201- Assert .assertNull (helloResponse );
201+ Assertions .assertNull (helloResponse );
202202 }
203203 } finally {
204204 backendConfig .stop ();
@@ -214,7 +214,7 @@ public void testHttpRpcClientBasePath1() {
214214 backendConfig .setRequestTimeout (10000 );
215215 consumerConfig .setServiceInterface (GreeterService .class );
216216 consumerConfig .setBackendConfig (backendConfig );
217- backendConfig .setNamingUrl ("ip://127.0.0.1 :18085" );
217+ backendConfig .setNamingUrl ("ip://localhost :18085" );
218218 backendConfig .setKeepAlive (false );
219219 backendConfig .setConnsPerAddr (4 );
220220 backendConfig .setProtocol (HTTP2_SCHEME );
@@ -227,10 +227,10 @@ public void testHttpRpcClientBasePath1() {
227227 for (int i = 0 ; i < 20 ; i ++) {
228228 RpcClientContext context = new RpcClientContext ();
229229 HelloResponse helloResponse = proxy .sayHello (context , createPbRequest (TEST_MESSAGE ));
230- Assert .assertNotNull (helloResponse );
230+ Assertions .assertNotNull (helloResponse );
231231 String rspMessage = helloResponse .getMessage ();
232232 logger .info ("http rpc client request result: {}" , rspMessage );
233- Assert .assertTrue (rspMessage .contains (TEST_MESSAGE ));
233+ Assertions .assertTrue (rspMessage .contains (TEST_MESSAGE ));
234234 }
235235 } finally {
236236 backendConfig .stop ();
@@ -246,7 +246,7 @@ public void testHttpRpcClientBasePath2() {
246246 backendConfig .setRequestTimeout (10000 );
247247 consumerConfig .setServiceInterface (GreeterJsonService .class );
248248 consumerConfig .setBackendConfig (backendConfig );
249- backendConfig .setNamingUrl ("ip://127.0.0.1 :18085" );
249+ backendConfig .setNamingUrl ("ip://localhost :18085" );
250250 backendConfig .setKeepAlive (false );
251251 backendConfig .setConnsPerAddr (4 );
252252 backendConfig .setProtocol (HTTP2_SCHEME );
@@ -262,10 +262,10 @@ public void testHttpRpcClientBasePath2() {
262262
263263 RpcClientContext context = new RpcClientContext ();
264264 Map helloResponse = proxy .sayHelloJson (context , obj );
265- Assert .assertNotNull (helloResponse );
265+ Assertions .assertNotNull (helloResponse );
266266 String rspMessage = (String ) helloResponse .get ("message" );
267267 logger .info ("http rpc client request result: {}" , rspMessage );
268- Assert .assertTrue (rspMessage .contains (TEST_MESSAGE ));
268+ Assertions .assertTrue (rspMessage .contains (TEST_MESSAGE ));
269269 }
270270 } finally {
271271 backendConfig .stop ();
@@ -281,7 +281,7 @@ public void testHttpRpcClientBasePathNotExist() {
281281 backendConfig .setRequestTimeout (10000 );
282282 consumerConfig .setServiceInterface (GreeterService .class );
283283 consumerConfig .setBackendConfig (backendConfig );
284- backendConfig .setNamingUrl ("ip://127.0.0.1 :18085" );
284+ backendConfig .setNamingUrl ("ip://localhost :18085" );
285285 backendConfig .setKeepAlive (false );
286286 backendConfig .setConnsPerAddr (4 );
287287 backendConfig .setProtocol (HTTP2_SCHEME );
@@ -293,7 +293,7 @@ public void testHttpRpcClientBasePathNotExist() {
293293
294294 RpcClientContext context = new RpcClientContext ();
295295 HelloResponse helloResponse = proxy .sayHello (context , createPbRequest (TEST_MESSAGE ));
296- Assert .fail ("no exception thrown" );
296+ Assertions .fail ("no exception thrown" );
297297 } catch (TRpcException e ) {
298298 logger .error ("error: " , e );
299299 } finally {
@@ -310,7 +310,7 @@ public void testHttpRpcClientWithFailed() {
310310 backendConfig .setRequestTimeout (10000 );
311311 consumerConfig .setServiceInterface (GreeterService .class );
312312 consumerConfig .setBackendConfig (backendConfig );
313- backendConfig .setNamingUrl ("ip://127.0.0.1 :18086" );
313+ backendConfig .setNamingUrl ("ip://localhost :18086" );
314314 backendConfig .setKeepAlive (false );
315315 backendConfig .setConnsPerAddr (4 );
316316 backendConfig .setProtocol (HTTP2_SCHEME );
@@ -322,9 +322,9 @@ public void testHttpRpcClientWithFailed() {
322322
323323 RpcClientContext context = new RpcClientContext ();
324324 proxy .sayHello (context , createPbRequest (TEST_MESSAGE ));
325- Assert .fail ("no exception thrown" );
325+ Assertions .fail ("no exception thrown" );
326326 } catch (TRpcException e ) {
327- Assert .assertEquals (0 , e .getBizCode ());
327+ Assertions .assertEquals (0 , e .getBizCode ());
328328 } finally {
329329 backendConfig .stop ();
330330 }
@@ -339,7 +339,7 @@ public void testHttpRpcClientWithBlankRsp() {
339339 backendConfig .setRequestTimeout (10000 );
340340 consumerConfig .setServiceInterface (GreeterService .class );
341341 consumerConfig .setBackendConfig (backendConfig );
342- backendConfig .setNamingUrl ("ip://127.0.0.1 :18084" );
342+ backendConfig .setNamingUrl ("ip://localhost :18084" );
343343 backendConfig .setKeepAlive (false );
344344 backendConfig .setConnsPerAddr (4 );
345345 backendConfig .setProtocol (HTTP2_SCHEME );
@@ -351,9 +351,9 @@ public void testHttpRpcClientWithBlankRsp() {
351351 for (int i = 0 ; i < 20 ; i ++) {
352352 RpcClientContext context = new RpcClientContext ();
353353 String helloResponse = proxy .sayBlankHello (context , createPbRequest (TEST_MESSAGE ));
354- Assert .assertNull (helloResponse );
354+ Assertions .assertNull (helloResponse );
355355 logger .info ("http rpc client request result: {}" , helloResponse );
356- Assert .assertTrue (StringUtils .isEmpty (helloResponse ));
356+ Assertions .assertTrue (StringUtils .isEmpty (helloResponse ));
357357 }
358358 } finally {
359359 backendConfig .stop ();
0 commit comments