use of org.apache.cxf.transport.http.Servlet3ContinuationProvider in project cxf by apache.
the class AsyncResponseImplTest method testCancelIntBehavesTheSameWhenInvokedMultipleTimes.
/**
* Similar to testCancelBehavesTheSameWhenInvokedMultipleTimes, but using the cancel(int) signature.
*/
@Test
public void testCancelIntBehavesTheSameWhenInvokedMultipleTimes() {
HttpServletRequest req = control.createMock(HttpServletRequest.class);
HttpServletResponse resp = control.createMock(HttpServletResponse.class);
AsyncContext asyncCtx = control.createMock(AsyncContext.class);
Message msg = new MessageImpl();
msg.setExchange(new ExchangeImpl());
msg.put(ContinuationProvider.class.getName(), new Servlet3ContinuationProvider(req, resp, msg));
req.startAsync();
EasyMock.expectLastCall().andReturn(asyncCtx);
control.replay();
AsyncResponse impl = new AsyncResponseImpl(msg);
// cancel the AsyncResponse for the first time
assertTrue("Unexpectedly returned false when canceling the first time", impl.cancel(10));
// check the state of the AsyncResponse
assertTrue("AsyncResponse was canceled but is reporting that it was not canceled", impl.isCancelled());
boolean isDone = impl.isDone();
boolean isSuspended = impl.isSuspended();
// cancel the AsyncResponse a second time
assertTrue("Unexpectedly returned false when canceling the second time", impl.cancel(25));
// verify that the state is the same as before the second cancel
assertTrue("AsyncResponse was canceled (twice) but is reporting that it was not canceled", impl.isCancelled());
assertEquals("AsynchResponse.isDone() returned a different response after canceling a second time", isDone, impl.isDone());
assertEquals("AsynchResponse.isSuspended() returned a different response after canceling a second time", isSuspended, impl.isSuspended());
}
use of org.apache.cxf.transport.http.Servlet3ContinuationProvider in project cxf by apache.
the class AsyncResponseImplTest method testCancelBehavesTheSameWhenInvokedMultipleTimes.
/**
* According to the spec, subsequent calls to cancel the same AsyncResponse should
* have the same behavior as the first call.
*/
@Test
public void testCancelBehavesTheSameWhenInvokedMultipleTimes() {
HttpServletRequest req = control.createMock(HttpServletRequest.class);
HttpServletResponse resp = control.createMock(HttpServletResponse.class);
AsyncContext asyncCtx = control.createMock(AsyncContext.class);
Message msg = new MessageImpl();
msg.setExchange(new ExchangeImpl());
msg.put(ContinuationProvider.class.getName(), new Servlet3ContinuationProvider(req, resp, msg));
req.startAsync();
EasyMock.expectLastCall().andReturn(asyncCtx);
control.replay();
AsyncResponse impl = new AsyncResponseImpl(msg);
// cancel the AsyncResponse for the first time
assertTrue("Unexpectedly returned false when canceling the first time", impl.cancel());
// check the state of the AsyncResponse
assertTrue("AsyncResponse was canceled but is reporting that it was not canceled", impl.isCancelled());
boolean isDone = impl.isDone();
boolean isSuspended = impl.isSuspended();
// cancel the AsyncResponse a second time
assertTrue("Unexpectedly returned false when canceling the second time", impl.cancel());
// verify that the state is the same as before the second cancel
assertTrue("AsyncResponse was canceled (twice) but is reporting that it was not canceled", impl.isCancelled());
assertEquals("AsynchResponse.isDone() returned a different response after canceling a second time", isDone, impl.isDone());
assertEquals("AsynchResponse.isSuspended() returned a different response after canceling a second time", isSuspended, impl.isSuspended());
}
use of org.apache.cxf.transport.http.Servlet3ContinuationProvider in project cxf by apache.
the class AsyncResponseImplTest method testCancelDateBehavesTheSameWhenInvokedMultipleTimes.
/**
* Similar to testCancelBehavesTheSameWhenInvokedMultipleTimes, but using the cancel(Date) signature.
*/
@Test
public void testCancelDateBehavesTheSameWhenInvokedMultipleTimes() {
HttpServletRequest req = control.createMock(HttpServletRequest.class);
HttpServletResponse resp = control.createMock(HttpServletResponse.class);
AsyncContext asyncCtx = control.createMock(AsyncContext.class);
Message msg = new MessageImpl();
msg.setExchange(new ExchangeImpl());
msg.put(ContinuationProvider.class.getName(), new Servlet3ContinuationProvider(req, resp, msg));
req.startAsync();
EasyMock.expectLastCall().andReturn(asyncCtx);
control.replay();
AsyncResponse impl = new AsyncResponseImpl(msg);
// cancel the AsyncResponse for the first time
Date d = new Date(System.currentTimeMillis() + 60000);
assertTrue("Unexpectedly returned false when canceling the first time", impl.cancel(d));
// check the state of the AsyncResponse
assertTrue("AsyncResponse was canceled but is reporting that it was not canceled", impl.isCancelled());
boolean isDone = impl.isDone();
boolean isSuspended = impl.isSuspended();
// cancel the AsyncResponse a second time
d = new Date(System.currentTimeMillis() + 120000);
assertTrue("Unexpectedly returned false when canceling the second time", impl.cancel(d));
// verify that the state is the same as before the second cancel
assertTrue("AsyncResponse was canceled (twice) but is reporting that it was not canceled", impl.isCancelled());
assertEquals("AsynchResponse.isDone() returned a different response after canceling a second time", isDone, impl.isDone());
assertEquals("AsynchResponse.isSuspended() returned a different response after canceling a second time", isSuspended, impl.isSuspended());
}
Aggregations