Migrate smoke tests to Geb

Since Htmlunit does not provide a complete support for Javascript, smoke
tests are migrated to Gab (i.e. using Selenium and an actual browser).

This present a major challenge: it is not easy to assert the content of
a file that the browser downloads when it submits a form. First, the
browser should be configured to download the file directly instead of
opening a (native) pop-up asking the users where to download it. Then,
the tests should be aware of the location of the file in order to assert
it.

Hopefully, Firefox can be configured to achieve this goal.

Closes gh-75
This commit is contained in:
Stephane Nicoll
2015-02-17 13:52:39 +01:00
parent 1a213cdbc7
commit 5a4a2b9f81
11 changed files with 357 additions and 514 deletions

View File

@@ -7,6 +7,7 @@ order.
=== Release 1.0.0 (In progress)
* https://github.com/spring-io/initializr/issues/75[#75]: migrate smoke tests to Geb.
* https://github.com/spring-io/initializr/issues/74[#74]: remove support for meta-data V1.
* https://github.com/spring-io/initializr/issues/71[#71]: update project layout for Groovy-based projects.
* https://github.com/spring-io/initializr/issues/69[#69]: improve the structure of templated urls.

View File

@@ -184,17 +184,21 @@ it yourself.
[[building]]
=== Building
NOTE: Initializr currently uses a milestone release of `spring-test-htmlunit` that is available from
the http://repo.spring.io/milestone[spring.io milestone repository]. If you use a repository
manager, please make sure to configure it accordingly. For your convenience, the project defines
a `springMilestone` that you should activate if you haven't defined that repository yourself.
The library is located in the `initializr` directory.
[indent=0]
----
$ cd initializr
$ mvn clean install -PspringMilestone
$ mvn clean install
----
If you want to run the smoke tests using Geb, you need to enable the
`smokeTests` profile. Firefox should also be installed on your machine
[indent=0]
----
$ cd initializr
$ mvn verify -PsmokeTests
----

View File

