com.squareup.okhttp.mockwebserver.MockWebServer.shutdown()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中com.squareup.okhttp.mockwebserver.MockWebServer.shutdown()方法的一些代码示例,展示了MockWebServer.shutdown()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MockWebServer.shutdown()方法的具体详情如下:
包路径:com.squareup.okhttp.mockwebserver.MockWebServer
类名称:MockWebServer
方法名:shutdown

MockWebServer.shutdown介绍

暂无

代码示例

代码示例来源:origin: google/data-transfer-project

@After
 public void tearDown() throws Exception {
  server.shutdown();
 }
}

代码示例来源:origin: google/data-transfer-project

@After
 public void tearDown() throws Exception {
  server.shutdown();
 }
}

代码示例来源:origin: google/data-transfer-project

@After
 public void tearDown() throws Exception {
  server.shutdown();
 }
}

代码示例来源:origin: facebook/stetho

@Test
public void testWithResponseCompression() throws IOException {
 ByteArrayOutputStream capturedOutput = hookAlmostRealInterpretResponseStream(mMockEventReporter);
 byte[] uncompressedData = repeat(".", 1024).getBytes();
 byte[] compressedData = compress(uncompressedData);
 MockWebServer server = new MockWebServer();
 server.start();
 server.enqueue(new MockResponse()
   .setBody(new Buffer().write(compressedData))
   .addHeader("Content-Encoding: gzip"));
 Request request = new Request.Builder()
   .url(server.url("/"))
   .build();
 Response response = mClientWithInterceptor.newCall(request).execute();
 // Verify that the final output and the caller both saw the uncompressed stream.
 assertArrayEquals(uncompressedData, response.body().bytes());
 assertArrayEquals(uncompressedData, capturedOutput.toByteArray());
 // And verify that the StethoInterceptor was able to see both.
 Mockito.verify(mMockEventReporter)
   .dataReceived(
     anyString(),
     eq(compressedData.length),
     eq(uncompressedData.length));
 server.shutdown();
}

代码示例来源:origin: facebook/stetho

eq(compressed.length));
server.shutdown();

代码示例来源:origin: com.squareup.okhttp/mockwebserver

@Override public void evaluate() throws Throwable {
  maybeStart();
  try {
   base.evaluate();
  } finally {
   try {
    shutdown();
   } catch (IOException e) {
    logger.log(Level.WARNING, "MockWebServer shutdown failed", e);
   }
  }
 }
};

代码示例来源:origin: appnexus/mobile-sdk-android

@After
public void tearDown() {
  try {
    server.shutdown();
    bgScheduler.reset();
    uiScheduler.reset();
  } catch (IOException e) {
    e.printStackTrace();
  }
  activity.finish();
}

代码示例来源:origin: appnexus/mobile-sdk-android

@After
public void tearDown() {
  try {
    server.shutdown();
    bgScheduler.reset();
    uiScheduler.reset();
  } catch (IOException e) {
    e.printStackTrace();
  }
  activity.finish();
}

代码示例来源:origin: apache/jclouds

public void testEmptyListNetworks() throws Exception {
 MockWebServer server = mockWebServer(new MockResponse().setResponseCode(404));
 NetworkApi api = getNetworkApi(server);
 try {
   assertTrue(api.listNetworks().isEmpty());
   assertSent(server, "GET", "/SoftLayer_Network/getAllObjects?objectMask=mask.subnets");
 } finally {
   server.shutdown();
 }
}

代码示例来源:origin: cfg4j/cfg4j

@Test
void getConfigurationThrowsAfterFailedReload() throws Exception {
 server.shutdown();
 try {
  source.getConfiguration(new ImmutableEnvironment("us-west-2"));
 } catch (Exception e) {
  // NOP
 }
 assertThatThrownBy(() -> source.getConfiguration(new ImmutableEnvironment("")))
   .isExactlyInstanceOf(SourceCommunicationException.class);
}

代码示例来源:origin: apache/jclouds

public void testGetNullNetwork() throws Exception {
 MockWebServer server = mockWebServer(new MockResponse().setResponseCode(404));
 NetworkApi api = getNetworkApi(server);
 try {
   assertNull(api.getNetwork(153001));
   assertSent(server, "GET", "/SoftLayer_Network/153001/getObject?objectMask=mask.subnets");
 } finally {
   server.shutdown();
 }
}

代码示例来源:origin: apache/jclouds

public void testSetTagsOnNonExistingVirtualGuest() throws Exception {
 MockWebServer server = mockWebServer(new MockResponse().setResponseCode(404));
 VirtualGuestApi api = api(SoftLayerApi.class, server.getUrl("/").toString()).getVirtualGuestApi();
 VirtualGuest virtualGuest = createVirtualGuest();
 try {
   assertFalse(api.setTags(virtualGuest.getId(), ImmutableSet.of("test1", "test2", "test3")));
   assertSent(server, "POST", "/SoftLayer_Virtual_Guest/1301396/setTags");
 } finally {
   server.shutdown();
 }
}

