List of usage examples for org.springframework.http ResponseEntity getStatusCode
public HttpStatus getStatusCode()
From source file:de.wirthedv.appname.SpringBootFacesApplicationTests.java
@Test public void testJsfWelcomePageRedirectsToLogin() 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("form name=\"loginForm\"")); }
From source file:org.akaademiwolof.ConfigurationTests.java
@SuppressWarnings("static-access") //@Test/*from w ww .j a v a 2s.co m*/ public void shouldUpdateWordWhenSendingRequestToController() throws Exception { HttpHeaders headers = new HttpHeaders(); JSONObject requestJson = new JSONObject(); requestJson.wrap(json); System.out.print(requestJson.toString()); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity<String> entity = new HttpEntity<String>(json, headers); ResponseEntity<String> loginResponse = restTemplate.exchange(localhostUrl, HttpMethod.POST, entity, String.class); if (loginResponse.getStatusCode() == HttpStatus.OK) { JSONObject wordJson = new JSONObject(loginResponse.getBody()); System.out.print(loginResponse.getStatusCode()); assertThat(wordJson != null); } else if (loginResponse.getStatusCode() == HttpStatus.BAD_REQUEST) { System.out.print(loginResponse.getStatusCode()); } }
From source file:org.cloudfoundry.identity.uaa.integration.VmcAuthenticationTests.java
@Test public void testDefaultScopes() { params.set("credentials", String.format("{\"username\":\"%s\",\"password\":\"%s\"}", testAccounts.getUserName(), testAccounts.getPassword())); ResponseEntity<Void> response = serverRunning.postForResponse(serverRunning.getAuthorizationUri(), headers, params);/*from w ww. j a v a 2s . c o m*/ assertEquals(HttpStatus.FOUND, response.getStatusCode()); String location = response.getHeaders().getLocation().toString(); assertTrue("Not authenticated (no access token): " + location, location.contains("access_token")); }
From source file:com.github.jmnarloch.spring.cloud.feign.FeignAcceptEncodingTest.java
@Test public void compressedResponse() { // when//from www . j a v a 2 s . co m final ResponseEntity<List<Invoice>> invoices = invoiceClient.getInvoices(); // then assertNotNull(invoices); assertEquals(HttpStatus.OK, invoices.getStatusCode()); assertNotNull(invoices.getBody()); assertEquals(100, invoices.getBody().size()); }
From source file:org.camunda.bpm.spring.boot.starter.webapp.WebappTest.java
@Test public void testLicenseEndpointNotAvailable() throws Exception { final ResponseEntity<String> response = testRestTemplate.getForEntity( "http://localhost:" + this.port + "/api/admin/plugin/license/default/key", String.class); assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); }
From source file:at.ac.tuwien.dsg.cloud.utilities.gateway.registry.UserController.java
@RequestMapping(method = RequestMethod.DELETE, value = REST_USER_PATH_VARIABLE) public ResponseEntity<String> remove(@PathVariable String user) { boolean res = this.kongUsers.getUsers().removeIf((KongUser u) -> { if (u.getUserName().equals(user)) { RequestEntity<Void> request = RequestEntity .delete(URI.create(this.kongUris.getKongConsumerIdUri(u.getId()))).accept(MediaType.ALL) .build();/*from w ww .ja va2s.c o m*/ ResponseEntity<String> resp = restUtilities.simpleRestExchange(request, String.class); if (resp == null || resp.getStatusCode() != HttpStatus.NO_CONTENT) { return false; } return true; } return false; }); if (!res) { return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } return new ResponseEntity<>(HttpStatus.OK); }
From source file:com.crazyacking.learn.spring.actuator.NoManagementSampleActuatorApplicationTests.java
@Test public void testMetricsNotAvailable() { testHome(); // makes sure some requests have been made @SuppressWarnings("rawtypes") ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/metrics", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); }
From source file:org.cloudfoundry.identity.uaa.integration.ClientInfoEndpointIntegrationTests.java
@Test public void testGetClientInfo() throws Exception { HttpHeaders headers = new HttpHeaders(); AuthorizationCodeResourceDetails app = testAccounts.getDefaultAuthorizationCodeResource(); headers.set("Authorization", testAccounts.getAuthorizationHeader(app.getClientId(), app.getClientSecret())); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); @SuppressWarnings("rawtypes") ResponseEntity<Map> response = serverRunning.getForObject("/clientinfo", Map.class, headers); assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(app.getClientId(), response.getBody().get("client_id")); }
From source file:org.cloudfoundry.identity.uaa.integration.ClientInfoEndpointIntegrationTests.java
@Test public void testImplicitClientInfo() throws Exception { HttpHeaders headers = new HttpHeaders(); ImplicitResourceDetails app = testAccounts.getDefaultImplicitResource(); headers.set("Authorization", testAccounts.getAuthorizationHeader(app.getClientId(), "")); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); @SuppressWarnings("rawtypes") ResponseEntity<Map> response = serverRunning.getForObject("/clientinfo", Map.class, headers); assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(app.getClientId(), response.getBody().get("client_id")); }
From source file:org.cloudfoundry.identity.uaa.login.integration.VmcAuthenticationTests.java
@Test public void testDefaultScopes() { params.set("source", "credentials"); params.set("username", testAccounts.getUserName()); params.set("password", testAccounts.getPassword()); ResponseEntity<Void> response = serverRunning.postForResponse(serverRunning.getAuthorizationUri(), headers, params);/*w w w . ja va 2 s.c o m*/ assertEquals(HttpStatus.FOUND, response.getStatusCode()); String location = response.getHeaders().getLocation().toString(); assertTrue("Not authenticated (no access token): " + location, location.contains("access_token")); }