Files
spring-session-data-geode/samples/boot/gemfire/spring-session-sample-boot-gemfire.gradle
John Blum 6ad1813ddf Refactor Spring Session Boot Sample to use Spring Data for Apache Geode Test.
Remove the sample.client.IntegrationTestConfiugration class.

Refactor sample.server.GemFireServer class to extend ClientServerIntegrationTestsConfiguration.

Refactor sample.client.Application.ClientCacheConfiguration class to import SubscriptionEnabledClientServerIntegrationTestsConfiguration class.

Refactor integrationTest.doFirst to set the 'spring.data.gemfire.cache.server.port' property.

Refactor integrationTest.onLast to call runGemFireServer.process?.destroy().

Add 'spring.data.gemfire.cache.server.port' property to the System properties when forking & launching the GemFire server in runGemFireServer.doLast.
2018-08-15 01:04:38 -07:00

107 lines
2.6 KiB
Groovy

apply plugin: 'io.spring.convention.spring-sample-boot'
apply plugin: "application"
apply from: IDE_GRADLE
repositories {
mavenCentral()
}
dependencies {
compile project(':spring-session-data-geode')
compile("org.springframework.boot:spring-boot-starter-thymeleaf") {
exclude group: "org.springframework.boot", module: "spring-boot-starter-logging"
}
compile("org.springframework.boot:spring-boot-starter-web") {
exclude group: "org.springframework.boot", module: "spring-boot-starter-logging"
}
compile "org.springframework.data:spring-data-geode-test"
compile "org.webjars:bootstrap"
compile "org.webjars:webjars-locator"
runtime "org.springframework.shell:spring-shell"
testCompile("org.springframework.boot:spring-boot-starter-test") {
exclude group: "org.springframework.boot", module: "spring-boot-starter-logging"
}
testCompile seleniumDependencies
integrationTestCompile seleniumDependencies
integrationTestRuntime "org.springframework.shell:spring-shell"
}
mainClassName = 'sample.client.Application'
bootJar {
mainClassName = 'sample.client.Application'
}
run {
doFirst {
mainClassName = 'sample.server.GemFireServer'
}
}
task runGemFireServer() {
doLast {
ext.port = reservePort()
println "Starting Apache Geode Server on port [$port] ..."
def out = new StringBuilder()
def err = new StringBuilder()
String classpath = project.sourceSets.main.runtimeClasspath.collect { it }.join(File.pathSeparator)
String[] commandLine = [
'java', '-server', '-ea', '-classpath', classpath,
//"-Dgemfire.log-file=gemfire-server.log",
//"-Dgemfire.log-level=config",
"-Dspring.data.gemfire.cache.server.port=$port",
'sample.server.GemFireServer'
]
//println commandLine
ext.process = commandLine.execute()
//ext.process = new ProcessBuilder().command(commandLine).redirectErrorStream(true).start();
ext.process.consumeProcessOutput(out, err)
//println 'OUT: ' + out
//println 'ERR: ' + err
}
}
integrationTest {
dependsOn runGemFireServer
doFirst {
def port = reservePort()
systemProperties['management.port'] = 0
systemProperties['server.port'] = port
//systemProperties['gemfire.log-file'] = "gemfire-client.log"
//systemProperties['gemfire.log-level'] = "config"
systemProperties['spring.data.gemfire.cache.server.port'] = runGemFireServer.port
}
doLast {
println 'Stopping Apache Geode Server...'
runGemFireServer.process?.destroy()
// runGemFireServer.process?.destroyForcibly()
}
}
def reservePort() {
def socket = new ServerSocket(0)
def result = socket.localPort
socket.close()
result
}