List of usage examples for org.springframework.amqp.rabbit.connection ConnectionFactory getHost
String getHost();
From source file:com.gopivotal.cloudfoundry.test.core.RabbitUtils.java
public String getUrl(ConnectionFactory connectionFactory) { return String.format("amqp://%s/%s", connectionFactory.getHost(), connectionFactory.getVirtualHost()); }
From source file:org.springframework.amqp.rabbit.connection.LocalizedQueueConnectionFactoryTests.java
@SuppressWarnings("unchecked") private ConnectionFactory mockCF(final String address, final CountDownLatch latch) throws Exception { ConnectionFactory connectionFactory = mock(ConnectionFactory.class); Connection connection = mock(Connection.class); Channel channel = mock(Channel.class); when(connectionFactory.createConnection()).thenReturn(connection); when(connection.createChannel(false)).thenReturn(channel); when(connection.isOpen()).thenReturn(true, false); when(channel.isOpen()).thenReturn(true, false); doAnswer(invocation -> {/* w w w . j a v a 2 s . c om*/ String tag = UUID.randomUUID().toString(); consumers.put(address, (Consumer) invocation.getArguments()[6]); consumerTags.put(address, tag); if (latch != null) { latch.countDown(); } return tag; }).when(channel).basicConsume(anyString(), anyBoolean(), anyString(), anyBoolean(), anyBoolean(), anyMap(), any(Consumer.class)); when(connectionFactory.getHost()).thenReturn(address); this.channels.put(address, channel); return connectionFactory; }
From source file:org.springframework.cloud.stream.binder.rabbit.LocalizedQueueConnectionFactoryTests.java
@SuppressWarnings("unchecked") private ConnectionFactory mockCF(final String address) throws Exception { ConnectionFactory connectionFactory = mock(ConnectionFactory.class); Connection connection = mock(Connection.class); Channel channel = mock(Channel.class); when(connectionFactory.createConnection()).thenReturn(connection); when(connection.createChannel(false)).thenReturn(channel); when(connection.isOpen()).thenReturn(true); when(channel.isOpen()).thenReturn(true); doAnswer(new Answer<String>() { @Override//from w ww.j av a 2 s. c om public String answer(InvocationOnMock invocation) throws Throwable { String tag = UUID.randomUUID().toString(); consumers.put(address, (Consumer) invocation.getArguments()[6]); consumerTags.put(address, tag); latch.countDown(); return tag; } }).when(channel).basicConsume(anyString(), anyBoolean(), anyString(), anyBoolean(), anyBoolean(), anyMap(), any(Consumer.class)); when(connectionFactory.getHost()).thenReturn(address); this.cfs.put(address, connectionFactory); this.connections.put(address, connection); this.channels.put(address, channel); return connectionFactory; }