@@ -10,6 +10,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<selenium.version>2.43.1</selenium.version>
<spring.boot.version>1.2.1.RELEASE</spring.boot.version>
</properties>
@@ -77,10 +78,21 @@
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test-htmlunit</artifactId>
<groupId>org.gebish</groupId>
<artifactId>geb-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
@@ -111,9 +123,25 @@
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test-htmlunit</artifactId>
<version>1.0.0.M2</version>
<groupId>org.gebish</groupId>
<artifactId>geb-core</artifactId>
<version>0.10.0</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>${selenium.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
@@ -145,13 +173,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<includes>
<include>**/*Tests.java</include>
</includes>
<excludes>
<exclude>**/Abstract*.java</exclude>
<exclude>**/*SmokeTests.java</exclude>
</excludes>
</configuration>
</plugin>
@@ -162,23 +190,46 @@
<extensions>true</extensions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>springMilestone</id>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<id>smokeTests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>
<include>**/*SmokeTests.java</include>
</includes>
<excludes>
<exclude>**/Abstract*.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@@ -1,183 +0,0 @@
/*
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.spring.initializr.web
import com.gargoylesoftware.htmlunit.WebClient
import com.gargoylesoftware.htmlunit.WebRequest
import com.gargoylesoftware.htmlunit.WebResponse
import com.gargoylesoftware.htmlunit.html.HtmlPage
import io.spring.initializr.test.PomAssert
import io.spring.initializr.test.ProjectAssert
import io.spring.initializr.web.support.HomePage
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.web.servlet.htmlunit.MockMvcWebConnection
import org.springframework.test.web.servlet.setup.MockMvcBuilders
import org.springframework.web.context.WebApplicationContext
import static org.junit.Assert.assertEquals
/**
* Integration tests that are actually using the HTML page to request new
* projects. Used to test both the default home page and the legacy one
* used by STS.
*
* @author Stephane Nicoll
*/
@ActiveProfiles('test-default')
abstract class AbstractInitializerControllerFormIntegrationTests extends AbstractInitializrControllerIntegrationTests {
@Autowired
private WebApplicationContext context
private WebClient webClient
@Before
void setup() {
def mockMvc = MockMvcBuilders
.webAppContextSetup(context)
.build()
webClient = new WebClient()
webClient.webConnection = new MockMvcWebConnection(mockMvc, '')
}
@After
void cleanup() {
this.webClient.closeAllWindows()
}
@Test
void createDefaultJavaProject() {
def page = home()
def projectAssert = zipProjectAssert(page, page.generateProject())
projectAssert.isMavenProject().isJavaProject().hasStaticAndTemplatesResources(false)
.pomAssert().hasDependenciesCount(2)
.hasSpringBootStarterRootDependency().hasSpringBootStarterDependency('test')
}
@Test
void createDefaultGroovyProject() {
def page = home()
page.language = 'groovy'
def projectAssert = zipProjectAssert(page, page.generateProject())
projectAssert.isMavenProject().isGroovyProject().hasStaticAndTemplatesResources(false)
.pomAssert().hasDependenciesCount(3)
.hasSpringBootStarterRootDependency().hasSpringBootStarterDependency('test')
.hasDependency('org.codehaus.groovy', 'groovy')
}
@Test
void createJavaProjectWithCustomDefaults() {
def page = createCustomPage()
WebResponse webResponse = page.generateProject()
String value = webResponse.getResponseHeaderValue('Content-Disposition')
assertEquals 'attachment; filename="foo-bar.zip"', value
def projectAssert = zipProjectAssert(page, webResponse)
projectAssert.isMavenProject().isJavaProject('MyProjectApplication')
.hasStaticAndTemplatesResources(true)
assertMavenProject(projectAssert.pomAssert())
}
@Test
void createGroovyProjectWithCustomDefaults() {
def page = createCustomPage()
page.language = 'groovy'
WebResponse webResponse = page.generateProject()
String value = webResponse.getResponseHeaderValue('Content-Disposition')
assertEquals 'attachment; filename="foo-bar.zip"', value
def projectAssert = zipProjectAssert(page, webResponse)
projectAssert.isMavenProject().isGroovyProject('MyProjectApplication')
.hasStaticAndTemplatesResources(true)
assertMavenProject(projectAssert.pomAssert())
.hasDependency('org.codehaus.groovy', 'groovy')
}
private def createCustomPage() {
def page = home()
page.groupId = 'com.acme'
page.artifactId = 'foo-bar'
page.name = 'My project'
page.description = 'A description for my project'
page.dependencies << 'web' << 'data-jpa'
page
}
private PomAssert assertMavenProject(PomAssert pomAssert) {
pomAssert.hasGroupId('com.acme').hasArtifactId('foo-bar')
.hasName('My project').hasDescription('A description for my project')
.hasSpringBootStarterDependency('web')
.hasSpringBootStarterDependency('data-jpa')
.hasSpringBootStarterDependency('test')
}
@Test
abstract void createSimpleGradleProject()
@Test
void createWarProject() {
def page = home()
page.packaging = 'war'
def projectAssert = zipProjectAssert(page, page.generateProject())
projectAssert.isMavenProject().isJavaWarProject()
.pomAssert().hasPackaging('war').hasDependenciesCount(3)
.hasSpringBootStarterDependency('web') // Added with war packaging
.hasSpringBootStarterDependency('tomcat')
.hasSpringBootStarterDependency('test')
}
void createSimpleGradleProject(String projectType) {
def page = home()
page.type = projectType
page.dependencies << 'data-jpa'
def projectAssert = zipProjectAssert(page, page.generateProject())
projectAssert.isGradleProject().isJavaProject().hasStaticAndTemplatesResources(false)
}
HomePage home() {
def request = new WebRequest(new URL("http://localhost${homeContext()}"), 'text/html')
def home = webClient.getPage(request)
createHomePage(home)
}
/**
* Initialize a {@link ProjectAssert} for the specified {@link HomePage} and {@link WebResponse}.
*/
protected ProjectAssert zipProjectAssert(HomePage page, WebResponse webResponse) {
zipProjectAssert(webResponse.contentAsStream.bytes)
}
/**
* Provide the context of the home page
*/
protected abstract String homeContext()
/**
* Create a {@link HomePage} instance based on the specified {@link HtmlPage}
*/
protected abstract HomePage createHomePage(HtmlPage home)
}

View File

@@ -1,60 +0,0 @@
/*
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.spring.initializr.web
import com.gargoylesoftware.htmlunit.html.HtmlPage
import io.spring.initializr.web.support.HomePage
import io.spring.initializr.web.support.StsHomePage
import org.springframework.boot.test.SpringApplicationConfiguration
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
/**
* Form based tests for the "legacy" home page that STS is still using.
*
* @author Stephane Nicoll
*/
@SpringApplicationConfiguration(classes = LegacyStsConfig.class)
class LegacyStsControllerFormIntegrationTests extends AbstractInitializerControllerFormIntegrationTests {
@Override
void createSimpleGradleProject() {
createSimpleGradleProject('gradle.zip')
}
@Override
protected String homeContext() {
'/sts'
}
@Override
protected HomePage createHomePage(HtmlPage home) {
new StsHomePage(home)
}
@Configuration
static class LegacyStsConfig {
@Bean
@SuppressWarnings("deprecation")
LegacyStsController legacyStsController() {
new LegacyStsController()
}
}
}

View File

@@ -1,56 +0,0 @@
/*
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.spring.initializr.web
import com.gargoylesoftware.htmlunit.WebResponse
import com.gargoylesoftware.htmlunit.html.HtmlPage
import io.spring.initializr.InitializrMetadata
import io.spring.initializr.test.ProjectAssert
import io.spring.initializr.web.support.DefaultHomePage
import io.spring.initializr.web.support.HomePage
/**
* Form based tests for the "regular" home page.
*
* @author Stephane Nicoll
*/
class MainControllerFormIntegrationTests extends AbstractInitializerControllerFormIntegrationTests {
@Override
void createSimpleGradleProject() {
createSimpleGradleProject('gradle-project')
}
@Override
protected String homeContext() {
'/'
}
@Override
protected HomePage createHomePage(HtmlPage home) {
new DefaultHomePage(home)
}
@Override
protected ProjectAssert zipProjectAssert(HomePage page, WebResponse webResponse) {
ProjectAssert projectAssert = super.zipProjectAssert(page, webResponse)
// we require self contained archive by default
String dirName = page.artifactId ?: InitializrMetadata.Defaults.DEFAULT_NAME
projectAssert.hasBaseDir(dirName)
}
}

View File

@@ -0,0 +1,229 @@
/*
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.spring.initializr.web
import geb.Browser
import io.spring.initializr.test.GradleBuildAssert
import io.spring.initializr.test.PomAssert
import io.spring.initializr.web.test.HomePage
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.openqa.selenium.WebDriver
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxProfile
import org.springframework.test.context.ActiveProfiles
import static org.junit.Assert.assertTrue
/**
*
* @author Stephane Nicoll
*/
@ActiveProfiles('test-default')
class ProjectGenerationSmokeTests extends AbstractInitializrControllerIntegrationTests {
private File downloadDir
private WebDriver driver
private Browser browser
@Before
void setup() {
downloadDir = folder.newFolder()
FirefoxProfile fxProfile = new FirefoxProfile();
fxProfile.setPreference("browser.download.folderList", 2);
fxProfile.setPreference("browser.download.manager.showWhenStarting", false);
fxProfile.setPreference("browser.download.dir", downloadDir.getAbsolutePath());
fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk",
"application/zip,application/x-compress,application/octet-stream");
driver = new FirefoxDriver(fxProfile);
browser = new Browser()
browser.driver = driver
}
@After
void destroy() {
if (driver != null) {
driver.close();
}
}
@Test
void createDefaultJavaProject() {
toHome {
page.generateProject.click()
at HomePage
def projectAssert = zipProjectAssert(from('demo.zip'))
projectAssert.hasBaseDir("demo").isMavenProject().isJavaProject()
.hasStaticAndTemplatesResources(false)
.pomAssert().hasDependenciesCount(2)
.hasSpringBootStarterRootDependency().hasSpringBootStarterDependency('test')
}
}
@Test
void createDefaultGroovyProject() {
toHome {
page.language = 'groovy'
page.generateProject.click()
at HomePage
def projectAssert = zipProjectAssert(from('demo.zip'))
projectAssert.hasBaseDir('demo').isMavenProject().isGroovyProject()
.hasStaticAndTemplatesResources(false)
.pomAssert().hasDependenciesCount(3)
.hasSpringBootStarterRootDependency().hasSpringBootStarterDependency('test')
.hasDependency('org.codehaus.groovy', 'groovy')
}
}
@Test
void createJavaProjectWithCustomDefaults() {
toHome {
page.groupId = 'com.acme'
page.artifactId = 'foo-bar'
page.name = 'My project'
page.description = 'A description for my project'
page.dependency('web')
page.dependency('data-jpa')
page.generateProject.click()
at HomePage
def projectAssert = zipProjectAssert(from('foo-bar.zip'))
projectAssert.hasBaseDir("foo-bar").isMavenProject()
.isJavaProject('MyProjectApplication')
.hasStaticAndTemplatesResources(true)
.pomAssert().hasGroupId('com.acme').hasArtifactId('foo-bar')
.hasName('My project').hasDescription('A description for my project')
.hasSpringBootStarterDependency('web')
.hasSpringBootStarterDependency('data-jpa')
.hasSpringBootStarterDependency('test')
}
}
@Test
void createGroovyProjectWithCustomDefaults() {
toHome {
page.language = 'groovy'
page.groupId = 'org.biz'
page.artifactId = 'groovy-project'
page.name = 'My Groovy project'
page.description = 'A description for my Groovy project'
page.dependency('web')
page.dependency('data-jpa')
page.generateProject.click()
at HomePage
def projectAssert = zipProjectAssert(from('groovy-project.zip'))
projectAssert.hasBaseDir("groovy-project").isMavenProject()
.isGroovyProject('MyGroovyProjectApplication')
.hasStaticAndTemplatesResources(true)
.pomAssert().hasGroupId('org.biz').hasArtifactId('groovy-project')
.hasName('My Groovy project').hasDescription('A description for my Groovy project')
.hasSpringBootStarterDependency('web')
.hasSpringBootStarterDependency('data-jpa')
.hasSpringBootStarterDependency('test')
.hasDependency('org.codehaus.groovy', 'groovy')
}
}
@Test
void createSimpleGradleProject() {
toHome {
page.type = 'gradle-project'
page.dependency('data-jpa')
page.generateProject.click()
at HomePage
def projectAssert = zipProjectAssert(from('demo.zip'))
projectAssert.hasBaseDir("demo").isGradleProject()
.isJavaProject()
.hasStaticAndTemplatesResources(false)
}
}
@Test
void createWarProject() {
toHome {
page.packaging = 'war'
page.generateProject.click()
at HomePage
def projectAssert = zipProjectAssert(from('demo.zip'))
projectAssert.hasBaseDir("demo").isMavenProject()
.isJavaWarProject()
.pomAssert().hasPackaging('war').hasDependenciesCount(3)
.hasSpringBootStarterDependency('web') // Added with war packaging
.hasSpringBootStarterDependency('tomcat')
.hasSpringBootStarterDependency('test')
}
}
@Test
void createMavenBuild() {
toHome {
page.type = 'maven-build'
page.dependency('data-jpa')
page.artifactId = 'my-maven-project'
page.generateProject.click()
at HomePage
pomAssert().hasArtifactId('my-maven-project')
.hasSpringBootStarterDependency('data-jpa')
}
}
@Test
void createGradleBuild() {
toHome {
page.type = 'gradle-build'
page.javaVersion = '1.6'
page.artifactId = 'my-gradle-project'
page.generateProject.click()
at HomePage
gradleBuildAssert().hasArtifactId('my-gradle-project').hasJavaVersion('1.6')
}
}
private Browser toHome(Closure script) {
browser.go("http://localhost:" + port + "/")
browser.at HomePage
script.delegate = browser
script()
browser
}
private GradleBuildAssert gradleBuildAssert() {
new GradleBuildAssert(getArchive('build.gradle').text)
}
private PomAssert pomAssert() {
new PomAssert(getArchive('pom.xml').text)
}
private byte[] from(String fileName) {
getArchive(fileName).bytes
}
private File getArchive(String fileName) {
File archive = new File(downloadDir, fileName)
assertTrue "Expected content with name $fileName", archive.exists()
archive
}
}

