static private PrintStream currentSystemOut = System.out;
static private List
....
@BeforeClass static public void setup() {
....
//redirect system.out to listchar
PrintStream printStream;
OutputStream outs = new OutputStream() {
@Override
public void write(int b) throws IOException {
char c = (char)b;
listchar.add(new Character(c));
}
};
printStream = new PrintStream(outs);
System.setOut(printStream);
}
@AfterClass static public void teardown() {
//revert setting
System.setOut(currentSystemOut);
}
private static String getOutContent() {
String res = "";
for(Character aChar: listchar ) {
res = res.concat( aChar +"");
}
return res;
}
...
No comments:
Post a Comment