Search in sources :

Example 6 with DeferredResultHandler

use of org.springframework.web.context.request.async.DeferredResult.DeferredResultHandler in project spring-framework by spring-projects.

the class DeferredResultTests method hasResult.

@Test
public void hasResult() {
    DeferredResultHandler handler = mock(DeferredResultHandler.class);
    DeferredResult<String> result = new DeferredResult<>();
    result.setResultHandler(handler);
    assertFalse(result.hasResult());
    assertNull(result.getResult());
    result.setResult("hello");
    assertEquals("hello", result.getResult());
}
Also used : DeferredResultHandler(org.springframework.web.context.request.async.DeferredResult.DeferredResultHandler) Test(org.junit.Test)

Example 7 with DeferredResultHandler

use of org.springframework.web.context.request.async.DeferredResult.DeferredResultHandler in project spring-framework by spring-projects.

the class DeferredResultTests method isSetOrExpired.

@Test
public void isSetOrExpired() {
    DeferredResultHandler handler = mock(DeferredResultHandler.class);
    DeferredResult<String> result = new DeferredResult<>();
    result.setResultHandler(handler);
    assertFalse(result.isSetOrExpired());
    result.setResult("hello");
    assertTrue(result.isSetOrExpired());
    verify(handler).handleResult("hello");
}
Also used : DeferredResultHandler(org.springframework.web.context.request.async.DeferredResult.DeferredResultHandler) Test(org.junit.Test)

Aggregations

DeferredResultHandler (org.springframework.web.context.request.async.DeferredResult.DeferredResultHandler)7 Test (org.junit.Test)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 Envelope (com.kixeye.chassis.transport.dto.Envelope)1 ServiceError (com.kixeye.chassis.transport.dto.ServiceError)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 GeneralSecurityException (java.security.GeneralSecurityException)1 ArrayList (java.util.ArrayList)1 Future (java.util.concurrent.Future)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 DeferredResult (org.springframework.web.context.request.async.DeferredResult)1