From 8c90ee6eacad2d635a53a448788b9dfb6d2ad5d7 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Wed, 27 Apr 2011 11:40:47 +0100 Subject: [PATCH] AMQP-164: add integration for bindings in XML --- .../ExchangeParserIntegrationTests.java | 61 +++++++++++++++++++ ...ExchangeParserIntegrationTests-context.xml | 38 ++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 spring-rabbit/src/test/java/org/springframework/amqp/rabbit/config/ExchangeParserIntegrationTests.java create mode 100644 spring-rabbit/src/test/resources/org/springframework/amqp/rabbit/config/ExchangeParserIntegrationTests-context.xml diff --git a/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/config/ExchangeParserIntegrationTests.java b/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/config/ExchangeParserIntegrationTests.java new file mode 100644 index 00000000..a4d2a9af --- /dev/null +++ b/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/config/ExchangeParserIntegrationTests.java @@ -0,0 +1,61 @@ +/* + * Copyright 2002-2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package org.springframework.amqp.rabbit.config; + +import static org.junit.Assert.assertEquals; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.amqp.core.Exchange; +import org.springframework.amqp.core.Queue; +import org.springframework.amqp.rabbit.connection.ConnectionFactory; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.amqp.rabbit.test.BrokerRunning; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@ContextConfiguration +@RunWith(SpringJUnit4ClassRunner.class) +public final class ExchangeParserIntegrationTests { + + @Rule + public BrokerRunning brokerIsRunning = BrokerRunning.isRunning(); + + @Autowired + private ConnectionFactory connectionFactory; + + @Autowired + private Exchange fanoutTest; + + @Autowired + @Qualifier("bucket") + private Queue queue; + + @Test + public void testBindingsDeclared() throws Exception { + + RabbitTemplate template = new RabbitTemplate(connectionFactory); + template.convertAndSend(fanoutTest.getName(), "", "message"); + Thread.sleep(200); + // The queue is anonymous so it will be deleted at the end of the test, but it should get the message as long as + // we use the same connection + String result = (String) template.receiveAndConvert(queue.getName()); + assertEquals("message", result); + + } + +} diff --git a/spring-rabbit/src/test/resources/org/springframework/amqp/rabbit/config/ExchangeParserIntegrationTests-context.xml b/spring-rabbit/src/test/resources/org/springframework/amqp/rabbit/config/ExchangeParserIntegrationTests-context.xml new file mode 100644 index 00000000..f2c954ab --- /dev/null +++ b/spring-rabbit/src/test/resources/org/springframework/amqp/rabbit/config/ExchangeParserIntegrationTests-context.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +