List of usage examples for org.springframework.http ResponseEntity getStatusCode
public HttpStatus getStatusCode()
From source file:be.boyenvaesen.EmployeeControllerTest.java
@Test public void testList() { ResponseEntity<Employee[]> responseEntity = restTemplate.getForEntity("/employees", Employee[].class); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); Employee[] employees = responseEntity.getBody(); assertEquals("Boyen", employees[0].getFirstName()); assertEquals("Maarten", employees[1].getFirstName()); assertEquals("Thijs", employees[2].getFirstName()); assertEquals("Jasper", employees[3].getFirstName()); assertEquals(4, employees.length);/*from ww w. j a v a 2 s .c o m*/ }
From source file:com.crazyacking.learn.spring.actuator.ManagementPathSampleActuatorApplicationTests.java
@Test public void testHealth() { ResponseEntity<String> entity = this.restTemplate.withBasicAuth("user", getPassword()) .getForEntity("/admin/health", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("\"status\":\"UP\""); }
From source file:com.dolphine.ultrasimple.microservice.ApplicationTests.java
@Test public void testHome() throws Exception { ResponseEntity<String> entity = new TestRestTemplate() .getForEntity("http://localhost:" + this.port + "?name=Tiago", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertEquals("Ol Tiago", entity.getBody()); }
From source file:sample.jetty.SampleJettyApplicationTests.java
@Test public void testCompression() throws Exception { HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.set("Accept-Encoding", "gzip"); HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders); ResponseEntity<byte[]> entity = this.restTemplate.exchange("/", HttpMethod.GET, requestEntity, byte[].class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); GZIPInputStream inflater = new GZIPInputStream(new ByteArrayInputStream(entity.getBody())); try {// w w w.ja v a 2 s . c o m // assertThat(StreamUtils.copyToString(inflater, Charset.forName("UTF-8"))).isEqualTo("Hello World"); } finally { inflater.close(); } }
From source file:com.batch.traditional.SampleTraditionalApplicationTests.java
@Test public void testHomeJsp() throws Exception { ResponseEntity<String> entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port, String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); String body = entity.getBody(); assertTrue("Wrong body:\n" + body, body.contains("<html>")); assertTrue("Wrong body:\n" + body, body.contains("<h1>Home</h1>")); }
From source file:comsat.sample.ui.SampleWebStaticApplicationTests.java
@Test public void testHome() throws Exception { ResponseEntity<String> entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port, String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(), entity.getBody().contains("<title>Static")); }
From source file:de.codecentric.boot.admin.controller.RegistryControllerTest.java
@Test public void unregister_notFound() { controller.register(new Application("http://localhost", "FOO")); ResponseEntity<?> response = controller.unregister("unknown"); assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); }
From source file:io.fabric8.quickstarts.camel.ApplicationTest.java
@Test public void newOrderTest() { // Wait for maximum 5s until the first order gets inserted and processed NotifyBuilder notify = new NotifyBuilder(camelContext).fromRoute("generate-order").whenDone(2).and() .fromRoute("process-order").whenDone(1).create(); assertThat(notify.matches(10, TimeUnit.SECONDS)).isTrue(); // Then call the REST API ResponseEntity<Order> orderResponse = restTemplate.getForEntity("/camel-rest-sql/books/order/1", Order.class); assertThat(orderResponse.getStatusCode()).isEqualTo(HttpStatus.OK); Order order = orderResponse.getBody(); assertThat(order.getId()).isEqualTo(1); assertThat(order.getAmount()).isBetween(1, 10); assertThat(order.getItem()).isIn("Camel", "ActiveMQ"); assertThat(order.getDescription()).isIn("Camel in Action", "ActiveMQ in Action"); assertThat(order.isProcessed()).isTrue(); ResponseEntity<List<Book>> booksResponse = restTemplate.exchange("/camel-rest-sql/books", HttpMethod.GET, null, new ParameterizedTypeReference<List<Book>>() { });//from w w w.jav a 2 s .c o m assertThat(booksResponse.getStatusCode()).isEqualTo(HttpStatus.OK); List<Book> books = booksResponse.getBody(); assertThat(books).hasSize(2); assertThat(books).element(0).hasFieldOrPropertyWithValue("description", "ActiveMQ in Action"); assertThat(books).element(1).hasFieldOrPropertyWithValue("description", "Camel in Action"); }
From source file:org.cloudfoundry.identity.uaa.integration.LoginInfoEndpointIntegrationTests.java
/** * tests a happy-day flow of the <code>/info</code> endpoint *///from ww w . j a v a 2 s .c o m @Test public void testHappyDay() throws Exception { @SuppressWarnings("rawtypes") ResponseEntity<Map> response = serverRunning.getForObject("/info", Map.class); assertEquals(HttpStatus.OK, response.getStatusCode()); @SuppressWarnings("unchecked") List<Map<String, String[]>> prompts = (List<Map<String, String[]>>) response.getBody().get("prompts"); assertNotNull(prompts); }
From source file:sample.jersey.SampleJerseyApplicationTests.java
@Test public void contextLoads() { ResponseEntity<String> entity = this.restTemplate.getForEntity("http://localhost:" + this.port + "/hello", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); }