Package feign

Examples of feign.Response


      options = new Request.Options(configOverride.get(CommonClientConfigKey.ConnectTimeout, connectTimeout),
          (configOverride.get(CommonClientConfigKey.ReadTimeout, readTimeout)));
    } else {
      options = new Request.Options(connectTimeout, readTimeout);
    }
    Response response = delegate.execute(request.toRequest(), options);
    return new RibbonResponse(request.getUri(), response);
  }
View Full Code Here


public class DefaultDecoderTest {
  private final Decoder decoder = new Decoder.Default();

  @Test public void testDecodesToString() throws Exception {
    Response response = knownResponse();
    Object decodedObject = decoder.decode(response, String.class);
    assertEquals(decodedObject.getClass(), String.class);
    assertEquals(decodedObject.toString(), "response body");
  }
View Full Code Here

    assertEquals(decodedObject.getClass(), String.class);
    assertEquals(decodedObject.toString(), "response body");
  }

  @Test public void testDecodesToByteArray() throws Exception {
    Response response = knownResponse();
    Object decodedObject = decoder.decode(response, byte[].class);
    assertEquals(decodedObject.getClass(), byte[].class);
    assertEquals((byte[]) decodedObject, "response body".getBytes(UTF_8));
  }
View Full Code Here

public class DefaultErrorDecoderTest {
  ErrorDecoder errorDecoder = new ErrorDecoder.Default();

  @Test(expectedExceptions = FeignException.class, expectedExceptionsMessageRegExp = "status 500 reading Service#foo\\(\\)")
  public void throwsFeignException() throws Throwable {
    Response response = Response.create(500, "Internal server error", ImmutableMap.<String, Collection<String>>of(),
        null);

    throw errorDecoder.decode("Service#foo()", response);
  }
View Full Code Here

    throw errorDecoder.decode("Service#foo()", response);
  }

  @Test(expectedExceptions = FeignException.class, expectedExceptionsMessageRegExp = "status 500 reading Service#foo\\(\\); content:\nhello world")
  public void throwsFeignExceptionIncludingBody() throws Throwable {
    Response response = Response.create(500, "Internal server error", ImmutableMap.<String, Collection<String>>of(),
        "hello world", UTF_8);

    throw errorDecoder.decode("Service#foo()", response);
  }
View Full Code Here

    throw errorDecoder.decode("Service#foo()", response);
  }

  @Test(expectedExceptions = RetryableException.class, expectedExceptionsMessageRegExp = "status 503 reading Service#foo\\(\\)")
  public void retryAfterHeaderThrowsRetryableException() throws Throwable {
    Response response = Response.create(503, "Service Unavailable",
        ImmutableMultimap.of(RETRY_AFTER, "Sat, 1 Jan 2000 00:00:00 GMT").asMap(), null);

    throw errorDecoder.decode("Service#foo()", response);
  }
View Full Code Here

    List<Zone> zones = new LinkedList<Zone>();
    zones.add(new Zone("denominator.io."));
    zones.add(new Zone("denominator.io.", "ABCD"));

    Response response =
        Response.create(200, "OK", Collections.<String, Collection<String>>emptyMap(), zonesJson, UTF_8);
    assertEquals(bindings.decoder.decode(response, new TypeToken<List<Zone>>() {
    }.getType()), zones);
  }
View Full Code Here

  @Test public void nullBodyDecodesToNull() throws Exception {
    DecoderBindings bindings = new DecoderBindings();
    ObjectGraph.create(bindings).inject(bindings);

    Response response = Response.create(204, "OK", Collections.<String, Collection<String>>emptyMap(), null);
    assertEquals(bindings.decoder.decode(response, String.class), null);
  }
View Full Code Here

    List<Zone> zones = new LinkedList<Zone>();
    zones.add(new Zone("DENOMINATOR.IO."));
    zones.add(new Zone("DENOMINATOR.IO.", "ABCD"));

    Response response =
        Response.create(200, "OK", Collections.<String, Collection<String>>emptyMap(), zonesJson, UTF_8);
    assertEquals(bindings.decoder.decode(response, new TypeToken<List<Zone>>() {
    }.getType()), zones);
  }
View Full Code Here

    List<Zone> zones = new LinkedList<Zone>();
    zones.add(new Zone("denominator.io."));
    zones.add(new Zone("denominator.io.", "ABCD"));

    Response response =
        Response.create(200, "OK", Collections.<String, Collection<String>>emptyMap(), zonesJson, UTF_8);
    assertEquals(bindings.decoder.decode(response, new TypeToken<List<Zone>>() {
    }.getType()), zones);
  }
View Full Code Here

TOP

Related Classes of feign.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.