Search in sources :

Example 11 with CseHttpEntity

use of org.apache.servicecomb.provider.springmvc.reference.CseHttpEntity in project java-chassis by ServiceComb.

the class TestContentType method testGlobalSetting.

private void testGlobalSetting() {
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);
    CseHttpEntity<String> requestEntity = new CseHttpEntity<>("from testGlobalSetting", requestHeaders);
    ResponseEntity<String> responseEntity = restTemplate.exchange("cse://springmvc/contentTypeSpringmvc/testGlobalSetting", HttpMethod.POST, requestEntity, String.class);
    TestMgr.check("testGlobalSetting: name=[from testGlobalSetting], request content-type=[" + MediaType.TEXT_PLAIN + "]", responseEntity.getBody());
    TestMgr.check(MediaType.TEXT_PLAIN, extractContentType(responseEntity.getHeaders().getContentType()));
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) CseHttpEntity(org.apache.servicecomb.provider.springmvc.reference.CseHttpEntity)

Example 12 with CseHttpEntity

use of org.apache.servicecomb.provider.springmvc.reference.CseHttpEntity in project java-chassis by ServiceComb.

the class BeanParamRestTemplateClient method testBeanParam.

private void testBeanParam() {
    HttpHeaders headers = new HttpHeaders();
    headers.add("Cookie", "cookieSwaggerLong=11");
    headers.add("headerSwaggerInt", "2");
    HttpEntity<Object> requestEntity1 = new CseHttpEntity<>(headers);
    ResponseEntity<String> result = restTemplate.exchange("cse://jaxrs/beanParamTest/pathSwaggerValue/simple?querySwaggerStr=querySwaggerValue&extraQuery=extra", HttpMethod.GET, requestEntity1, String.class);
    TestMgr.check("invocationContextConsistency=true|testBeanParameter=TestBeanParameter{queryStr='querySwaggerValue', headerInt=2, " + "pathStr='pathSwaggerValue', cookieLong=11}|extraQuery=extra", result.getBody());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) CseHttpEntity(org.apache.servicecomb.provider.springmvc.reference.CseHttpEntity)

Aggregations

CseHttpEntity (org.apache.servicecomb.provider.springmvc.reference.CseHttpEntity)12 HttpHeaders (org.springframework.http.HttpHeaders)8 Date (java.util.Date)4 LocalDate (java.time.LocalDate)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 VersionedCache (org.apache.servicecomb.foundation.common.cache.VersionedCache)2 DiscoveryContext (org.apache.servicecomb.registry.discovery.DiscoveryContext)2 InvocationContext (org.apache.servicecomb.swagger.invocation.context.InvocationContext)2 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)2 MultiValueMap (org.springframework.util.MultiValueMap)2 RestTemplate (org.springframework.web.client.RestTemplate)2