Skip to content

Instantly share code, notes, and snippets.

Created April 30, 2016 03:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
import ratpack.exec.Promise
import ratpack.handling.Context
import ratpack.groovy.test.embed.GroovyEmbeddedApp
@GrabResolver(name = 'jcenter', root = '')
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