@@ -34,19 +34,48 @@ class AopUtilsKotlinTests {
34
34
@Test
35
35
fun `Invoking suspending function should return Mono` () {
36
36
val value = " foo"
37
- val method = ReflectionUtils .findMethod(AopUtilsKotlinTests ::class .java, " suspendingFunction " ,
38
- String ::class .java, Continuation ::class .java)!!
37
+ val method = ReflectionUtils .findMethod(WithoutInterface ::class .java, " handle " ,
38
+ String ::class . java, Continuation ::class .java)!!
39
39
val continuation = Continuation <Any >(CoroutineName (" test" )) { }
40
- val result = AopUtils .invokeJoinpointUsingReflection(this , method, arrayOf(value, continuation))
40
+ val result = AopUtils .invokeJoinpointUsingReflection(WithoutInterface () , method, arrayOf(value, continuation))
41
41
assertThat(result).isInstanceOfSatisfying(Mono ::class .java) {
42
42
assertThat(it.block()).isEqualTo(value)
43
43
}
44
44
}
45
45
46
+ @Test
47
+ fun `Invoking suspending function on bridged method should return Mono` () {
48
+ val value = " foo"
49
+ val bridgedMethod = ReflectionUtils .findMethod(WithInterface ::class .java, " handle" , Object ::class .java, Continuation ::class .java)!!
50
+ val continuation = Continuation <Any >(CoroutineName (" test" )) { }
51
+ val result = AopUtils .invokeJoinpointUsingReflection(WithInterface (), bridgedMethod, arrayOf(value, continuation))
52
+ assertThat(result).isInstanceOfSatisfying(Mono ::class .java) {
53
+ assertThat(it.block()).isEqualTo(value)
54
+ }
55
+ }
56
+
46
57
@Suppress(" unused" )
47
58
suspend fun suspendingFunction (value : String ): String {
48
59
delay(1 )
49
60
return value
50
61
}
51
62
63
+ class WithoutInterface {
64
+ suspend fun handle (value : String ): String {
65
+ delay(1 )
66
+ return value
67
+ }
68
+ }
69
+
70
+ interface ProxyInterface <T > {
71
+ suspend fun handle (value : T ): T
72
+ }
73
+
74
+ class WithInterface : ProxyInterface <String > {
75
+ override suspend fun handle (value : String ): String {
76
+ delay(1 )
77
+ return value
78
+ }
79
+ }
80
+
52
81
}
0 commit comments