mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 13:49:53 +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
|
@Test
|
||||||
public void testFlushWithoutBufferedDataWritesFrame() throws Exception {
|
public void testFlushWithoutBufferedDataOnlyFlushes() throws Exception {
|
||||||
Mockery context = new Mockery();
|
Mockery context = new Mockery();
|
||||||
final FrameWriter writer = context.mock(FrameWriter.class);
|
final FrameWriter writer = context.mock(FrameWriter.class);
|
||||||
StreamWriterImpl w = new StreamWriterImpl(writer, FRAME_LENGTH);
|
StreamWriterImpl w = new StreamWriterImpl(writer, FRAME_LENGTH);
|
||||||
@@ -41,6 +41,16 @@ public class StreamWriterImplTest extends BriarTestCase {
|
|||||||
}});
|
}});
|
||||||
w.flush();
|
w.flush();
|
||||||
context.assertIsSatisfied();
|
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
|
@Test
|
||||||
@@ -59,6 +69,16 @@ public class StreamWriterImplTest extends BriarTestCase {
|
|||||||
w.write(0);
|
w.write(0);
|
||||||
w.flush();
|
w.flush();
|
||||||
context.assertIsSatisfied();
|
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
|
@Test
|
||||||
@@ -75,6 +95,16 @@ public class StreamWriterImplTest extends BriarTestCase {
|
|||||||
w.write(0);
|
w.write(0);
|
||||||
}
|
}
|
||||||
context.assertIsSatisfied();
|
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
|
@Test
|
||||||
@@ -96,6 +126,16 @@ public class StreamWriterImplTest extends BriarTestCase {
|
|||||||
w.write(b);
|
w.write(b);
|
||||||
w.write(b);
|
w.write(b);
|
||||||
context.assertIsSatisfied();
|
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
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user