提交 | 用户 | 时间
|
191b3d
|
1 |
package com.iailab.module.data.controller; |
H |
2 |
|
|
3 |
import com.iailab.DataWebApplication; |
|
4 |
import com.iailab.framework.test.core.ut.BaseMockitoUnitTest; |
|
5 |
import com.iailab.module.data.mq.consumer.ImageMessage; |
|
6 |
import org.junit.jupiter.api.Test; |
|
7 |
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
|
8 |
import org.springframework.boot.test.context.SpringBootTest; |
|
9 |
|
|
10 |
import javax.annotation.Resource; |
|
11 |
import java.time.LocalDateTime; |
|
12 |
import java.time.format.DateTimeFormatter; |
|
13 |
import java.util.*; |
|
14 |
|
|
15 |
/** |
|
16 |
* @author Houzhongjian |
|
17 |
* @Description |
|
18 |
* @createTime 2024年11月06日 |
|
19 |
*/ |
|
20 |
@SpringBootTest(classes = DataWebApplication.class) |
|
21 |
public class RabbitMQTest extends BaseMockitoUnitTest { |
|
22 |
|
|
23 |
@Resource |
|
24 |
private RabbitTemplate rabbitTemplate; |
|
25 |
|
|
26 |
|
|
27 |
@Test |
|
28 |
public void testProducer() { |
|
29 |
String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
|
30 |
Map<String, Object> imageMap = new HashMap<>(); |
|
31 |
imageMap.put("messageId", "111111111111111"); |
|
32 |
imageMap.put("image", "8888888888888888888"); |
|
33 |
imageMap.put("createTime", createTime); |
|
34 |
rabbitTemplate.convertAndSend(ImageMessage.EXCHANGE, ImageMessage.ROUTING_KEY, imageMap); |
|
35 |
} |
|
36 |
} |