mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Leverage JUnit 6 suspending function support
Closes gh-36215
This commit is contained in:
+11
-18
@@ -17,7 +17,6 @@
|
||||
package org.springframework.aop.framework.autoproxy
|
||||
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.aopalliance.intercept.MethodInterceptor
|
||||
import org.aopalliance.intercept.MethodInvocation
|
||||
import org.aspectj.lang.ProceedingJoinPoint
|
||||
@@ -73,43 +72,37 @@ class AspectJAutoProxyInterceptorKotlinIntegrationTests(
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Multiple interceptors with suspending function`() {
|
||||
suspend fun `Multiple interceptors with suspending function`() {
|
||||
assertThat(firstAdvisor.interceptor.invocations).isEmpty()
|
||||
assertThat(secondAdvisor.interceptor.invocations).isEmpty()
|
||||
val value = "Hello!"
|
||||
runBlocking {
|
||||
assertThat(echo.suspendingEcho(value)).isEqualTo(value)
|
||||
}
|
||||
assertThat(echo.suspendingEcho(value)).isEqualTo(value)
|
||||
assertThat(firstAdvisor.interceptor.invocations).singleElement().matches { Mono::class.java.isAssignableFrom(it) }
|
||||
assertThat(secondAdvisor.interceptor.invocations).singleElement().matches { Mono::class.java.isAssignableFrom(it) }
|
||||
}
|
||||
|
||||
@Test // gh-33095
|
||||
fun `Aspect and reactive transactional with suspending function`() {
|
||||
suspend fun `Aspect and reactive transactional with suspending function`() {
|
||||
assertThat(countingAspect.counter).isZero()
|
||||
assertThat(reactiveTransactionManager.commits).isZero()
|
||||
val value = "Hello!"
|
||||
runBlocking {
|
||||
assertThat(echo.suspendingTransactionalEcho(value)).isEqualTo(value)
|
||||
}
|
||||
assertThat(echo.suspendingTransactionalEcho(value)).isEqualTo(value)
|
||||
assertThat(countingAspect.counter).`as`("aspect applied").isOne()
|
||||
assertThat(reactiveTransactionManager.begun).isOne()
|
||||
assertThat(reactiveTransactionManager.commits).`as`("transactional applied").isOne()
|
||||
}
|
||||
|
||||
@Test // gh-33210
|
||||
fun `Aspect and cacheable with suspending function`() {
|
||||
suspend fun `Aspect and cacheable with suspending function`() {
|
||||
assertThat(countingAspect.counter).isZero()
|
||||
val value = "Hello!"
|
||||
runBlocking {
|
||||
assertThat(echo.suspendingCacheableEcho(value)).isEqualTo("$value 0")
|
||||
assertThat(echo.suspendingCacheableEcho(value)).isEqualTo("$value 0")
|
||||
assertThat(echo.suspendingCacheableEcho(value)).isEqualTo("$value 0")
|
||||
assertThat(countingAspect.counter).`as`("aspect applied once").isOne()
|
||||
assertThat(echo.suspendingCacheableEcho(value)).isEqualTo("$value 0")
|
||||
assertThat(echo.suspendingCacheableEcho(value)).isEqualTo("$value 0")
|
||||
assertThat(echo.suspendingCacheableEcho(value)).isEqualTo("$value 0")
|
||||
assertThat(countingAspect.counter).`as`("aspect applied once").isOne()
|
||||
|
||||
assertThat(echo.suspendingCacheableEcho("$value bis")).isEqualTo("$value bis 1")
|
||||
assertThat(echo.suspendingCacheableEcho("$value bis")).isEqualTo("$value bis 1")
|
||||
}
|
||||
assertThat(echo.suspendingCacheableEcho("$value bis")).isEqualTo("$value bis 1")
|
||||
assertThat(echo.suspendingCacheableEcho("$value bis")).isEqualTo("$value bis 1")
|
||||
assertThat(countingAspect.counter).`as`("aspect applied once per key").isEqualTo(2)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user