View File

@@ -1,47 +0,0 @@
/*
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.spring.initializr.web.support
import com.gargoylesoftware.htmlunit.html.HtmlPage
import com.gargoylesoftware.htmlunit.html.HtmlSelect
/**
* The default home page.
*
* @author Stephane Nicoll
*/
class DefaultHomePage extends HomePage {
DefaultHomePage(HtmlPage page) {
super(page)
}
@Override
protected void setup() {
super.setup()
select('type', type)
select('packaging', packaging)
}
@Override
protected void select(String selectId, String value) {
if (value) {
def input = page.getHtmlElementById(selectId)
input.setSelectedAttribute(value, true)
}
}
}

View File

@@ -1,97 +0,0 @@
/*
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.spring.initializr.web.support
import com.gargoylesoftware.htmlunit.WebResponse
import com.gargoylesoftware.htmlunit.html.*
/**
* Represent the home page of the service.
*
* @author Stephane Nicoll
*/
abstract class HomePage {
String groupId
String artifactId
String name
String description
String packageName
String type
String packaging
String language
List<String> dependencies = []
protected final HtmlPage page
protected HomePage(HtmlPage page) {
this.page = page
}
/**
* Generate a project using the specified temporary directory. Return
* the {@link WebResponse}.
* @see org.junit.rules.TemporaryFolder
*/
WebResponse generateProject() {
setup()
def submit = page.getElementByName('generate-project')
def newMessagePage = submit.click();
newMessagePage.webResponse
}
/**
* Setup the {@link HtmlPage} with the customization of this
* instance. Only applied when a non-null value is set
*/
protected void setup() {
setTextValue('groupId', groupId)
setTextValue('artifactId', artifactId)
setTextValue('name', name)
setTextValue('description', description)
setTextValue('packageName', packageName)
select('language', language)
selectDependencies(dependencies)
}
protected void setTextValue(String elementId, String value) {
if (value) {
def input = page.getHtmlElementById(elementId)
input.setValueAttribute(value)
}
}
protected abstract void select(String selectId, String value)
protected void selectDependencies(List<String> dependencies) {
def styles = page.getElementsByName("style")
def allStyles = [:]
for (HtmlCheckBoxInput checkBoxInput : styles) {
allStyles[checkBoxInput.getValueAttribute()] = checkBoxInput
}
for (String dependency : dependencies) {
def checkBox = allStyles.get(dependency)
if (checkBox) {
checkBox.checked = true
} else {
throw new IllegalArgumentException(
"No dependency with name '$dependency' was found amongst '${allStyles.keySet()}")
}
}
}
}

