@@ -21,12 +21,15 @@ import assertk.assertions.isEqualTo
21
21
import assertk.assertions.isTrue
22
22
import org.junit.jupiter.api.Test
23
23
import org.springframework.amqp.core.AcknowledgeMode
24
+ import org.springframework.amqp.core.MessageListener
24
25
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory
25
26
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory
26
27
import org.springframework.amqp.rabbit.core.RabbitTemplate
27
28
import org.springframework.amqp.rabbit.junit.RabbitAvailable
28
29
import org.springframework.amqp.rabbit.junit.RabbitAvailableCondition
30
+ import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry
29
31
import org.springframework.amqp.rabbit.listener.api.RabbitListenerErrorHandler
32
+ import org.springframework.amqp.utils.test.TestUtils
30
33
import org.springframework.aop.framework.ProxyFactory
31
34
import org.springframework.beans.BeansException
32
35
import org.springframework.beans.factory.annotation.Autowired
@@ -57,17 +60,20 @@ class EnableRabbitKotlinTests {
57
60
private lateinit var config: Config
58
61
59
62
@Test
60
- fun `send and wait for consume` () {
63
+ fun `send and wait for consume` (@Autowired registry : RabbitListenerEndpointRegistry ) {
61
64
val template = RabbitTemplate (this .config.cf())
62
65
template.convertAndSend(" kotlinQueue" , " test" )
63
- assertThat(this .config.latch.await(10 , TimeUnit .SECONDS )).isTrue();
66
+ assertThat(this .config.latch.await(10 , TimeUnit .SECONDS )).isTrue()
67
+ val listener = registry.getListenerContainer(" single" ).messageListener
68
+ assertThat(TestUtils .getPropertyValue(listener, " messagingMessageConverter.inferredArgumentType" ).toString())
69
+ .isEqualTo(" class java.lang.String" )
64
70
}
65
71
66
72
@Test
67
73
fun `send and wait for consume with EH` () {
68
74
val template = RabbitTemplate (this .config.cf())
69
75
template.convertAndSend(" kotlinQueue1" , " test" )
70
- assertThat(this .config.ehLatch.await(10 , TimeUnit .SECONDS )).isTrue();
76
+ assertThat(this .config.ehLatch.await(10 , TimeUnit .SECONDS )).isTrue()
71
77
val reply = template.receiveAndConvert(" kotlinReplyQueue" , 10_000 )
72
78
assertThat(reply).isEqualTo(" error processed" );
73
79
}
@@ -78,7 +84,7 @@ class EnableRabbitKotlinTests {
78
84
79
85
val latch = CountDownLatch (1 )
80
86
81
- @RabbitListener(queues = [" kotlinQueue" ])
87
+ @RabbitListener(id = " single " , queues = [" kotlinQueue" ])
82
88
suspend fun handle (@Suppress(" UNUSED_PARAMETER" ) data : String ) {
83
89
this .latch.countDown()
84
90
}
@@ -121,7 +127,7 @@ class EnableRabbitKotlinTests {
121
127
122
128
}
123
129
124
- @RabbitListener(queues = [" kotlinQueue1" ], errorHandler = " #{eh}" )
130
+ @RabbitListener(id = " multi " , queues = [" kotlinQueue1" ], errorHandler = " #{eh}" )
125
131
@SendTo(" kotlinReplyQueue" )
126
132
open class Multi {
127
133
0 commit comments