@@ -375,39 +375,29 @@ void testDubboChain() throws ReflectiveOperationException {
375375 @ Test
376376 @ DisplayName ("test ignore injvm calls" )
377377 void testDubboChainInJvm () throws ReflectiveOperationException {
378- int port = PortUtils .findOpenPorts (2 );
379- int middlePort = port + 1 ;
380-
381- // setup hello service provider
382- ProtocolConfig protocolConfig = new ProtocolConfig ();
383- protocolConfig .setPort (port );
384-
385- DubboBootstrap bootstrap = DubboTestUtil .newDubboBootstrap ();
386- cleanup .deferCleanup (bootstrap ::destroy );
387- bootstrap
388- .application (new ApplicationConfig ("dubbo-test-provider" ))
389- .service (configureServer ())
390- .protocol (protocolConfig )
391- .start ();
378+ int port = PortUtils .findOpenPort ();
392379
393- // setup middle service provider, hello service consumer
380+ // setup middle service provider with HelloService provider and consumer in same bootstrap for
381+ // in-JVM calls
394382 ProtocolConfig middleProtocolConfig = new ProtocolConfig ();
395- middleProtocolConfig .setPort (middlePort );
383+ middleProtocolConfig .setPort (port );
396384
397385 ReferenceConfig <HelloService > clientReference = configureLocalClient (port );
398386 DubboBootstrap middleBootstrap = DubboTestUtil .newDubboBootstrap ();
399387 cleanup .deferCleanup (middleBootstrap ::destroy );
400388 middleBootstrap
401389 .application (new ApplicationConfig ("dubbo-demo-middle" ))
402- .service (configureMiddleServer (clientReference ))
390+ .service (configureServer ()) // HelloService provider in same bootstrap
391+ .reference (clientReference ) // HelloService consumer using in-JVM calls
392+ .service (configureMiddleServer (clientReference )) // MiddleService provider
403393 .protocol (middleProtocolConfig )
404394 .start ();
405395
406396 // setup middle service consumer
407397 ProtocolConfig consumerProtocolConfig = new ProtocolConfig ();
408398 consumerProtocolConfig .setRegister (false );
409399
410- ReferenceConfig <MiddleService > middleReference = configureMiddleClient (middlePort );
400+ ReferenceConfig <MiddleService > middleReference = configureMiddleClient (port );
411401 DubboBootstrap consumerBootstrap = DubboTestUtil .newDubboBootstrap ();
412402 cleanup .deferCleanup (consumerBootstrap ::destroy );
413403 consumerBootstrap
0 commit comments