Created
November 24, 2015 11:20
-
-
Save patrykorwat/89152914626c127abd64 to your computer and use it in GitHub Desktop.
HttpClientResponse freeze
This file contains hidden or 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
package eu.ydp.esa.tts.controller.impl; | |
import com.github.tomakehurst.wiremock.junit.WireMockRule; | |
import io.vertx.rxjava.core.Vertx; | |
import io.vertx.rxjava.core.http.HttpClientRequest; | |
import io.vertx.rxjava.core.http.HttpClientResponse; | |
import org.junit.Rule; | |
import org.junit.Test; | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.TimeUnit; | |
import static com.github.tomakehurst.wiremock.client.WireMock.*; | |
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; | |
import static org.assertj.core.api.Assertions.assertThat; | |
public class HttpClientResponseFreeze { | |
@Rule | |
public WireMockRule mockServer = new WireMockRule(12344); | |
public CountDownLatch latch = new CountDownLatch(1); | |
@Test | |
public void testVertx() throws Exception { | |
Vertx vertx = Vertx.vertx(); | |
stubFor(post(urlPathEqualTo("/test")) | |
.willReturn(aResponse() | |
.withStatus(500))); | |
HttpClientRequest httpClientRequest = vertx.createHttpClient() | |
.postAbs("http://localhost:12344/test"); | |
httpClientRequest | |
.toObservable() | |
.flatMap(HttpClientResponse::toObservable) | |
.subscribe(v -> { | |
latch.countDown(); | |
}); | |
httpClientRequest.end(); | |
latch.await(5, TimeUnit.SECONDS); | |
assertThat(latch.getCount()).isEqualTo(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment