FileSystem fs = cluster.getFileSystem();
PrintStream psBackup = System.out;
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintStream psOut = new PrintStream(out);
System.setOut(psOut);
DumpTypedBytes dumptb = new DumpTypedBytes(conf);
try {
Path root = new Path("/typedbytestest");
assertTrue(fs.mkdirs(root));
assertTrue(fs.exists(root));
OutputStreamWriter writer = new OutputStreamWriter(fs.create(new Path(
root, "test.txt")));
try {
for (int i = 0; i < 100; i++) {
writer.write("" + (10 * i) + "\n");
}
} finally {
writer.close();
}
String[] args = new String[1];
args[0] = "/typedbytestest";
int ret = dumptb.run(args);
assertEquals("Return value != 0.", 0, ret);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
TypedBytesInput tbinput = new TypedBytesInput(new DataInputStream(in));
int counter = 0;