From 9f3ff2af34d4094af1485bd4afea872c0f0b250f Mon Sep 17 00:00:00 2001 From: wonyongChoi05 Date: Thu, 12 Oct 2023 09:55:02 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20TSM=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...TransactionSynchronizationManagerTest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/jdbc/src/test/java/org/springframework/transaction/support/TransactionSynchronizationManagerTest.java b/jdbc/src/test/java/org/springframework/transaction/support/TransactionSynchronizationManagerTest.java index b2b28c7d8c..b7a5784fa6 100644 --- a/jdbc/src/test/java/org/springframework/transaction/support/TransactionSynchronizationManagerTest.java +++ b/jdbc/src/test/java/org/springframework/transaction/support/TransactionSynchronizationManagerTest.java @@ -1,6 +1,37 @@ package org.springframework.transaction.support; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +import javax.sql.DataSource; +import java.sql.Connection; + +import static org.mockito.Mockito.mock; +import static org.springframework.transaction.support.TransactionSynchronizationManager.*; + class TransactionSynchronizationManagerTest { + DataSource dataSource = mock(DataSource.class); + Connection connection = mock(Connection.class); + + @Test + void 커넥션이_null이라면_null을_반환한다() { + Connection resource = getResource(dataSource); + Assertions.assertThat(resource).isNull(); + } + + @Test + void 커넥션을_반환한다() { + bindResource(dataSource, connection); + Connection resource = getResource(dataSource); + Assertions.assertThat(resource).isNotNull(); + } + + @Test + void 커넥션을_바인딩한다() { + bindResource(dataSource, connection); + Connection resource = getResource(dataSource); + Assertions.assertThat(resource).isNotNull(); + } } \ No newline at end of file