From a804b7c9d2986556c91c1741c1ae7ac2b9c579f3 Mon Sep 17 00:00:00 2001 From: Inigo Goiri Date: Sat, 2 Jun 2018 20:25:42 -0700 Subject: [PATCH] MAPREDUCE-7102. Fix TestJavaSerialization for Windows due a mismatch line separator. Contributed by Giovanni Matteo Fumarola. --- .../hadoop/mapred/TestJavaSerialization.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestJavaSerialization.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestJavaSerialization.java index a787e68c124..e5ef4d26873 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestJavaSerialization.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestJavaSerialization.java @@ -91,6 +91,8 @@ public class TestJavaSerialization { wr.write("b a\n"); wr.close(); } + + @SuppressWarnings("deprecation") @Test public void testMapReduceJob() throws Exception { @@ -131,16 +133,17 @@ public class TestJavaSerialization { FileUtil.stat2Paths(fs.listStatus(OUTPUT_DIR, new Utils.OutputFileUtils.OutputFilesFilter())); assertEquals(1, outputFiles.length); - InputStream is = fs.open(outputFiles[0]); - String reduceOutput = org.apache.commons.io.IOUtils.toString(is); - String[] lines = reduceOutput.split(System.getProperty("line.separator")); - assertEquals("Unexpected output; received output '" + reduceOutput + "'", - "a\t1", lines[0]); - assertEquals("Unexpected output; received output '" + reduceOutput + "'", - "b\t1", lines[1]); - assertEquals("Reduce output has extra lines; output is '" + reduceOutput - + "'", 2, lines.length); - is.close(); + try (InputStream is = fs.open(outputFiles[0])) { + String reduceOutput = org.apache.commons.io.IOUtils.toString(is); + String[] lines = reduceOutput.split("\n"); + assertEquals("Unexpected output; received output '" + reduceOutput + "'", + "a\t1", lines[0]); + assertEquals("Unexpected output; received output '" + reduceOutput + "'", + "b\t1", lines[1]); + assertEquals( + "Reduce output has extra lines; output is '" + reduceOutput + "'", 2, + lines.length); + } } /**