当前位置: 首页>>代码示例>>Java>>正文


Java HttpRequest类代码示例

本文整理汇总了Java中org.mockserver.model.HttpRequest的典型用法代码示例。如果您正苦于以下问题:Java HttpRequest类的具体用法?Java HttpRequest怎么用?Java HttpRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpRequest类属于org.mockserver.model包,在下文中一共展示了HttpRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSpans

import org.mockserver.model.HttpRequest; //导入依赖的package包/类
private List<Span> getSpans(int count) throws InterruptedException, IOException {
  HttpRequest v2traces = HttpRequest.request().withMethod("PUT").withPath("/v0.2/traces");
  // wait for server to deliver traces
  for (long expire = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(10); System.currentTimeMillis() < expire; Thread.sleep(200)) {
    HttpRequest[] requests = new MockServerClient("localhost", APM_PORT).retrieveRecordedRequests(v2traces);
    List<Span> spans = requestsToSpans(requests);
    if (spans.size() == count) {
      return spans;
    }
  }
  throw new AssertionError("Did not get " + count + " spans within 10 seconds");
}
 
开发者ID:chonton,项目名称:apm-client,代码行数:13,代码来源:HelloIT.java

示例2: verifications

import org.mockserver.model.HttpRequest; //导入依赖的package包/类
private void verifications() throws AssertionError {
  new MockServerClient("localhost", 7755)
  .verify(HttpRequest.request()
        .withMethod("PUT")
        .withPath("/v0.3/traces")
        .withHeaders(new Header("Content-Type", "application/msgpack")),
        VerificationTimes.exactly(1))
  .verify(HttpRequest.request()
        .withMethod("PUT")
        .withPath("/v0.2/traces")
        .withHeaders(new Header("Content-Type", "application/json")),
        VerificationTimes.exactly(1));
}
 
开发者ID:chonton,项目名称:apm-client,代码行数:14,代码来源:WriterTest.java

示例3: startServer

import org.mockserver.model.HttpRequest; //导入依赖的package包/类
private void startServer() {
  mockServer = ClientAndServer.startClientAndServer(7755);

  MockServerClient client = new MockServerClient("localhost", 7755)
    .reset();

  client.when(HttpRequest.request()
        .withMethod("PUT")
        .withPath("/v0.3/traces")
        .withHeaders(new Header("Content-Type", "application/msgpack")),
        Times.exactly(1), TimeToLive.exactly(TimeUnit.MINUTES, 1l))
    .respond(HttpResponse.response()
        .withStatusCode(200)
        .withHeaders(new Header("Content-Type", "text/plain"))
        .withBody("OK\n")
    );
}
 
开发者ID:chonton,项目名称:apm-client,代码行数:18,代码来源:WriterBackoffTest.java

示例4: emulateV0_2

import org.mockserver.model.HttpRequest; //导入依赖的package包/类
@Before
public void emulateV0_2() {
  MockServerClient client = new MockServerClient("localhost", APM_PORT).reset();

  client.when(
      HttpRequest.request()
          .withMethod("PUT")
          .withPath("/v0.3/traces"), Times.unlimited(), TimeToLive.exactly(TimeUnit.MINUTES, 1l))
      .respond(HttpResponse.response()
          .withStatusCode(404)
          .withHeaders(new Header("Content-Type", "text/plain")));

  client.when(
      HttpRequest.request()
          .withMethod("PUT")
          .withPath("/v0.2/traces"), Times.unlimited(), TimeToLive.exactly(TimeUnit.MINUTES, 1l))
      .respond(HttpResponse.response()
          .withStatusCode(200)
          .withHeaders(new Header("Content-Type", "text/plain"))
          .withBody("OK\n").withDelay(new Delay(TimeUnit.MILLISECONDS, 20)));
}
 
开发者ID:chonton,项目名称:apm-client,代码行数:22,代码来源:HelloIT.java

示例5: emulateV0_2

