List of usage examples for org.springframework.http ResponseEntity getStatusCode
public HttpStatus getStatusCode()
From source file:uk.urchinly.wabi.expose.ApplicationConfigurationTests.java
@Test public void testServerStatus() throws Exception { ResponseEntity<String> entity = new TestRestTemplate() .getForEntity("http://localhost:" + this.port + "/info", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); }
From source file:comsat.sample.data.jpa.SampleDataJpaApplicationTests.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 (doesn't contain 'Bath'):\n" + entity.getBody(), entity.getBody().contains("Bath")); }
From source file:de.codecentric.boot.admin.controller.RegistryControllerTest.java
@Test public void get_notFound() { controller.register(new Application("http://localhost", "FOO")); ResponseEntity<?> response = controller.get("unknown"); assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); }
From source file:io.curly.artifact.integration.service.NotifyOnCreationCommand.java
@Retryable @HystrixCommand/*from ww w .ja v a 2 s. c om*/ public void emitFallback(Object object) { if (object instanceof Artifact) { ResponseEntity<?> responseEntity = notifierClient.postNotification(((Artifact) object)); log.info("Fallback emitted event through HTTP response is {}", responseEntity.getStatusCode().value()); } }
From source file:com.walmart.gatling.AbstractRestIntTest.java
protected void delete(String url, HttpStatus status) { ResponseEntity<Void> response = template.exchange(url, HttpMethod.DELETE, null, Void.class); HttpStatus code = response.getStatusCode(); assertEquals(status, code);/*from w w w . j a va 2 s. c o m*/ }
From source file:comsat.sample.tomcat.SampleTomcatSslApplicationTests.java
@Test public void testHome() throws Exception { SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory( new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build()); HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build(); TestRestTemplate testRestTemplate = new TestRestTemplate(); ((HttpComponentsClientHttpRequestFactory) testRestTemplate.getRequestFactory()).setHttpClient(httpClient); ResponseEntity<String> entity = testRestTemplate.getForEntity("https://localhost:" + this.port, String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertEquals("Hello, world", entity.getBody()); }
From source file:com.tce.oauth2.spring.client.controller.UserInfoController.java
@RequestMapping("/userinfo") public String index(HttpServletRequest request) { if (request.getSession().getAttribute("access_token") == null) { return "redirect:/"; }/*ww w . j a v a 2 s . c o m*/ String accessToken = (String) request.getSession().getAttribute("access_token"); HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", "Bearer " + accessToken); HttpEntity<?> entity = new HttpEntity<>(headers); ResponseEntity<User> response = restTemplate.exchange(OAUTH_URL + "/userinfo", HttpMethod.GET, entity, User.class); if (response.getStatusCode().is4xxClientError()) { return "redirect:/login"; } User user = response.getBody(); request.getSession(false).setAttribute("username", user.getUsername()); return "redirect:/"; }
From source file:dk.nsi.haiba.lprimporter.status.StatusReporterTest.java
@Test public void willReturn500whenHAIBADBisDown() throws Exception { Mockito.when(haibaJdbcTemplate.queryForObject("SELECT Id from ImporterStatus LIMIT 1", Long.class)) .thenThrow(Exception.class); final ResponseEntity<String> response = reporter.reportStatus(); assertEquals(500, response.getStatusCode().value()); assertTrue(response.getBody().contains("HAIBA Database is _NOT_ running correctly")); }
From source file:dk.nsi.haiba.lprimporter.status.StatusReporterTest.java
@Test public void willReturn500whenLPRDBisDown() throws Exception { Mockito.when(jdbcTemplate.queryForObject("SELECT v_recnum from T_ADM LIMIT 1", Object.class)) .thenThrow(Exception.class); final ResponseEntity<String> response = reporter.reportStatus(); assertEquals(500, response.getStatusCode().value()); assertTrue(response.getBody().contains("LPR Database is _NOT_ running correctly")); }
From source file:com.zalando.zmon.boot.jetty.AbstractRunner.java
@Test public void run() throws InterruptedException { RestTemplate rest = new RestTemplate(); for (int i = 0; i < 100; i++) { ResponseEntity<String> response = rest .getForEntity("http://localhost:" + port + "/api/simple/" + i + "/complex", String.class); Assertions.assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); }// ww w . j av a 2 s . c o m ResponseEntity<String> metrics = rest.getForEntity("http://localhost:" + port + "/metrics", String.class); Assertions.assertThat(metrics.getBody()).contains(LINE); // to use browser /metrics // TimeUnit.MINUTES.sleep(2); }