Search in sources :

Example 1 with feign

use of feign in project feign by OpenFeign.

the class HystrixBuilderTest method errorInFallbackHasExpectedBehavior.

@Test
public void errorInFallbackHasExpectedBehavior() {
    thrown.expect(HystrixRuntimeException.class);
    thrown.expectMessage("GitHub#contributors(String,String) failed and fallback failed.");
    thrown.expectCause(// as opposed to RuntimeException (from the fallback)
    isA(FeignException.class));
    server.enqueue(new MockResponse().setResponseCode(500));
    final GitHub fallback = (owner, repo) -> {
        throw new RuntimeException("oops");
    };
    final GitHub api = target(GitHub.class, "http://localhost:" + server.getPort(), fallback);
    api.contributors("Netflix", "feign");
}
Also used : Completable(rx.Completable) HystrixCommandGroupKey(com.netflix.hystrix.HystrixCommandGroupKey) java.util(java.util) java.util.concurrent(java.util.concurrent) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) HystrixRuntimeException(com.netflix.hystrix.exception.HystrixRuntimeException) HardCodedTarget(feign.Target.HardCodedTarget) Observable(rx.Observable) Is.isA(org.hamcrest.core.Is.isA) HystrixCommand(com.netflix.hystrix.HystrixCommand) Single(rx.Single) Rule(org.junit.Rule) TestSubscriber(rx.observers.TestSubscriber) MockWebServer(okhttp3.mockwebserver.MockWebServer) Assertions(org.assertj.core.api.Assertions) GsonDecoder(feign.gson.GsonDecoder) MockResponse(okhttp3.mockwebserver.MockResponse) ExpectedException(org.junit.rules.ExpectedException) feign(feign) MockResponse(okhttp3.mockwebserver.MockResponse) HystrixRuntimeException(com.netflix.hystrix.exception.HystrixRuntimeException) Test(org.junit.Test)

Aggregations

HystrixCommand (com.netflix.hystrix.HystrixCommand)1 HystrixCommandGroupKey (com.netflix.hystrix.HystrixCommandGroupKey)1 HystrixRuntimeException (com.netflix.hystrix.exception.HystrixRuntimeException)1 feign (feign)1 HardCodedTarget (feign.Target.HardCodedTarget)1 GsonDecoder (feign.gson.GsonDecoder)1 java.util (java.util)1 java.util.concurrent (java.util.concurrent)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 MockWebServer (okhttp3.mockwebserver.MockWebServer)1 Assertions (org.assertj.core.api.Assertions)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Is.isA (org.hamcrest.core.Is.isA)1 Rule (org.junit.Rule)1 Test (org.junit.Test)1 ExpectedException (org.junit.rules.ExpectedException)1 Completable (rx.Completable)1 Observable (rx.Observable)1 Single (rx.Single)1 TestSubscriber (rx.observers.TestSubscriber)1