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

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

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

MockWebServer.<init>介绍

暂无

代码示例

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

@Before
public void setUp() {
 client = new OkHttpClient.Builder().build();
 mapper = new ObjectMapper();
 transformerService = new TransformerServiceImpl();
 token = new TokensAndUrlAuthData("token123", "refreshToken", "tokenUrl");
 server = new MockWebServer();
}

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

@Before
public void setUp() {
 client = new OkHttpClient.Builder().build();
 mapper = new ObjectMapper();
 token = new TokensAndUrlAuthData("token456", "refreshToken", "tokenUrl");
 server = new MockWebServer();
 jobStore = new MockJobStore();
}

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

@Before
public void setUp() {
 client = new OkHttpClient.Builder().build();
 mapper = new ObjectMapper();
 transformerService = new TransformerServiceImpl();
 token = new TokenAuthData("token456");
 server = new MockWebServer();
 jobStore = new MockJobStore();
}

代码示例来源: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

hookAlmostRealRequestWillBeSent(mMockEventReporter);
MockWebServer server = new MockWebServer();
server.start();
server.enqueue(new MockResponse()

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

@BeforeMethod
public void start() throws IOException {
 suffix.set(0);
 server = new MockWebServer();
 server.play();
}

代码示例来源:origin: cdancy/bitbucket-rest

/**
 * Create a MockWebServer.
 *
 * @return instance of MockWebServer
 * @throws IOException
 *             if unable to start/play server
 */
public static MockWebServer mockWebServer() throws IOException {
  final MockWebServer server = new MockWebServer();
  server.start();
  return server;
}

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

@BeforeMethod
public void start() throws IOException {
 tempAuthServer = new MockWebServer();
 tempAuthServer.play();
 swiftServer = new MockWebServer();
 swiftServer.play();
}

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

@BeforeMethod
public void start() throws IOException {
 MockWebServer server = new MockWebServer();
 server.play();
 regionToServers.put(DEFAULT_REGION, server);
}

代码示例来源:origin: cdancy/jenkins-rest

/**
 * Create a MockWebServer with an initial bread-crumb response.
 *
 * @return instance of MockWebServer
 * @throws IOException
 *             if unable to start/play server
 */
public static MockWebServer mockWebServer() throws IOException {
  final MockWebServer server = new MockWebServer();
  server.start();
  return server;
}

代码示例来源:origin: Karumi/MarvelApiClientAndroid

@Before public void setUp() throws Exception {
 System.setProperty("user.timezone", ANY_TIME_ZONE);
 MockitoAnnotations.initMocks(this);
 this.server = new MockWebServer();
 this.server.start();
}

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

private void runMockServer() throws IOException {
  server = new MockWebServer();
  server.setDispatcher(dispatcher);
  server.start(0);
 }
}

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

private void runMockServer() throws IOException {
  server = new MockWebServer();
  server.setDispatcher(dispatcher);
  server.start(0);
 }
}

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

static MockWebServer createMockWebServer() throws IOException {
 MockWebServer server = new MockWebServer();
 server.play();
 URL url = server.getUrl("");
 return server;
}

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

/**
* Creates a {@link MockWebServer} that uses the
* {@link GlobalChecksRequestDispatcher}.
*/
protected static MockWebServer mockWebServer(MockResponse... responses) throws IOException {
 MockWebServer server = new MockWebServer();
 server.play();
 for (MockResponse response : responses) {
   server.enqueue(response);
 }
 return server;
}

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

/**
* Creates a {@link MockWebServer} that uses the given {@link Dispatcher}.
*/
protected static MockWebServer mockWebServer(Dispatcher dispatcher) throws IOException {
 MockWebServer server = new MockWebServer();
 server.play();
 server.setDispatcher(dispatcher);
 return server;
}

代码示例来源:origin: openwalletGH/openwallet-android

@Before
public void setup() throws IOException {
  server = new MockWebServer();
  server.start();
  shapeShift = new ShapeShift();
  shapeShift.baseUrl = server.getUrl("/").toString();
  shapeShift.client.setConnectionSpecs(Collections.singletonList(ConnectionSpec.CLEARTEXT));
}

代码示例来源:origin: Coinomi/coinomi-android

@Before
public void setup() throws IOException {
  server = new MockWebServer();
  server.start();
  shapeShift = new ShapeShift();
  shapeShift.baseUrl = server.getUrl("/").toString();
  shapeShift.client.setConnectionSpecs(Collections.singletonList(ConnectionSpec.CLEARTEXT));
}

代码示例来源:origin: jclouds/jclouds-labs

@BeforeMethod
public void start() throws IOException {
 server = new MockWebServer();
 server.play();
 ctx = ContextBuilder.newBuilder(DimensionDataCloudControlProviderMetadata.builder().build()).credentials("", "")
    .endpoint(url("")).modules(modules).overrides(new Properties()).build();
 json = ctx.utils().injector().getInstance(Json.class);
 api = ctx.getApi();
 applyAdditionalServerConfig();
 assertedRequestCount = 0;
 datacenters = getZones();
}

代码示例来源:origin: plivo/plivo-java

@Before
public void setUp() throws Exception {
 server = new MockWebServer();
 server.start();
 PlivoClient.BASE_URL = server.url("/").toString();
 Plivo.init(authId, authToken);
 Plivo.getClient().setTesting(true);
}

相关文章