-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: EXPOSED-109 change implement of spring transaction manager (#1840
) * refactor: Implement a new one with AbstractPlatformTransactionManager * refactor: remove unused property * fix: remove nullable * fix: add show sql feature * fix: rebuild api file * chore: remove property * chore: add default show sql value * fix: api definition * feat: add default database config value * feat :Add SmartTranscationObject implementation * feat: close connection when transaction end * chore: remove unused values * feat: reset outer tx manager when transaction clean up * test: Add outer transaction manager setting exception test * chore: Add import * test: add manager setting test * chore: remake api file * fix: fix when commit or rollback failure * chore: fix detekt issue * test: Add transactionAwareDataSourceProxy test * chore: refactor spring transaction manager test * refactor: remove default value in test * refactor: apply code review * refactor: apply test code review * refactor: merge duplicate tests * refactor: remove mockk and change exposed transaction object to private * refactor: move database to private * refactor: clean up transaction manager after test ended * fix: while condition * test: Add exposed and spring combine transaction * fix: test * fix: api dump * refactor: apply connection spy suggestion * refactor: apply code review * refactor: apply code reivew
- Loading branch information
1 parent
5199654
commit fa73510
Showing
8 changed files
with
523 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,5 @@ | ||
public final class org/jetbrains/exposed/spring/SpringTransactionManager : org/springframework/jdbc/datasource/DataSourceTransactionManager, org/jetbrains/exposed/sql/transactions/TransactionManager { | ||
public fun <init> (Ljavax/sql/DataSource;Lorg/jetbrains/exposed/sql/DatabaseConfig;ZZIJJ)V | ||
public synthetic fun <init> (Ljavax/sql/DataSource;Lorg/jetbrains/exposed/sql/DatabaseConfig;ZZIJJILkotlin/jvm/internal/DefaultConstructorMarker;)V | ||
public fun bindTransactionToThread (Lorg/jetbrains/exposed/sql/Transaction;)V | ||
public fun currentOrNull ()Lorg/jetbrains/exposed/sql/Transaction; | ||
public fun getDefaultIsolationLevel ()I | ||
public fun getDefaultMaxRepetitionDelay ()J | ||
public fun getDefaultMinRepetitionDelay ()J | ||
public fun getDefaultReadOnly ()Z | ||
public fun getDefaultRepetitionAttempts ()I | ||
public fun newTransaction (IZLorg/jetbrains/exposed/sql/Transaction;)Lorg/jetbrains/exposed/sql/Transaction; | ||
public fun setDefaultIsolationLevel (I)V | ||
public fun setDefaultMaxRepetitionDelay (J)V | ||
public fun setDefaultMinRepetitionDelay (J)V | ||
public fun setDefaultReadOnly (Z)V | ||
public fun setDefaultRepetitionAttempts (I)V | ||
public final class org/jetbrains/exposed/spring/SpringTransactionManager : org/springframework/transaction/support/AbstractPlatformTransactionManager { | ||
public fun <init> (Ljavax/sql/DataSource;Lorg/jetbrains/exposed/sql/DatabaseConfig;Z)V | ||
public synthetic fun <init> (Ljavax/sql/DataSource;Lorg/jetbrains/exposed/sql/DatabaseConfig;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
spring-transaction/src/test/kotlin/org/jetbrains/exposed/spring/ConnectionSpy.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.jetbrains.exposed.spring | ||
|
||
import java.sql.Connection | ||
import java.sql.Savepoint | ||
|
||
internal class ConnectionSpy(private val connection: Connection) : Connection by connection { | ||
|
||
var commitCallCount: Int = 0 | ||
var rollbackCallCount: Int = 0 | ||
var closeCallCount: Int = 0 | ||
var mockReadOnly: Boolean = false | ||
var mockIsClosed: Boolean = false | ||
var mockAutoCommit: Boolean = false | ||
var mockTransactionIsolation: Int = Connection.TRANSACTION_READ_COMMITTED | ||
var mockCommit: () -> Unit = {} | ||
var mockRollback: () -> Unit = {} | ||
private val callOrder = mutableListOf<String>() | ||
|
||
fun verifyCallOrder(vararg functions: String): Boolean { | ||
val indices = functions.map { callOrder.indexOf(it) } | ||
return indices.none { it == -1 } && indices == indices.sorted() | ||
} | ||
|
||
fun clearMock() { | ||
commitCallCount = 0 | ||
rollbackCallCount = 0 | ||
closeCallCount = 0 | ||
mockAutoCommit = false | ||
mockReadOnly = false | ||
mockIsClosed = false | ||
mockTransactionIsolation = Connection.TRANSACTION_READ_COMMITTED | ||
mockCommit = {} | ||
mockRollback = {} | ||
callOrder.clear() | ||
} | ||
|
||
override fun close() { | ||
callOrder.add("close") | ||
closeCallCount++ | ||
} | ||
|
||
override fun setAutoCommit(autoCommit: Boolean) { | ||
callOrder.add("setAutoCommit") | ||
mockAutoCommit = autoCommit | ||
} | ||
|
||
override fun getAutoCommit() = mockAutoCommit | ||
override fun commit() { | ||
callOrder.add("commit") | ||
commitCallCount++ | ||
mockCommit() | ||
} | ||
|
||
override fun rollback() { | ||
callOrder.add("rollback") | ||
rollbackCallCount++ | ||
mockRollback() | ||
} | ||
|
||
override fun rollback(savepoint: Savepoint?) = Unit | ||
override fun isClosed(): Boolean { | ||
callOrder.add("isClosed") | ||
return mockIsClosed | ||
} | ||
|
||
override fun setReadOnly(readOnly: Boolean) { | ||
callOrder.add("setReadOnly") | ||
mockReadOnly = readOnly | ||
} | ||
|
||
override fun isReadOnly(): Boolean { | ||
callOrder.add("isReadOnly") | ||
return mockReadOnly | ||
} | ||
|
||
override fun getTransactionIsolation() = mockTransactionIsolation | ||
} |
Oops, something went wrong.