/** * {@inheritDoc} */ @Override public void setSuspendTimeout(long timeOut, TimeUnit timeUnit) throws IllegalStateException { if (timeoutHandler == null) { throw new IllegalStateException("The timeoutHandler is null"); } suspend(timeOut, timeUnit, timeoutHandler); }
/** * {@inheritDoc} */ @Override public void setSuspendTimeout(long timeOut, TimeUnit timeUnit) throws IllegalStateException { if (timeoutHandler == null) { throw new IllegalStateException("The timeoutHandler is null"); } suspend(timeOut, timeUnit, timeoutHandler); }
/** * {@inheritDoc} */ @Override public void setSuspendTimeout(long timeOut, TimeUnit timeUnit) throws IllegalStateException { if (timeoutHandler == null) { throw new IllegalStateException("The timeoutHandler is null"); } suspend(timeOut, timeUnit, timeoutHandler); }
@Test public void testSuspend() throws Exception { boolean result; ContainerResponseWriter.TimeoutHandler timeoutHandler = mock(ContainerResponseWriter.TimeoutHandler.class); result = writer.suspend(10, TimeUnit.SECONDS, timeoutHandler); assertTrue(result); verify(vertx, times(1)).setTimer(anyLong(), any(Handler.class)); result = writer.suspend(0, TimeUnit.SECONDS, timeoutHandler); assertTrue(result); verify(vertx, times(1)).setTimer(anyLong(), any(Handler.class)); result = writer.suspend(10, TimeUnit.SECONDS, timeoutHandler); assertTrue(result); verify(vertx, times(2)).setTimer(anyLong(), any(Handler.class)); }
@Test public void testSetSuspendTimeout() throws Exception { ContainerResponseWriter.TimeoutHandler timeoutHandler = mock(ContainerResponseWriter.TimeoutHandler.class); try { writer.setSuspendTimeout(10, TimeUnit.SECONDS); fail(); } catch (IllegalStateException e) { // Expected } writer.suspend(0, TimeUnit.SECONDS, timeoutHandler); writer.setSuspendTimeout(5, TimeUnit.MINUTES); verify(vertx, times(1)).setTimer(anyLong(), any(Handler.class)); }