mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-28 14:52:24 +00:00
SEC-2622: Add integration test support to samples
This commit is contained in:
parent
fb25273672
commit
82e89db1c8
@ -38,6 +38,13 @@ ext.spockDependencies = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
ext.gebDependencies = spockDependencies + [
|
||||||
|
"org.seleniumhq.selenium:selenium-htmlunit-driver:$seleniumVersion",
|
||||||
|
"org.gebish:geb-spock:$gebVersion",
|
||||||
|
'commons-httpclient:commons-httpclient:3.1',
|
||||||
|
"org.codehaus.groovy:groovy:$groovyVersion"
|
||||||
|
]
|
||||||
|
|
||||||
ext.powerMockDependencies = [
|
ext.powerMockDependencies = [
|
||||||
"org.powermock:powermock-core:$powerMockVersion",
|
"org.powermock:powermock-core:$powerMockVersion",
|
||||||
"org.powermock:powermock-api-support:$powerMockVersion",
|
"org.powermock:powermock-api-support:$powerMockVersion",
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
maven { url "https://repo.spring.io/plugins-release" }
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.gradle.api.plugins:gradle-tomcat-plugin:1.2.3")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
apply plugin: 'tomcat'
|
apply plugin: 'tomcat'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -8,3 +17,49 @@ dependencies {
|
|||||||
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
|
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task integrationTomcatRun(type: org.gradle.api.plugins.tomcat.tasks.TomcatRun) {
|
||||||
|
onlyIf { !sourceSets.integrationTest.allSource.empty }
|
||||||
|
buildscriptClasspath = tomcatRun.buildscriptClasspath
|
||||||
|
classesDirectory = project.sourceSets.main.output.classesDir
|
||||||
|
contextPath = tomcatRun.contextPath
|
||||||
|
daemon = true
|
||||||
|
tomcatClasspath = tomcatRun.tomcatClasspath
|
||||||
|
webAppClasspath = tomcatRun.webAppClasspath
|
||||||
|
webAppSourceDirectory = tomcatRun.webAppSourceDirectory
|
||||||
|
doFirst {
|
||||||
|
|
||||||
|
// delay reserving ports to ensure they are still available
|
||||||
|
def ports = reservePorts(3)
|
||||||
|
httpPort = ports[0]
|
||||||
|
ajpPort = ports[1]
|
||||||
|
stopPort = ports[2]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task integrationTomcatStop(type: org.gradle.api.plugins.tomcat.tasks.TomcatStop) {
|
||||||
|
onlyIf { !sourceSets.integrationTest.allSource.empty }
|
||||||
|
doFirst {
|
||||||
|
stopPort = integrationTomcatRun.stopPort
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
integrationTest {
|
||||||
|
dependsOn integrationTomcatRun
|
||||||
|
doFirst {
|
||||||
|
def host = 'localhost:' + integrationTomcatRun.httpPort
|
||||||
|
systemProperties['geb.build.baseUrl'] = 'http://'+host+'/' + integrationTomcatRun.contextPath + '/'
|
||||||
|
systemProperties['geb.build.reportsDir'] = 'build/geb-reports'
|
||||||
|
}
|
||||||
|
finalizedBy integrationTomcatStop
|
||||||
|
}
|
||||||
|
|
||||||
|
def reservePorts(int count) {
|
||||||
|
def sockets = []
|
||||||
|
for(int i in 1..count) {
|
||||||
|
sockets << new ServerSocket(0)
|
||||||
|
}
|
||||||
|
def result = sockets*.localPort
|
||||||
|
sockets*.close()
|
||||||
|
result
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user