|
10 | 10 | import org.apache.commons.io.FileUtils;
|
11 | 11 | import org.apache.qpid.server.Broker;
|
12 | 12 | import org.apache.qpid.server.BrokerOptions;
|
13 |
| -import org.apache.qpid.server.exchange.TopicExchange; |
14 | 13 | import org.junit.After;
|
15 | 14 | import org.junit.AfterClass;
|
16 | 15 | import org.junit.Before;
|
|
19 | 18 | import org.junit.runner.RunWith;
|
20 | 19 | import org.slf4j.Logger;
|
21 | 20 | import org.slf4j.LoggerFactory;
|
| 21 | +import org.springframework.amqp.core.BindingBuilder; |
| 22 | +import org.springframework.amqp.core.Queue; |
| 23 | +import org.springframework.amqp.core.TopicExchange; |
| 24 | +import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; |
| 25 | +import org.springframework.amqp.rabbit.core.RabbitAdmin; |
22 | 26 | import org.springframework.beans.factory.annotation.Autowired;
|
23 | 27 | import org.springframework.boot.test.context.SpringBootTest;
|
24 | 28 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
@@ -160,9 +164,11 @@ public static void tearDown() throws Exception {
|
160 | 164 | @Test
|
161 | 165 | public void test() {
|
162 | 166 | try {
|
163 |
| - Channel channel = conn.createChannel(); |
164 | 167 | String queueName = rmqConsumer.getQueueName();
|
165 | 168 | String exchange = "ei-poc-4";
|
| 169 | + createExchange(exchange, queueName); |
| 170 | + Channel channel = conn.createChannel(); |
| 171 | + |
166 | 172 |
|
167 | 173 | ArrayList<String> eventNames = getEventNamesToSend();
|
168 | 174 | int eventsCount = eventNames.size();
|
@@ -201,4 +207,15 @@ private ArrayList<String> getEventNamesToSend() {
|
201 | 207 |
|
202 | 208 | return eventNames;
|
203 | 209 | }
|
| 210 | + |
| 211 | + private void createExchange(final String exchangeName, final String queueName) { |
| 212 | + final CachingConnectionFactory cf = new CachingConnectionFactory(AMQPBrokerManager.PORT); |
| 213 | + final RabbitAdmin admin = new RabbitAdmin(cf); |
| 214 | + final Queue queue = new Queue(queueName, false); |
| 215 | + admin.declareQueue(queue); |
| 216 | + final TopicExchange exchange = new TopicExchange(exchangeName); |
| 217 | + admin.declareExchange(exchange); |
| 218 | + admin.declareBinding(BindingBuilder.bind(queue).to(exchange).with("#")); |
| 219 | + cf.destroy(); |
| 220 | + } |
204 | 221 | }
|
0 commit comments