diff --git a/briar-tests/src/org/briarproject/transport/StreamWriterImplTest.java b/briar-tests/src/org/briarproject/transport/StreamWriterImplTest.java index 8fc9cd6f1..e55e9092d 100644 --- a/briar-tests/src/org/briarproject/transport/StreamWriterImplTest.java +++ b/briar-tests/src/org/briarproject/transport/StreamWriterImplTest.java @@ -31,7 +31,7 @@ public class StreamWriterImplTest extends BriarTestCase { } @Test - public void testFlushWithoutBufferedDataWritesFrame() throws Exception { + public void testFlushWithoutBufferedDataOnlyFlushes() throws Exception { Mockery context = new Mockery(); final FrameWriter writer = context.mock(FrameWriter.class); StreamWriterImpl w = new StreamWriterImpl(writer, FRAME_LENGTH); @@ -41,6 +41,16 @@ public class StreamWriterImplTest extends BriarTestCase { }}); w.flush(); context.assertIsSatisfied(); + + // Clean up + context.checking(new Expectations() {{ + // Closing the writer writes a final frame and flushes again + oneOf(writer).writeFrame(with(any(byte[].class)), with(0), + with(true)); + oneOf(writer).flush(); + }}); + w.close(); + context.assertIsSatisfied(); } @Test @@ -59,6 +69,16 @@ public class StreamWriterImplTest extends BriarTestCase { w.write(0); w.flush(); context.assertIsSatisfied(); + + // Clean up + context.checking(new Expectations() {{ + // Closing the writer writes a final frame and flushes again + oneOf(writer).writeFrame(with(any(byte[].class)), with(0), + with(true)); + oneOf(writer).flush(); + }}); + w.close(); + context.assertIsSatisfied(); } @Test @@ -75,6 +95,16 @@ public class StreamWriterImplTest extends BriarTestCase { w.write(0); } context.assertIsSatisfied(); + + // Clean up + context.checking(new Expectations() {{ + // Closing the writer writes a final frame and flushes again + oneOf(writer).writeFrame(with(any(byte[].class)), with(0), + with(true)); + oneOf(writer).flush(); + }}); + w.close(); + context.assertIsSatisfied(); } @Test @@ -96,6 +126,16 @@ public class StreamWriterImplTest extends BriarTestCase { w.write(b); w.write(b); context.assertIsSatisfied(); + + // Clean up + context.checking(new Expectations() {{ + // Closing the writer writes a final frame and flushes again + oneOf(writer).writeFrame(with(any(byte[].class)), with(0), + with(true)); + oneOf(writer).flush(); + }}); + w.close(); + context.assertIsSatisfied(); } @Test