[ https://issues.apache.org/jira/browse/FLINK-2480?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14728651#comment-14728651 ]
ASF GitHub Bot commented on FLINK-2480: --------------------------------------- Github user mxm commented on a diff in the pull request: https://github.com/apache/flink/pull/1073#discussion_r38621439 --- Diff: flink-staging/flink-streaming/flink-streaming-core/src/test/java/org/apache/flink/streaming/api/functions/PrintSinkFunctionTest.java --- @@ -97,20 +76,43 @@ public void testPrintSinkStdErr(){ try { printSink.open(new Configuration()); } catch (Exception e) { - e.printStackTrace(); + Assert.fail(); } printSink.setTargetToStandardErr(); printSink.invoke("hello world!"); assertEquals("Print to System.err", printSink.toString()); - assertEquals("hello world!", stream.result); + assertEquals("hello world!\r\n", baos.toString()); printSink.close(); + stream.close(); } - @Override - public void invoke(IN record) { + @Test + public void testPrintSinkWithPrefix(){ + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintStream stream = new PrintStream(baos); + System.setOut(stream); + + final StreamingRuntimeContext ctx = Mockito.mock(StreamingRuntimeContext.class); + Mockito.when(ctx.getNumberOfParallelSubtasks()).thenReturn(2); + Mockito.when(ctx.getIndexOfThisSubtask()).thenReturn(1); + PrintSinkFunction<String> printSink = new PrintSinkFunction<>(); + printSink.setRuntimeContext(ctx); + try { + printSink.open(new Configuration()); + } catch (Exception e) { + Assert.fail(); + } + printSink.setTargetToStandardErr(); + printSink.invoke("hello world!"); + + assertEquals("Print to System.err", printSink.toString()); + assertEquals("2> hello world!\r\n", baos.toString()); --- End diff -- Same compatibility issue here. > Improving tests coverage for org.apache.flink.streaming.api > ----------------------------------------------------------- > > Key: FLINK-2480 > URL: https://issues.apache.org/jira/browse/FLINK-2480 > Project: Flink > Issue Type: Test > Components: Streaming > Affects Versions: 0.10 > Reporter: Huang Wei > Fix For: 0.10 > > Original Estimate: 504h > Remaining Estimate: 504h > > The streaming API is quite a bit newer than the other code so it is not that > well covered with tests. -- This message was sent by Atlassian JIRA (v6.3.4#6332)