-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRabbitMQConfigTest.java
More file actions
49 lines (42 loc) · 1.67 KB
/
RabbitMQConfigTest.java
File metadata and controls
49 lines (42 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.techevents.config;
import org.junit.jupiter.api.Test;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(
classes = RabbitMQConfig.class,
properties = {
"app.rabbitmq.queue=test.queue",
"app.rabbitmq.exchange=test.exchange",
"app.rabbitmq.routing-key=test.key"
}
)
@ImportAutoConfiguration(RabbitAutoConfiguration.class)
class RabbitMQConfigTest {
@Autowired Queue eventQueue;
@Autowired TopicExchange eventExchange;
@Autowired Binding eventBinding;
@Autowired RabbitTemplate rabbitTemplate;
@Test void queueIsConfigured() {
assertThat(eventQueue.getName()).isEqualTo("test.queue");
assertThat(eventQueue.isDurable()).isTrue();
}
@Test void exchangeIsConfigured() {
assertThat(eventExchange.getName()).isEqualTo("test.exchange");
assertThat(eventExchange.isDurable()).isTrue();
}
@Test void bindingIsConfigured() {
assertThat(eventBinding.getExchange()).isEqualTo(eventExchange.getName());
assertThat(eventBinding.getDestination()).isEqualTo(eventQueue.getName());
assertThat(eventBinding.getRoutingKey()).isEqualTo("test.key");
}
@Test void rabbitTemplateIsAvailable() {
assertThat(rabbitTemplate).isNotNull();
}
}