import org.mockserver.model.HttpRequest; //导入依赖的package包/类
@Before
public void emulateV0_2() {
  MockServerClient client = new MockServerClient("localhost", APM_PORT)
    .reset();

  client
    .when(HttpRequest.request().withMethod("PUT").withPath("/v0.3/traces"),
        Times.unlimited(), TimeToLive.exactly(TimeUnit.MINUTES, 1l))
    .respond(HttpResponse.response().withStatusCode(404)
      .withHeaders(new Header("Content-Type", "text/plain"))
  );

  client
    .when(HttpRequest.request().withMethod("PUT").withPath("/v0.2/traces"),
      Times.unlimited(), TimeToLive.exactly(TimeUnit.MINUTES, 1l))
    .respond(HttpResponse.response().withStatusCode(200)
      .withHeaders(new Header("Content-Type", "text/plain")).withBody("OK\n")
      .withDelay(new Delay(TimeUnit.MILLISECONDS, 20)));
}
 
开发者ID:chonton,项目名称:apm-client,代码行数:20,代码来源:HelloIT.java

示例6: verifications

import org.mockserver.model.HttpRequest; //导入依赖的package包/类
private void verifications() throws AssertionError {
  new MockServerClient("localhost", 7755)
  .verify(HttpRequest.request()
        .withMethod("PUT")
        .withPath("/v0.3/traces")
        .withHeaders(new Header("Content-Type", "application/msgpack")),
        VerificationTimes.exactly(1));
}
 
开发者ID:chonton,项目名称:apm-client,代码行数:9,代码来源:WriterBackoffTest.java

示例7: emailUser

import org.mockserver.model.HttpRequest; //导入依赖的package包/类
private void emailUser(MockServerClient mockServerClient) {

        mockServerClient.
        dumpToLog().
        when(
            HttpRequest.request()
            .withMethod("POST")
            .withCookie(Cookie.cookie("session", "0a1bc2a7-11ef-4781-9c06-8d9b42719797"))
            .withCookie(Cookie.cookie("username", "jdoe"))
            .withPath("/user/email")
            .withBody("{\"name\":\"John Doe\"}"),
            Times.unlimited()
        ).respond(
            HttpResponse.response()
            .withStatusCode(200)
            
        );        
    }
 
开发者ID:kenzanlabs,项目名称:bowtie,代码行数:19,代码来源:MockServerInitializationClass.java

示例8: mutateUser

import org.mockserver.model.HttpRequest; //导入依赖的package包/类
private void mutateUser(MockServerClient mockServerClient) {

    mockServerClient.
    dumpToLog().
    when(
        HttpRequest.request()
        .withMethod("PUT")
        .withCookie(Cookie.cookie("session", "aa8a2e85-412e-46a2-889f-b2c133a59c89"))
        .withPath("/user")
        .withBody("{\"name\":\"John Doe\"}"),
        Times.unlimited()
    ).respond(
        HttpResponse.response()
        .withStatusCode(200)
        
    );        
}
 
开发者ID:kenzanlabs,项目名称:bowtie,代码行数:18,代码来源:MockServerInitializationClass.java

示例9: getUsers

import org.mockserver.model.HttpRequest; //导入依赖的package包/类
private void getUsers(MockServerClient mockServerClient) {

        mockServerClient
        .dumpToLog()
        .when(
            HttpRequest.request()
            .withMethod("GET")
            .withPath("/user")
            .withHeader(Header.header("X-SESSION-ID", "020835c7-cf7e-4ba5-b117-4402e5d79079"))
            .withQueryStringParameter(Parameter.param("byUsername", "jdoe")),
            Times.unlimited()
        ).respond(
            HttpResponse.response()
            .withStatusCode(200)
            .withBody("{ \"users\" : [{ \"name\" : \"John Doe\" }] }")
        );
    }
 
开发者ID:kenzanlabs,项目名称:bowtie,代码行数:18,代码来源:MockServerInitializationClass.java

示例10: getUser

import org.mockserver.model.HttpRequest; //导入依赖的package包/类
private void getUser(MockServerClient mockServerClient) {

        mockServerClient
        .dumpToLog()
        .when(
            HttpRequest.request()
            .withMethod("GET")
            .withHeader(Header.header("X-SESSION-ID", "55892d6d-77df-4617-b728-6f5de97f5752"))
            .withPath("/user/jdoe"),
            Times.unlimited()
        ).respond(
            HttpResponse.response()
            .withStatusCode(200)
            .withBody("{ \"name\" : \"John Doe\" }")
        );
    }
 
开发者ID:kenzanlabs,项目名称:bowtie,代码行数:17,代码来源:MockServerInitializationClass.java

