mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-20 02:29:44 +08:00
polishing
This commit is contained in:
@@ -52,7 +52,7 @@ class DefaultInitializrMetadataProvider implements InitializrMetadataProvider {
|
|||||||
def url = metadata.env.springBootMetadataUrl
|
def url = metadata.env.springBootMetadataUrl
|
||||||
if (url) {
|
if (url) {
|
||||||
try {
|
try {
|
||||||
log.info('Fetching boot metadata from '+ url)
|
log.info("Fetching boot metadata from $url")
|
||||||
return new SpringBootMetadataReader(url).getBootVersions()
|
return new SpringBootMetadataReader(url).getBootVersions()
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn('Failed to fetch spring boot metadata', e)
|
log.warn('Failed to fetch spring boot metadata', e)
|
||||||
|
@@ -138,8 +138,7 @@ class InitializrMetadata {
|
|||||||
private void indexDependency(String id, Dependency dependency) {
|
private void indexDependency(String id, Dependency dependency) {
|
||||||
def existing = indexedDependencies[id]
|
def existing = indexedDependencies[id]
|
||||||
if (existing) {
|
if (existing) {
|
||||||
throw new IllegalArgumentException('Could not register ' + dependency +
|
throw new IllegalArgumentException("Could not register $dependency another dependency has also the '$id' id $existing");
|
||||||
': another dependency has also the "' + id + '" id ' + existing)
|
|
||||||
}
|
}
|
||||||
indexedDependencies[id] = dependency
|
indexedDependencies[id] = dependency
|
||||||
}
|
}
|
||||||
@@ -148,8 +147,8 @@ class InitializrMetadata {
|
|||||||
def id = dependency.id
|
def id = dependency.id
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
if (!dependency.hasCoordinates()) {
|
if (!dependency.hasCoordinates()) {
|
||||||
throw new InvalidInitializrMetadataException('Invalid dependency, ' +
|
throw new InvalidInitializrMetadataException(
|
||||||
'should have at least an id or a groupId/artifactId pair.')
|
'Invalid dependency, should have at least an id or a groupId/artifactId pair.')
|
||||||
}
|
}
|
||||||
dependency.generateId()
|
dependency.generateId()
|
||||||
} else if (!dependency.hasCoordinates()) {
|
} else if (!dependency.hasCoordinates()) {
|
||||||
@@ -164,8 +163,8 @@ class InitializrMetadata {
|
|||||||
dependency.version = st.nextToken()
|
dependency.version = st.nextToken()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidInitializrMetadataException('Invalid dependency, id should ' +
|
throw new InvalidInitializrMetadataException(
|
||||||
'have the form groupId:artifactId[:version] but got ' + id)
|
"Invalid dependency, id should have the form groupId:artifactId[:version] but got $id")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,7 +175,7 @@ class InitializrMetadata {
|
|||||||
return element.id
|
return element.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.warn('No default found amongst' + elements)
|
log.warn("No default found amongst $elements")
|
||||||
return (elements.isEmpty() ? null : elements.get(0).id)
|
return (elements.isEmpty() ? null : elements.get(0).id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,8 +228,8 @@ class InitializrMetadata {
|
|||||||
*/
|
*/
|
||||||
def generateId() {
|
def generateId() {
|
||||||
if (groupId == null || artifactId == null) {
|
if (groupId == null || artifactId == null) {
|
||||||
throw new IllegalArgumentException('Could not generate id for ' + this
|
throw new IllegalArgumentException(
|
||||||
+ ': at least groupId and artifactId must be set.')
|
"Could not generate id for $this: at least groupId and artifactId must be set.")
|
||||||
}
|
}
|
||||||
StringBuilder sb = new StringBuilder()
|
StringBuilder sb = new StringBuilder()
|
||||||
sb.append(groupId).append(':').append(artifactId)
|
sb.append(groupId).append(':').append(artifactId)
|
||||||
|
@@ -49,37 +49,43 @@ class ProjectGenerationMetricsListener implements ProjectGenerationListener {
|
|||||||
|
|
||||||
protected void handleDependencies(ProjectRequest request) {
|
protected void handleDependencies(ProjectRequest request) {
|
||||||
request.dependencies.each {
|
request.dependencies.each {
|
||||||
increment(key('dependency.' + sanitize(it.id)))
|
def id = sanitize(it.id)
|
||||||
|
increment(key("dependency.$id"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleType(ProjectRequest request) {
|
protected void handleType(ProjectRequest request) {
|
||||||
if (StringUtils.hasText(request.type)) {
|
if (StringUtils.hasText(request.type)) {
|
||||||
increment(key('type.' + sanitize(request.type)))
|
def type = sanitize(request.type)
|
||||||
|
increment(key("type.$type"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleJavaVersion(ProjectRequest request) {
|
protected void handleJavaVersion(ProjectRequest request) {
|
||||||
if (StringUtils.hasText(request.javaVersion)) {
|
if (StringUtils.hasText(request.javaVersion)) {
|
||||||
increment(key('java_version.' + sanitize(request.javaVersion)))
|
def javaVersion = sanitize(request.javaVersion)
|
||||||
|
increment(key("java_version.$javaVersion"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handlePackaging(ProjectRequest request) {
|
protected void handlePackaging(ProjectRequest request) {
|
||||||
if (StringUtils.hasText(request.packaging)) {
|
if (StringUtils.hasText(request.packaging)) {
|
||||||
increment(key('packaging.' + sanitize(request.packaging)))
|
def packaging = sanitize(request.packaging)
|
||||||
|
increment(key("packaging.$packaging"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleLanguage(ProjectRequest request) {
|
protected void handleLanguage(ProjectRequest request) {
|
||||||
if (StringUtils.hasText(request.language)) {
|
if (StringUtils.hasText(request.language)) {
|
||||||
increment(key('language.' + sanitize(request.language)))
|
def language = sanitize(request.language)
|
||||||
|
increment(key("language.$language"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleBootVersion(ProjectRequest request) {
|
protected void handleBootVersion(ProjectRequest request) {
|
||||||
if (StringUtils.hasText(request.bootVersion)) {
|
if (StringUtils.hasText(request.bootVersion)) {
|
||||||
increment(key('boot_version.' + sanitize(request.bootVersion)))
|
def bootVersion = sanitize(request.bootVersion)
|
||||||
|
increment(key("boot_version.$bootVersion"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +94,7 @@ class ProjectGenerationMetricsListener implements ProjectGenerationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String key(String part) {
|
protected String key(String part) {
|
||||||
'initializr.' + part
|
"initializr.$part"
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String sanitize(String s) {
|
protected String sanitize(String s) {
|
||||||
|
@@ -86,15 +86,15 @@ class ProjectGenerator {
|
|||||||
|
|
||||||
def language = request.language
|
def language = request.language
|
||||||
|
|
||||||
def src = new File(new File(dir, 'src/main/' + language), request.packageName.replace('.', '/'))
|
def src = new File(new File(dir, "src/main/$language"), request.packageName.replace('.', '/'))
|
||||||
src.mkdirs()
|
src.mkdirs()
|
||||||
write(src, 'Application.' + language, model)
|
write(src, "Application.$language", model)
|
||||||
|
|
||||||
if (request.packaging == 'war') {
|
if (request.packaging == 'war') {
|
||||||
write(src, 'ServletInitializer.' + language, model)
|
write(src, "ServletInitializer.$language", model)
|
||||||
}
|
}
|
||||||
|
|
||||||
def test = new File(new File(dir, 'src/test/' + language), request.packageName.replace('.', '/'))
|
def test = new File(new File(dir, "src/test/$language"), request.packageName.replace('.', '/'))
|
||||||
test.mkdirs()
|
test.mkdirs()
|
||||||
if (request.hasWebFacet()) {
|
if (request.hasWebFacet()) {
|
||||||
model.testAnnotations = '@WebAppConfiguration\n'
|
model.testAnnotations = '@WebAppConfiguration\n'
|
||||||
@@ -103,7 +103,7 @@ class ProjectGenerator {
|
|||||||
model.testAnnotations = ''
|
model.testAnnotations = ''
|
||||||
model.testImports = ''
|
model.testImports = ''
|
||||||
}
|
}
|
||||||
write(test, 'ApplicationTests.' + language, model)
|
write(test, "ApplicationTests.$language", model)
|
||||||
|
|
||||||
def resources = new File(dir, 'src/main/resources')
|
def resources = new File(dir, 'src/main/resources')
|
||||||
resources.mkdirs()
|
resources.mkdirs()
|
||||||
@@ -158,8 +158,8 @@ class ProjectGenerator {
|
|||||||
request.resolve(metadata)
|
request.resolve(metadata)
|
||||||
|
|
||||||
// request resolved so we can log what has been requested
|
// request resolved so we can log what has been requested
|
||||||
log.info('Processing request{type=' + request.type + ', ' +
|
def dependencies = request.dependencies.collect { it.id }
|
||||||
'dependencies=' + request.dependencies.collect {it.id}+ '}')
|
log.info("Processing request{type=$request.type, dependencies=$dependencies}")
|
||||||
|
|
||||||
request.properties.each { model[it.key] = it.value }
|
request.properties.each { model[it.key] = it.value }
|
||||||
model
|
model
|
||||||
@@ -182,7 +182,7 @@ class ProjectGenerator {
|
|||||||
|
|
||||||
private void addTempFile(String group, File file) {
|
private void addTempFile(String group, File file) {
|
||||||
def content = temporaryFiles[group]
|
def content = temporaryFiles[group]
|
||||||
if (content == null) {
|
if (!content) {
|
||||||
content = []
|
content = []
|
||||||
temporaryFiles[group] = content
|
temporaryFiles[group] = content
|
||||||
}
|
}
|
||||||
|
@@ -57,9 +57,9 @@ class ProjectRequest {
|
|||||||
def dependency = metadata.getDependency(it)
|
def dependency = metadata.getDependency(it)
|
||||||
if (dependency == null) {
|
if (dependency == null) {
|
||||||
if (it.contains(':')) {
|
if (it.contains(':')) {
|
||||||
throw new IllegalArgumentException('Unknown dependency ' + it + ' check project metadata')
|
throw new IllegalArgumentException("Unknown dependency '$it' check project metadata")
|
||||||
}
|
}
|
||||||
log.warn('No known dependency for style ' + it + ' assuming spring-boot-starter')
|
log.warn("No known dependency for style '$it' assuming spring-boot-starter")
|
||||||
dependency = new InitializrMetadata.Dependency()
|
dependency = new InitializrMetadata.Dependency()
|
||||||
dependency.asSpringBootStarter(it)
|
dependency.asSpringBootStarter(it)
|
||||||
}
|
}
|
||||||
|
@@ -67,12 +67,14 @@ class MainController extends AbstractInitializrController {
|
|||||||
|
|
||||||
@RequestMapping('/spring')
|
@RequestMapping('/spring')
|
||||||
String spring() {
|
String spring() {
|
||||||
'redirect:' + metadataProvider.get().createCliDistributionURl('zip')
|
def url = metadataProvider.get().createCliDistributionURl('zip')
|
||||||
|
"redirect:$url"
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = ['/spring.tar.gz', 'spring.tgz'])
|
@RequestMapping(value = ['/spring.tar.gz', 'spring.tgz'])
|
||||||
String springTgz() {
|
String springTgz() {
|
||||||
'redirect:' + metadataProvider.get().createCliDistributionURl('tar.gz')
|
def url = metadataProvider.get().createCliDistributionURl('tar.gz')
|
||||||
|
"redirect:$url"
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping('/pom')
|
@RequestMapping('/pom')
|
||||||
|
@@ -38,7 +38,7 @@ class SpringBootMetadataReaderTests {
|
|||||||
assertNotNull 'Name must be set', it.name
|
assertNotNull 'Name must be set', it.name
|
||||||
if (it.default) {
|
if (it.default) {
|
||||||
if (defaultFound) {
|
if (defaultFound) {
|
||||||
fail('One default version was already found ' + it.id)
|
fail("One default version was already found $it.id")
|
||||||
}
|
}
|
||||||
defaultFound = true
|
defaultFound = true
|
||||||
}
|
}
|
||||||
|
@@ -44,24 +44,24 @@ class GradleBuildAssert {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GradleBuildAssert hasArtifactId(String artifactId) {
|
GradleBuildAssert hasArtifactId(String artifactId) {
|
||||||
contains('baseName = \'' + artifactId + '\'')
|
contains("baseName = '$artifactId'")
|
||||||
}
|
}
|
||||||
|
|
||||||
GradleBuildAssert hasVersion(String version) {
|
GradleBuildAssert hasVersion(String version) {
|
||||||
contains('version = \'' + version + '\'')
|
contains("version = '$version'")
|
||||||
}
|
}
|
||||||
|
|
||||||
GradleBuildAssert hasBootVersion(String bootVersion) {
|
GradleBuildAssert hasBootVersion(String bootVersion) {
|
||||||
contains('springBootVersion = \'' + bootVersion + '\'')
|
contains("springBootVersion = '$bootVersion'")
|
||||||
}
|
}
|
||||||
|
|
||||||
GradleBuildAssert hasJavaVersion(String javaVersion) {
|
GradleBuildAssert hasJavaVersion(String javaVersion) {
|
||||||
contains('sourceCompatibility = ' + javaVersion + '')
|
contains("sourceCompatibility = $javaVersion")
|
||||||
contains('targetCompatibility = ' + javaVersion + '')
|
contains("targetCompatibility = $javaVersion")
|
||||||
}
|
}
|
||||||
|
|
||||||
GradleBuildAssert contains(String expression) {
|
GradleBuildAssert contains(String expression) {
|
||||||
assertTrue expression + ' has not been found in gradle build', content.contains(expression)
|
assertTrue "$expression has not been found in gradle build", content.contains(expression)
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -36,21 +36,21 @@ class MetricsAssert {
|
|||||||
metrics.each {
|
metrics.each {
|
||||||
def actual = counterService.values[it]
|
def actual = counterService.values[it]
|
||||||
if (actual == null) {
|
if (actual == null) {
|
||||||
fail('Metric ' + it + ' not found, got ' + counterService.values.keySet())
|
fail("Metric '$it' not found, got '${counterService.values.keySet()}")
|
||||||
}
|
}
|
||||||
assertEquals 'Wrong value for metric ' + it, value, actual
|
assertEquals "Wrong value for metric $it", value, actual
|
||||||
}
|
}
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
MetricsAssert hasNoValue(String... metrics) {
|
MetricsAssert hasNoValue(String... metrics) {
|
||||||
metrics.each {
|
metrics.each {
|
||||||
assertEquals 'Metric ' + it + ' should not be registered', null, counterService.values[it]
|
assertEquals "Metric '$it' should not be registered", null, counterService.values[it]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MetricsAssert metricsCount(int count) {
|
MetricsAssert metricsCount(int count) {
|
||||||
assertEquals 'Wrong number of metrics, got ' + counterService.values.keySet(),
|
assertEquals "Wrong number of metrics, got '${counterService.values.keySet()}",
|
||||||
count, counterService.values.size()
|
count, counterService.values.size()
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
@@ -105,12 +105,13 @@ class PomAssert {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PomAssert hasDependenciesCount(int count) {
|
PomAssert hasDependenciesCount(int count) {
|
||||||
assertEquals 'Wrong number of declared dependencies -->' + dependencies.keySet(), count, dependencies.size()
|
assertEquals "Wrong number of declared dependencies -->'${dependencies.keySet()}",
|
||||||
|
count, dependencies.size()
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
PomAssert hasSpringBootStarterDependency(String dependency) {
|
PomAssert hasSpringBootStarterDependency(String dependency) {
|
||||||
hasDependency('org.springframework.boot', 'spring-boot-starter-' + dependency)
|
hasDependency('org.springframework.boot', "spring-boot-starter-$dependency")
|
||||||
}
|
}
|
||||||
|
|
||||||
PomAssert hasSpringBootStarterRootDependency() {
|
PomAssert hasSpringBootStarterRootDependency() {
|
||||||
@@ -124,9 +125,9 @@ class PomAssert {
|
|||||||
PomAssert hasDependency(String groupId, String artifactId, String version) {
|
PomAssert hasDependency(String groupId, String artifactId, String version) {
|
||||||
def id = generateId(groupId, artifactId)
|
def id = generateId(groupId, artifactId)
|
||||||
def dependency = dependencies[id]
|
def dependency = dependencies[id]
|
||||||
assertNotNull 'No dependency found with ' + id + ' --> ' + dependencies.keySet(), dependency
|
assertNotNull "No dependency found with '$id' --> ${dependencies.keySet()}", dependency
|
||||||
if (version) {
|
if (version) {
|
||||||
assertEquals 'Wrong version for '+dependency, version, dependency.version
|
assertEquals "Wrong version for $dependency", version, dependency.version
|
||||||
}
|
}
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
@@ -149,7 +150,7 @@ class PomAssert {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException('No repository found with id ' + name)
|
throw new IllegalArgumentException("No repository found with id $name")
|
||||||
}
|
}
|
||||||
|
|
||||||
def hasPluginRepository(String name) {
|
def hasPluginRepository(String name) {
|
||||||
@@ -159,15 +160,15 @@ class PomAssert {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException('No plugin repository found with id ' + name)
|
throw new IllegalArgumentException("No plugin repository found with id $name")
|
||||||
}
|
}
|
||||||
|
|
||||||
static String createPropertyNodeXpath(String propertyName) {
|
static String createPropertyNodeXpath(String propertyName) {
|
||||||
createRootNodeXPath('properties/pom:' + propertyName)
|
createRootNodeXPath("properties/pom:$propertyName")
|
||||||
}
|
}
|
||||||
|
|
||||||
static String createRootNodeXPath(String node) {
|
static String createRootNodeXPath(String node) {
|
||||||
'/pom:project/pom:' + node
|
"/pom:project/pom:$node"
|
||||||
}
|
}
|
||||||
|
|
||||||
private def parseDependencies() {
|
private def parseDependencies() {
|
||||||
|
@@ -83,7 +83,7 @@ class ProjectAssert {
|
|||||||
|
|
||||||
ProjectAssert assertFile(String localPath, boolean exist) {
|
ProjectAssert assertFile(String localPath, boolean exist) {
|
||||||
def candidate = file(localPath)
|
def candidate = file(localPath)
|
||||||
assertEquals 'Invalid presence (' + exist + ') for ' + localPath, exist, candidate.exists()
|
assertEquals "Invalid presence ('$exist') for $localPath", exist, candidate.exists()
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -110,7 +110,7 @@ abstract class AbstractInitializerControllerFormIntegrationTests extends Abstrac
|
|||||||
}
|
}
|
||||||
|
|
||||||
HomePage home() {
|
HomePage home() {
|
||||||
def request = new WebRequest(new URL('http://localhost' + homeContext()), 'text/html')
|
def request = new WebRequest(new URL("http://localhost${homeContext()}"), 'text/html')
|
||||||
def home = webClient.getPage(request)
|
def home = webClient.getPage(request)
|
||||||
createHomePage(home)
|
createHomePage(home)
|
||||||
}
|
}
|
||||||
|
@@ -55,7 +55,7 @@ abstract class AbstractInitializrControllerIntegrationTests {
|
|||||||
final RestTemplate restTemplate = new RestTemplate()
|
final RestTemplate restTemplate = new RestTemplate()
|
||||||
|
|
||||||
String createUrl(String context) {
|
String createUrl(String context) {
|
||||||
'http://localhost:' + port + context
|
"http://localhost:$port$context"
|
||||||
}
|
}
|
||||||
|
|
||||||
String htmlHome() {
|
String htmlHome() {
|
||||||
|
@@ -34,8 +34,8 @@ class MainControllerEnvIntegrationTests extends AbstractInitializrControllerInte
|
|||||||
void downloadCliWithCustomRepository() {
|
void downloadCliWithCustomRepository() {
|
||||||
def entity = restTemplate.getForEntity(createUrl('/spring'), HttpEntity.class)
|
def entity = restTemplate.getForEntity(createUrl('/spring'), HttpEntity.class)
|
||||||
assertEquals HttpStatus.FOUND, entity.getStatusCode()
|
assertEquals HttpStatus.FOUND, entity.getStatusCode()
|
||||||
assertEquals new URI('https://repo.spring.io/lib-release/org/springframework/boot/spring-boot-cli/1.1.4.RELEASE' +
|
def expected = "https://repo.spring.io/lib-release/org/springframework/boot/spring-boot-cli/1.1.4.RELEASE/spring-boot-cli-1.1.4.RELEASE-bin.zip"
|
||||||
'/spring-boot-cli-1.1.4.RELEASE-bin.zip'), entity.getHeaders().getLocation()
|
assertEquals new URI(expected), entity.getHeaders().getLocation()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -95,8 +95,8 @@ class MainControllerIntegrationTests extends AbstractInitializrControllerIntegra
|
|||||||
private void assertSpringCliRedirect(String context, String extension) {
|
private void assertSpringCliRedirect(String context, String extension) {
|
||||||
def entity = restTemplate.getForEntity(createUrl(context), ResponseEntity.class)
|
def entity = restTemplate.getForEntity(createUrl(context), ResponseEntity.class)
|
||||||
assertEquals HttpStatus.FOUND, entity.getStatusCode()
|
assertEquals HttpStatus.FOUND, entity.getStatusCode()
|
||||||
assertEquals new URI('https://repo.spring.io/release/org/springframework/boot/spring-boot-cli/1.1.4.RELEASE' +
|
def expected = "https://repo.spring.io/release/org/springframework/boot/spring-boot-cli/1.1.4.RELEASE/spring-boot-cli-1.1.4.RELEASE-bin.$extension"
|
||||||
'/spring-boot-cli-1.1.4.RELEASE-bin.'+extension), entity.getHeaders().getLocation()
|
assertEquals new URI(expected), entity.getHeaders().getLocation()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,47 +149,47 @@ class MainControllerIntegrationTests extends AbstractInitializrControllerIntegra
|
|||||||
@Test
|
@Test
|
||||||
void homeIsForm() {
|
void homeIsForm() {
|
||||||
def body = htmlHome()
|
def body = htmlHome()
|
||||||
assertTrue 'Wrong body:\n' + body, body.contains('action="/starter.zip"')
|
assertTrue "Wrong body:\n$body", body.contains('action="/starter.zip"')
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void homeIsJson() {
|
void homeIsJson() {
|
||||||
def body = restTemplate.getForObject(createUrl('/'), String)
|
def body = restTemplate.getForObject(createUrl('/'), String)
|
||||||
assertTrue('Wrong body:\n' + body, body.contains('{"dependencies"'))
|
assertTrue("Wrong body:\n$body", body.contains('{"dependencies"'))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void webIsAddedPom() {
|
void webIsAddedPom() {
|
||||||
def body = restTemplate.getForObject(createUrl('/pom.xml?packaging=war'), String)
|
def body = restTemplate.getForObject(createUrl('/pom.xml?packaging=war'), String)
|
||||||
assertTrue('Wrong body:\n' + body, body.contains('spring-boot-starter-web'))
|
assertTrue("Wrong body:\n$body", body.contains('spring-boot-starter-web'))
|
||||||
assertTrue('Wrong body:\n' + body, body.contains('provided'))
|
assertTrue("Wrong body:\n$body", body.contains('provided'))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void webIsAddedGradle() {
|
void webIsAddedGradle() {
|
||||||
def body = restTemplate.getForObject(createUrl('/build.gradle?packaging=war'), String)
|
def body = restTemplate.getForObject(createUrl('/build.gradle?packaging=war'), String)
|
||||||
assertTrue('Wrong body:\n' + body, body.contains('spring-boot-starter-web'))
|
assertTrue("Wrong body:\n$body", body.contains('spring-boot-starter-web'))
|
||||||
assertTrue('Wrong body:\n' + body, body.contains('providedRuntime'))
|
assertTrue("Wrong body:\n$body", body.contains('providedRuntime'))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void infoHasExternalProperties() {
|
void infoHasExternalProperties() {
|
||||||
def body = restTemplate.getForObject(createUrl('/info'), String)
|
def body = restTemplate.getForObject(createUrl('/info'), String)
|
||||||
assertTrue('Wrong body:\n' + body, body.contains('"spring-boot"'))
|
assertTrue("Wrong body:\n$body", body.contains('"spring-boot"'))
|
||||||
assertTrue('Wrong body:\n' + body, body.contains('"version":"1.1.4.RELEASE"'))
|
assertTrue("Wrong body:\n$body", body.contains('"version":"1.1.4.RELEASE"'))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void homeHasWebStyle() {
|
void homeHasWebStyle() {
|
||||||
def body = htmlHome()
|
def body = htmlHome()
|
||||||
assertTrue('Wrong body:\n' + body, body.contains('name="style" value="web"'))
|
assertTrue("Wrong body:\n$body", body.contains('name="style" value="web"'))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void homeHasBootVersion() {
|
void homeHasBootVersion() {
|
||||||
def body = htmlHome()
|
def body = htmlHome()
|
||||||
assertTrue('Wrong body:\n' + body, body.contains('name="bootVersion"'))
|
assertTrue("Wrong body:\n$body", body.contains('name="bootVersion"'))
|
||||||
assertTrue('Wrong body:\n' + body, body.contains('1.2.0.BUILD-SNAPSHOT"'))
|
assertTrue("Wrong body:\n$body", body.contains('1.2.0.BUILD-SNAPSHOT"'))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -218,7 +218,7 @@ class MainControllerIntegrationTests extends AbstractInitializrControllerIntegra
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static JSONObject readJson(String version) {
|
private static JSONObject readJson(String version) {
|
||||||
def resource = new ClassPathResource('metadata/test-default-' + version + '.json')
|
def resource = new ClassPathResource("metadata/test-default-$version" + ".json")
|
||||||
def stream = resource.inputStream
|
def stream = resource.inputStream
|
||||||
try {
|
try {
|
||||||
def json = StreamUtils.copyToString(stream, Charset.forName('UTF-8'))
|
def json = StreamUtils.copyToString(stream, Charset.forName('UTF-8'))
|
||||||
|
@@ -85,8 +85,8 @@ abstract class HomePage {
|
|||||||
if (checkBox) {
|
if (checkBox) {
|
||||||
checkBox.checked = true
|
checkBox.checked = true
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException('No dependency with name '
|
throw new IllegalArgumentException(
|
||||||
+ dependency + ' was found amongst ' + allStyles.keySet())
|
"No dependency with name '$dependency' was found amongst '${allStyles.keySet()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user