### Question:
ScheduledVideoContentHandlerWrapper implements VideoContentHandler<T>, Runnable { @Override public synchronized void handleContent(T content, long ptsMillis) { if (myClosed || ptsMillis < 0) { if (content instanceof AutoCloseable) { Utilities.close((AutoCloseable)content); } return; } if (myFirstNanoTime == NO_VALUE) { myFirstNanoTime = System.nanoTime(); } if (myReferencePtsMillis == NO_VALUE) { myReferencePtsMillis = ptsMillis; } long ptsOffsetMillis = ptsMillis - myReferencePtsMillis; TimestampedContent<T> timestamped = new TimestampedContent<>(content, myReferenceTime.plus(new Milliseconds(ptsOffsetMillis)), ptsMillis); if (timestamped.getTimestamp().minus(TimeInstant.get()).isLessThan(MAX_SLEEP)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Queuing content " + timestamped); } myContentQueue.offer(timestamped); kickQueue(); } else if (timestamped.getContent() != null) { LOGGER.warn("Skipping future content for " + timestamped); if (content instanceof AutoCloseable) { Utilities.close((AutoCloseable)content); } } } ScheduledVideoContentHandlerWrapper(VideoContentHandler<? super T> videoContentHandler, long referencePtsMillis,
            TimeInstant referenceTime, ReadOnlyProperty<TimeInstant> handleTime); @Override void close(); synchronized void drainAndClose(); @Override synchronized void handleContent(T content, long ptsMillis); @Override synchronized void open(); @Override void run(); static final long NO_VALUE; }### Answer:
@Test public void testHandleContent() { EasyMockSupport support = new EasyMockSupport(); int[] order = new int[] { 2, 1, 3, 4, 0 }; long[] times = new long[order.length]; List<Object> objs = New.list(times.length); for (int index = 0; index < order.length; ++index) { times[index] = 100L * index + 100L; objs.add(new Object()); } final VolatileReference<AutoCloseable> ref = new VolatileReference<>(); @SuppressWarnings("unchecked") VideoContentHandler<Object> wrapped = support.createStrictMock(VideoContentHandler.class); for (int index = 0; index < order.length; ++index) { wrapped.handleContent(objs.get(index), times[index]); if (index == order.length - 1) { EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { @Override public Object answer() { Utilities.close(ref.get()); return null; } }); } } support.replayAll(); TimeInstant startTime = TimeInstant.get(); ReadOnlyProperty<TimeInstant> handleTime = new SimpleObjectProperty<TimeInstant>(); try (ScheduledVideoContentHandlerWrapper<Object> wrapper = new ScheduledVideoContentHandlerWrapper<>(wrapped, 0L, startTime, handleTime)) { for (int index = 0; index < order.length; ++index) { wrapper.handleContent(objs.get(order[index]), times[order[index]]); } ref.set(wrapper); wrapper.run(); } support.verifyAll(); }