use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.
the class MustacheWebIntegrationTests method testPartialPage.
@Test
public void testPartialPage() throws Exception {
String body = new TestRestTemplate().getForObject("http://localhost:" + this.port + "/partial", String.class);
assertThat(body.contains("Hello World")).isTrue();
}
use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.
the class MustacheWebIntegrationTests 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();
}
use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.
the class SecurityFilterAutoConfigurationEarlyInitializationTests method testSecurityFilterDoesNotCauseEarlyInitialization.
@Test
public void testSecurityFilterDoesNotCauseEarlyInitialization() throws Exception {
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext();
try {
EnvironmentTestUtils.addEnvironment(context, "server.port:0", "security.user.password:password");
context.register(Config.class);
context.refresh();
int port = context.getWebServer().getPort();
new TestRestTemplate("user", "password").getForEntity("http://localhost:" + port, Object.class);
// If early initialization occurred a ConverterNotFoundException is thrown
} finally {
context.close();
}
}
use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.
the class SpringBootWebSecurityConfigurationTests method testHiddenHttpMethodFilterOrderedFirst.
// gh-3447
@Test
public void testHiddenHttpMethodFilterOrderedFirst() throws Exception {
this.context = SpringApplication.run(DenyPostRequestConfig.class, "--server.port=0");
int port = Integer.parseInt(this.context.getEnvironment().getProperty("local.server.port"));
TestRestTemplate rest = new TestRestTemplate();
// not overriding causes forbidden
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
ResponseEntity<Object> result = rest.postForEntity("http://localhost:" + port + "/", form, Object.class);
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
// override method with GET
form = new LinkedMultiValueMap<>();
form.add("_method", "GET");
result = rest.postForEntity("http://localhost:" + port + "/", form, Object.class);
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.
the class SampleWildFlyDeployApplicationIT method testHome.
@Test
public void testHome() throws Exception {
String url = "http://localhost:" + this.port + "/bootapp/";
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("Hello World");
}
Aggregations