You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@crunch.apache.org by mk...@apache.org on 2016/07/29 22:29:29 UTC
crunch git commit: CRUNCH-613: Fix
FileTargetImplTest.testHandleOutputsMovesFilesToDestination instability
Repository: crunch
Updated Branches:
refs/heads/master 983019aab -> 8ca28db25
CRUNCH-613: Fix FileTargetImplTest.testHandleOutputsMovesFilesToDestination instability
Signed-off-by: Micah Whitacre <mk...@gmail.com>
CRUNCH-613: Fixed up the test to consolidate constants used.
Project: http://git-wip-us.apache.org/repos/asf/crunch/repo
Commit: http://git-wip-us.apache.org/repos/asf/crunch/commit/8ca28db2
Tree: http://git-wip-us.apache.org/repos/asf/crunch/tree/8ca28db2
Diff: http://git-wip-us.apache.org/repos/asf/crunch/diff/8ca28db2
Branch: refs/heads/master
Commit: 8ca28db25b44c4f86e103b2d485f4ada6c850568
Parents: 983019a
Author: Cl�ment MATHIEU <cl...@unportant.info>
Authored: Tue Jul 19 21:30:35 2016 +0200
Committer: Micah Whitacre <mk...@gmail.com>
Committed: Fri Jul 29 17:27:50 2016 -0500
----------------------------------------------------------------------
.../crunch/io/impl/FileTargetImplTest.java | 38 ++++++++++++++------
1 file changed, 28 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/crunch/blob/8ca28db2/crunch-core/src/test/java/org/apache/crunch/io/impl/FileTargetImplTest.java
----------------------------------------------------------------------
diff --git a/crunch-core/src/test/java/org/apache/crunch/io/impl/FileTargetImplTest.java b/crunch-core/src/test/java/org/apache/crunch/io/impl/FileTargetImplTest.java
index 6bc13d2..981e20a 100644
--- a/crunch-core/src/test/java/org/apache/crunch/io/impl/FileTargetImplTest.java
+++ b/crunch-core/src/test/java/org/apache/crunch/io/impl/FileTargetImplTest.java
@@ -17,6 +17,7 @@
*/
package org.apache.crunch.io.impl;
+
import org.apache.commons.io.FileUtils;
import org.apache.crunch.io.SequentialFileNamingScheme;
import org.apache.hadoop.conf.Configuration;
@@ -27,8 +28,17 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.hasItem;
public class FileTargetImplTest {
@@ -44,19 +54,27 @@ public class FileTargetImplTest {
SequenceFileOutputFormat.class,
SequentialFileNamingScheme.getInstance());
- File testPart1 = new File(testWorkingPath.toAbsolutePath().toString(), "part-m-00000");
- File testPart2 = new File(testWorkingPath.toAbsolutePath().toString(), "part-m-00001");
- FileUtils.writeStringToFile(testPart1, "test1");
- FileUtils.writeStringToFile(testPart2, "test2");
+ Map<String, String> partToContent = new HashMap<>();
+ partToContent.put("part-m-00000", "test1");
+ partToContent.put("part-m-00001", "test2");
+ Collection<String> expectedContent = partToContent.values();
+
+ for(Map.Entry<String, String> entry: partToContent.entrySet()){
+ File part = new File(testWorkingPath.toAbsolutePath().toString(), entry.getKey());
+ FileUtils.writeStringToFile(part, entry.getValue());
+ }
fileTarget.handleOutputs(new Configuration(),
new Path(testWorkingPath.toAbsolutePath().toString()),
-1);
- assertEquals(FileUtils.readFileToString(
- new File(testDestinationPath.toAbsolutePath().toString(), "part-m-00000")),
- "test1");
- assertEquals(FileUtils.readFileToString(
- new File(testDestinationPath.toAbsolutePath().toString(), "part-m-00001")),
- "test2");
+ Set<String> fileContents = new HashSet<>();
+ for (String fileName : partToContent.keySet()) {
+ fileContents.add(FileUtils.readFileToString(testDestinationPath.resolve(fileName).toFile()));
+ }
+
+ assertThat(expectedContent.size(), is(fileContents.size()));
+ for(String content: expectedContent){
+ assertThat(fileContents, hasItem(content));
+ }
}
}
\ No newline at end of file