Search in sources :

Example 1 with TestRequest

use of io.servicecomb.demo.server.TestRequest 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 2 with TestRequest

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

the class PojoClient method testWrapParam.

private static void testWrapParam(Test test) {
    User user = new User();
    TestRequest request = new TestRequest();
    request.setUser(user);
    request.setIndex(0);
    request.setData(buffer);
    request.getUsers().add(user);
    User result = test.wrapParam(request);
    LOGGER.info("wrap param result:{}", result);
    TestMgr.check("User [name=nameA,  users count:1, age=100, index=0]", result);
}
Also used : User(io.servicecomb.demo.server.User) TestRequest(io.servicecomb.demo.server.TestRequest)

Example 3 with TestRequest

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

the class ClientThread method run.

@Override
public void run() {
    Test test = PojoClient.test;
    CseContext.getInstance().getConsumerProviderManager().setTransport("pojo", Config.getTransport());
    System.out.printf("test %s performance\n", Config.getTransport());
    while (isRunning()) {
        int idx = 0;
        for (; ; ) {
            User user = new User();
            TestRequest request = new TestRequest();
            request.setUser(user);
            request.setIndex(idx);
            request.setData(PojoClient.buffer);
            try {
                User result = test.wrapParam(request);
                if (result.getIndex() != idx) {
                    System.out.printf("error result:%s, expect idx %d\n", result, idx);
                }
            } catch (Throwable e) {
            //                    e.printStackTrace();
            }
        }
    }
}
Also used : User(io.servicecomb.demo.server.User) Test(io.servicecomb.demo.server.Test) TestRequest(io.servicecomb.demo.server.TestRequest)

Example 4 with TestRequest

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

the class PojoClientTest method testWrapParam.

private static void testWrapParam(Test test) {
    User user = new User();
    TestRequest request = new TestRequest();
    request.setUser(user);
    request.setIndex(0);
    request.setData(buffer);
    request.getUsers().add(user);
    User result = test.wrapParam(request);
    LOGGER.info("wrap param result:{}", result);
    TestMgr.check("User [name=nameA,  users count:1, age=100, index=0]", result);
}
Also used : User(io.servicecomb.demo.server.User) TestRequest(io.servicecomb.demo.server.TestRequest)

Aggregations

TestRequest (io.servicecomb.demo.server.TestRequest)4 User (io.servicecomb.demo.server.User)4 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