类org.apache.http.impl.execchain.RequestAbortedException源码实例Demo

下面列出了怎么用org.apache.http.impl.execchain.RequestAbortedException的API类实例代码及写法,或者点击链接到github查看源代码。

@Test
public void throwNonRuntime_returnsWrappedException() {
    try {
        isRuntimeException = false;
        throwException = true;
        LambdaContainerHandler.getContainerConfig().setDisableExceptionMapper(true);
        handler.proxy(new AwsProxyRequestBuilder("/test", "GET").build(), new MockLambdaContext());
    } catch (Exception e) {
        assertNotNull(e);
        assertNotNull(e.getCause());
        assertTrue(e.getCause() instanceof RequestAbortedException);
        assertEquals(ExceptionContainerHandlerTest.NON_RUNTIME_MESSAGE, e.getCause().getMessage());
        return;
    }
    fail("Did not throw exception");
}
 
@Override
protected void handleRequest(HttpServletRequest containerRequest, AwsHttpServletResponse containerResponse, Context lambdaContext) throws Exception {
    if (throwException) {
        if (isRuntimeException) {
            throw new RuntimeException(RUNTIME_MESSAGE);
        } else {
            throw new RequestAbortedException(NON_RUNTIME_MESSAGE);
        }
    }
    containerResponse.setStatus(200);
    containerResponse.getWriter().print("OK");
    containerResponse.flushBuffer();
}
 
 类所在包
 类方法
 同包方法