Skip to content

Commit 866204a

Browse files
committed
springboot-16-rabbit(完)
1 parent a5c0485 commit 866204a

File tree

1 file changed

+53
-0
lines changed
  • springboot-16-rabbit/springboot-16-user/src/test/java/com/clown/rabbit/admin

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.clown.rabbit.admin;
2+
3+
import com.clown.rabbit.user.UserApplication;
4+
import org.junit.Test;
5+
import org.junit.runner.RunWith;
6+
import org.springframework.amqp.core.AmqpAdmin;
7+
import org.springframework.amqp.core.Binding;
8+
import org.springframework.amqp.core.DirectExchange;
9+
import org.springframework.amqp.core.Queue;
10+
import org.springframework.beans.factory.annotation.Autowired;
11+
import org.springframework.boot.test.context.SpringBootTest;
12+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
13+
14+
/**
15+
* @author: Richard·Ackerman
16+
* @create: 2019/1/22
17+
**/
18+
@RunWith(SpringJUnit4ClassRunner.class)
19+
@SpringBootTest(classes = UserApplication.class)
20+
public class AmqpAdminTest {
21+
22+
@Autowired
23+
private AmqpAdmin amqpAdmin;
24+
25+
/**
26+
* 创建交换器
27+
*/
28+
@Test
29+
public void creatExchange(){
30+
DirectExchange exchange = new DirectExchange("admin.exchange");
31+
amqpAdmin.declareExchange(exchange);
32+
System.out.println("创建完成");
33+
}
34+
35+
/**
36+
* 创建队列
37+
*/
38+
@Test
39+
public void creatQueue(){
40+
amqpAdmin.declareQueue(new Queue("admin.queue",true));
41+
System.out.println("创建完成");
42+
}
43+
44+
/**
45+
* 创建Binding
46+
*/
47+
@Test
48+
public void creatBinding(){
49+
Binding binding = new Binding("admin.queue", Binding.DestinationType.QUEUE,"admin.exchange","admin.queue",null);
50+
amqpAdmin.declareBinding(binding);
51+
System.out.println("创建完成");
52+
}
53+
}

0 commit comments

Comments
 (0)