NamespaceSliceDU nssd = namespaceSliceDUMap.get(0);
// Throw when exit code is not 1
boolean thrown = false;
try {
nssd.processErrorOutput(new ExitCodeException(1, "du: cannot access `a1.txt': No such file or directory"));
} catch(ExitCodeException ece) {
thrown = true;
}
TestCase.assertTrue(thrown);
Field exitCodeField = Shell.class.getDeclaredField("exitCode");
exitCodeField.setAccessible(true);
exitCodeField.set(nssd, 1);
// One single file fails to be accessed.
nssd.processErrorOutput(new ExitCodeException(1, "du: cannot access `a1.txt': No such file or directory"));
// Two files fail to be accessed
nssd.processErrorOutput(new ExitCodeException(1, "du: cannot access `a2.txt': No such file or directory\ndu: cannot access `a3.txt': No such file or directory"));
// Two files fail to be accessed, one is the same as the previous one
thrown = false;
try {
nssd.processErrorOutput(new ExitCodeException(
1,
"du: cannot access `a4.txt': No such file or directory\ndu: cannot access `a3.txt': No such file or directory"));
} catch (IOException ioe) {
thrown = true;
}
TestCase.assertTrue(thrown);
// Two files fail to be accessed, one is the same as a previous one
thrown = false;
try {
nssd.processErrorOutput(new ExitCodeException(
1,
"du: cannot access `a2.txt': No such file or directory\ndu: cannot access `a5.txt': No such file or directory"));
} catch (IOException ioe) {
thrown = true;
}
TestCase.assertTrue(thrown);
// Two files fail to be accessed
nssd.processErrorOutput(new ExitCodeException(1, "du: cannot access `a6.txt': No such file or directory"));
}