You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2022/05/06 22:30:37 UTC

[GitHub] [cassandra-sidecar] frankgh commented on a diff in pull request #28: CASSANDRASC-36: Support for ErrorHandler in Sidecar

frankgh commented on code in PR #28:
URL: https://github.com/apache/cassandra-sidecar/pull/28#discussion_r867249712


##########
src/test/java/org/apache/cassandra/sidecar/LoggerHandlerInjectionTest.java:
##########
@@ -34,55 +36,75 @@
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
+/**
+ * Tests for the {@link LoggerHandler} injection tests
+ */
 @DisplayName("LoggerHandler Injection Test")
 @ExtendWith(VertxExtension.class)
 public class LoggerHandlerInjectionTest
 {
     private Vertx vertx;
     private Configuration config;
     private final Logger logger = mock(Logger.class);
+    private HttpServer server;
 
     @BeforeEach
     void setUp() throws InterruptedException
     {
         FakeLoggerHandler loggerHandler = new FakeLoggerHandler(logger);
-        Injector injector = Guice.createInjector(Modules.override(Modules.override(new MainModule()).with(new TestModule()))
-                                                        .with(binder -> binder.bind(LoggerHandler.class).toInstance(loggerHandler)));
+        Injector injector = Guice.createInjector(Modules.override(Modules.override(new MainModule())
+                                                                         .with(new TestModule()))
+                                                        .with(binder -> binder.bind(LoggerHandler.class)
+                                                                              .toInstance(loggerHandler)));
         vertx = injector.getInstance(Vertx.class);
         config = injector.getInstance(Configuration.class);
         Router router = injector.getInstance(Router.class);
 
-        router.get("/500-route").handler(p -> {
-            throw new RuntimeException("Fails with 500");
-        });
+        router.get("/500-route").handler(p ->
+                                         {
+                                             throw new RuntimeException("Fails with 500");
+                                         });
 
-        router.get("/404-route").handler(p -> {
-            throw new HttpException(NOT_FOUND.code(), "Sorry, it's not here");
-        });
+        router.get("/404-route").handler(p ->
+                                         {
+                                             throw new HttpException(NOT_FOUND.code(), "Sorry, it's not here");
+                                         });
 
-        router.get("/204-route").handler(p -> {
-            throw new HttpException(NO_CONTENT.code(), "Sorry, no content");
-        });
+        router.get("/204-route").handler(p ->
+                                         {
+                                             throw new HttpException(NO_CONTENT.code(), "Sorry, no content");
+                                         });
 
         VertxTestContext context = new VertxTestContext();
-        HttpServer server = injector.getInstance(HttpServer.class);
+        server = injector.getInstance(HttpServer.class);
         server.listen(config.getPort(), context.succeedingThenComplete());
 
         context.awaitCompletion(5, TimeUnit.SECONDS);
     }
 
+    @AfterEach
+    void tearDown() throws InterruptedException
+    {
+        final CountDownLatch closeLatch = new CountDownLatch(1);
+        server.close(res -> closeLatch.countDown());
+        vertx.close();
+        if (closeLatch.await(60, TimeUnit.SECONDS)) logger.info("Close event received before timeout.");

Review Comment:
   thanks!



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org