2014-05-28 17:26:53 +01:00
|
|
|
package test
|
|
|
|
|
2014-05-29 09:17:39 +01:00
|
|
|
@SpringApplicationConfiguration(classes=TestConfiguration)
|
2014-05-28 17:26:53 +01:00
|
|
|
@WebAppConfiguration
|
|
|
|
@IntegrationTest('server.port:0')
|
|
|
|
@DirtiesContext
|
|
|
|
class IntegrationTests {
|
|
|
|
|
|
|
|
@Value('${local.server.port}')
|
|
|
|
int port
|
2014-05-30 09:50:24 +01:00
|
|
|
|
|
|
|
private String home() {
|
|
|
|
HttpHeaders headers = new HttpHeaders()
|
|
|
|
headers.setAccept([MediaType.TEXT_HTML])
|
|
|
|
new TestRestTemplate().exchange('http://localhost:' + port, HttpMethod.GET, new HttpEntity<Void>(headers), String).body
|
|
|
|
}
|
2014-05-28 17:26:53 +01:00
|
|
|
|
|
|
|
@Test
|
2014-05-29 09:17:39 +01:00
|
|
|
void homeIsForm() {
|
2014-05-30 09:50:24 +01:00
|
|
|
String body = home()
|
2014-05-28 17:26:53 +01:00
|
|
|
assertTrue('Wrong body:\n' + body, body.contains('action="/starter.zip"'))
|
|
|
|
}
|
|
|
|
|
2014-05-30 09:50:24 +01:00
|
|
|
@Test
|
|
|
|
void homeIsJson() {
|
|
|
|
String body = new TestRestTemplate().getForObject('http://localhost:' + port, String)
|
|
|
|
assertTrue('Wrong body:\n' + body, body.contains('{"styles"'))
|
|
|
|
}
|
|
|
|
|
2014-05-29 16:26:47 +01:00
|
|
|
@Test
|
2014-06-04 15:31:11 +01:00
|
|
|
void webIsAddedPom() {
|
2014-05-29 16:26:47 +01:00
|
|
|
String body = new TestRestTemplate().getForObject('http://localhost:' + port + '/pom.xml?packaging=war', String)
|
|
|
|
assertTrue('Wrong body:\n' + body, body.contains('spring-boot-starter-web'))
|
2014-06-04 15:31:11 +01:00
|
|
|
assertTrue('Wrong body:\n' + body, body.contains('provided'))
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void webIsAddedGradle() {
|
|
|
|
String body = new TestRestTemplate().getForObject('http://localhost:' + port + '/build.gradle?packaging=war', String)
|
|
|
|
assertTrue('Wrong body:\n' + body, body.contains('spring-boot-starter-web'))
|
|
|
|
assertTrue('Wrong body:\n' + body, body.contains('providedRuntime'))
|
2014-05-29 16:26:47 +01:00
|
|
|
}
|
|
|
|
|
2014-05-28 19:25:35 +01:00
|
|
|
@Test
|
|
|
|
void infoHasExternalProperties() {
|
|
|
|
String body = new TestRestTemplate().getForObject('http://localhost:' + port + '/info', String)
|
|
|
|
assertTrue('Wrong body:\n' + body, body.contains('"project"'))
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void homeHasWebStyle() {
|
2014-05-30 09:50:24 +01:00
|
|
|
String body = home()
|
2014-05-28 19:25:35 +01:00
|
|
|
assertTrue('Wrong body:\n' + body, body.contains('name="style" value="web"'))
|
|
|
|
}
|
|
|
|
|
2014-06-24 09:42:54 +01:00
|
|
|
@Test
|
|
|
|
void homeHasBootVersion() {
|
|
|
|
String body = home()
|
|
|
|
assertTrue('Wrong body:\n' + body, body.contains('name="bootVersion" value="1'))
|
|
|
|
}
|
|
|
|
|
2014-05-29 09:17:39 +01:00
|
|
|
@Test
|
|
|
|
void downloadStarter() {
|
|
|
|
byte[] body = new TestRestTemplate().getForObject('http://localhost:' + port + 'starter.zip', byte[])
|
|
|
|
assertNotNull(body)
|
|
|
|
assertTrue(body.length>100)
|
|
|
|
}
|
|
|
|
|
2014-05-30 11:12:43 +01:00
|
|
|
@Test
|
|
|
|
void installer() {
|
|
|
|
ResponseEntity<String> response = new TestRestTemplate().getForEntity('http://localhost:' + port + 'install.sh', String)
|
|
|
|
assertEquals(HttpStatus.OK, response.getStatusCode())
|
|
|
|
assertNotNull(response.body)
|
|
|
|
}
|
|
|
|
|
2014-05-29 09:17:39 +01:00
|
|
|
}
|
|
|
|
|
2014-05-29 16:26:47 +01:00
|
|
|
// CLI compiled classes are not @ComponentScannable so we have to create
|
2014-05-29 09:17:39 +01:00
|
|
|
// an explicit configuration for the test
|
|
|
|
@Configuration
|
|
|
|
@Import([app.MainController, app.Projects, app.TemporaryFileCleaner])
|
|
|
|
class TestConfiguration {
|
2014-05-28 17:26:53 +01:00
|
|
|
}
|