Search in sources :

Example 16 with IcecreamServiceApi

use of reactivefeign.testcase.IcecreamServiceApi in project feign-reactive by kptfh.

the class ConnectionTimeoutTest method shouldFailOnConnectionTimeout.

// TODO investigate why doesn't work on codecov.io but works locally
@Ignore
@Test
public void shouldFailOnConnectionTimeout() {
    expectedException.expectCause(Matchers.any(ConnectException.class));
    IcecreamServiceApi client = builder(new ReactiveOptions.Builder().setConnectTimeoutMillis(300).setReadTimeoutMillis(100).build()).target(IcecreamServiceApi.class, "http://localhost:" + port);
    client.findOrder(1).block();
}
Also used : IcecreamServiceApi(reactivefeign.testcase.IcecreamServiceApi) ConnectException(java.net.ConnectException)

Example 17 with IcecreamServiceApi

use of reactivefeign.testcase.IcecreamServiceApi in project feign-reactive by kptfh.

the class DefaultMethodTest method shouldOverrideHashcode.

@Test
public void shouldOverrideHashcode() {
    IcecreamServiceApi client = builder().target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
    IcecreamServiceApi otherClientWithSameTarget = builder().target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
    Assertions.assertThat(client.hashCode()).isEqualTo(otherClientWithSameTarget.hashCode());
}
Also used : IcecreamServiceApi(reactivefeign.testcase.IcecreamServiceApi) Test(org.junit.Test)

Example 18 with IcecreamServiceApi

use of reactivefeign.testcase.IcecreamServiceApi in project feign-reactive by kptfh.

the class DefaultMethodTest method shouldProcessDefaultMethodOnProxy.

@Test
public void shouldProcessDefaultMethodOnProxy() throws JsonProcessingException {
    IceCreamOrder orderGenerated = new OrderGenerator().generate(1);
    String orderStr = TestUtils.MAPPER.writeValueAsString(orderGenerated);
    wireMockRule.stubFor(get(urlEqualTo("/icecream/orders/1")).withHeader("Accept", equalTo("application/json")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(orderStr)));
    IcecreamServiceApi client = builder().target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
    StepVerifier.create(client.findFirstOrder()).expectNextMatches(equalsComparingFieldByFieldRecursively(orderGenerated)).verifyComplete();
}
Also used : IcecreamServiceApi(reactivefeign.testcase.IcecreamServiceApi) IceCreamOrder(reactivefeign.testcase.domain.IceCreamOrder) OrderGenerator(reactivefeign.testcase.domain.OrderGenerator) Test(org.junit.Test)

Example 19 with IcecreamServiceApi

use of reactivefeign.testcase.IcecreamServiceApi in project feign-reactive by kptfh.

the class NotFoundTest method shouldReturnEmptyMono.

@Test
public void shouldReturnEmptyMono() {
    String orderUrl = "/icecream/orders/2";
    wireMockRule.stubFor(get(urlEqualTo(orderUrl)).withHeader("Accept", equalTo("application/json")).willReturn(aResponse().withStatus(HttpStatus.SC_NOT_FOUND)));
    IcecreamServiceApi client = builder().decode404().target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
    StepVerifier.create(client.findOrder(2)).expectNextCount(0).verifyComplete();
}
Also used : IcecreamServiceApi(reactivefeign.testcase.IcecreamServiceApi) Test(org.junit.Test)

Example 20 with IcecreamServiceApi

use of reactivefeign.testcase.IcecreamServiceApi in project feign-reactive by kptfh.

the class RetryingTest method shouldSuccessOnRetriesWoRetryAfter.

@Test
public void shouldSuccessOnRetriesWoRetryAfter() throws JsonProcessingException {
    IceCreamOrder orderGenerated = new OrderGenerator().generate(1);
    String orderStr = TestUtils.MAPPER.writeValueAsString(orderGenerated);
    mockResponseAfterSeveralAttempts(wireMockRule, 2, "testRetrying_success", "/icecream/orders/1", aResponse().withStatus(SC_SERVICE_UNAVAILABLE), aResponse().withStatus(SC_OK).withHeader("Content-Type", "application/json").withBody(orderStr));
    IcecreamServiceApi client = builder().retryWhen(ReactiveRetryers.retryWithBackoff(3, 0)).target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
    StepVerifier.create(client.findOrder(1)).expectNextMatches(equalsComparingFieldByFieldRecursively(orderGenerated)).verifyComplete();
}
Also used : IcecreamServiceApi(reactivefeign.testcase.IcecreamServiceApi) IceCreamOrder(reactivefeign.testcase.domain.IceCreamOrder) OrderGenerator(reactivefeign.testcase.domain.OrderGenerator) Test(org.junit.Test)

Aggregations

IcecreamServiceApi (reactivefeign.testcase.IcecreamServiceApi)22 Test (org.junit.Test)21 IceCreamOrder (reactivefeign.testcase.domain.IceCreamOrder)12 OrderGenerator (reactivefeign.testcase.domain.OrderGenerator)12 WireMockConfiguration.wireMockConfig (com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig)6 WireMockClassRule (com.github.tomakehurst.wiremock.junit.WireMockClassRule)6 Before (org.junit.Before)6 ClassRule (org.junit.ClassRule)6 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)5 WireMock (com.github.tomakehurst.wiremock.client.WireMock)4 RetryableException (feign.RetryableException)4 StepVerifier (reactor.test.StepVerifier)4 TestUtils.equalsComparingFieldByFieldRecursively (reactivefeign.TestUtils.equalsComparingFieldByFieldRecursively)3 ResponseDefinitionBuilder (com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder)2 WireMock.aResponse (com.github.tomakehurst.wiremock.client.WireMock.aResponse)2 WireMock.equalTo (com.github.tomakehurst.wiremock.client.WireMock.equalTo)2 WireMock.get (com.github.tomakehurst.wiremock.client.WireMock.get)2 WireMock.urlEqualTo (com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo)2 STARTED (com.github.tomakehurst.wiremock.stubbing.Scenario.STARTED)2 Arrays (java.util.Arrays)2