List of usage examples for org.springframework.http ResponseEntity getStatusCode
public HttpStatus getStatusCode()
From source file:com.borabora.ui.secure.SampleSecureApplicationTests.java
@Test public void testCss() throws Exception { ResponseEntity<String> entity = new TestRestTemplate() .getForEntity("http://localhost:" + this.port + "/css/bootstrap.min.css", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("body")); }
From source file:com.nebhale.cyclinglibrary.web.PointControllerTest.java
@Test public void readXml() throws ParserConfigurationException, FactoryConfigurationError, TransformerException, IOException { Collection collection = new Collection(Long.valueOf(0), Long.valueOf(1), "test-name", "test-short-name", Long.valueOf(2));// w ww . j a va2 s .co m when(this.collectionRepository.read(Long.valueOf(1))).thenReturn(collection); List<Point> points = Arrays.asList(new Point(Double.valueOf(3), Double.valueOf(4), Double.valueOf(5))); Item item = new Item(Long.valueOf(0), Long.valueOf(1), Long.valueOf(2), "test-name", "test-short-name", points); when(this.itemRepository.read(Long.valueOf(2))).thenReturn(item); ResponseEntity<String> result = this.controller.read(Long.valueOf(1), Long.valueOf(2)); assertEquals(HttpStatus.OK, result.getStatusCode()); assertEquals(read(new File("src/test/resources/expected-output.gpx")), result.getBody()); }
From source file:com.opensearchserver.hadse.index.IndexTest.java
@Test public void t02_createDefaultIndex() { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); RestTemplate template = new RestTemplate(); ResponseEntity<String> entity = template.exchange("http://localhost:8080/my_index", HttpMethod.PUT, null, String.class); assertEquals(HttpStatus.CREATED, entity.getStatusCode()); }
From source file:movies.spring.jdbc.SampleMovieApplicationTests.java
@Test public void testMovie() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(asList(MediaType.APPLICATION_JSON)); TestRestTemplate template = new TestRestTemplate(); template.setMessageConverters(/*from www. j ava 2 s. c o m*/ Arrays.<HttpMessageConverter<?>>asList(new MappingJackson2HttpMessageConverter())); ResponseEntity<Map> entity = template.getForEntity("http://localhost:" + this.port + "/movie/{title}", Map.class, "The Matrix"); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertEquals("The Matrix", entity.getBody().get("title")); }
From source file:com.cloudbees.jenkins.plugins.demo.actuator.ManagementAddressActuatorApplicationTests.java
@Test public void testHealth() throws Exception { ResponseEntity<String> entity = new TestRestTemplate() .getForEntity("http://localhost:" + this.managementPort + "/admin/health", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertEquals("ok", entity.getBody()); }
From source file:comsat.sample.actuator.ui.SampleActuatorUiApplicationPortTests.java
@Test public void testHealth() throws Exception { ResponseEntity<String> entity = new TestRestTemplate() .getForEntity("http://localhost:" + this.managementPort + "/health", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertEquals("{\"status\":\"UP\"}", entity.getBody()); }
From source file:org.moserp.product.rest.ProductRestTest.java
@Test public void createProduct() { ResponseEntity<Object> response = restTemplate.postForEntity(testEnvironment.createRestUri("/products"), new Product("My Product"), null); assertEquals("Status", HttpStatus.CREATED, response.getStatusCode()); String productUri = response.getHeaders().getLocation().toString(); assertNotNull("productUri", productUri); assertNotNull(productUtil.getByUri(productUri)); }
From source file:org.openbaton.nfvo.vnfm_reg.impl.sender.RestVnfmSender.java
private void put(String path, String json, String url) { HttpEntity<String> requestEntity = new HttpEntity<>(json, headers); ResponseEntity<String> responseEntity = rest.exchange(url + path, HttpMethod.PUT, requestEntity, String.class); this.setStatus(responseEntity.getStatusCode()); }
From source file:de.pentasys.playground.springbootexample.ManagementAddressActuatorApplicationTests.java
@Test public void testHealth() throws Exception { ResponseEntity<String> entity = new TestRestTemplate() .getForEntity("http://localhost:" + this.managementPort + "/admin/health", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertTrue(entity.getBody().contains("\"status\" : \"UP\"")); }
From source file:io.jmnarloch.spring.cloud.feign.OAuth2HttpClientTest.java
@Test public void authenticate() { // given//from w w w . java 2 s.c o m final String token = UUID.randomUUID().toString(); oauth2ClientContext.setAccessToken(new DefaultOAuth2AccessToken(token)); // when final ResponseEntity response = authenticationClient.authenticate(); // then assertNotNull(response); assertEquals(HttpStatus.OK, response.getStatusCode()); assertTrue(response.getHeaders().containsKey("Authorization")); assertEquals(token, response.getHeaders().getFirst("Authorization").split(" ")[1]); }