From b7b0975e2ad297d72ce8c43d59ccd1eb5db65016 Mon Sep 17 00:00:00 2001 From: Andrew Carbonetto Date: Fri, 5 Jan 2024 05:19:34 -0800 Subject: [PATCH] Clean up from merge Signed-off-by: Andrew Carbonetto --- .../src/main/java/glide/api/RedisClient.java | 1 - .../glide/managers/ConnectionManagerTest.java | 52 +++++++++---------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/java/client/src/main/java/glide/api/RedisClient.java b/java/client/src/main/java/glide/api/RedisClient.java index 4ccbad009f..d11f490fee 100644 --- a/java/client/src/main/java/glide/api/RedisClient.java +++ b/java/client/src/main/java/glide/api/RedisClient.java @@ -9,7 +9,6 @@ import glide.api.commands.Transaction; import glide.api.commands.VoidCommands; import glide.api.models.commands.SetOptions; -import glide.api.models.configuration.NodeAddress; import glide.api.models.configuration.RedisClientConfiguration; import glide.connectors.handlers.CallbackDispatcher; import glide.connectors.handlers.ChannelHandler; diff --git a/java/client/src/test/java/glide/managers/ConnectionManagerTest.java b/java/client/src/test/java/glide/managers/ConnectionManagerTest.java index 67d1dc586a..743c89d300 100644 --- a/java/client/src/test/java/glide/managers/ConnectionManagerTest.java +++ b/java/client/src/test/java/glide/managers/ConnectionManagerTest.java @@ -184,8 +184,7 @@ public void onConnection_emptyResponse_throwsRuntimeException() { // setup RedisClientConfiguration redisClientConfiguration = RedisClientConfiguration.builder().build(); CompletableFuture completedFuture = new CompletableFuture<>(); - Response response = - Response.newBuilder().setConstantResponse(ResponseOuterClass.ConstantResponse.OK).build(); + Response response = Response.newBuilder().build(); completedFuture.complete(response); // execute @@ -200,30 +199,6 @@ public void onConnection_emptyResponse_throwsRuntimeException() { "Connection response expects an OK response", executionException.getCause().getMessage()); } - @SneakyThrows - @Test - public void CloseConnection_closesChannels() { - // setup - RedisClientConfiguration redisClientConfiguration = RedisClientConfiguration.builder().build(); - CompletableFuture completedFuture = new CompletableFuture<>(); - Response response = - Response.newBuilder().setConstantResponse(ResponseOuterClass.ConstantResponse.OK).build(); - completedFuture.complete(response); - - // execute - when(channel.connect(any())).thenReturn(completedFuture); - CompletableFuture resultConnect = - connectionManager.connectToRedis(redisClientConfiguration); - assertNull(resultConnect.get()); - verify(channel).connect(any()); - - CompletableFuture resultClose = connectionManager.closeConnection(); - assertNull(resultClose.get()); - - // verify - verify(channel).close(); - } - @SneakyThrows @Test public void CheckRedisResponse_ConstantResponse_returnsSuccessfully() { @@ -283,4 +258,29 @@ public void CheckRedisResponse_ClosingError_throwsRuntimeException() { ExecutionException exception = assertThrows(ExecutionException.class, result::get); assertTrue(exception.getCause() instanceof RuntimeException); } + + + @SneakyThrows + @Test + public void CloseConnection_closesChannels() { + // setup + RedisClientConfiguration redisClientConfiguration = RedisClientConfiguration.builder().build(); + CompletableFuture completedFuture = new CompletableFuture<>(); + Response response = + Response.newBuilder().setConstantResponse(ResponseOuterClass.ConstantResponse.OK).build(); + completedFuture.complete(response); + + // execute + when(channel.connect(any())).thenReturn(completedFuture); + CompletableFuture resultConnect = + connectionManager.connectToRedis(redisClientConfiguration); + assertNull(resultConnect.get()); + verify(channel).connect(any()); + + CompletableFuture resultClose = connectionManager.closeConnection(); + assertNull(resultClose.get()); + + // verify + verify(channel).close(); + } }