Skip to content

Commit a804b7c

Browse files
author
Inigo Goiri
committed
MAPREDUCE-7102. Fix TestJavaSerialization for Windows due a mismatch line separator. Contributed by Giovanni Matteo Fumarola.
1 parent 8f83b9a commit a804b7c

File tree

1 file changed

+13
-10
lines changed
  • hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred

1 file changed

+13
-10
lines changed

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestJavaSerialization.java

+13-10
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ private void cleanAndCreateInput(FileSystem fs) throws IOException {
9191
wr.write("b a\n");
9292
wr.close();
9393
}
94+
95+
@SuppressWarnings("deprecation")
9496
@Test
9597
public void testMapReduceJob() throws Exception {
9698

@@ -131,16 +133,17 @@ public void testMapReduceJob() throws Exception {
131133
FileUtil.stat2Paths(fs.listStatus(OUTPUT_DIR,
132134
new Utils.OutputFileUtils.OutputFilesFilter()));
133135
assertEquals(1, outputFiles.length);
134-
InputStream is = fs.open(outputFiles[0]);
135-
String reduceOutput = org.apache.commons.io.IOUtils.toString(is);
136-
String[] lines = reduceOutput.split(System.getProperty("line.separator"));
137-
assertEquals("Unexpected output; received output '" + reduceOutput + "'",
138-
"a\t1", lines[0]);
139-
assertEquals("Unexpected output; received output '" + reduceOutput + "'",
140-
"b\t1", lines[1]);
141-
assertEquals("Reduce output has extra lines; output is '" + reduceOutput
142-
+ "'", 2, lines.length);
143-
is.close();
136+
try (InputStream is = fs.open(outputFiles[0])) {
137+
String reduceOutput = org.apache.commons.io.IOUtils.toString(is);
138+
String[] lines = reduceOutput.split("\n");
139+
assertEquals("Unexpected output; received output '" + reduceOutput + "'",
140+
"a\t1", lines[0]);
141+
assertEquals("Unexpected output; received output '" + reduceOutput + "'",
142+
"b\t1", lines[1]);
143+
assertEquals(
144+
"Reduce output has extra lines; output is '" + reduceOutput + "'", 2,
145+
lines.length);
146+
}
144147
}
145148

146149
/**

0 commit comments

Comments
 (0)