java类okhttp3.mockwebserver.QueueDispatcher的实例源码

DigdagClientTest.java 文件源码 项目:digdag 阅读 20 收藏 0 点赞 0 评论 0
@Test
public void getLogFileFailsAfter10Attempts()
        throws Exception
{
    QueueDispatcher dispatcher = new QueueDispatcher();
    dispatcher.setFailFast(new MockResponse().setResponseCode(500));
    mockWebServer.setDispatcher(dispatcher);

    try {
        client.getLogFile(Id.of("17"), RestLogFileHandle.builder()
                .agentId("test-agent")
                .fileName("test-task-1.log")
                .fileSize(4711)
                .fileTime(Instant.now().truncatedTo(SECONDS))
                .taskName("test-task-1")
                .build());
        fail();
    }
    catch (InternalServerErrorException ignore) {
    }

    assertThat(mockWebServer.getRequestCount(), is(10));
}
MockWebServerPlusTest.java 文件源码 项目:mockwebserverplus 阅读 17 收藏 0 点赞 0 评论 0
@Test public void enqueueSocketPolicy() throws IOException {
  server.enqueue(SocketPolicy.KEEP_OPEN);
  QueueDispatcher dispatcher = new QueueDispatcher();
  server.setDispatcher(dispatcher);

  MockResponse mockResponse = dispatcher.peek();

  assertThat(mockResponse.getSocketPolicy()).isEqualTo(SocketPolicy.KEEP_OPEN);
}
MockWebServerPlusTest.java 文件源码 项目:mockwebserverplus 阅读 20 收藏 0 点赞 0 评论 0
@Test public void interceptDispatch() throws InterruptedException, IOException {
  Dispatcher dispatcher = spy(new QueueDispatcher());
  server.setDispatcher(dispatcher);
  server.enqueue(new MockResponse());

  execute();

  verify(dispatcher).dispatch(any(RecordedRequest.class));
}
SlaIT.java 文件源码 项目:digdag 阅读 21 收藏 0 点赞 0 评论 0
@Test
public void verifyAlertIsRetried()
        throws Exception
{
    mockWebServer.setDispatcher(new QueueDispatcher());
    mockWebServer.enqueue(new MockResponse().setResponseCode(500).setBody("FAIL"));
    mockWebServer.enqueue(new MockResponse().setResponseCode(200));
    Id attemptId = pushAndStart("duration_alert_enabled.dig", Duration.ofSeconds(5));
    RecordedRequest recordedRequest1 = mockWebServer.takeRequest(30, TimeUnit.SECONDS);
    RecordedRequest recordedRequest2 = mockWebServer.takeRequest(30, TimeUnit.SECONDS);
    verifyNotification(attemptId, recordedRequest1);
    verifyNotification(attemptId, recordedRequest2);
}
HttpIT.java 文件源码 项目:digdag 阅读 21 收藏 0 点赞 0 评论 0
@Test
public void testForEach()
        throws Exception
{
    String uri = "http://localhost:" + httpMockWebServer.getPort() + "/";
    httpMockWebServer.setDispatcher(new QueueDispatcher());
    String content = DigdagClient.objectMapper().writeValueAsString(
            ImmutableList.of("foo", "bar", "baz"));
    httpMockWebServer.enqueue(new MockResponse().setBody(content));
    runWorkflow(folder, "acceptance/http/http_for_each.dig", ImmutableMap.of("test_uri", uri));
    assertThat(httpMockWebServer.getRequestCount(), is(1));
}
BaseLogicTest.java 文件源码 项目:mockstar 阅读 19 收藏 0 点赞 0 评论 0
protected MockWebServer getErrorMockWebServer() {
    mockWebServer.setDispatcher(new QueueDispatcher());
    return mockWebServer;
}
WebServerBuilder.java 文件源码 项目:datacollector 阅读 17 收藏 0 点赞 0 评论 0
public WebServerBuilder() {
  server = new MockWebServer();
  QueueDispatcher dispatcher = new QueueDispatcher();
  dispatcher.setFailFast(new MockResponse().setResponseCode(400));
  server.setDispatcher(dispatcher);
}


问题


面经


文章

微信
公众号

扫码关注公众号