flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tillrohrmann <...@git.apache.org>
Subject [GitHub] flink pull request: [FLINK-2622][streaming]add WriteMode for write...
Date Tue, 24 Nov 2015 15:40:55 GMT
Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1098#discussion_r45751119
  
    --- Diff: flink-staging/flink-streaming/flink-streaming-scala/src/test/java/org/apache/flink/streaming/scala/api/CsvOutputFormatITCase.java
---
    @@ -17,32 +17,107 @@
     
     package org.apache.flink.streaming.scala.api;
     
    +import junit.framework.Assert;
     import org.apache.flink.api.common.functions.FlatMapFunction;
     import org.apache.flink.api.java.tuple.Tuple2;
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.core.fs.FileSystem;
     import org.apache.flink.streaming.api.scala.OutputFormatTestPrograms;
    -import org.apache.flink.streaming.util.StreamingProgramTestBase;
    +import org.apache.flink.streaming.util.StreamingMultipleProgramsTestBase;
     import org.apache.flink.test.testdata.WordCountData;
    +import org.apache.flink.test.util.AbstractTestBase;
     import org.apache.flink.util.Collector;
    +import org.junit.After;
    +import org.junit.Before;
    +import org.junit.Test;
     
    -public class CsvOutputFormatITCase extends StreamingProgramTestBase {
    +import java.io.File;
    +import static org.junit.Assert.assertTrue;
    +
    +
    +public class CsvOutputFormatITCase extends StreamingMultipleProgramsTestBase  {
     
     	protected String resultPath;
     
    -	@Override
    -	protected void preSubmit() throws Exception {
    -		resultPath = getTempDirPath("result");
    +	public AbstractTestBase fileInfo = new AbstractTestBase(new Configuration()) {
    +		@Override
    +		public void startCluster() throws Exception {
    +			super.startCluster();
    +		}
    +	};
    +
    +	@Before
    +	public void createFile() throws Exception {
    +		File f = fileInfo.createAndRegisterTempFile("result");
    +		resultPath = f.toURI().toString();
     	}
     
    -	@Override
    -	protected void testProgram() throws Exception {
    +	@Test
    +	public void testPath() throws Exception {
     		OutputFormatTestPrograms.wordCountToCsv(WordCountData.TEXT, resultPath);
     	}
     
    -	@Override
    -	protected void postSubmit() throws Exception {
    -		//Strip the parentheses from the expected text like output
    +	@Test
    +	public void testPathMillis() throws Exception {
    +		OutputFormatTestPrograms.wordCountToCsv(WordCountData.TEXT, resultPath, 1);
    +	}
    +
    +	@Test
    +	public void testPathWriteMode() throws Exception {
    +		OutputFormatTestPrograms.wordCountToCsv(WordCountData.TEXT, resultPath, FileSystem.WriteMode.NO_OVERWRITE);
    +	}
    +
    +	@Test
    +	public void testPathWriteModeMillis() throws Exception {
    +		OutputFormatTestPrograms.wordCountToCsv(WordCountData.TEXT, resultPath, FileSystem.WriteMode.NO_OVERWRITE,
1);
    +	}
    +
    +	@Test
    +	public void testPathWriteModeMillisDelimiter() throws Exception {
    +		OutputFormatTestPrograms.wordCountToCsv(WordCountData.TEXT, resultPath, FileSystem.WriteMode.NO_OVERWRITE,
1, "\n", ",");
    +	}
    +
    +	@Test
    +	public void failtestPathWriteMode() throws Exception {
    +		OutputFormatTestPrograms.wordCountToCsv(WordCountData.TEXT, resultPath);
    +		try {
    +			OutputFormatTestPrograms.wordCountToCsv(WordCountData.TEXT, resultPath, FileSystem.WriteMode.NO_OVERWRITE);
    +		} catch (Exception e) {
    +			assertTrue(e.getCause().getMessage().indexOf("File already exists") != -1);
    +			return;
    +		}
    +		Assert.fail();
    +	}
    +
    +	@Test
    +	public void failtestPathWriteModeMillis() throws Exception {
    +		OutputFormatTestPrograms.wordCountToCsv(WordCountData.TEXT, resultPath);
    +		try {
    +			OutputFormatTestPrograms.wordCountToCsv(WordCountData.TEXT, resultPath, FileSystem.WriteMode.NO_OVERWRITE,
1);
    --- End diff --
    
    How do you test that the `millis` parameter is respected?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message