Skip to content

Commit

Permalink
feat: TSM 테스트코드 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
wonyongChoi05 committed Oct 12, 2023
1 parent da70f23 commit 9f3ff2a
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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();
}

}

0 comments on commit 9f3ff2a

Please sign in to comment.