Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingZC committed Dec 27, 2024
1 parent ffeb1c1 commit cd39ff9
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;

class TransactionConnectionContextTest {

private final TransactionConnectionContext transactionConnectionContext = new TransactionConnectionContext();

@Test
void assertBeginTransaction() {
transactionConnectionContext.beginTransaction("XA");
transactionConnectionContext.beginTransaction("XA", mock(TransactionManager.class));
assertThat(transactionConnectionContext.getTransactionType(), is(Optional.of("XA")));
assertTrue(transactionConnectionContext.isInTransaction());
}
Expand All @@ -44,19 +45,19 @@ void assertIsNotInDistributedTransactionWhenNotBegin() {

@Test
void assertIsNotInDistributedTransactionWithLocal() {
transactionConnectionContext.beginTransaction("LOCAL");
transactionConnectionContext.beginTransaction("LOCAL", mock(TransactionManager.class));
assertFalse(transactionConnectionContext.isInDistributedTransaction());
}

@Test
void assertIsInDistributedTransactionWithXA() {
transactionConnectionContext.beginTransaction("XA");
transactionConnectionContext.beginTransaction("XA", mock(TransactionManager.class));
assertTrue(transactionConnectionContext.isInDistributedTransaction());
}

@Test
void assertIsInDistributedTransactionWithBASE() {
transactionConnectionContext.beginTransaction("BASE");
transactionConnectionContext.beginTransaction("BASE", mock(TransactionManager.class));
assertTrue(transactionConnectionContext.isInDistributedTransaction());
}

Expand All @@ -68,7 +69,7 @@ void assertGetReadWriteSplitReplicaRoute() {

@Test
void assertClose() {
transactionConnectionContext.beginTransaction("XA");
transactionConnectionContext.beginTransaction("XA", mock(TransactionManager.class));
transactionConnectionContext.close();
assertFalse(transactionConnectionContext.getTransactionType().isPresent());
assertFalse(transactionConnectionContext.isInTransaction());
Expand Down

0 comments on commit cd39ff9

Please sign in to comment.