Search in sources :

Example 6 with User

use of org.apache.servicecomb.demo.server.User in project incubator-servicecomb-java-chassis by apache.

the class MyHandler method handle.

@Override
public void handle(Invocation invocation, AsyncResponse asyncResp) throws Exception {
    LOGGER.info("If you see this log, that means this demo project has been converted to ServiceComb framework.");
    invocation.next(response -> {
        if (invocation.getOperationMeta().getSchemaQualifiedName().equals("server.splitParam")) {
            User user = response.getResult();
            user.setName(user.getName() + SPLITPARAM_RESPONSE_USER_SUFFIX);
            asyncResp.handle(response);
        } else {
            asyncResp.handle(response);
        }
    });
}
Also used : User(org.apache.servicecomb.demo.server.User)

Example 7 with User

use of org.apache.servicecomb.demo.server.User in project incubator-servicecomb-java-chassis by apache.

the class TestGeneric method testHolderUser_rest.

@SuppressWarnings("unchecked")
private void testHolderUser_rest() {
    Holder<User> holder = new Holder<>(new User());
    Holder<User> result = intf.testHolderUser(holder);
    TestMgr.check("{\"name\":\"nameA\",\"age\":100,\"index\":0,\"names\":null}", result.value.jsonString());
    result = restTemplate.postForObject(prefix + "/holderUser", holder, Holder.class);
    TestMgr.check("{\"name\":\"nameA\",\"age\":100,\"index\":0,\"names\":null}", result.value.jsonString());
}
Also used : User(org.apache.servicecomb.demo.server.User) Holder(javax.xml.ws.Holder)

Example 8 with User

use of org.apache.servicecomb.demo.server.User in project incubator-servicecomb-java-chassis by apache.

the class CodeFirstPojoClient method testCodeFirstUserArray.

private void testCodeFirstUserArray(CodeFirstPojoIntf codeFirst) {
    User user1 = new User();
    user1.setNames(new String[] { "u1", "u2" });
    User user2 = new User();
    user2.setNames(new String[] { "u3", "u4" });
    User[] users = new User[] { user1, user2 };
    List<User> result = codeFirst.testUserArray(Arrays.asList(users));
    TestMgr.check("u1", result.get(0).getNames()[0]);
    TestMgr.check("u2", result.get(0).getNames()[1]);
    TestMgr.check("u3", result.get(1).getNames()[0]);
    TestMgr.check("u4", result.get(1).getNames()[1]);
}
Also used : User(org.apache.servicecomb.demo.server.User)

Example 9 with User

use of org.apache.servicecomb.demo.server.User in project incubator-servicecomb-java-chassis by apache.

the class PojoClient 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.4", transport, "server", "splitParam", new Object[] { 3, new User() });
    TestMgr.check("User [name=nameA,  users count:0, age=100, index=3]", result);
}
Also used : User(org.apache.servicecomb.demo.server.User)

Example 10 with User

use of org.apache.servicecomb.demo.server.User in project incubator-servicecomb-java-chassis by apache.

the class PojoClient 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(org.apache.servicecomb.demo.server.User)

Aggregations

User (org.apache.servicecomb.demo.server.User)27 Response (org.apache.servicecomb.swagger.invocation.Response)4 InvocationContext (org.apache.servicecomb.swagger.invocation.context.InvocationContext)4 Headers (org.apache.servicecomb.swagger.invocation.response.Headers)4 Test (org.junit.Test)4 ApiResponse (io.swagger.annotations.ApiResponse)3 HashMap (java.util.HashMap)3 TestRequest (org.apache.servicecomb.demo.server.TestRequest)3 ResponseHeaders (org.apache.servicecomb.swagger.extend.annotations.ResponseHeaders)3 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Generic (org.apache.servicecomb.demo.Generic)2 HttpHeaders (org.springframework.http.HttpHeaders)2 Holder (javax.xml.ws.Holder)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1