代码示例来源:origin: apache/jclouds

public void testGetName() throws Exception {
 MockWebServer server = mockWebServer(new MockResponse().setBody("testNet"));
 NetworkApi api = getNetworkApi(server);
 String name = api.getName(153001);
 try {
   assertEquals(server.getRequestCount(), 1);
   assertSent(server, "GET", "/SoftLayer_Network/153001/getName");
 } finally {
   server.shutdown();
 }
}

代码示例来源:origin: apache/jclouds

public void testRestartContainer() throws Exception {
 MockWebServer server = mockWebServer(new MockResponse().setResponseCode(204));
 ContainerApi api = api(DockerApi.class, server.getUrl("/").toString()).getContainerApi();
 try {
   api.restart("1");
   assertSent(server, "POST", "/containers/1/restart");
 } finally {
   server.shutdown();
 }
}

代码示例来源:origin: cfg4j/cfg4j

@Test
void initThrowsOnConnectionFailure() throws Exception {
 server.shutdown();
 source = new ConsulConfigurationSourceBuilder()
   .withHost(server.getHostName())
   .withPort(server.getPort())
   .build();
 assertThatThrownBy(() -> source.init())
   .isExactlyInstanceOf(SourceCommunicationException.class);
}

代码示例来源:origin: apache/jclouds

public void testGetObject() throws Exception {
 MockWebServer server = mockWebServer(new MockResponse().setBody(payloadFromResource("/virtual_guest_block_device_template_group_get.json")));
 VirtualGuestBlockDeviceTemplateGroupApi api = getVirtualGuestBlockDeviceTemplateGroupApi(server);
 try {
   assertEquals(api.getObject("3001812"), new VirtualGuestBlockDeviceTemplateGroupParseTest().expected());
   assertSent(server, "GET", "/SoftLayer_Virtual_Guest_Block_Device_Template_Group/3001812/getObject?objectMask=children.blockDevices.diskImage.softwareReferences.softwareDescription");
 } finally {
   server.shutdown();
 }
}

代码示例来源:origin: apache/jclouds

public void testCopyFileFromContainer() throws Exception {
 MockWebServer server = mockWebServer(new MockResponse().setResponseCode(204));
 ContainerApi api = api(DockerApi.class, server.getUrl("/").toString()).getContainerApi();
 try {
   api.copy("1", Resource.create("test"));
   assertSent(server, "POST", "/containers/1/copy");
 } finally {
   server.shutdown();
 }
}

代码示例来源:origin: apache/jclouds

public void testGetVirtualGuest() throws Exception {
  MockWebServer server = mockWebServer(new MockResponse().setBody(payloadFromResource("/virtual_guest_get.json")));
  VirtualGuestApi api = getVirtualGuestApi(server);
  try {
   assertEquals(api.getVirtualGuest(3001812), new VirtualGuestParseTest().expected());
   assertSent(server, "GET", "/SoftLayer_Virtual_Guest/3001812/getObject?objectMask=id%3Bhostname%3Bdomain%3BfullyQualifiedDomainName%3BpowerState%3BmaxCpu%3BmaxMemory%3BstatusId%3BoperatingSystem.passwords%3BprimaryBackendIpAddress%3BprimaryIpAddress%3BactiveTransactionCount%3BblockDevices.diskImage%3Bdatacenter%3BtagReferences%3BprivateNetworkOnlyFlag%3BsshKeys");
  } finally {
   server.shutdown();
  }
}

代码示例来源:origin: apache/jclouds

public void testRebootHardVirtualGuest() throws Exception {
 MockWebServer server = mockWebServer(new MockResponse().setBody(payloadFromResource("/datacenter_get.json")));
 VirtualGuestApi api = api(SoftLayerApi.class, server.getUrl("/").toString()).getVirtualGuestApi();
 try {
   api.rebootHardVirtualGuest(1301396);
   assertSent(server, "GET", "/SoftLayer_Virtual_Guest/1301396/rebootHard.json");
 } finally {
   server.shutdown();
 }
}

代码示例来源:origin: apache/jclouds

public void testPauseVirtualGuest() throws Exception {
 MockWebServer server = mockWebServer(new MockResponse().setBody(payloadFromResource("/datacenter_get.json")));
 VirtualGuestApi api = api(SoftLayerApi.class, server.getUrl("/").toString()).getVirtualGuestApi();
 try {
   api.pauseVirtualGuest(1301396);
   assertSent(server, "GET", "/SoftLayer_Virtual_Guest/1301396/pause.json");
 } finally {
   server.shutdown();
 }
}

相关文章