-
Notifications
You must be signed in to change notification settings - Fork 33
/
AmqpApplicationTest.java
36 lines (28 loc) · 1.11 KB
/
AmqpApplicationTest.java
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
package com.github.fridujo.rabbitmq.mock.integration.springboot;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = AmqpApplicationTestConfiguration.class)
public class AmqpApplicationTest {
@Autowired
private Sender sender;
@Autowired
private Receiver receiver;
@Test
public void message_is_received_when_sent_by_sender() throws InterruptedException {
sender.send();
List<String> receivedMessages = new ArrayList<>();
while (receivedMessages.isEmpty()) {
receivedMessages.addAll(receiver.getMessages());
TimeUnit.MILLISECONDS.sleep(100L);
}
assertThat(receivedMessages).containsExactly("Hello from RabbitMQ!");
}
}