Package com.google.mockwebserver

Examples of com.google.mockwebserver.MockWebServer.enqueue()


  }

  @Test public void retriesLostConnectionBeforeRead() throws IOException, InterruptedException {
    MockWebServer server = new MockWebServer();
    server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.DISCONNECT_AT_START));
    server.enqueue(new MockResponse().setBody("success!".getBytes(UTF_8)));
    server.play();

    try {
      TestInterface api = Feign.create(TestInterface.class, "http://localhost:" + server.getPort(),
          new TestInterface.Module());
View Full Code Here


    }
  }

  public void overrideTypeSpecificDecoder() throws IOException, InterruptedException {
    MockWebServer server = new MockWebServer();
    server.enqueue(new MockResponse().setBody("success!".getBytes(UTF_8)));
    server.play();

    try {
      TestInterface api = Feign.create(TestInterface.class, "http://localhost:" + server.getPort(),
          new DecodeFail());
View Full Code Here

  /**
   * when you must parse a 2xx status to determine if the operation succeeded or not.
   */
  public void retryableExceptionInDecoder() throws IOException, InterruptedException {
    MockWebServer server = new MockWebServer();
    server.enqueue(new MockResponse().setBody("retry!".getBytes(UTF_8)));
    server.enqueue(new MockResponse().setBody("success!".getBytes(UTF_8)));
    server.play();

    try {
      TestInterface api = Feign.create(TestInterface.class, "http://localhost:" + server.getPort(),
View Full Code Here

   * when you must parse a 2xx status to determine if the operation succeeded or not.
   */
  public void retryableExceptionInDecoder() throws IOException, InterruptedException {
    MockWebServer server = new MockWebServer();
    server.enqueue(new MockResponse().setBody("retry!".getBytes(UTF_8)));
    server.enqueue(new MockResponse().setBody("success!".getBytes(UTF_8)));
    server.play();

    try {
      TestInterface api = Feign.create(TestInterface.class, "http://localhost:" + server.getPort(),
          new RetryableExceptionOnRetry());
View Full Code Here

  }

  @Test(expectedExceptions = FeignException.class, expectedExceptionsMessageRegExp = "error reading response POST http://.*")
  public void doesntRetryAfterResponseIsSent() throws IOException, InterruptedException {
    MockWebServer server = new MockWebServer();
    server.enqueue(new MockResponse().setBody("success!".getBytes(UTF_8)));
    server.play();

    try {
      TestInterface api = Feign.create(TestInterface.class, "http://localhost:" + server.getPort(),
          new IOEOnDecode());
View Full Code Here

  }

  @Test public void canOverrideSSLSocketFactory() throws IOException, InterruptedException {
    MockWebServer server = new MockWebServer();
    server.useHttps(TrustingSSLSocketFactory.get("localhost"), false);
    server.enqueue(new MockResponse().setBody("success!".getBytes(UTF_8)));
    server.play();

    try {
      TestInterface api = Feign.create(TestInterface.class, "https://localhost:" + server.getPort(),
          new TrustSSLSockets());
View Full Code Here

  }

  @Test public void canOverrideHostnameVerifier() throws IOException, InterruptedException {
    MockWebServer server = new MockWebServer();
    server.useHttps(TrustingSSLSocketFactory.get("bad.example.com"), false);
    server.enqueue(new MockResponse().setBody("success!".getBytes(UTF_8)));
    server.play();

    try {
      TestInterface api = Feign.create(TestInterface.class, "https://localhost:" + server.getPort(),
          new DisableHostnameVerification());
View Full Code Here

  }

  @Test public void retriesFailedHandshake() throws IOException, InterruptedException {
    MockWebServer server = new MockWebServer();
    server.useHttps(TrustingSSLSocketFactory.get("localhost"), false);
    server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.FAIL_HANDSHAKE));
    server.enqueue(new MockResponse().setBody("success!".getBytes(UTF_8)));
    server.play();

    try {
      TestInterface api = Feign.create(TestInterface.class, "https://localhost:" + server.getPort(),
View Full Code Here

  @Test public void retriesFailedHandshake() throws IOException, InterruptedException {
    MockWebServer server = new MockWebServer();
    server.useHttps(TrustingSSLSocketFactory.get("localhost"), false);
    server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.FAIL_HANDSHAKE));
    server.enqueue(new MockResponse().setBody("success!".getBytes(UTF_8)));
    server.play();

    try {
      TestInterface api = Feign.create(TestInterface.class, "https://localhost:" + server.getPort(),
          new TestInterface.Module(), new TrustSSLSockets());
View Full Code Here

  }

  @Test public void decodeLogicSupportsByteArray() throws Exception {
    byte[] expectedResponse = {12, 34, 56};
    final MockWebServer server = new MockWebServer();
    server.enqueue(new MockResponse().setBody(expectedResponse));
    server.play();

    try {
      OtherTestInterface api = Feign.builder().target(OtherTestInterface.class, "http://localhost:" + server.getPort());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.