List of usage examples for org.springframework.http ResponseEntity getStatusCode
public HttpStatus getStatusCode()
From source file:com.cloudbees.jenkins.plugins.demo.actuator.EndpointsPropertiesSampleActuatorApplicationTests.java
@Test public void testCustomErrorPath() throws Exception { @SuppressWarnings("rawtypes") ResponseEntity<Map> entity = new TestRestTemplate("user", "password") .getForEntity("http://localhost:" + this.port + "/oops", Map.class); assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, entity.getStatusCode()); @SuppressWarnings("unchecked") Map<String, Object> body = entity.getBody(); assertEquals("None", body.get("error")); assertEquals(999, body.get("status")); }
From source file:comsat.sample.tomcat.SampleTomcatTwoConnectorsApplicationTests.java
@Test public void testHello() throws Exception { RestTemplate template = new RestTemplate(); final MySimpleClientHttpRequestFactory factory = new MySimpleClientHttpRequestFactory( new HostnameVerifier() { @Override/* ww w . j a v a 2 s .c o m*/ public boolean verify(final String hostname, final SSLSession session) { return true; // these guys are alright by me... } }); template.setRequestFactory(factory); ResponseEntity<String> entity = template.getForEntity("http://localhost:" + this.port + "/hello", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertEquals("hello", entity.getBody()); ResponseEntity<String> httpsEntity = template .getForEntity("https://localhost:" + this.context.getBean("port") + "/hello", String.class); assertEquals(HttpStatus.OK, httpsEntity.getStatusCode()); assertEquals("hello", httpsEntity.getBody()); }
From source file:de.codecentric.boot.admin.web.CorsFilterOnDifferentPortsTest.java
@Test public void testCORS_OPTIONS_application() { // DO NOT serve CORS-Headers on application-endpoints ResponseEntity<Void> options = new TestRestTemplate().exchange("http://localhost:" + serverPort + "/hello", HttpMethod.OPTIONS, HttpEntity.EMPTY, Void.class); assertEquals(HttpStatus.OK, options.getStatusCode()); assertEquals(null, options.getHeaders().get("Access-Control-Allow-Origin")); assertEquals(null, options.getHeaders().get("Access-Control-Allow-Headers")); }
From source file:com.crazyacking.learn.spring.actuator.ManagementPortSampleActuatorApplicationTests.java
@Test public void testErrorPage() { @SuppressWarnings("rawtypes") ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword()) .getForEntity("http://localhost:" + this.managementPort + "/error", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); @SuppressWarnings("unchecked") Map<String, Object> body = entity.getBody(); assertThat(body.get("status")).isEqualTo(999); }
From source file:com.cloudbees.jenkins.plugins.demo.actuator.ManagementPortSampleActuatorApplicationTests.java
@Test public void testHome() throws Exception { @SuppressWarnings("rawtypes") ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword()) .getForEntity("http://localhost:" + this.port, Map.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); @SuppressWarnings("unchecked") Map<String, Object> body = entity.getBody(); assertEquals("Hello Phil", body.get("message")); }
From source file:com.cloudbees.jenkins.plugins.demo.actuator.ManagementPortSampleActuatorApplicationTests.java
@Test public void testErrorPage() throws Exception { @SuppressWarnings("rawtypes") ResponseEntity<Map> entity = new TestRestTemplate() .getForEntity("http://localhost:" + this.managementPort + "/error", Map.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); @SuppressWarnings("unchecked") Map<String, Object> body = entity.getBody(); assertEquals(999, body.get("status")); }
From source file:de.codecentric.boot.admin.web.CorsFilterOnSamePortsTest.java
@Test public void testCORS_OPTIONS_jolokia_endpoint() { // DO serve CORS-Headers on management-endpoints ResponseEntity<Void> options = new TestRestTemplate().exchange( "http://localhost:" + serverPort + "/jolokia", HttpMethod.OPTIONS, HttpEntity.EMPTY, Void.class); assertEquals(HttpStatus.OK, options.getStatusCode()); assertEquals(Arrays.asList("*"), options.getHeaders().get("Access-Control-Allow-Origin")); assertEquals(Arrays.asList("Origin, X-Requested-With, Content-Type, Accept"), options.getHeaders().get("Access-Control-Allow-Headers")); }
From source file:de.zib.gndms.taskflows.interslicetransfer.client.InterSliceTransferExample.java
private void showFiles(final Specifier<Void> slice) { final ResponseEntity<List<FileStats>> listResponseEntity = sliceClient.listFiles(slice, dn); if (HttpStatus.OK.equals(listResponseEntity.getStatusCode())) { final List<FileStats> fileStats = listResponseEntity.getBody(); System.out.println(" transferred " + fileStats.size() + " files"); for (FileStats fs : fileStats) System.out.println(" " + fs); }/*from ww w. j a v a2 s .com*/ }
From source file:com.crazyacking.learn.spring.actuator.ManagementPortAndPathSampleActuatorApplicationTests.java
@Test public void testMetrics() { testHome(); // makes sure some requests have been made @SuppressWarnings("rawtypes") ResponseEntity<Map> entity = new TestRestTemplate() .getForEntity("http://localhost:" + this.managementPort + "/admin/metrics", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); }
From source file:com.salmon.security.xacml.demo.springmvc.rest.HTTPPopulatorsTest.java
@Test public void testCreateDriver() { ResponseEntity<Driver> entity = this.createOneDriver(); String path = entity.getHeaders().getLocation().getPath(); assertEquals(HttpStatus.CREATED, entity.getStatusCode()); Driver driver = entity.getBody(); LOG.info("The Driver ID is " + driver.getInternalID()); LOG.info("The Location is " + entity.getHeaders().getLocation()); LOG.info("The Path is " + path); assertEquals("JOEBOGGS2015LICENSE", driver.getDriversLicense()); assertTrue(path.startsWith("/xacml/aggregators/dvla/drivers/")); }