Search in sources :

Example 1 with User

use of io.servicecomb.demo.server.User in project java-chassis by ServiceComb.

the class CodeFirstJaxrs method cseResponse.

//    public Response getUserResponse() {
//
//    }
@ApiResponse(code = 200, response = User.class, message = "")
@ResponseHeaders({ @ResponseHeader(name = "h1", response = String.class), @ResponseHeader(name = "h2", response = String.class) })
@Path("/cseResponse")
@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) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ResponseHeaders(io.servicecomb.swagger.extend.annotations.ResponseHeaders) ApiResponse(io.swagger.annotations.ApiResponse)

Example 2 with User

use of io.servicecomb.demo.server.User in project java-chassis by ServiceComb.

the class ClientVerticle method send.

protected void send(Long event) {
    User user = new User();
    TestRequest request = new TestRequest();
    request.setUser(user);
    request.setIndex(idx);
    request.setData(PojoClient.buffer);
    SchemaMeta schemaMeta = config.getMicroserviceMeta().ensureFindSchemaMeta("server");
    Object[] args = new Object[] { request };
    Invocation invocation = InvocationFactory.forConsumer(config, schemaMeta, "wrapParam", args);
    InvokerUtils.reactiveInvoke(invocation, ar -> {
        if (ar.isSuccessed()) {
            User result = ar.getResult();
            if (result.getIndex() != idx) {
                System.out.printf("error result:%s, expect idx %d\n", result, idx);
            }
        } else {
            CommonExceptionData data = (CommonExceptionData) ((InvocationException) ar.getResult()).getErrorData();
            System.out.println(data.getMessage());
        }
        send(null);
    });
}
Also used : User(io.servicecomb.demo.server.User) Invocation(io.servicecomb.core.Invocation) SchemaMeta(io.servicecomb.core.definition.SchemaMeta) CommonExceptionData(io.servicecomb.core.exception.CommonExceptionData) TestRequest(io.servicecomb.demo.server.TestRequest)

Example 3 with User

use of io.servicecomb.demo.server.User in project java-chassis by ServiceComb.

the class PojoClientTest method testCommonInvoke.

private static void testCommonInvoke(String transport) {
    Object result = InvokerUtils.syncInvoke("pojo", "server", "splitParam", new Object[] { 2, new User() });
    TestMgr.check("User [name=nameA,  users count:0, age=100, index=2]", result);
    result = InvokerUtils.syncInvoke("pojo", "0.0.1", transport, "server", "splitParam", new Object[] { 3, new User() });
    TestMgr.check("User [name=nameA,  users count:0, age=100, index=3]", result);
}
Also used : User(io.servicecomb.demo.server.User)

Example 4 with User

use of io.servicecomb.demo.server.User in project java-chassis by ServiceComb.

the class PojoClientTest method testChinese.

private static void testChinese(Test test) {
    TestMgr.check("code is '测试'", test.getTestString("测试"));
    User user = new User();
    user.setName("名字");
    User result = test.splitParam(1, user);
    TestMgr.check("名字,  users count:0", result.getName());
}
Also used : User(io.servicecomb.demo.server.User)

Example 5 with User

use of io.servicecomb.demo.server.User in project java-chassis by ServiceComb.

the class PojoClientTest method testSplitParam.

private static void testSplitParam(Test test) {
    User result = test.splitParam(1, new User());
    LOGGER.info("split param result:{}", result);
    TestMgr.check("User [name=nameA,  users count:0, age=100, index=1]", result);
}
Also used : User(io.servicecomb.demo.server.User)

Aggregations

User (io.servicecomb.demo.server.User)15 TestRequest (io.servicecomb.demo.server.TestRequest)4 Response (io.servicecomb.core.Response)3 ResponseHeaders (io.servicecomb.swagger.extend.annotations.ResponseHeaders)3 ApiResponse (io.swagger.annotations.ApiResponse)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Invocation (io.servicecomb.core.Invocation)1 SchemaMeta (io.servicecomb.core.definition.SchemaMeta)1 CommonExceptionData (io.servicecomb.core.exception.CommonExceptionData)1 Test (io.servicecomb.demo.server.Test)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 HttpHeaders (org.springframework.http.HttpHeaders)1 ResponseEntity (org.springframework.http.ResponseEntity)1