List of usage examples for org.springframework.http ResponseEntity getStatusCode
public HttpStatus getStatusCode()
From source file:comsat.sample.undertow.SampleUndertowApplicationTests.java
private void assertOkResponse(String path, String body) { ResponseEntity<String> entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port + path, String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertEquals(body, entity.getBody()); }
From source file:sample.tomcat.jndi.SampleTomcatJndiApplicationTests.java
@Test public void testDirect() throws Exception { ResponseEntity<String> entity = new TestRestTemplate() .getForEntity("http://localhost:" + this.port + "/direct", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertThat(entity.getBody(), containsString(BasicDataSource.class.getName())); }
From source file:de.codecentric.boot.admin.controller.RegistryControllerTest.java
@Test public void register_twice() { controller.register(new Application("http://localhost", "test")); Application app = new Application("http://localhost", "test"); ResponseEntity<Application> response = controller.register(app); assertEquals(HttpStatus.CREATED, response.getStatusCode()); assertEquals("http://localhost", response.getBody().getUrl()); assertEquals("test", response.getBody().getName()); }
From source file:edu.infsci2560.AboutIT.java
@Test public void testAboutPage() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); ResponseEntity<String> entity = this.restTemplate.exchange("/about.html", HttpMethod.GET, new HttpEntity<>(headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); }
From source file:edu.infsci2560.AboutIT.java
@Test public void testAboutPageValid() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); ResponseEntity<String> entity = this.restTemplate.exchange("/about.html", HttpMethod.GET, new HttpEntity<>(headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); PageHtmlValidator.validatePage(entity.getBody()); }
From source file:comsat.sample.mustache.SampleWebMustacheApplicationTests.java
@Test public void testMustacheTemplate() throws Exception { ResponseEntity<String> entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port, String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("Hello, Andy")); }
From source file:org.cloudfoundry.identity.uaa.integration.PasswordCheckEndpointIntegrationTests.java
@Test public void passwordPostSucceeds() throws Exception { MultiValueMap<String, String> formData = new LinkedMultiValueMap<String, String>(); formData.add("password", "password1"); HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); @SuppressWarnings("rawtypes") ResponseEntity<Map> response = serverRunning.postForMap("/password/score", formData, headers); assertEquals(HttpStatus.OK, response.getStatusCode()); assertTrue(response.getBody().containsKey("score")); assertTrue(response.getBody().containsKey("requiredScore")); assertEquals(0, response.getBody().get("score")); }
From source file:com.ge.predix.acs.commons.web.ResponseEntityBuilderTest.java
@Test public void testOk() { ResponseEntity<Object> ok = ResponseEntityBuilder.ok(); Assert.assertNotNull(ok);// www .jav a 2s.c o m Assert.assertNull(ok.getBody()); Assert.assertEquals(ok.getStatusCode(), HttpStatus.OK); }
From source file:comsat.sample.velocity.SampleWebVelocityApplicationTests.java
@Test public void testVelocityTemplate() throws Exception { ResponseEntity<String> entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port, String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("Hello, Andy")); }
From source file:de.codecentric.boot.admin.controller.RegistryControllerTest.java
@Test public void unregister() { Application app = new Application("http://localhost", "FOO"); app = controller.register(app).getBody(); ResponseEntity<?> response = controller.unregister(app.getId()); assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode()); assertEquals(app, response.getBody()); assertEquals(HttpStatus.NOT_FOUND, controller.get(app.getId()).getStatusCode()); }