package com.itheima.frwameworkcache;

import com.alibaba.fastjson.JSON;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.HashMap;
import java.util.Map;

@RunWith(SpringRunner.class)
@SpringBootTest
public class FrwameworkCacheApplicationTests {

	//用于发送MQ消息
	@Autowired
	private RabbitTemplate rabbitTemplate;

	/***
	 * 发消息测试
	 */
	@Test
	public void testSendMessage() throws InterruptedException {
		//消息
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("user","lisi");
		map.put("money",25);

		rabbitTemplate.convertAndSend("","red.queue", JSON.toJSONString(map));
	}

}
