@@ -56,33 +56,33 @@ import kotlin.annotation.AnnotationTarget.TYPE
56
56
@SpringJUnitConfig(InterceptorConfig ::class )
57
57
@DirtiesContext(classMode = DirtiesContext .ClassMode .AFTER_EACH_TEST_METHOD )
58
58
class AspectJAutoProxyInterceptorKotlinIntegrationTests (
59
- @Autowired val echo : Echo ,
60
- @Autowired val firstAdvisor : TestPointcutAdvisor ,
61
- @Autowired val secondAdvisor : TestPointcutAdvisor ,
62
- @Autowired val countingAspect : CountingAspect ,
63
- @Autowired val reactiveTransactionManager : ReactiveCallCountingTransactionManager ) {
64
-
65
- @Test
66
- fun `Multiple interceptors with regular function` () {
67
- assertThat(firstAdvisor.interceptor.invocations).isEmpty()
68
- assertThat(secondAdvisor.interceptor.invocations).isEmpty()
69
- val value = " Hello!"
70
- assertThat(echo.echo(value)).isEqualTo(value)
59
+ @Autowired val echo : Echo ,
60
+ @Autowired val firstAdvisor : TestPointcutAdvisor ,
61
+ @Autowired val secondAdvisor : TestPointcutAdvisor ,
62
+ @Autowired val countingAspect : CountingAspect ,
63
+ @Autowired val reactiveTransactionManager : ReactiveCallCountingTransactionManager ) {
64
+
65
+ @Test
66
+ fun `Multiple interceptors with regular function` () {
67
+ assertThat(firstAdvisor.interceptor.invocations).isEmpty()
68
+ assertThat(secondAdvisor.interceptor.invocations).isEmpty()
69
+ val value = " Hello!"
70
+ assertThat(echo.echo(value)).isEqualTo(value)
71
71
assertThat(firstAdvisor.interceptor.invocations).singleElement().matches { String ::class .java.isAssignableFrom(it) }
72
72
assertThat(secondAdvisor.interceptor.invocations).singleElement().matches { String ::class .java.isAssignableFrom(it) }
73
- }
74
-
75
- @Test
76
- fun `Multiple interceptors with suspending function` () {
77
- assertThat(firstAdvisor.interceptor.invocations).isEmpty()
78
- assertThat(secondAdvisor.interceptor.invocations).isEmpty()
79
- val value = " Hello!"
80
- runBlocking {
81
- assertThat(echo.suspendingEcho(value)).isEqualTo(value)
82
- }
73
+ }
74
+
75
+ @Test
76
+ fun `Multiple interceptors with suspending function` () {
77
+ assertThat(firstAdvisor.interceptor.invocations).isEmpty()
78
+ assertThat(secondAdvisor.interceptor.invocations).isEmpty()
79
+ val value = " Hello!"
80
+ runBlocking {
81
+ assertThat(echo.suspendingEcho(value)).isEqualTo(value)
82
+ }
83
83
assertThat(firstAdvisor.interceptor.invocations).singleElement().matches { Mono ::class .java.isAssignableFrom(it) }
84
84
assertThat(secondAdvisor.interceptor.invocations).singleElement().matches { Mono ::class .java.isAssignableFrom(it) }
85
- }
85
+ }
86
86
87
87
@Test // gh-33095
88
88
fun `Aspect and reactive transactional with suspending function` () {
@@ -113,17 +113,17 @@ class AspectJAutoProxyInterceptorKotlinIntegrationTests(
113
113
assertThat(countingAspect.counter).`as `(" aspect applied once per key" ).isEqualTo(2 )
114
114
}
115
115
116
- @Configuration
117
- @EnableAspectJAutoProxy
118
- @EnableTransactionManagement
116
+ @Configuration
117
+ @EnableAspectJAutoProxy
118
+ @EnableTransactionManagement
119
119
@EnableCaching
120
- open class InterceptorConfig {
120
+ open class InterceptorConfig {
121
121
122
- @Bean
123
- open fun firstAdvisor () = TestPointcutAdvisor ().apply { order = 0 }
122
+ @Bean
123
+ open fun firstAdvisor () = TestPointcutAdvisor ().apply { order = 0 }
124
124
125
- @Bean
126
- open fun secondAdvisor () = TestPointcutAdvisor ().apply { order = 1 }
125
+ @Bean
126
+ open fun secondAdvisor () = TestPointcutAdvisor ().apply { order = 1 }
127
127
128
128
@Bean
129
129
open fun countingAspect () = CountingAspect ()
@@ -138,34 +138,34 @@ class AspectJAutoProxyInterceptorKotlinIntegrationTests(
138
138
return ConcurrentMapCacheManager ()
139
139
}
140
140
141
- @Bean
142
- open fun echo (): Echo {
143
- return Echo ()
144
- }
145
- }
141
+ @Bean
142
+ open fun echo (): Echo {
143
+ return Echo ()
144
+ }
145
+ }
146
146
147
- class TestMethodInterceptor : MethodInterceptor {
147
+ class TestMethodInterceptor : MethodInterceptor {
148
148
149
- var invocations: MutableList <Class <* >> = mutableListOf ()
149
+ var invocations: MutableList <Class <* >> = mutableListOf ()
150
150
151
- @Suppress(" RedundantNullableReturnType" )
152
- override fun invoke (invocation : MethodInvocation ): Any? {
153
- val result = invocation.proceed()
154
- invocations.add(result!! .javaClass)
155
- return result
156
- }
151
+ @Suppress(" RedundantNullableReturnType" )
152
+ override fun invoke (invocation : MethodInvocation ): Any? {
153
+ val result = invocation.proceed()
154
+ invocations.add(result!! .javaClass)
155
+ return result
156
+ }
157
157
158
- }
158
+ }
159
159
160
- class TestPointcutAdvisor : StaticMethodMatcherPointcutAdvisor (TestMethodInterceptor ()) {
160
+ class TestPointcutAdvisor : StaticMethodMatcherPointcutAdvisor (TestMethodInterceptor ()) {
161
161
162
- val interceptor: TestMethodInterceptor
163
- get() = advice as TestMethodInterceptor
162
+ val interceptor: TestMethodInterceptor
163
+ get() = advice as TestMethodInterceptor
164
164
165
- override fun matches (method : Method , targetClass : Class <* >): Boolean {
166
- return targetClass == Echo ::class .java && method.name.lowercase().endsWith(" echo" )
167
- }
168
- }
165
+ override fun matches (method : Method , targetClass : Class <* >): Boolean {
166
+ return targetClass == Echo ::class .java && method.name.lowercase().endsWith(" echo" )
167
+ }
168
+ }
169
169
170
170
@Target(CLASS , FUNCTION , ANNOTATION_CLASS , TYPE )
171
171
@Retention(AnnotationRetention .RUNTIME )
@@ -185,16 +185,16 @@ class AspectJAutoProxyInterceptorKotlinIntegrationTests(
185
185
}
186
186
}
187
187
188
- open class Echo {
188
+ open class Echo {
189
189
190
- open fun echo (value : String ): String {
191
- return value
192
- }
190
+ open fun echo (value : String ): String {
191
+ return value
192
+ }
193
193
194
- open suspend fun suspendingEcho (value : String ): String {
195
- delay(1 )
196
- return value
197
- }
194
+ open suspend fun suspendingEcho (value : String ): String {
195
+ delay(1 )
196
+ return value
197
+ }
198
198
199
199
@Transactional
200
200
@Counting
@@ -212,6 +212,6 @@ class AspectJAutoProxyInterceptorKotlinIntegrationTests(
212
212
return " $value ${cacheCounter++ } "
213
213
}
214
214
215
- }
215
+ }
216
216
217
217
}
0 commit comments