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


Java ClientAndServer.startClientAndServer方法代码示例

本文整理汇总了Java中org.mockserver.integration.ClientAndServer.startClientAndServer方法的典型用法代码示例。如果您正苦于以下问题:Java ClientAndServer.startClientAndServer方法的具体用法?Java ClientAndServer.startClientAndServer怎么用?Java ClientAndServer.startClientAndServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mockserver.integration.ClientAndServer的用法示例。


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

示例1: startServer

import org.mockserver.integration.ClientAndServer; //导入方法依赖的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

示例2: getCollaborators_validRepoId_successful

import org.mockserver.integration.ClientAndServer; //导入方法依赖的package包/类
@Test
public void getCollaborators_validRepoId_successful() throws IOException {
    MockServerClient mockServer = ClientAndServer.startClientAndServer(8888);
    String sampleCollaborators = TestUtils.readFileFromResource(this, "tests/CollaboratorsSample.json");

    mockServer.when(
            request()
                .withPath(TestUtils.API_PREFIX + "/repos/hubturbo/tests/collaborators")
    ).respond(response().withBody(sampleCollaborators));

    Type listOfUsers = new TypeToken<List<User>>() {}.getType();
    List<User> expectedCollaborators = new Gson().fromJson(sampleCollaborators, listOfUsers);
    List<User> actualCollaborators = service.getCollaborators(RepositoryId.createFromId("hubturbo/tests"));

    assertEquals(expectedCollaborators.size(), actualCollaborators.size());

    for (int i = 0; i < expectedCollaborators.size(); i++) {
        assertEquals(expectedCollaborators.get(i).getLogin(), actualCollaborators.get(i).getLogin());
        assertEquals(expectedCollaborators.get(i).getName(), actualCollaborators.get(i).getName());
        assertEquals(true, actualCollaborators.get(i).getName() != null);
    }

    mockServer.stop();
}
 
开发者ID:HubTurbo,项目名称:HubTurbo,代码行数:25,代码来源:CollaboratorServiceExTests.java

示例3: startServer

