Search in sources :

Example 1 with RMQConnectionConfig

use of org.apache.flink.streaming.connectors.rabbitmq.common.RMQConnectionConfig in project flink by apache.

the class RMQSourceTest method throwExceptionIfConnectionFactoryReturnNull.

@Test
public void throwExceptionIfConnectionFactoryReturnNull() throws Exception {
    RMQConnectionConfig connectionConfig = Mockito.mock(RMQConnectionConfig.class);
    ConnectionFactory connectionFactory = Mockito.mock(ConnectionFactory.class);
    Connection connection = Mockito.mock(Connection.class);
    Mockito.when(connectionConfig.getConnectionFactory()).thenReturn(connectionFactory);
    Mockito.when(connectionFactory.newConnection()).thenReturn(connection);
    Mockito.when(connection.createChannel()).thenReturn(null);
    RMQSource<String> rmqSource = new RMQSource<>(connectionConfig, "queueDummy", true, new StringDeserializationScheme());
    try {
        rmqSource.open(new Configuration());
    } catch (RuntimeException ex) {
        assertEquals("None of RabbitMQ channels are available", ex.getMessage());
    }
}
Also used : ConnectionFactory(com.rabbitmq.client.ConnectionFactory) Configuration(org.apache.flink.configuration.Configuration) RMQConnectionConfig(org.apache.flink.streaming.connectors.rabbitmq.common.RMQConnectionConfig) Connection(com.rabbitmq.client.Connection) Test(org.junit.Test)

Aggregations

Connection (com.rabbitmq.client.Connection)1 ConnectionFactory (com.rabbitmq.client.ConnectionFactory)1 Configuration (org.apache.flink.configuration.Configuration)1 RMQConnectionConfig (org.apache.flink.streaming.connectors.rabbitmq.common.RMQConnectionConfig)1 Test (org.junit.Test)1