Created
April 30, 2016 03:42
-
-
Save tednaleid/cb3a46e598f78ddaabd17da4af881ea8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ratpack.exec.Promise | |
import ratpack.handling.Context | |
import ratpack.groovy.test.embed.GroovyEmbeddedApp | |
@GrabResolver(name = 'jcenter', root = 'http://jcenter.bintray.com/') | |
@GrabExclude('org.codehaus.groovy:groovy-all') | |
@Grab('org.slf4j:slf4j-simple:1.7.12') | |
@Grab('io.ratpack:ratpack-groovy:1.3.3') | |
@Grab('io.ratpack:ratpack-rx:1.3.3') | |
@Grab('io.ratpack:ratpack-groovy-test:1.3.3') | |
GroovyEmbeddedApp app = GroovyEmbeddedApp.of { | |
handlers { | |
all { Context context -> | |
println "A. Original compute thread: ${Thread.currentThread().name}" | |
Promise.async { downstream -> | |
println "B. Promise thread : ${Thread.currentThread().name}" | |
downstream.success("hello from async promise") | |
}.then { result -> | |
context.render result | |
} | |
println "C. Original compute thread: ${Thread.currentThread().name}" | |
} | |
} | |
}.test { | |
assert getText() == "hello from async promise" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment