use of io.servicecomb.common.rest.codec.RestServerRequestInternal in project java-chassis by ServiceComb.
the class MockUtil method mockAbstactRestServer.
public void mockAbstactRestServer() {
new MockUp<AbstractRestServer<HttpServletResponse>>() {
@Mock
protected RestOperationMeta findRestOperation(RestServerRequestInternal restRequest) {
RestOperationMeta restOperationMeta = Mockito.mock(RestOperationMeta.class);
OperationMeta operationMeta = Mockito.mock(OperationMeta.class);
Executor executor = Mockito.mock(Executor.class);
operationMeta.setExecutor(executor);
return restOperationMeta;
}
};
}
use of io.servicecomb.common.rest.codec.RestServerRequestInternal in project java-chassis by ServiceComb.
the class VertxRestServer method failureHandler.
private void failureHandler(RoutingContext context) {
LOGGER.error("http server failed.", context.failure());
RestServerRequestInternal restRequest = context.get(REST_REQUEST);
Throwable e = context.failure();
if (ErrorDataDecoderException.class.isInstance(e)) {
Throwable cause = e.getCause();
if (InvocationException.class.isInstance(cause)) {
e = cause;
}
}
sendFailResponse(restRequest, context.response(), e);
// 走到这里,应该都是不可控制的异常,直接关闭连接
context.response().close();
}
use of io.servicecomb.common.rest.codec.RestServerRequestInternal in project java-chassis by ServiceComb.
the class TestVertxRestServer method testSetHttpRequestContext.
@Test
public void testSetHttpRequestContext() {
boolean status = false;
try {
Invocation invocation = Mockito.mock(Invocation.class);
RestServerRequestInternal restRequest = Mockito.mock(RestServerRequestInternal.class);
instance.setHttpRequestContext(invocation, restRequest);
Assert.assertNotNull(instance);
} catch (Exception e) {
status = true;
}
Assert.assertFalse(status);
}
use of io.servicecomb.common.rest.codec.RestServerRequestInternal in project java-chassis by ServiceComb.
the class TestServletRestServer method testSetHttpRequestContext.
@Test
public void testSetHttpRequestContext() {
boolean status = true;
try {
Invocation invocation = Mockito.mock(Invocation.class);
RestServerRequestInternal restRequest = Mockito.mock(RestServerRequestInternal.class);
servletRestServer.setHttpRequestContext(invocation, restRequest);
} catch (Exception exce) {
Assert.assertNotNull(exce);
status = false;
}
Assert.assertTrue(status);
}
use of io.servicecomb.common.rest.codec.RestServerRequestInternal in project java-chassis by ServiceComb.
the class ServletRestServer method service.
public void service(HttpServletRequest request, HttpServletResponse response) {
// 异步场景
final AsyncContext asyncCtx = request.startAsync();
asyncCtx.addListener(restAsyncListener);
asyncCtx.setTimeout(ServletConfig.getServerTimeout());
RestServerRequestInternal restRequest = new RestServletHttpRequest(request, asyncCtx);
handleRequest(restRequest, response);
}
Aggregations