use of org.springframework.amqp.rabbit.core.RabbitAdmin in project spring-integration by spring-projects.
the class ChannelTests method channelDeclarationTests.
/*
* Verify queue is declared if not present and not declared if it is already present.
*/
@Test
public void channelDeclarationTests() {
RabbitAdmin admin = new RabbitAdmin(this.connectionFactory);
admin.deleteQueue("implicit");
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(this.connectionFactory);
container.setAutoStartup(false);
AmqpTemplate amqpTemplate = mock(AmqpTemplate.class);
PointToPointSubscribableAmqpChannel channel = new PointToPointSubscribableAmqpChannel("implicit", container, amqpTemplate);
channel.setBeanFactory(mock(BeanFactory.class));
channel.afterPropertiesSet();
channel.onCreate(null);
assertNotNull(admin.getQueueProperties("implicit"));
admin.deleteQueue("explicit");
channel.setQueueName("explicit");
channel.afterPropertiesSet();
channel.onCreate(null);
assertNotNull(admin.getQueueProperties("explicit"));
admin.deleteQueue("explicit");
// verify no declaration if exists with non-standard props
admin.declareQueue(new Queue("explicit", false));
channel.afterPropertiesSet();
channel.onCreate(null);
assertNotNull(admin.getQueueProperties("explicit"));
admin.deleteQueue("explicit");
}
use of org.springframework.amqp.rabbit.core.RabbitAdmin in project spring-integration by spring-projects.
the class ChannelTests method testAmqpChannelFactoryBean.
@Test
public void testAmqpChannelFactoryBean() throws Exception {
AmqpChannelFactoryBean channelFactoryBean = new AmqpChannelFactoryBean();
channelFactoryBean.setBeanFactory(mock(BeanFactory.class));
channelFactoryBean.setConnectionFactory(this.connectionFactory);
channelFactoryBean.setBeanName("testChannel");
channelFactoryBean.afterPropertiesSet();
AbstractAmqpChannel channel = channelFactoryBean.getObject();
assertThat(channel, instanceOf(PointToPointSubscribableAmqpChannel.class));
channelFactoryBean = new AmqpChannelFactoryBean();
channelFactoryBean.setBeanFactory(mock(BeanFactory.class));
channelFactoryBean.setConnectionFactory(this.connectionFactory);
channelFactoryBean.setBeanName("testChannel");
channelFactoryBean.setPubSub(true);
channelFactoryBean.afterPropertiesSet();
channel = channelFactoryBean.getObject();
assertThat(channel, instanceOf(PublishSubscribeAmqpChannel.class));
RabbitAdmin rabbitAdmin = new RabbitAdmin(this.connectionFactory);
rabbitAdmin.deleteQueue("testChannel");
rabbitAdmin.deleteExchange("si.fanout.testChannel");
}
Aggregations