Search in sources :

Example 36 with TestRestTemplate

use of org.springframework.boot.test.web.client.TestRestTemplate in project java-function-invoker by projectriff.

the class FatJarPojoTests method init.

@Before
public void init() {
    runner = new JavaFunctionInvokerApplication();
    rest = new TestRestTemplate();
}
Also used : TestRestTemplate(org.springframework.boot.test.web.client.TestRestTemplate) Before(org.junit.Before)

Example 37 with TestRestTemplate

use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot-admin by codecentric.

the class AdminApplicationTest method testReverseProxy.

@Test
public void testReverseProxy() {
    String apiBaseUrl = "http://localhost:" + port + "/api/applications";
    Map<String, String> application = new HashMap<>();
    application.put("name", "TestApp");
    application.put("managementUrl", "http://localhost:" + port);
    application.put("serviceUrl", "http://localhost:" + port);
    application.put("healthUrl", "http://localhost:" + port + "/health");
    @SuppressWarnings("unchecked") ResponseEntity<Map<String, String>> entity = new TestRestTemplate().postForEntity(apiBaseUrl, application, (Class<Map<String, String>>) (Class<?>) Map.class);
    @SuppressWarnings("rawtypes") ResponseEntity<Map> app = new TestRestTemplate().getForEntity(apiBaseUrl + "/" + entity.getBody().get("id"), Map.class);
    assertEquals(HttpStatus.OK, app.getStatusCode());
    assertEquals("TestApp", app.getBody().get("name"));
    @SuppressWarnings("rawtypes") ResponseEntity<Map> info = new TestRestTemplate().getForEntity(apiBaseUrl + "/" + entity.getBody().get("id") + "/info", Map.class);
    assertEquals(HttpStatus.OK, info.getStatusCode());
    @SuppressWarnings("rawtypes") ResponseEntity<Map> health = new TestRestTemplate().getForEntity(apiBaseUrl + "/" + entity.getBody().get("id") + "/health", Map.class);
    assertEquals(HttpStatus.OK, health.getStatusCode());
}
Also used : HashMap(java.util.HashMap) TestRestTemplate(org.springframework.boot.test.web.client.TestRestTemplate) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 38 with TestRestTemplate

use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot-admin by codecentric.

the class AdminApplicationTest method testGetApplications.

@Test
public void testGetApplications() {
    @SuppressWarnings("rawtypes") ResponseEntity<List> entity = new TestRestTemplate().getForEntity("http://localhost:" + port + "/api/applications", List.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
}
Also used : TestRestTemplate(org.springframework.boot.test.web.client.TestRestTemplate) List(java.util.List) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 39 with TestRestTemplate

use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.

the class EndpointMvcIntegrationTests method healthEndpointNotHidden.

@Test
public void healthEndpointNotHidden() throws InterruptedException {
    String body = new TestRestTemplate().getForObject("http://localhost:" + this.port + "/health", String.class);
    assertThat(body).isNotNull().contains("status");
    assertThat(this.interceptor.invoked()).isTrue();
}
Also used : TestRestTemplate(org.springframework.boot.test.web.client.TestRestTemplate) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 40 with TestRestTemplate

use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.

the class MustacheAutoConfigurationIntegrationTests method testHomePage.

@Test
public void testHomePage() throws Exception {
    String body = new TestRestTemplate().getForObject("http://localhost:" + this.port, String.class);
    assertThat(body.contains("Hello World")).isTrue();
}
Also used : TestRestTemplate(org.springframework.boot.test.web.client.TestRestTemplate) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

TestRestTemplate (org.springframework.boot.test.web.client.TestRestTemplate)75 Test (org.junit.Test)67 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)53 Map (java.util.Map)23 HttpHeaders (org.springframework.http.HttpHeaders)15 Before (org.junit.Before)5 RequestEntity (org.springframework.http.RequestEntity)2 OAuth2ContextConfiguration (org.springframework.security.oauth2.client.test.OAuth2ContextConfiguration)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 File (java.io.File)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 JSONArray (net.minidev.json.JSONArray)1 AnnotationConfigServletWebServerApplicationContext (org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext)1 OAuth2AccessToken (org.springframework.security.oauth2.common.OAuth2AccessToken)1 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)1 MethodArgumentNotValidException (org.springframework.web.bind.MethodArgumentNotValidException)1