pandaapo commented on code in PR #4484:
URL: https://github.com/apache/eventmesh/pull/4484#discussion_r1358171184
##########
eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/util/BannerUtilTest.java:
##########
@@ -17,17 +17,13 @@
package org.apache.eventmesh.runtime.util;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class BannerUtilTest {
@Test
public void testGenerateBanner() {
- try {
- BannerUtil.generateBanner();
- } catch (Exception e) {
- Assertions.fail("BannerUtil.generateBanner() test failed");
- }
+ // Must not throw an exception
+ BannerUtil.generateBanner();
Review Comment:
The same situation as above.
##########
eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/util/EventMeshUtilTest.java:
##########
@@ -167,13 +167,10 @@ public void testCloneObject() throws IOException,
ClassNotFoundException {
@Test
public void testPrintState() {
- try {
- ScheduledExecutorService serviceRebalanceScheduler =
ThreadPoolFactory
- .createScheduledExecutor(5, new
EventMeshThreadFactory("proxy-rebalance-sch", true));
- EventMeshUtil.printState((ThreadPoolExecutor)
serviceRebalanceScheduler);
- } catch (Exception e) {
- Assertions.fail(e.getMessage());
- }
+ // Must not throw an exception
+ ScheduledExecutorService serviceRebalanceScheduler = ThreadPoolFactory
+ .createScheduledExecutor(5, new
EventMeshThreadFactory("proxy-rebalance-sch", true));
+ EventMeshUtil.printState((ThreadPoolExecutor)
serviceRebalanceScheduler);
Review Comment:
The same situation as above.
And you can check if there are similar situations in the other code you have
modified.
##########
eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/admin/controller/ClientManageControllerTest.java:
##########
@@ -85,13 +85,8 @@ public void testStart() throws Exception {
try (MockedStatic<HttpServer> dummyStatic =
Mockito.mockStatic(HttpServer.class)) {
HttpServer server = mock(HttpServer.class);
dummyStatic.when(() -> HttpServer.create(any(),
anyInt())).thenReturn(server);
- try {
- Mockito.doNothing().when(adminController).run(server);
- controller.start();
- } catch (IOException e) {
- Assertions.fail(e.getMessage());
- }
-
+ Mockito.doNothing().when(adminController).run(server);
+ controller.start();
Review Comment:
I think the purpose of the original code is to test that `start()` did not
throw any exceptions, so you can use JUnit5's `Assertions.
assertDoesNotThrow()` to optimize, instead of doing nothing after removing the
`try catch`.
--
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]