mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Clean up output streams in unit test.
This fixes some lint warnings and may also fix dev task #102.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user