List of usage examples for org.springframework.integration.amqp.channel PointToPointSubscribableAmqpChannel PointToPointSubscribableAmqpChannel
public PointToPointSubscribableAmqpChannel(String channelName, AbstractMessageListenerContainer container,
AmqpTemplate amqpTemplate)
From source file:org.springframework.integration.amqp.channel.DispatcherHasNoSubscribersTests.java
@Test public void testPtP() { final Channel channel = mock(Channel.class); Connection connection = mock(Connection.class); doAnswer(new Answer<Channel>() { public Channel answer(InvocationOnMock invocation) throws Throwable { return channel; }/* www .j ava 2 s .co m*/ }).when(connection).createChannel(anyBoolean()); ConnectionFactory connectionFactory = mock(ConnectionFactory.class); when(connectionFactory.createConnection()).thenReturn(connection); SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setConnectionFactory(connectionFactory); AmqpTemplate amqpTemplate = mock(AmqpTemplate.class); PointToPointSubscribableAmqpChannel amqpChannel = new PointToPointSubscribableAmqpChannel( "noSubscribersChannel", container, amqpTemplate); amqpChannel.setBeanName("noSubscribersChannel"); amqpChannel.afterPropertiesSet(); MessageListener listener = (MessageListener) container.getMessageListener(); try { listener.onMessage(new Message("Hello world!".getBytes(), null)); fail("Exception expected"); } catch (MessageDeliveryException e) { assertEquals("Dispatcher has no subscribers for amqp-channel 'noSubscribersChannel'.", e.getMessage()); } }