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) {
|
||||
def request = client.request(HttpMethod.valueOf(method), uri.port, uri.host, "$uri")
|
||||
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 {
|
||||
command.complete(it)
|
||||
}.doOnError {
|
||||
command.fail(it)
|
||||
}.subscribe()
|
||||
}
|
||||
|
||||
def future = new CompletableFuture<Integer>()
|
||||
result.setHandler {
|
||||
}, {
|
||||
callback?.call()
|
||||
if (it.succeeded()) {
|
||||
future.complete(it.result().statusCode())
|
||||
} else {
|
||||
future.completeExceptionally(it.cause())
|
||||
}
|
||||
}
|
||||
})
|
||||
return future.get()
|
||||
}
|
||||
|
||||
|
|
|
@ -33,10 +33,9 @@ class VertxRxCircuitBreakerHttpServerTest extends VertxHttpServerTest {
|
|||
)
|
||||
|
||||
router.route(SUCCESS.path).handler { ctx ->
|
||||
def result = breaker.execute { future ->
|
||||
def result = breaker.executeCommand({ future ->
|
||||
future.complete(SUCCESS)
|
||||
}
|
||||
result.setHandler {
|
||||
}, { it ->
|
||||
if (it.failed()) {
|
||||
throw it.cause()
|
||||
}
|
||||
|
@ -44,13 +43,12 @@ class VertxRxCircuitBreakerHttpServerTest extends VertxHttpServerTest {
|
|||
controller(endpoint) {
|
||||
ctx.response().setStatusCode(endpoint.status).end(endpoint.body)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
router.route(REDIRECT.path).handler { ctx ->
|
||||
def result = breaker.execute { future ->
|
||||
def result = breaker.executeCommand({ future ->
|
||||
future.complete(REDIRECT)
|
||||
}
|
||||
result.setHandler {
|
||||
}, {
|
||||
if (it.failed()) {
|
||||
throw it.cause()
|
||||
}
|
||||
|
@ -58,13 +56,12 @@ class VertxRxCircuitBreakerHttpServerTest extends VertxHttpServerTest {
|
|||
controller(endpoint) {
|
||||
ctx.response().setStatusCode(endpoint.status).putHeader("location", endpoint.body).end()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
router.route(ERROR.path).handler { ctx ->
|
||||
def result = breaker.execute { future ->
|
||||
def result = breaker.executeCommand({ future ->
|
||||
future.complete(ERROR)
|
||||
}
|
||||
result.setHandler {
|
||||
}, {
|
||||
if (it.failed()) {
|
||||
throw it.cause()
|
||||
}
|
||||
|
@ -72,13 +69,12 @@ class VertxRxCircuitBreakerHttpServerTest extends VertxHttpServerTest {
|
|||
controller(endpoint) {
|
||||
ctx.response().setStatusCode(endpoint.status).end(endpoint.body)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
router.route(EXCEPTION.path).handler { ctx ->
|
||||
def result = breaker.execute { future ->
|
||||
def result = breaker.executeCommand({ future ->
|
||||
future.fail(new Exception(EXCEPTION.body))
|
||||
}
|
||||
result.setHandler {
|
||||
}, {
|
||||
try {
|
||||
def cause = it.cause()
|
||||
controller(EXCEPTION) {
|
||||
|
@ -87,7 +83,7 @@ class VertxRxCircuitBreakerHttpServerTest extends VertxHttpServerTest {
|
|||
} catch (Exception ex) {
|
||||
ctx.response().setStatusCode(EXCEPTION.status).end(ex.message)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
super.@vertx.createHttpServer()
|
||||
|
|
Loading…
Reference in New Issue