use of io.servicecomb.core.Response in project java-chassis by ServiceComb.
the class TestVertxRestServer method testDoSend.
@Test
public void testDoSend() {
boolean status = false;
try {
HttpServerResponse httpServerResponse = Mockito.mock(HttpServerResponse.class);
ProduceProcessor produceProcessor = Mockito.mock(ProduceProcessor.class);
Response response = Response.create(0, "reasonPhrase", new Object());
instance.doSendResponse(httpServerResponse, produceProcessor, response);
} catch (Exception e) {
status = true;
}
Assert.assertFalse(status);
}
use of io.servicecomb.core.Response in project java-chassis by ServiceComb.
the class CodeFirstSpringmvc method cseResponse.
@ApiResponse(code = 200, response = User.class, message = "")
@ResponseHeaders({ @ResponseHeader(name = "h1", response = String.class), @ResponseHeader(name = "h2", response = String.class) })
@RequestMapping(path = "/cseResponse", method = RequestMethod.GET)
public Response cseResponse() {
Response response = Response.createSuccess(Status.ACCEPTED, new User());
response.getHeaders().addHeader("h1", "h1v").addHeader("h2", "h2v");
return response;
}
use of io.servicecomb.core.Response in project java-chassis by ServiceComb.
the class CseClientHttpRequest method invoke.
private CseClientHttpResponse invoke(RequestMeta requestMeta, Object[] args) {
Invocation invocation = InvocationFactory.forConsumer(requestMeta.getReferenceConfig(), requestMeta.getOperationMeta(), args);
invocation.getHandlerContext().put(RestConst.REST_CLIENT_REQUEST_PATH, this.uri.getPath() + "?" + this.uri.getQuery());
Response response = InvokerUtils.innerSyncInvoke(invocation);
if (response.isSuccessed()) {
return new CseClientHttpResponse(response);
}
throw ExceptionFactory.convertConsumerException((Throwable) response.getResult());
}
use of io.servicecomb.core.Response in project java-chassis by ServiceComb.
the class AbstractRestServer method sendFailResponse.
public void sendFailResponse(RestServerRequestInternal restRequest, HTTP_RESPONSE httpResponse, Throwable throwable) {
Response response = Response.createProducerFail(throwable);
sendResponse(restRequest, httpResponse, ProduceProcessorManager.DEFAULT_PROCESSOR, response);
}
use of io.servicecomb.core.Response in project java-chassis by ServiceComb.
the class CodeFirstRestTemplateSpringmvc method testIntf.
private void testIntf() {
ResponseEntity<User> responseEntity = intf.responseEntity();
TestMgr.check("User [name=nameA, age=100, index=0]", responseEntity.getBody());
TestMgr.check("h1v", responseEntity.getHeaders().getFirst("h1"));
TestMgr.check("h2v", responseEntity.getHeaders().getFirst("h2"));
checkStatusCode("springmvc", 202, responseEntity.getStatusCode());
Response cseResponse = intf.cseResponse();
TestMgr.check("User [name=nameA, age=100, index=0]", cseResponse.getResult());
TestMgr.check("h1v", cseResponse.getHeaders().getFirst("h1"));
TestMgr.check("h2v", cseResponse.getHeaders().getFirst("h2"));
}
Aggregations