Add TimestampedObserver.
Fat-fingered the class name previously.
RENAME
src/main/java/org/apache/commons/io/input/TimetampedObserver.java
src/main/java/org/apache/commons/io/input/TimestampedObserver.java
* </p>
*
* <pre>
- * final TimetampedObserver timetampedObserver = new TimetampedObserver();
+ * final TimestampedObserver timetampedObserver = new TimestampedObserver();
* try (final ObservableInputStream inputStream = new ObservableInputStream(...),
* timetampedObserver)) {
* ...
*
* @since 2.9.0
*/
-public class TimetampedObserver extends Observer {
+public class TimestampedObserver extends Observer {
private volatile Instant closeInstant;
private final Instant openInstant = Instant.now();

RENAME
src/test/java/org/apache/commons/io/input/TimetampedObserverTest.java
src/test/java/org/apache/commons/io/input/TimestampedObserverTest.java
import org.junit.jupiter.api.Test;
/**
- * Tests {@link TimetampedObserver}.
+ * Tests {@link TimestampedObserver}.
*/
-public class TimetampedObserverTest {
+public class TimestampedObserverTest {
@Test
public void test() throws IOException, InterruptedException {
final Instant before = Instant.now();
Thread.sleep(20); // Some OS' clock granularity may be high.
- final TimetampedObserver timetampedObserver = new TimetampedObserver();
- assertTrue(timetampedObserver.getOpenInstant().isAfter(before));
- assertTrue(timetampedObserver.getOpenToNowDuration().toNanos() > 0);
- assertNull(timetampedObserver.getCloseInstant());
+ final TimestampedObserver timestampedObserver = new TimestampedObserver();
+ assertTrue(timestampedObserver.getOpenInstant().isAfter(before));
+ assertTrue(timestampedObserver.getOpenToNowDuration().toNanos() > 0);
+ assertNull(timestampedObserver.getCloseInstant());
final byte[] buffer = MessageDigestCalculatingInputStreamTest
.generateRandomByteStream(IOUtils.DEFAULT_BUFFER_SIZE);
try (final ObservableInputStream ois = new ObservableInputStream(new ByteArrayInputStream(buffer),
- timetampedObserver)) {
- assertTrue(timetampedObserver.getOpenInstant().isAfter(before));
- assertTrue(timetampedObserver.getOpenToNowDuration().toNanos() > 0);
+ timestampedObserver)) {
+ assertTrue(timestampedObserver.getOpenInstant().isAfter(before));
+ assertTrue(timestampedObserver.getOpenToNowDuration().toNanos() > 0);
}
- assertTrue(timetampedObserver.getOpenInstant().isAfter(before));
- assertTrue(timetampedObserver.getOpenToNowDuration().toNanos() > 0);
- assertTrue(timetampedObserver.getCloseInstant().isAfter(timetampedObserver.getOpenInstant()));
- assertTrue(timetampedObserver.getOpenToCloseDuration().toNanos() > 0);
+ assertTrue(timestampedObserver.getOpenInstant().isAfter(before));
+ assertTrue(timestampedObserver.getOpenToNowDuration().toNanos() > 0);
+ assertTrue(timestampedObserver.getCloseInstant().isAfter(timestampedObserver.getOpenInstant()));
+ assertTrue(timestampedObserver.getOpenToCloseDuration().toNanos() > 0);
}
@Test
public void testExample() throws IOException, InterruptedException {
- final TimetampedObserver timetampedObserver = new TimetampedObserver();
+ final TimestampedObserver timestampedObserver = new TimestampedObserver();
final byte[] buffer = MessageDigestCalculatingInputStreamTest
.generateRandomByteStream(IOUtils.DEFAULT_BUFFER_SIZE);
try (final ObservableInputStream ois = new ObservableInputStream(new ByteArrayInputStream(buffer),
- timetampedObserver)) {
+ timestampedObserver)) {
//
}
- System.out.printf("IO duration: %s%n", timetampedObserver.getOpenToCloseDuration());
+ System.out.printf("IO duration: %s%n", timestampedObserver.getOpenToCloseDuration());
}
}

[IO-706] Add TimestampedObserver.

Fat-fingered the class name previously.