out.write("#!/bin/bash\necho \"Hello world!\" >&2 \n"
+ "sleep 1s \necho \"Hello world!\" >&2 \n");
out.close();
String cmd = temp.getAbsolutePath();
EventSource source = new ExecNioSource.Builder().build("/bin/bash " + cmd,
"true");
source.open();
Event e = source.next();
assertNotNull(e);
assertEquals(26, e.getBody().length); // check that we read both lines
source.close();
// Check that the stdout reader closed correctly
assertTrue(((ExecNioSource) source).readOut.signalDone.get());
}