AMQP-164: add integration for bindings in XML
This commit is contained in:
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/rabbit"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<direct-exchange name="directTest">
|
||||
<bindings>
|
||||
<binding queue="bucket" />
|
||||
</bindings>
|
||||
</direct-exchange>
|
||||
|
||||
<topic-exchange name="topicTest">
|
||||
<bindings>
|
||||
<binding queue="bucket" pattern="bucket.#"/>
|
||||
</bindings>
|
||||
</topic-exchange>
|
||||
|
||||
<fanout-exchange name="fanoutTest">
|
||||
<bindings>
|
||||
<binding queue="bucket" />
|
||||
</bindings>
|
||||
</fanout-exchange>
|
||||
|
||||
<headers-exchange name="headersTest">
|
||||
<bindings>
|
||||
<binding queue="bucket" key="type" value="bucket" />
|
||||
</bindings>
|
||||
</headers-exchange>
|
||||
|
||||
<queue id="bucket" />
|
||||
|
||||
<admin id="admin-test" connection-factory="connectionFactory" auto-startup="true"/>
|
||||
|
||||
<connection-factory id="connectionFactory"/>
|
||||
|
||||
</beans:beans>
|
||||
Reference in New Issue
Block a user