Skip to content

Commit 36c58b9

Browse files
author
Vali (Vasile Baluta)
committed
fix flow test sending events
Change-Id: I7d456ad452d21ff8ff0a053058fcb253f2e37404
1 parent 85e01b6 commit 36c58b9

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/test/java/com/ericsson/ei/flowtests/FlowTest.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.apache.commons.io.FileUtils;
1111
import org.apache.qpid.server.Broker;
1212
import org.apache.qpid.server.BrokerOptions;
13-
import org.apache.qpid.server.exchange.TopicExchange;
1413
import org.junit.After;
1514
import org.junit.AfterClass;
1615
import org.junit.Before;
@@ -19,6 +18,11 @@
1918
import org.junit.runner.RunWith;
2019
import org.slf4j.Logger;
2120
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;
2226
import org.springframework.beans.factory.annotation.Autowired;
2327
import org.springframework.boot.test.context.SpringBootTest;
2428
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -160,9 +164,11 @@ public static void tearDown() throws Exception {
160164
@Test
161165
public void test() {
162166
try {
163-
Channel channel = conn.createChannel();
164167
String queueName = rmqConsumer.getQueueName();
165168
String exchange = "ei-poc-4";
169+
createExchange(exchange, queueName);
170+
Channel channel = conn.createChannel();
171+
166172

167173
ArrayList<String> eventNames = getEventNamesToSend();
168174
int eventsCount = eventNames.size();
@@ -201,4 +207,15 @@ private ArrayList<String> getEventNamesToSend() {
201207

202208
return eventNames;
203209
}
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+
}
204221
}

0 commit comments

Comments
 (0)