Package com.google.mockwebserver

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


   @Test(expectedExceptions = JobStillRunningException.class, expectedExceptionsMessageRegExp = "This session already has a job running")
   public void test200OnFailureThrowsExceptionWithoutRetryWhenJobRunning() throws IOException, InterruptedException {
      MockWebServer server = new MockWebServer();
      server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(session));
      server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(running));
      server.play();

      DynTrafficApi api = mockDynectApi(server.getUrl("/").toString());

      try {
         api.getZoneApi().list();
View Full Code Here


   public void test200OnFailureThrowsExceptionWithoutRetryWhenOperationBlocked() throws IOException,
         InterruptedException {
      MockWebServer server = new MockWebServer();
      server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(session));
      server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(taskBlocking));
      server.play();

      DynTrafficApi api = mockDynectApi(server.getUrl("/").toString());

      try {
         api.getZoneApi().list();
View Full Code Here

   @Test(expectedExceptions = TargetExistsException.class, expectedExceptionsMessageRegExp = "Name already exists")
   public void test200OnFailureThrowsExceptionWithoutRetryOnNameExists() throws IOException, InterruptedException {
      MockWebServer server = new MockWebServer();
      server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(session));
      server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(targetExists));
      server.play();

      DynTrafficApi api = mockDynectApi(server.getUrl("/").toString());

      try {
         api.getZoneApi().list();
View Full Code Here

    @Ignore("[FABRIC-1092] Fix Docker API tests")
    public void testImageDelete() throws IOException {
        String json = Resources.toString(getResource("image/image-delete.json"), Charsets.UTF_8);
        MockWebServer server = new MockWebServer();
        server.enqueue(new MockResponse().setBody(json));
        server.play();
        List<DeleteInfo> info = docker.imageDelete("b750fe79269d");
        assertNotNull(info);
        assertEquals(info.size(), 3);
    }
View Full Code Here

  }

  @Test public void testDefaults() throws Exception {
    MockWebServer server = new MockWebServer();
    server.enqueue(new MockResponse().setBody("response data"));
    server.play();

    String url = "http://localhost:" + server.getPort();
    try {
      TestInterface api = Feign.builder().target(TestInterface.class, url);
      Response response = api.codecPost("request data");
View Full Code Here

  }

  @Test public void testOverrideEncoder() throws Exception {
    MockWebServer server = new MockWebServer();
    server.enqueue(new MockResponse().setBody("response data"));
    server.play();

    String url = "http://localhost:" + server.getPort();
    Encoder encoder = new Encoder() {
      @Override
      public void encode(Object object, RequestTemplate template) throws EncodeException {
View Full Code Here

  }

  @Test public void testOverrideDecoder() throws Exception {
    MockWebServer server = new MockWebServer();
    server.enqueue(new MockResponse().setBody("success!"));
    server.play();

    String url = "http://localhost:" + server.getPort();
    Decoder decoder = new Decoder() {
      @Override
      public Object decode(Response response, Type type) {
View Full Code Here

  }

  @Test public void testProvideRequestInterceptors() throws Exception {
    MockWebServer server = new MockWebServer();
    server.enqueue(new MockResponse().setBody("response data"));
    server.play();

    String url = "http://localhost:" + server.getPort();
    RequestInterceptor requestInterceptor = new RequestInterceptor() {
      @Override
      public void apply(RequestTemplate template) {
View Full Code Here

  }

  @Test public void testProvideInvocationHandlerFactory() throws Exception {
    MockWebServer server = new MockWebServer();
    server.enqueue(new MockResponse().setBody("response data"));
    server.play();

    String url = "http://localhost:" + server.getPort();

    final AtomicInteger callCount = new AtomicInteger();
    InvocationHandlerFactory factory = new InvocationHandlerFactory() {
View Full Code Here

  @Test(dataProvider = "levelToOutput")
  public void levelEmits(final Logger.Level logLevel, List<String> expectedMessages) throws IOException, InterruptedException {
    final MockWebServer server = new MockWebServer();
    server.enqueue(new MockResponse().setBody("foo"));
    server.play();

    try {
      SendsStuff api = Feign.create(SendsStuff.class, "http://localhost:" + server.getUrl("").getPort(),
          new DefaultModule(logger, logLevel));
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.