Search in sources :

Example 1 with Person

use of io.servicecomb.demo.compute.Person in project java-chassis by ServiceComb.

the class JaxrsClient method testPost.

private static void testPost(RestTemplate template, String cseUrlPrefix) {
    Map<String, String> params = new HashMap<>();
    params.put("a", "5");
    params.put("b", "3");
    int result = template.postForObject(cseUrlPrefix + "/compute/add", params, Integer.class);
    TestMgr.check(8, result);
    Person person = new Person();
    person.setName("world");
    Person resultPerson = template.postForObject(cseUrlPrefix + "/compute/sayhello", person, Person.class);
    TestMgr.check("hello world", resultPerson.getName());
    HttpHeaders headers = new HttpHeaders();
    headers.add("prefix", "haha");
    HttpEntity<Person> reqEntity = new HttpEntity<>(person, headers);
    TestMgr.check("haha world", template.postForObject(cseUrlPrefix + "/compute/saysomething", reqEntity, String.class));
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) HashMap(java.util.HashMap) Person(io.servicecomb.demo.compute.Person)

Example 2 with Person

use of io.servicecomb.demo.compute.Person in project java-chassis by ServiceComb.

the class CodeFirstPojoClient method testCodeFirstSaySomething.

protected void testCodeFirstSaySomething(CodeFirstPojoIntf codeFirst) {
    Person person = new Person();
    person.setName("person name");
    String result = codeFirst.saySomething("prefix  prefix", person);
    TestMgr.check("prefix  prefix person name", result);
}
Also used : Person(io.servicecomb.demo.compute.Person)

Example 3 with Person

use of io.servicecomb.demo.compute.Person in project java-chassis by ServiceComb.

the class CodeFirstPojoClient method testCodeFirstSayHello.

protected void testCodeFirstSayHello(CodeFirstPojoIntf codeFirst) {
    Person input = new Person();
    input.setName("person name");
    Person result = codeFirst.sayHello(input);
    TestMgr.check("hello person name", result.getName());
}
Also used : Person(io.servicecomb.demo.compute.Person)

Example 4 with Person

use of io.servicecomb.demo.compute.Person in project java-chassis by ServiceComb.

the class CodeFirstRestTemplate method testCodeFirstSaySomething.

protected void testCodeFirstSaySomething(RestTemplate template, String cseUrlPrefix) {
    Person person = new Person();
    person.setName("person name");
    HttpHeaders headers = new HttpHeaders();
    headers.add("prefix", "prefix  prefix");
    HttpEntity<Person> requestEntity = new HttpEntity<>(person, headers);
    String result = template.postForObject(cseUrlPrefix + "saysomething", requestEntity, String.class);
    TestMgr.check("prefix  prefix person name", result);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) Person(io.servicecomb.demo.compute.Person)

Example 5 with Person

use of io.servicecomb.demo.compute.Person in project java-chassis by ServiceComb.

the class JaxrsClient method testExchange.

private static void testExchange(RestTemplate template, String cseUrlPrefix) {
    HttpHeaders headers = new HttpHeaders();
    headers.add("Accept", MediaType.APPLICATION_JSON);
    Person person = new Person();
    person.setName("world");
    HttpEntity<Person> requestEntity = new HttpEntity<>(person, headers);
    ResponseEntity<Person> resEntity = template.exchange(cseUrlPrefix + "/compute/sayhello", HttpMethod.POST, requestEntity, Person.class);
    TestMgr.check("hello world", resEntity.getBody());
    ResponseEntity<String> resEntity2 = template.exchange(cseUrlPrefix + "/compute/addstring?s=abc&s=def", HttpMethod.DELETE, null, String.class);
    TestMgr.check("abcdef", resEntity2.getBody());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) Person(io.servicecomb.demo.compute.Person)

Aggregations

Person (io.servicecomb.demo.compute.Person)6 HttpEntity (org.springframework.http.HttpEntity)3 HttpHeaders (org.springframework.http.HttpHeaders)3 HashMap (java.util.HashMap)2