Search in sources :

Example 11 with User

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

the class CodeFirstSpringmvc method responseEntity.

@ResponseHeaders({ @ResponseHeader(name = "h1", response = String.class), @ResponseHeader(name = "h2", response = String.class) })
@RequestMapping(path = "/responseEntity", method = RequestMethod.GET)
public ResponseEntity<User> responseEntity() {
    HttpHeaders headers = new HttpHeaders();
    headers.add("h1", "h1v");
    headers.add("h2", "h2v");
    return new ResponseEntity<User>(new User(), headers, HttpStatus.ACCEPTED);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) User(io.servicecomb.demo.server.User) ResponseHeaders(io.servicecomb.swagger.extend.annotations.ResponseHeaders) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with User

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

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

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.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 14 with User

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

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

Example 15 with User

use of io.servicecomb.demo.server.User 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

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