View File

@@ -1,47 +0,0 @@
/*
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.spring.initializr.web.support
import com.gargoylesoftware.htmlunit.html.HtmlPage
/**
* The old home page, still used by the STS wizard.
*
* @author Stephane Nicoll
*/
class StsHomePage extends HomePage {
StsHomePage(HtmlPage page) {
super(page)
}
@Override
protected void setup() {
super.setup()
select('type', type)
select('packaging', packaging)
}
@Override
protected void select(String selectId, String value) {
if (value) {
page.getElementsByIdAndOrName(selectId).each {
it.checked = value.equals(it.defaultValue)
}
}
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.spring.initializr.web.test
import geb.Page
/**
* A {@link Page} representing the home page of the application.
*
* @author Stephane Nicoll
* @since 1.0
*/
class HomePage extends Page {
static at = { title == 'Spring Initializr' }
static content = {
groupId { $('form').groupId() }
artifactId { $('form').artifactId() }
name { $('form').name() }
description { $('form').description() }
packageName { $('form').packageName() }
type { $('form').type() }
packaging { $('form').packaging() }
javaVersion { $('form').javaVersion() }
language { $('form').language() }
dependency { id ->
$("form").find('input', type: "checkbox", name: "style", value: id).click()
}
generateProject { $('form').find('button', name: 'generate-project') }
}
}