Search in sources :

Example 16 with Response

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);
}
Also used : HttpServerResponse(io.vertx.core.http.HttpServerResponse) Response(io.servicecomb.core.Response) ProduceProcessor(io.servicecomb.common.rest.codec.produce.ProduceProcessor) HttpServerResponse(io.vertx.core.http.HttpServerResponse) Test(org.junit.Test)

Example 17 with Response

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;
}
Also used : ApiResponse(io.swagger.annotations.ApiResponse) Response(io.servicecomb.core.Response) User(io.servicecomb.demo.server.User) ResponseHeaders(io.servicecomb.swagger.extend.annotations.ResponseHeaders) ApiResponse(io.swagger.annotations.ApiResponse) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with 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());
}
Also used : ClientHttpResponse(org.springframework.http.client.ClientHttpResponse) Response(io.servicecomb.core.Response) Invocation(io.servicecomb.core.Invocation)

Example 19 with Response

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);
}
Also used : Response(io.servicecomb.core.Response)

Example 20 with 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"));
}
Also used : Response(io.servicecomb.core.Response) User(io.servicecomb.demo.server.User)

Aggregations

Response (io.servicecomb.core.Response)37 Test (org.junit.Test)21 Invocation (io.servicecomb.core.Invocation)20 OperationMeta (io.servicecomb.core.definition.OperationMeta)11 AsyncResponse (io.servicecomb.core.AsyncResponse)8 OperationProtobuf (io.servicecomb.codec.protobuf.definition.OperationProtobuf)7 WrapSchema (io.servicecomb.codec.protobuf.utils.WrapSchema)7 HystrixCommandProperties (com.netflix.hystrix.HystrixCommandProperties)6 HttpServerResponse (io.vertx.core.http.HttpServerResponse)5 InvocationException (io.servicecomb.core.exception.InvocationException)4 MockUp (mockit.MockUp)4 ProduceProcessor (io.servicecomb.common.rest.codec.produce.ProduceProcessor)3 SyncResponseExecutor (io.servicecomb.core.provider.consumer.SyncResponseExecutor)3 User (io.servicecomb.demo.server.User)3 HttpClientResponse (io.vertx.core.http.HttpClientResponse)3 List (java.util.List)3 ExecutionListener (com.netflix.loadbalancer.reactive.ExecutionListener)2 CommonExceptionData (io.servicecomb.core.exception.CommonExceptionData)2 ResponseHeaders (io.servicecomb.swagger.extend.annotations.ResponseHeaders)2 ApiResponse (io.swagger.annotations.ApiResponse)2