List of usage examples for org.springframework.web.client RestTemplate postForEntity
@Override public <T> ResponseEntity<T> postForEntity(URI url, @Nullable Object request, Class<T> responseType) throws RestClientException
From source file:org.apache.servicecomb.demo.springmvc.client.CodeFirstRestTemplateSpringmvc.java
protected void testCodeFirstTestForm(RestTemplate template, String cseUrlPrefix) { HttpHeaders formHeaders = new HttpHeaders(); formHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED); Map<String, String> map = new HashMap<>(); String code = "servicecomb%2bwelcome%40%23%24%25%5e%26*()%3d%3d"; map.put("form1", code); HttpEntity<Map<String, String>> formEntiry = new HttpEntity<>(map, formHeaders); TestMgr.check(code + "null", template.postForEntity(cseUrlPrefix + "/testform", formEntiry, String.class).getBody()); map.put("form2", ""); TestMgr.check(code + "", template.postForEntity(cseUrlPrefix + "/testform", formEntiry, String.class).getBody()); }
From source file:org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils.java
public static IdentityZone createZoneOrUpdateSubdomain(RestTemplate client, String url, String id, String subdomain, Consumer<IdentityZoneConfiguration> configureZone) { ResponseEntity<String> zoneGet = client.getForEntity(url + "/identity-zones/{id}", String.class, id); if (zoneGet.getStatusCode() == HttpStatus.OK) { IdentityZone existing = JsonUtils.readValue(zoneGet.getBody(), IdentityZone.class); existing.setSubdomain(subdomain); client.put(url + "/identity-zones/{id}", existing, id); return existing; }//from w ww . j a v a 2s.co m IdentityZone identityZone = fixtureIdentityZone(id, subdomain, new IdentityZoneConfiguration()); configureZone.accept(identityZone.getConfig()); ResponseEntity<IdentityZone> zone = client.postForEntity(url + "/identity-zones", identityZone, IdentityZone.class); return zone.getBody(); }
From source file:org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils.java
public static IdentityZone createZoneOrUpdateSubdomain(RestTemplate client, String url, String id, String subdomain, IdentityZoneConfiguration config) { ResponseEntity<String> zoneGet = client.getForEntity(url + "/identity-zones/{id}", String.class, id); if (zoneGet.getStatusCode() == HttpStatus.OK) { IdentityZone existing = JsonUtils.readValue(zoneGet.getBody(), IdentityZone.class); existing.setSubdomain(subdomain); existing.setConfig(config);/*from ww w . j av a2s .co m*/ client.put(url + "/identity-zones/{id}", existing, id); return existing; } IdentityZone identityZone = fixtureIdentityZone(id, subdomain, config); ResponseEntity<IdentityZone> zone = client.postForEntity(url + "/identity-zones", identityZone, IdentityZone.class); return zone.getBody(); }