|
|
|
|
@ -16,11 +16,48 @@
@@ -16,11 +16,48 @@
|
|
|
|
|
|
|
|
|
|
package sample.devtools; |
|
|
|
|
|
|
|
|
|
import org.junit.Test; |
|
|
|
|
import org.junit.runner.RunWith; |
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest; |
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; |
|
|
|
|
import org.springframework.boot.test.web.client.TestRestTemplate; |
|
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
|
import org.springframework.test.annotation.DirtiesContext; |
|
|
|
|
import org.springframework.test.context.junit4.SpringRunner; |
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Integration tests for {@link SampleDevToolsApplication}. |
|
|
|
|
* |
|
|
|
|
* @author Andy Wilkinson |
|
|
|
|
* @author Phillip Webb |
|
|
|
|
*/ |
|
|
|
|
@RunWith(SpringRunner.class) |
|
|
|
|
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) |
|
|
|
|
@DirtiesContext |
|
|
|
|
public class SampleDevToolsApplicationIntegrationTests { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private TestRestTemplate restTemplate; |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testStaticResource() throws Exception { |
|
|
|
|
ResponseEntity<String> entity = this.restTemplate |
|
|
|
|
.getForEntity("/css/application.css", String.class); |
|
|
|
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); |
|
|
|
|
assertThat(entity.getBody()).contains("color: green;"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testPublicResource() throws Exception { |
|
|
|
|
ResponseEntity<String> entity = this.restTemplate.getForEntity("/public.txt", |
|
|
|
|
String.class); |
|
|
|
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); |
|
|
|
|
assertThat(entity.getBody()).contains("public file"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|