2020import static org .junit .jupiter .api .Assertions .assertNotNull ;
2121import static org .junit .jupiter .api .Assertions .assertNull ;
2222import static org .junit .jupiter .api .Assertions .assertTrue ;
23+ import static org .junit .jupiter .api .Assertions .assertFalse ;
2324
2425import java .io .ByteArrayInputStream ;
2526import java .io .IOException ;
@@ -39,18 +40,22 @@ public void test() throws IOException, InterruptedException {
3940 // Some OS' clock granularity may be high.
4041 Thread .sleep (20 );
4142 final TimestampedObserver timestampedObserver = new TimestampedObserver ();
43+ assertFalse (timestampedObserver .isClosed ());
4244 // Java 8 instant resolution is not great.
4345 Thread .sleep (20 );
4446 // toString() should not blow up before close().
4547 assertNotNull (timestampedObserver .toString ());
4648 assertTrue (timestampedObserver .getOpenInstant ().isAfter (before ));
4749 assertTrue (timestampedObserver .getOpenToNowDuration ().toNanos () > 0 );
4850 assertNull (timestampedObserver .getCloseInstant ());
51+ assertFalse (timestampedObserver .isClosed ());
4952 final byte [] buffer = MessageDigestCalculatingInputStreamTest .generateRandomByteStream (IOUtils .DEFAULT_BUFFER_SIZE );
5053 try (ObservableInputStream ois = new ObservableInputStream (new ByteArrayInputStream (buffer ), timestampedObserver )) {
5154 assertTrue (timestampedObserver .getOpenInstant ().isAfter (before ));
5255 assertTrue (timestampedObserver .getOpenToNowDuration ().toNanos () > 0 );
56+ assertFalse (timestampedObserver .isClosed ());
5357 }
58+ assertTrue (timestampedObserver .isClosed ());
5459 assertTrue (timestampedObserver .getOpenInstant ().isAfter (before ));
5560 assertTrue (timestampedObserver .getOpenToNowDuration ().toNanos () > 0 );
5661 assertTrue (timestampedObserver .getCloseInstant ().isAfter (timestampedObserver .getOpenInstant ()));
0 commit comments