Clean up output streams in unit test.

This fixes some lint warnings and may also fix dev task #102.
This commit is contained in:
akwizgran
2014-12-05 19:22:35 +00:00
parent d94637b5cf
commit 64d644d8b8

View File

@@ -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