Skip to content

Commit

Permalink
Improvements to unit tests.
Browse files Browse the repository at this point in the history
Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
  • Loading branch information
spericas committed Jul 9, 2020
1 parent 5201857 commit 7a9a2ae
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ void testByteAtTimeBuffer() throws IOException {
publisher.write(0);
publisher.write(0);
publisher.write(0); // first
subscriber.assertEmpty();
publisher.flush(); // second
long size = subscriber.getItems().stream().count();
assertThat(size, is(equalTo(2L)));
subscriber.assertItemCount(2);
}

@Test
Expand All @@ -187,15 +187,19 @@ void testByteAtTimeBufferArray() throws IOException {
TestSubscriber<ByteBuffer> subscriber = new TestSubscriber<>();
publisher.subscribe(subscriber);
subscriber.requestMax();
publisher.write(0); // first
publisher.write(new byte[] { 0 }); // second
publisher.write(0); // first
subscriber.assertEmpty();
publisher.write(new byte[] { 0 }); // second
subscriber.assertItemCount(2);
publisher.write(0);
publisher.write(0); // third
publisher.write(new byte[] { 0 }); // fourth
publisher.write(0); // fifth
publisher.write(0); // third
subscriber.assertItemCount(2);
publisher.write(new byte[] { 0 }); // fourth
subscriber.assertItemCount(4);
publisher.write(0); // fifth
subscriber.assertItemCount(4);
publisher.close();
long size = subscriber.getItems().stream().count();
assertThat(size, is(equalTo(5L)));
subscriber.assertItemCount(5).assertComplete();
}

private static final class UnitTestException extends RuntimeException {
Expand Down

0 comments on commit 7a9a2ae

Please sign in to comment.