use of org.apache.cxf.transport.http.HTTPConduit.WrappedOutputStream in project cxf by apache.
the class HTTPConduitTest method testHandleResponseOnWorkqueueAllowCurrentThread.
@Test
public void testHandleResponseOnWorkqueueAllowCurrentThread() throws Exception {
Message m = getNewMessage();
Exchange exchange = new ExchangeImpl();
Bus bus = new ExtensionManagerBus();
exchange.put(Bus.class, bus);
EndpointInfo endpointInfo = new EndpointInfo();
Endpoint endpoint = new EndpointImpl(null, null, endpointInfo);
exchange.put(Endpoint.class, endpoint);
m.setExchange(exchange);
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setAsyncExecuteTimeoutRejection(true);
m.put(HTTPClientPolicy.class, policy);
exchange.put(Executor.class, new Executor() {
@Override
public void execute(Runnable command) {
// forces us to use current thread
throw new RejectedExecutionException("expected");
}
});
HTTPConduit conduit = new MockHTTPConduit(bus, endpointInfo, policy);
OutputStream os = conduit.createOutputStream(m, false, false, 0);
assertTrue(os instanceof WrappedOutputStream);
WrappedOutputStream wos = (WrappedOutputStream) os;
try {
wos.handleResponseOnWorkqueue(true, false);
assertEquals(Thread.currentThread(), m.get(Thread.class));
try {
wos.handleResponseOnWorkqueue(false, false);
fail("Expected RejectedExecutionException not thrown");
} catch (RejectedExecutionException ex) {
assertEquals("expected", ex.getMessage());
}
} catch (Exception ex) {
throw ex;
}
}
Aggregations