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.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to