Package com.google.mockwebserver

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


      fail();
    } catch (FeignException e) {

      assertMessagesMatch(expectedMessages);

      assertEquals(new String(server.takeRequest().getBody(), UTF_8),
          "{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"}");
    } finally {
      server.shutdown();
    }
  }
View Full Code Here


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

      api.queryParams("user", Arrays.asList("apple", "pear"));
      assertEquals(server.takeRequest().getRequestLine(), "GET /?1=user&2=apple&2=pear HTTP/1.1");
    } finally {
      server.shutdown();
    }
  }
View Full Code Here

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

      api.login("netflix", "denominator", "password");
      assertEquals(new String(server.takeRequest().getBody(), UTF_8),
          "{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"}");
    } finally {
      server.shutdown();
    }
  }
View Full Code Here

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

      api.form("netflix", "denominator", "password");
      assertEquals(new String(server.takeRequest().getBody(), UTF_8),
          "customer_name=netflix,user_name=denominator,password=password");
    } finally {
      server.shutdown();
    }
  }
View Full Code Here

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

      api.body(Arrays.asList("netflix", "denominator", "password"));
      RecordedRequest request = server.takeRequest();
      assertEquals(request.getHeader("Content-Length"), "32");
      assertEquals(new String(request.getBody(), UTF_8), "[netflix, denominator, password]");
    } finally {
      server.shutdown();
    }
View Full Code Here

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

      api.gzipBody(Arrays.asList("netflix", "denominator", "password"));
      RecordedRequest request = server.takeRequest();
      assertNull(request.getHeader("Content-Length"));
      byte[] compressedBody = request.getBody();
      String uncompressedBody = CharStreams.toString(CharStreams.newReaderSupplier(
          GZIPStreams.newInputStreamSupplier(ByteStreams.newInputStreamSupplier(compressedBody)), UTF_8));
      assertEquals(uncompressedBody, "[netflix, denominator, password]");
View Full Code Here

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

      api.post();
      assertEquals(server.takeRequest().getHeader("X-Forwarded-For"), "origin.host.com");
    } finally {
      server.shutdown();
    }
  }
View Full Code Here

    try {
      TestInterface api = Feign.create(TestInterface.class, "http://localhost:" + server.getPort(),
          new TestInterface.Module(), new ForwardedForInterceptor(), new UserAgentInterceptor());

      api.post();
      RecordedRequest request = server.takeRequest();
      assertEquals(request.getHeader("X-Forwarded-For"), "origin.host.com");
      assertEquals(request.getHeader("User-Agent"), "Feign");
    } finally {
      server.shutdown();
    }
View Full Code Here

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

      api.binaryRequestBody(expectedRequest);
      byte[] actualRequest = server.takeRequest().getBody();
      assertEquals(actualRequest, expectedRequest);
    } finally {
      server.shutdown();
    }
  }
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.