@Test(expected = RuntimeException.class) public void exceptionDuringPublishingIsNotIgnored() throws Exception { RMQSink<String> rmqSink = createRMQSink(); doThrow(IOException.class).when(channel).basicPublish("", QUEUE_NAME, null, MESSAGE); rmqSink.invoke("msg"); }
@Test public void exceptionDuringPublishingIsIgnoredIfLogFailuresOnly() throws Exception { RMQSink<String> rmqSink = createRMQSink(); rmqSink.setLogFailuresOnly(true); doThrow(IOException.class).when(channel).basicPublish("", QUEUE_NAME, null, MESSAGE); rmqSink.invoke("msg"); }
@Test public void invokePublishBytesToQueue() throws Exception { RMQSink<String> rmqSink = createRMQSink(); rmqSink.invoke(MESSAGE_STR); verify(serializationSchema).serialize(MESSAGE_STR); verify(channel).basicPublish("", QUEUE_NAME, null, MESSAGE); }
@Test public void closeAllResources() throws Exception { RMQSink<String> rmqSink = createRMQSink(); rmqSink.close(); verify(channel).close(); verify(connection).close(); }
private RMQSink<String> createRMQSink() throws Exception { RMQSink rmqSink = new RMQSink<String>(rmqConnectionConfig, QUEUE_NAME, serializationSchema); rmqSink.open(new Configuration()); return rmqSink; }