Search in sources :

Example 21 with MockStreamingRuntimeContext

use of org.apache.flink.streaming.util.MockStreamingRuntimeContext in project flink by apache.

the class PrintSinkFunctionTest method testPrintSinkWithIdentifierAndPrefix.

@Test
public void testPrintSinkWithIdentifierAndPrefix() throws Exception {
    PrintSinkFunction<String> printSink = new PrintSinkFunction<>("mySink", false);
    printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 2, 1));
    printSink.open(new Configuration());
    printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));
    assertEquals("Print to System.out", printSink.toString());
    assertEquals("mySink:2> hello world!" + line, arrayOutputStream.toString());
    printSink.close();
}
Also used : MockStreamingRuntimeContext(org.apache.flink.streaming.util.MockStreamingRuntimeContext) Configuration(org.apache.flink.configuration.Configuration) PrintSinkFunction(org.apache.flink.streaming.api.functions.sink.PrintSinkFunction) Test(org.junit.Test)

Example 22 with MockStreamingRuntimeContext

use of org.apache.flink.streaming.util.MockStreamingRuntimeContext in project flink by apache.

the class PrintSinkFunctionTest method testPrintSinkWithIdentifierButNoPrefix.

@Test
public void testPrintSinkWithIdentifierButNoPrefix() throws Exception {
    PrintSinkFunction<String> printSink = new PrintSinkFunction<>("mySink", false);
    printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));
    printSink.open(new Configuration());
    printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));
    assertEquals("Print to System.out", printSink.toString());
    assertEquals("mySink> hello world!" + line, arrayOutputStream.toString());
    printSink.close();
}
Also used : MockStreamingRuntimeContext(org.apache.flink.streaming.util.MockStreamingRuntimeContext) Configuration(org.apache.flink.configuration.Configuration) PrintSinkFunction(org.apache.flink.streaming.api.functions.sink.PrintSinkFunction) Test(org.junit.Test)

Aggregations

MockStreamingRuntimeContext (org.apache.flink.streaming.util.MockStreamingRuntimeContext)22 Configuration (org.apache.flink.configuration.Configuration)19 Test (org.junit.Test)15 OperatorState (org.apache.flink.runtime.checkpoint.OperatorState)5 PrintSinkFunction (org.apache.flink.streaming.api.functions.sink.PrintSinkFunction)5 ArrayList (java.util.ArrayList)4 OperatorSubtaskState (org.apache.flink.runtime.checkpoint.OperatorSubtaskState)4 HashMap (java.util.HashMap)3 OperatorStateInputSplit (org.apache.flink.state.api.input.splits.OperatorStateInputSplit)3 Nonnull (javax.annotation.Nonnull)2 GenericJdbcSinkFunction (org.apache.flink.connector.jdbc.internal.GenericJdbcSinkFunction)2 OperatorID (org.apache.flink.runtime.jobgraph.OperatorID)2 StateSnapshotContextSynchronousImpl (org.apache.flink.runtime.state.StateSnapshotContextSynchronousImpl)2 KeyGroupRangeInputSplit (org.apache.flink.state.api.input.splits.KeyGroupRangeInputSplit)2 ResolvedSchema (org.apache.flink.table.catalog.ResolvedSchema)2 DynamicTableSink (org.apache.flink.table.connector.sink.DynamicTableSink)2 SinkFunctionProvider (org.apache.flink.table.connector.sink.SinkFunctionProvider)2 Channel (com.rabbitmq.client.Channel)1 Connection (com.rabbitmq.client.Connection)1 IOException (java.io.IOException)1