import org.mockserver.integration.ClientAndServer; //导入方法依赖的package包/类
@Before
public void startServer() {
  mockServer = ClientAndServer.startClientAndServer(7755);

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

示例4: should_return_server_version

import org.mockserver.integration.ClientAndServer; //导入方法依赖的package包/类
@Test
public void should_return_server_version() throws Exception {
	// Make sure SSL works by adding MockServer CA certificate to context
	SSLSocketFactory previousFactory = HttpsURLConnection.getDefaultSSLSocketFactory();
	HttpsURLConnection.setDefaultSSLSocketFactory(SSLFactory.getInstance().sslContext().getSocketFactory());
	ClientAndServer mockServer = ClientAndServer.startClientAndServer(port);
	try {
		// Given: the server expects a request of its version
		mockServer
				.when(request().withMethod("POST").withPath("/xmlrpc/2/db")
						.withBody(new StringBody(
								"<?xml version=\"1.0\" encoding=\"UTF-8\"?><methodCall><methodName>server_version</methodName><params/></methodCall>")))
				.respond(response().withStatusCode(200).withBody(
						"<?xml version='1.0'?>\n<methodResponse>\n<params>\n<param>\n<value><string>9.0e</string></value>\n</param>\n</params>\n</methodResponse>\n"));

		// When: Server version is requested
		Version version = OdooXmlRpcProxy.getServerVersion(RPCProtocol.RPC_HTTPS, host, port);

		// Then: the server version is returned
		assertThat(version).as("Server version").isNotNull().hasToString("9.0e");
	} finally {
		mockServer.stop();
		HttpsURLConnection.setDefaultSSLSocketFactory(previousFactory);
	}

}
 
开发者ID:DeBortoliWines,项目名称:openerp-java-api,代码行数:27,代码来源:OdooXmlRpcProxyTest.java

示例5: startServer

import org.mockserver.integration.ClientAndServer; //导入方法依赖的package包/类
@BeforeClass
public static void startServer() throws Exception {
    int port = PortFactory.findFreePort();
    System.out.println("port is " + port);
    mockServer = ClientAndServer.startClientAndServer(port);
    baseUrl = "http://localhost:" + port;
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:8,代码来源:BaseMockServerTest.java

示例6: startProxy

import org.mockserver.integration.ClientAndServer; //导入方法依赖的package包/类
@BeforeClass
public static void startProxy() throws Exception {

  int port = PortFactory.findFreePort();
  clientAndProxy = startClientAndProxy(port);
  proxy = new HttpHost("localhost", port);
  // load truststore with MockServer CA
  sslContext = SSLContexts.custom().loadTrustMaterial(new File("src/test/resources/truststore.jks"), "changeit".toCharArray()).build();
  httpClientBuilder = HttpClients.custom().setSSLContext(sslContext);
  httpclient = httpClientBuilder.build();

  serverPort = PortFactory.findFreePort();
  clientAndServer = ClientAndServer.startClientAndServer(serverPort);
  clientAndServer.when(new HttpRequest().withMethod("GET")).respond(HttpResponse.response("OK"));
}
 
开发者ID:confluentinc,项目名称:support-metrics-common,代码行数:16,代码来源:WebClientProxyTest.java

示例7: testGetReviewComments

import org.mockserver.integration.ClientAndServer; //导入方法依赖的package包/类
/**
 * Tests that getReviewComments method correctly receives 1 page of review comments
 * returned from a MockServer that emulates GitHub API service.
 */
@Test
public void testGetReviewComments() throws IOException {
    MockServerClient mockServer = ClientAndServer.startClientAndServer(8888);
    String sampleComments = TestUtils.readFileFromResource(this, "tests/ReviewCommentsSample.json");

    mockServer.when(
            request()
                    .withPath(TestUtils.API_PREFIX + "/repos/hubturbo/hubturbo/pulls/1125/comments")
                    .withQueryStringParameters(
                            new Parameter("per_page", "100"),
                            new Parameter("page", "1")
                    )
    ).respond(response().withBody(sampleComments));

    GitHubClient client = new GitHubClient("localhost", 8888, "http");
    PullRequestServiceEx service = new PullRequestServiceEx(client);

    Type listOfComments = new TypeToken<List<ReviewComment>>() {
    }.getType();
    List<ReviewComment> expectedComments = new Gson().fromJson(sampleComments, listOfComments);
    List<ReviewComment> actualComments = service.getReviewComments(
            RepositoryId.createFromId("hubturbo/hubturbo"), 1125);

    assertEquals(expectedComments.size(), actualComments.size());

    Comparator<ReviewComment> comparator = (a, b) -> (int) (a.getId() - b.getId());
    Collections.sort(expectedComments, comparator);
    Collections.sort(actualComments, comparator);

    for (int i = 0; i < expectedComments.size(); i++) {
        assertEquals(expectedComments.get(i).getId(), actualComments.get(i).getId());
    }

    mockServer.stop();

}
 
开发者ID:HubTurbo,项目名称:HubTurbo,代码行数:41,代码来源:PullRequestServiceExTests.java

示例8: startProxy

import org.mockserver.integration.ClientAndServer; //导入方法依赖的package包/类
@BeforeClass
public static void startProxy() throws Exception {
	if (isUsingMockServer()) {
		previousFactory = HttpsURLConnection.getDefaultSSLSocketFactory();
		HttpsURLConnection.setDefaultSSLSocketFactory(SSLFactory.getInstance().sslContext().getSocketFactory());
		proxy = ClientAndProxy.startClientAndProxy(PortFactory.findFreePort());
		mockServer = ClientAndServer.startClientAndServer(MOCKSERVER_PORT);
	}
}
 
开发者ID:DeBortoliWines,项目名称:openerp-java-api,代码行数:10,代码来源:SessionTest.java

示例9: setUp

import org.mockserver.integration.ClientAndServer; //导入方法依赖的package包/类
@Before
public void setUp() {
    server = ClientAndServer.startClientAndServer();
    server
        .when(
            request()
                .withPath("/my/echo")
        )
        .respond(callback()
            .withCallbackClass("org.mockserver.integration.mocking.ConcurrencyBasicResponseMockingIntegrationTest$ClassCallback"));
    httpClient = new NettyHttpClient();
}
 
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:13,代码来源:ConcurrencyBasicResponseMockingIntegrationTest.java

示例10: startServer

import org.mockserver.integration.ClientAndServer; //导入方法依赖的package包/类
@BeforeClass
public static void startServer() {
  mockServer = ClientAndServer.startClientAndServer(7755);
}
 
开发者ID:chonton,项目名称:apm-client,代码行数:5,代码来源:WriterTest.java

示例11: beforeClass

import org.mockserver.integration.ClientAndServer; //导入方法依赖的package包/类
@BeforeClass
public void beforeClass() {
    mockServer = ClientAndServer.startClientAndServer(port);
}
 
开发者ID:AnomalyXII,项目名称:werewolv.es-tools,代码行数:5,代码来源:HttpRouterTest.java

示例12: startServer

import org.mockserver.integration.ClientAndServer; //导入方法依赖的package包/类
@Before
public void startServer() {
    server = ClientAndServer.startClientAndServer(PortFactory.findFreePort());
    serverUrl = "http://127.0.0.1:" + server.getPort();
}
 
开发者ID:RoboZonky,项目名称:robozonky,代码行数:6,代码来源:UpdateMonitorTest.java

示例13: startServer

import org.mockserver.integration.ClientAndServer; //导入方法依赖的package包/类
@Before
public void startServer() {
    server = ClientAndServer.startClientAndServer(PortFactory.findFreePort());
    serverUrl = "127.0.0.1:" + server.getPort();
}
 
开发者ID:RoboZonky,项目名称:robozonky,代码行数:6,代码来源:ZonkoidConfirmationProviderTest.java

示例14: start

import org.mockserver.integration.ClientAndServer; //导入方法依赖的package包/类
@BeforeClass
public void start() {
    int port = PortFactory.findFreePort();
    tokenEndpointUri = "https://localhost:" + port + "/oauth2/token";
    mockServer = ClientAndServer.startClientAndServer(port);
}
 
开发者ID:Scalepoint,项目名称:oauth-token-java-client,代码行数:7,代码来源:MockServerTestBase.java

示例15: setup

import org.mockserver.integration.ClientAndServer; //导入方法依赖的package包/类
@Before
public void setup() {
    mockServer = ClientAndServer.startClientAndServer(port);
}
 
开发者ID:Capoot,项目名称:build-status-traffic-light,代码行数:5,代码来源:SimpleHttpClientTest.java


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