示例11: getCachedUser

import org.mockserver.model.HttpRequest; //导入依赖的package包/类
private void getCachedUser(MockServerClient mockServerClient) {

        mockServerClient
        .dumpToLog()
        .when(
            HttpRequest.request()
            .withMethod("GET")
            .withHeader(Header.header("X-SESSION-ID", "55892d6d-77df-4617-b728-6f5de97f5752"))
            .withPath("/user/bdoe"),
            Times.unlimited()
        ).respond(
            HttpResponse.response()
            .withStatusCode(200)
            .withHeader(Header.header("Cache-Control","no-transform,public,max-age=300,s-maxage=900"))
            .withBody("{ \"name\" : \"Bob Doe\" }")
        );
    }
 
开发者ID:kenzanlabs,项目名称:bowtie,代码行数:18,代码来源:MockServerInitializationClass.java

示例12: getUserAddress

import org.mockserver.model.HttpRequest; //导入依赖的package包/类
private void getUserAddress(MockServerClient mockServerClient) {

        mockServerClient
        .dumpToLog()
        .when(
            HttpRequest.request()
            .withMethod("GET")
            .withHeader(Header.header("Cache-Control", "no-cache"))
            .withPath("/user/address/jdoe"),
            Times.unlimited()
        ).respond(
            HttpResponse.response()
            .withStatusCode(200)
            .withBody("{ \"address\" : \"1060 W Addison St, Chicago, IL 60613\" }")
        );
    }
 
开发者ID:kenzanlabs,项目名称:bowtie,代码行数:17,代码来源:MockServerInitializationClass.java

示例13: getRoleUsers

import org.mockserver.model.HttpRequest; //导入依赖的package包/类
private void getRoleUsers(MockServerClient mockServerClient) {

    mockServerClient
    .dumpToLog()
    .when(
        HttpRequest.request()
        .withMethod("GET")
        .withPath("/user/role")
        .withQueryStringParameter(Parameter.param("byRole", "vanessa")),
        Times.unlimited()
    ).respond(
        HttpResponse.response()
        .withStatusCode(200)
        .withBody("{ \"users\" : [] }")
    );
}
 
开发者ID:kenzanlabs,项目名称:bowtie,代码行数:17,代码来源:MockServerInitializationClass.java

示例14: testEnableAuth

import org.mockserver.model.HttpRequest; //导入依赖的package包/类
@Test
public void testEnableAuth() throws Exception {
  VaultConfiguration conf = VaultConfigurationBuilder.newVaultConfiguration()
      .withAddress(address)
      .withToken(token)
      .build();

  new MockServerClient(localhost, mockServerRule.getPort())
      .when(
      HttpRequest.request()
          .withMethod("POST")
          .withHeader(tokenHeader)
          .withPath("/v1/sys/auth/app-id")
          .withBody("{\"type\":\"app-id\"}"),
      Times.exactly(1)
  )
  .respond(
      HttpResponse.response()
          .withStatusCode(HttpStatusCode.NO_CONTENT_204.code())
          .withHeader(contentJson)
  );

  VaultClient vault = new VaultClient(conf);
  assertTrue(vault.sys().auth().enable("app-id", "app-id"));
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:26,代码来源:TestAuth.java

示例15: shouldSendPostRequestOnJsonFormat

import org.mockserver.model.HttpRequest; //导入依赖的package包/类
@Test
public void shouldSendPostRequestOnJsonFormat() {
	mockServerClient = new MockServerClient("localhost", 7081);

	HttpRequest httpRequest = request()
		.withMethod("POST")
		.withPath("/json")
		.withHeader("Content-Type", "application/json; charset=UTF-8")
		.withBody(json("{\"name\":\"Tiago de Freitas Lima\",\"age\":31}"));

	mockServerClient
		.when(httpRequest)
		.respond(response()
			.withStatusCode(201)
			.withHeader("Content-Type", "text/plain")
			.withBody(exact("OK")));

	myApi.json(new MyModel("Tiago de Freitas Lima", 31));

	mockServerClient.verify(httpRequest, once());
}
 
开发者ID:ljtfreitas,项目名称:java-restify,代码行数:22,代码来源:ZookeeperServiceDiscoveryTest.java


注:本文中的org.mockserver.model.HttpRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。