Skip to content

Commit f1e0d13

Browse files
authored
Merge pull request #20 from Dockerel/Refactor/issue-#19
Refactor: Redis Conn Test에 try-with-resources 적용
2 parents 994553c + eb65992 commit f1e0d13

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

src/test/java/com/knu/ddip/DBTest/RedisForTestConnectionTest.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,13 @@ public void testRedisConnection() {
4141
@Test
4242
public void testRedisConnectionInfo() {
4343
// When
44-
RedisConnection connection = redisTemplate.getConnectionFactory().getConnection();
45-
46-
try {
44+
try (RedisConnection connection = redisTemplate.getConnectionFactory().getConnection()) {
4745
// Then
4846
assertThat(connection).isNotNull();
4947
assertThat(connection.ping()).isNotNull();
5048

5149
System.out.println("Redis connection successful");
52-
System.out.println("Redis ping response: " + new String(connection.ping()));
53-
} finally {
54-
connection.close();
50+
System.out.println("Redis ping response: " + connection.ping());
5551
}
5652
}
5753

0 commit comments

Comments
 (0)