mytang0 commented on code in PR #15347:
URL: https://github.com/apache/dubbo/pull/15347#discussion_r2076717025
##########
dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp3ProtocolTest.java:
##########
@@ -87,50 +100,70 @@ void testDemoProtocol() throws Exception {
ProxyFactory proxy =
applicationModel.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
Invoker<IGreeter> invoker = proxy.getInvoker(serviceImpl,
IGreeter.class, providerUrl);
+
Exporter<IGreeter> export = protocol.export(invoker);
URL consumerUrl = URL.valueOf("tri://127.0.0.1:" + availablePort + "/"
+ IGreeter.class.getName());
-
ConsumerModel consumerModel =
new ConsumerModel(consumerUrl.getServiceKey(), null,
serviceDescriptor, null, null, null);
consumerUrl = consumerUrl.setServiceModel(consumerModel);
+
IGreeter greeterProxy = proxy.getProxy(protocol.refer(IGreeter.class,
consumerUrl));
Thread.sleep(1000);
Assertions.assertTrue(Http3Exchanger.isEnabled(providerUrl));
- // 1. test unaryStream
+ // 1. Test unaryStream
String REQUEST_MSG = "hello world";
Assertions.assertEquals(REQUEST_MSG, greeterProxy.echo(REQUEST_MSG));
Assertions.assertEquals(REQUEST_MSG,
serviceImpl.echoAsync(REQUEST_MSG).get());
- // 2. test serverStream
+ // 2. Test serverStream
MockStreamObserver outboundMessageSubscriber1 = new
MockStreamObserver();
greeterProxy.serverStream(REQUEST_MSG, outboundMessageSubscriber1);
outboundMessageSubscriber1.getLatch().await(3000,
TimeUnit.MILLISECONDS);
Assertions.assertEquals(REQUEST_MSG,
outboundMessageSubscriber1.getOnNextData());
Assertions.assertTrue(outboundMessageSubscriber1.isOnCompleted());
- // 3. test bidirectionalStream
+ // 3. Test bidirectionalStream
MockStreamObserver outboundMessageSubscriber2 = new
MockStreamObserver();
StreamObserver<String> inboundMessageObserver =
greeterProxy.bidirectionalStream(outboundMessageSubscriber2);
inboundMessageObserver.onNext(REQUEST_MSG);
inboundMessageObserver.onCompleted();
outboundMessageSubscriber2.getLatch().await(3000,
TimeUnit.MILLISECONDS);
- // verify client
+
+ // Verify client
Assertions.assertEquals(IGreeter.SERVER_MSG,
outboundMessageSubscriber2.getOnNextData());
Assertions.assertTrue(outboundMessageSubscriber2.isOnCompleted());
- // verify server
+
+ // Verify server
MockStreamObserver serverOutboundMessageSubscriber =
(MockStreamObserver) serviceImpl.getMockStreamObserver();
serverOutboundMessageSubscriber.getLatch().await(1000,
TimeUnit.MILLISECONDS);
Assertions.assertEquals(REQUEST_MSG,
serverOutboundMessageSubscriber.getOnNextData());
Assertions.assertTrue(serverOutboundMessageSubscriber.isOnCompleted());
export.unexport();
protocol.destroy();
- // resource recycle.
serviceRepository.destroy();
- System.out.println("serviceRepository destroyed");
+ System.out.println("ServiceRepository destroyed at end of test");
+ }
+
+ @AfterEach
+ void cleanup() {
+ if (applicationModel != null) {
+ try {
+ DefaultRequestMappingRegistry registry = applicationModel
+ .getFrameworkModel()
+ .getBeanFactory()
+ .getBean(DefaultRequestMappingRegistry.class);
+ if (registry != null) {
+ registry.destroy();
+ System.out.println("DefaultRequestMappingRegistry
destroyed after test");
+ }
+ } catch (Exception e) {
+ System.err.println("Cleanup error: " + e.getMessage());
+ }
Review Comment:
Exception should be thrown instead of just logging the error.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]