Search in sources :

Example 1 with Person

use of org.apache.servicecomb.demo.compute.Person in project incubator-servicecomb-java-chassis by apache.

the class JaxrsIntegrationTestBase method ableToPostWithHeader.

@Test
public void ableToPostWithHeader() {
    Person person = new Person();
    person.setName("person name");
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(APPLICATION_JSON);
    headers.add("prefix", "prefix  prefix");
    HttpEntity<Person> requestEntity = new HttpEntity<>(person, headers);
    for (String url : urls) {
        ResponseEntity<String> responseEntity = restTemplate.postForEntity(url + "saysomething", requestEntity, String.class);
        assertEquals("prefix  prefix person name", jsonBodyOf(responseEntity, String.class));
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) Person(org.apache.servicecomb.demo.compute.Person) Test(org.junit.Test)

Example 2 with Person

use of org.apache.servicecomb.demo.compute.Person in project incubator-servicecomb-java-chassis by apache.

the class JaxrsIntegrationTestBase method ableToPostWithHeaderWithIdentifier.

@Test
public void ableToPostWithHeaderWithIdentifier() {
    Person person = new Person();
    person.setName("person name");
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(APPLICATION_JSON);
    headers.add("prefix-test", "prefix  prefix");
    HttpEntity<Person> requestEntity = new HttpEntity<>(person, headers);
    for (String url : urls) {
        ResponseEntity<String> responseEntity = restTemplate.postForEntity(url + "saysomething1", requestEntity, String.class);
        assertEquals("prefix  prefix person name", jsonBodyOf(responseEntity, String.class));
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) Person(org.apache.servicecomb.demo.compute.Person) Test(org.junit.Test)

Example 3 with Person

use of org.apache.servicecomb.demo.compute.Person in project incubator-servicecomb-java-chassis by apache.

the class SpringMvcIntegrationTestBase method ableToPostWithHeader.

@Test
public void ableToPostWithHeader() {
    Person person = new Person();
    person.setName("person name");
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(APPLICATION_JSON);
    headers.add("prefix", "prefix  prefix");
    HttpEntity<Person> requestEntity = new HttpEntity<>(person, headers);
    ResponseEntity<String> responseEntity = restTemplate.postForEntity(codeFirstUrl + "saysomething", requestEntity, String.class);
    assertThat(jsonOf(responseEntity.getBody(), String.class), is("prefix  prefix person name"));
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) Person(org.apache.servicecomb.demo.compute.Person) Test(org.junit.Test)

Example 4 with Person

use of org.apache.servicecomb.demo.compute.Person in project incubator-servicecomb-java-chassis by apache.

the class SpringMvcIntegrationTestBase method ableToPostObjectAsJson.

@Test
public void ableToPostObjectAsJson() {
    Map<String, String> personFieldMap = new HashMap<>();
    personFieldMap.put("name", "person name from map");
    Person person = restTemplate.postForObject(codeFirstUrl + "sayhello", jsonRequest(personFieldMap), Person.class);
    assertThat(person.toString(), is("hello person name from map"));
    Person input = new Person();
    input.setName("person name from Object");
    person = restTemplate.postForObject(codeFirstUrl + "sayhello", jsonRequest(input), Person.class);
    assertThat(person.toString(), is("hello person name from Object"));
}
Also used : HashMap(java.util.HashMap) Person(org.apache.servicecomb.demo.compute.Person) Test(org.junit.Test)

Example 5 with Person

use of org.apache.servicecomb.demo.compute.Person in project incubator-servicecomb-java-chassis by apache.

the class PojoIntegrationTestBase method remoteCodeFirstPojo_saySomething.

@Test
public void remoteCodeFirstPojo_saySomething() {
    Person person = new Person();
    person.setName("person name");
    String result = PojoService.codeFirst.saySomething("prefix  prefix", person);
    assertThat(result, is("prefix  prefix person name"));
}
Also used : Person(org.apache.servicecomb.demo.compute.Person) Test(org.junit.Test)

Aggregations

Person (org.apache.servicecomb.demo.compute.Person)36 Test (org.junit.Test)16 HttpEntity (org.springframework.http.HttpEntity)13 HttpHeaders (org.springframework.http.HttpHeaders)12 HashMap (java.util.HashMap)8 GenericParam (org.apache.servicecomb.demo.compute.GenericParam)4 JAXBPerson (org.apache.servicecomb.demo.jaxbbean.JAXBPerson)3 ResponseEntity (org.springframework.http.ResponseEntity)3 JsonObject (io.vertx.core.json.JsonObject)2 ArrayList (java.util.ArrayList)2 InputModelForTestIgnore (org.apache.servicecomb.demo.ignore.InputModelForTestIgnore)2 OutputModelForTestIgnore (org.apache.servicecomb.demo.ignore.OutputModelForTestIgnore)2 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)2 MappingJackson2HttpMessageConverter (org.springframework.http.converter.json.MappingJackson2HttpMessageConverter)2