List of usage examples for org.springframework.http ResponseEntity getStatusCode
public HttpStatus getStatusCode()
From source file:com.digitalriver.artifact.NickArtifactServerTests.java
public void testCss() throws Exception { ResponseEntity<String> entity = new TestRestTemplate().getForEntity( "http://localhost:" + this.port + "/webjars/bootstrap/3.0.3/css/bootstrap.min.css", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("body")); assertEquals("Wrong content type:\n" + entity.getHeaders().getContentType(), MediaType.valueOf("text/css"), entity.getHeaders().getContentType()); }
From source file:com.github.wnameless.spring.bulkapi.DefaultBulkApiService.java
private BulkResult buldResult(ResponseEntity<String> rawRes) { BulkResult res = new BulkResult(); res.setStatus(Short.valueOf(rawRes.getStatusCode().toString())); res.setHeaders(rawRes.getHeaders().toSingleValueMap()); res.setBody(rawRes.getBody());//from w ww . j a v a2s . co m return res; }
From source file:com.intel.databackend.handlers.Data.java
@RequestMapping(value = "/v1/accounts/{accountId}/dataSubmission", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody//from w w w . j a v a 2 s . c o m public ResponseEntity dataSubmission(@PathVariable String accountId, @Valid @RequestBody DataSubmissionRequest request, BindingResult result) throws ServiceException, BindException { logger.info(REQUEST_LOG_ENTRY, accountId); logger.debug(DEBUG_LOG, request); if (result.hasErrors()) { throw new BindException(result); } else { dataSubmissionService.withParams(accountId, request); dataSubmissionService.invoke(); ResponseEntity res = new ResponseEntity<>(HttpStatus.CREATED); logger.info(RESPONSE_LOG_ENTRY, res.getStatusCode()); return res; } }
From source file:com.opensearchserver.hadse.cluster.ClusterTest.java
@Test public void t01_get() { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); RestTemplate template = new RestTemplate(); ResponseEntity<NodeItem[]> entity = template.exchange("http://localhost:8080/_cluster", HttpMethod.GET, null, NodeItem[].class); assertTrue(entity.getBody().length >= 1); assertEquals(HttpStatus.OK, entity.getStatusCode()); }
From source file:de.zib.gndms.gndmc.gorfx.Test.GORFXClientTest.java
@Test(groups = { "GORFXServiceTest" }) public void listFacets() { ResponseEntity<Facets> gorfxFacets; gorfxFacets = gorfxClient.listAvailableFacets(admindn); Assert.assertNotNull(gorfxFacets);/* w w w.jav a2 s.c o m*/ Assert.assertEquals(gorfxFacets.getStatusCode(), HttpStatus.OK); }
From source file:com.cloudbees.jenkins.plugins.demo.actuator.ManagementAddressActuatorApplicationTests.java
@Test public void testHome() throws Exception { @SuppressWarnings("rawtypes") ResponseEntity<Map> entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port, Map.class); assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode()); }
From source file:com.crazyacking.learn.spring.actuator.ServletPathSampleActuatorApplicationTests.java
@Test public void testErrorPath() { @SuppressWarnings("rawtypes") ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()) .getForEntity("/spring/error", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); @SuppressWarnings("unchecked") Map<String, Object> body = entity.getBody(); assertThat(body.get("error")).isEqualTo("None"); assertThat(body.get("status")).isEqualTo(999); }
From source file:de.wirthedv.appname.SpringBootFacesApplicationTests.java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Test//from w w w. ja v a 2 s .c om public void testActuatorHealthPageOpenForAll() throws Exception { ResponseEntity<Map> entity = new TestRestTemplate() .getForEntity("http://localhost:" + this.port + actuatorPath + "/health", Map.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); Map<String, Object> body = entity.getBody(); assertTrue("Wrong body:\n" + entity.getBody(), body.containsKey("status")); }
From source file:com.eg.hello.HelloWorldConfigurationTests.java
@Test public void testGreeting() throws Exception { @SuppressWarnings("rawtypes") ResponseEntity<Map> entity = new TestRestTemplate() .getForEntity("http://localhost:" + this.port + "/hello-world", Map.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); }
From source file:com.redhat.fisdemoaggregator.ApplicationTest.java
@Test public void transferTest() throws Exception { String responseMsg = "Tested!"; camelContext.getRouteDefinition("gatewaytransfer").adviceWith(camelContext, new AdviceWithRouteBuilder() { @Override//from ww w . j av a 2 s.c o m public void configure() throws Exception { interceptSendToEndpoint("http*").skipSendToOriginalEndpoint().setBody(constant(responseMsg)); } }); ResponseEntity<String> balanceResponse = restTemplate .getForEntity("/demos/sourcegateway/transfer/123456/50/345678?moneysource=bitcoin", String.class); assertThat(balanceResponse.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(balanceResponse.getBody()).isEqualTo("\"" + responseMsg + "\""); balanceResponse = restTemplate.getForEntity("/demos/sourcegateway/transfer/123456/50/345678", String.class); assertThat(balanceResponse.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(balanceResponse.getBody()).isEqualTo("\"" + responseMsg + "\""); }