@Test
 public void logsPartialLineOnClose() throws IOException {
   context.checking(
       new Expectations() {
         {
           one(action).execute("line 1");
         }
       });
   outputStream.write("line 1".getBytes());
   outputStream.close();
 }
 @Test
 public void logsLineWhichIsLongerThanInitialBufferLength() throws IOException {
   context.checking(
       new Expectations() {
         {
           one(action).execute("a line longer than 8 bytes long");
           one(action).execute("line 2");
         }
       });
   outputStream.write(String.format("a line longer than 8 bytes long%n").getBytes());
   outputStream.write("line 2".getBytes());
   outputStream.close();
 }
 @Test(expected = IOException.class)
 public void cannotWriteAfterClose() throws IOException {
   outputStream.close();
   outputStream.write("ignore me".getBytes());
 }