use of reactivefeign.testcase.IcecreamServiceApi in project feign-reactive by kptfh.
the class DefaultMethodTest method shouldOverrideToString.
@Test
public void shouldOverrideToString() {
IcecreamServiceApi client = builder().target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
Assertions.assertThat(client.toString()).isEqualTo("HardCodedTarget(type=IcecreamServiceApi, " + "url=http://localhost:" + wireMockRule.port() + ")");
}
use of reactivefeign.testcase.IcecreamServiceApi in project feign-reactive by kptfh.
the class ReadTimeoutTest method shouldFailOnReadTimeout.
@Test
public void shouldFailOnReadTimeout() {
String orderUrl = "/icecream/orders/1";
wireMockRule.stubFor(get(urlEqualTo(orderUrl)).withHeader("Accept", equalTo("application/json")).willReturn(aResponse().withFixedDelay(200)));
IcecreamServiceApi client = builder(new ReactiveOptions.Builder().setConnectTimeoutMillis(300).setReadTimeoutMillis(100).build()).target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
StepVerifier.create(client.findOrder(1)).expectError(ReadTimeoutException.class).verify();
}
use of reactivefeign.testcase.IcecreamServiceApi in project feign-reactive by kptfh.
the class RetryingTest method shouldFailAsNoMoreRetries.
@Test
public void shouldFailAsNoMoreRetries() {
String orderUrl = "/icecream/orders/1";
wireMockRule.stubFor(get(urlEqualTo(orderUrl)).withHeader("Accept", equalTo("application/json")).willReturn(aResponse().withStatus(503).withHeader(RETRY_AFTER, "1")));
IcecreamServiceApi client = builder().retryWhen(ReactiveRetryers.retry(3)).target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
StepVerifier.create(client.findOrder(1)).expectErrorMatches(throwable -> throwable instanceof RetryPublisherHttpClient.OutOfRetriesException && hasProperty("cause", isA(RetryableException.class)).matches(throwable)).verify();
}
use of reactivefeign.testcase.IcecreamServiceApi in project feign-reactive by kptfh.
the class RetryingTest method shouldSuccessOnRetriesFlux.
@Test
public void shouldSuccessOnRetriesFlux() throws JsonProcessingException {
String mixinsStr = TestUtils.MAPPER.writeValueAsString(Mixin.values());
mockResponseAfterSeveralAttempts(wireMockRule, 2, "testRetrying_success", "/icecream/mixins", aResponse().withStatus(SC_SERVICE_UNAVAILABLE).withHeader(RETRY_AFTER, "1"), aResponse().withStatus(SC_OK).withHeader("Content-Type", "application/json").withBody(mixinsStr));
IcecreamServiceApi client = builder().retryWhen(ReactiveRetryers.retryWithBackoff(3, 0)).target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
StepVerifier.create(client.getAvailableMixins()).expectNextSequence(Arrays.asList(Mixin.values())).verifyComplete();
}
use of reactivefeign.testcase.IcecreamServiceApi in project feign-reactive by kptfh.
the class RetryingTest method shouldFailAsNoMoreRetriesWithBackoff.
@Test
public void shouldFailAsNoMoreRetriesWithBackoff() {
String orderUrl = "/icecream/orders/1";
wireMockRule.stubFor(get(urlEqualTo(orderUrl)).withHeader("Accept", equalTo("application/json")).willReturn(aResponse().withStatus(503).withHeader(RETRY_AFTER, "1")));
IcecreamServiceApi client = builder().retryWhen(ReactiveRetryers.retryWithBackoff(7, 5)).target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
StepVerifier.create(client.findOrder(1)).expectErrorMatches(throwable -> throwable instanceof RetryPublisherHttpClient.OutOfRetriesException && hasProperty("cause", isA(RetryableException.class)).matches(throwable)).verify();
}
Aggregations