Update tests to play nice with latest version
This commit is contained in:
parent
6b98564d30
commit
6f4ff22af2
|
@ -32,23 +32,23 @@ class VertxRxCircuitBreakerWebClientTest extends HttpClientTest<NettyHttpClientD
|
||||||
int doRequest(String method, URI uri, Map<String, String> headers, Closure callback) {
|
int doRequest(String method, URI uri, Map<String, String> headers, Closure callback) {
|
||||||
def request = client.request(HttpMethod.valueOf(method), uri.port, uri.host, "$uri")
|
def request = client.request(HttpMethod.valueOf(method), uri.port, uri.host, "$uri")
|
||||||
headers.each { request.putHeader(it.key, it.value) }
|
headers.each { request.putHeader(it.key, it.value) }
|
||||||
Future<HttpResponse> result = breaker.execute { command ->
|
|
||||||
|
def future = new CompletableFuture<Integer>()
|
||||||
|
|
||||||
|
Future<HttpResponse> result = breaker.executeCommand({ command ->
|
||||||
request.rxSend().doOnSuccess {
|
request.rxSend().doOnSuccess {
|
||||||
command.complete(it)
|
command.complete(it)
|
||||||
}.doOnError {
|
}.doOnError {
|
||||||
command.fail(it)
|
command.fail(it)
|
||||||
}.subscribe()
|
}.subscribe()
|
||||||
}
|
}, {
|
||||||
|
|
||||||
def future = new CompletableFuture<Integer>()
|
|
||||||
result.setHandler {
|
|
||||||
callback?.call()
|
callback?.call()
|
||||||
if (it.succeeded()) {
|
if (it.succeeded()) {
|
||||||
future.complete(it.result().statusCode())
|
future.complete(it.result().statusCode())
|
||||||
} else {
|
} else {
|
||||||
future.completeExceptionally(it.cause())
|
future.completeExceptionally(it.cause())
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
return future.get()
|
return future.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,9 @@ class VertxRxCircuitBreakerHttpServerTest extends VertxHttpServerTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
router.route(SUCCESS.path).handler { ctx ->
|
router.route(SUCCESS.path).handler { ctx ->
|
||||||
def result = breaker.execute { future ->
|
def result = breaker.executeCommand({ future ->
|
||||||
future.complete(SUCCESS)
|
future.complete(SUCCESS)
|
||||||
}
|
}, { it ->
|
||||||
result.setHandler {
|
|
||||||
if (it.failed()) {
|
if (it.failed()) {
|
||||||
throw it.cause()
|
throw it.cause()
|
||||||
}
|
}
|
||||||
|
@ -44,13 +43,12 @@ class VertxRxCircuitBreakerHttpServerTest extends VertxHttpServerTest {
|
||||||
controller(endpoint) {
|
controller(endpoint) {
|
||||||
ctx.response().setStatusCode(endpoint.status).end(endpoint.body)
|
ctx.response().setStatusCode(endpoint.status).end(endpoint.body)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
router.route(REDIRECT.path).handler { ctx ->
|
router.route(REDIRECT.path).handler { ctx ->
|
||||||
def result = breaker.execute { future ->
|
def result = breaker.executeCommand({ future ->
|
||||||
future.complete(REDIRECT)
|
future.complete(REDIRECT)
|
||||||
}
|
}, {
|
||||||
result.setHandler {
|
|
||||||
if (it.failed()) {
|
if (it.failed()) {
|
||||||
throw it.cause()
|
throw it.cause()
|
||||||
}
|
}
|
||||||
|
@ -58,13 +56,12 @@ class VertxRxCircuitBreakerHttpServerTest extends VertxHttpServerTest {
|
||||||
controller(endpoint) {
|
controller(endpoint) {
|
||||||
ctx.response().setStatusCode(endpoint.status).putHeader("location", endpoint.body).end()
|
ctx.response().setStatusCode(endpoint.status).putHeader("location", endpoint.body).end()
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
router.route(ERROR.path).handler { ctx ->
|
router.route(ERROR.path).handler { ctx ->
|
||||||
def result = breaker.execute { future ->
|
def result = breaker.executeCommand({ future ->
|
||||||
future.complete(ERROR)
|
future.complete(ERROR)
|
||||||
}
|
}, {
|
||||||
result.setHandler {
|
|
||||||
if (it.failed()) {
|
if (it.failed()) {
|
||||||
throw it.cause()
|
throw it.cause()
|
||||||
}
|
}
|
||||||
|
@ -72,13 +69,12 @@ class VertxRxCircuitBreakerHttpServerTest extends VertxHttpServerTest {
|
||||||
controller(endpoint) {
|
controller(endpoint) {
|
||||||
ctx.response().setStatusCode(endpoint.status).end(endpoint.body)
|
ctx.response().setStatusCode(endpoint.status).end(endpoint.body)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
router.route(EXCEPTION.path).handler { ctx ->
|
router.route(EXCEPTION.path).handler { ctx ->
|
||||||
def result = breaker.execute { future ->
|
def result = breaker.executeCommand({ future ->
|
||||||
future.fail(new Exception(EXCEPTION.body))
|
future.fail(new Exception(EXCEPTION.body))
|
||||||
}
|
}, {
|
||||||
result.setHandler {
|
|
||||||
try {
|
try {
|
||||||
def cause = it.cause()
|
def cause = it.cause()
|
||||||
controller(EXCEPTION) {
|
controller(EXCEPTION) {
|
||||||
|
@ -87,7 +83,7 @@ class VertxRxCircuitBreakerHttpServerTest extends VertxHttpServerTest {
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ctx.response().setStatusCode(EXCEPTION.status).end(ex.message)
|
ctx.response().setStatusCode(EXCEPTION.status).end(ex.message)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
super.@vertx.createHttpServer()
|
super.@vertx.createHttpServer()
|
||||||
|
|
Loading…
Reference in New Issue