org.springframework.web.context.request.async.DeferredResult.DeferredResultHandler Java Examples
The following examples show how to use
org.springframework.web.context.request.async.DeferredResult.DeferredResultHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeferredResultTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void onTimeout() throws Exception { final StringBuilder sb = new StringBuilder(); DeferredResultHandler handler = mock(DeferredResultHandler.class); DeferredResult<String> result = new DeferredResult<String>(null, "timeout result"); result.setResultHandler(handler); result.onTimeout(new Runnable() { @Override public void run() { sb.append("timeout event"); } }); result.getInterceptor().handleTimeout(null, null); assertEquals("timeout event", sb.toString()); assertFalse("Should not be able to set result a second time", result.setResult("hello")); verify(handler).handleResult("timeout result"); }
Example #2
Source File: DeferredResultTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void onTimeout() throws Exception { final StringBuilder sb = new StringBuilder(); DeferredResultHandler handler = mock(DeferredResultHandler.class); DeferredResult<String> result = new DeferredResult<>(null, "timeout result"); result.setResultHandler(handler); result.onTimeout(new Runnable() { @Override public void run() { sb.append("timeout event"); } }); result.getInterceptor().handleTimeout(null, null); assertEquals("timeout event", sb.toString()); assertFalse("Should not be able to set result a second time", result.setResult("hello")); verify(handler).handleResult("timeout result"); }
Example #3
Source File: DeferredResultTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void onError() throws Exception { final StringBuilder sb = new StringBuilder(); DeferredResultHandler handler = mock(DeferredResultHandler.class); DeferredResult<String> result = new DeferredResult<>(null, "error result"); result.setResultHandler(handler); Exception e = new Exception(); result.onError(new Consumer<Throwable>() { @Override public void accept(Throwable t) { sb.append("error event"); } }); result.getInterceptor().handleError(null, null, e); assertEquals("error event", sb.toString()); assertFalse("Should not be able to set result a second time", result.setResult("hello")); verify(handler).handleResult(e); }
Example #4
Source File: DeferredResultTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void onError() throws Exception { final StringBuilder sb = new StringBuilder(); DeferredResultHandler handler = mock(DeferredResultHandler.class); DeferredResult<String> result = new DeferredResult<>(null, "error result"); result.setResultHandler(handler); Exception e = new Exception(); result.onError(new Consumer<Throwable>() { @Override public void accept(Throwable t) { sb.append("error event"); } }); result.getInterceptor().handleError(null, null, e); assertEquals("error event", sb.toString()); assertFalse("Should not be able to set result a second time", result.setResult("hello")); verify(handler).handleResult(e); }
Example #5
Source File: DeferredResultTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void onTimeout() throws Exception { final StringBuilder sb = new StringBuilder(); DeferredResultHandler handler = mock(DeferredResultHandler.class); DeferredResult<String> result = new DeferredResult<>(null, "timeout result"); result.setResultHandler(handler); result.onTimeout(new Runnable() { @Override public void run() { sb.append("timeout event"); } }); result.getInterceptor().handleTimeout(null, null); assertEquals("timeout event", sb.toString()); assertFalse("Should not be able to set result a second time", result.setResult("hello")); verify(handler).handleResult("timeout result"); }
Example #6
Source File: DeferredResultTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void setResultTwice() { DeferredResultHandler handler = mock(DeferredResultHandler.class); DeferredResult<String> result = new DeferredResult<>(); result.setResultHandler(handler); assertTrue(result.setResult("hello")); assertFalse(result.setResult("hi")); verify(handler).handleResult("hello"); }
Example #7
Source File: DeferredResultTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void hasResult() { DeferredResultHandler handler = mock(DeferredResultHandler.class); DeferredResult<String> result = new DeferredResult<String>(); result.setResultHandler(handler); assertFalse(result.hasResult()); assertNull(result.getResult()); result.setResult("hello"); assertEquals("hello", result.getResult()); }
Example #8
Source File: DeferredResultTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void setResultTwice() { DeferredResultHandler handler = mock(DeferredResultHandler.class); DeferredResult<String> result = new DeferredResult<String>(); result.setResultHandler(handler); assertTrue(result.setResult("hello")); assertFalse(result.setResult("hi")); verify(handler).handleResult("hello"); }
Example #9
Source File: DeferredResultTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void setResult() { DeferredResultHandler handler = mock(DeferredResultHandler.class); DeferredResult<String> result = new DeferredResult<String>(); result.setResultHandler(handler); assertTrue(result.setResult("hello")); verify(handler).handleResult("hello"); }
Example #10
Source File: DeferredResultTests.java From java-technology-stack with MIT License | 5 votes |
@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()); }
Example #11
Source File: DeferredResultTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void setResultTwice() { DeferredResultHandler handler = mock(DeferredResultHandler.class); DeferredResult<String> result = new DeferredResult<>(); result.setResultHandler(handler); assertTrue(result.setResult("hello")); assertFalse(result.setResult("hi")); verify(handler).handleResult("hello"); }
Example #12
Source File: DeferredResultTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void setResult() { DeferredResultHandler handler = mock(DeferredResultHandler.class); DeferredResult<String> result = new DeferredResult<>(); result.setResultHandler(handler); assertTrue(result.setResult("hello")); verify(handler).handleResult("hello"); }
Example #13
Source File: DeferredResultTests.java From spring-analysis-note with MIT License | 5 votes |
@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()); }
Example #14
Source File: DeferredResultTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void setResult() { DeferredResultHandler handler = mock(DeferredResultHandler.class); DeferredResult<String> result = new DeferredResult<>(); result.setResultHandler(handler); assertTrue(result.setResult("hello")); verify(handler).handleResult("hello"); }
Example #15
Source File: DeferredResultTests.java From java-technology-stack with MIT License | 3 votes |
@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"); }
Example #16
Source File: DeferredResultTests.java From spring4-understanding with Apache License 2.0 | 3 votes |
@Test public void isSetOrExpired() { DeferredResultHandler handler = mock(DeferredResultHandler.class); DeferredResult<String> result = new DeferredResult<String>(); result.setResultHandler(handler); assertFalse(result.isSetOrExpired()); result.setResult("hello"); assertTrue(result.isSetOrExpired()); verify(handler).handleResult("hello"); }
Example #17
Source File: DeferredResultTests.java From spring-analysis-note with MIT License | 3 votes |
@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"); }