本文整理汇总了Java中org.mockserver.verify.VerificationTimes类的典型用法代码示例。如果您正苦于以下问题:Java VerificationTimes类的具体用法?Java VerificationTimes怎么用?Java VerificationTimes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VerificationTimes类属于org.mockserver.verify包,在下文中一共展示了VerificationTimes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifications
import org.mockserver.verify.VerificationTimes; //导入依赖的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));
}
示例2: verifications
import org.mockserver.verify.VerificationTimes; //导入依赖的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));
}
示例3: shouldSuccessfulSendDatapoint
import org.mockserver.verify.VerificationTimes; //导入依赖的package包/类
@Test
public void shouldSuccessfulSendDatapoint() throws Exception {
Datapoint datapoint = new Datapoint("metric", timestamp, Collections.emptyMap(), 123);
MockedSources sources = new MockedSources();
// TODO: rather than use Topic.OTSDB, grab it from the TopologyConfig object (which does
// not exist at this point in the code.
sources.addMockData(Topic.OTSDB+"-spout",
new Values(MAPPER.writeValueAsString(datapoint)));
completeTopologyParam.setMockedSources(sources);
Testing.withTrackedCluster(clusterParam, (cluster) -> {
OpenTSDBTopology topology = new TestingTargetTopology(new TestingKafkaBolt());
StormTopology stormTopology = topology.createTopology();
Map result = Testing.completeTopology(cluster, stormTopology, completeTopologyParam);
});
//verify that request is sent to OpenTSDB server
mockServer.verify(HttpRequest.request(), VerificationTimes.exactly(1));
}
示例4: shouldSendDatapointRequestsOnlyOnce
import org.mockserver.verify.VerificationTimes; //导入依赖的package包/类
@Test
public void shouldSendDatapointRequestsOnlyOnce() throws Exception {
Datapoint datapoint = new Datapoint("metric", timestamp, Collections.emptyMap(), 123);
String jsonDatapoint = MAPPER.writeValueAsString(datapoint);
MockedSources sources = new MockedSources();
sources.addMockData(Topic.OTSDB+"-spout",
new Values(jsonDatapoint), new Values(jsonDatapoint));
completeTopologyParam.setMockedSources(sources);
Testing.withTrackedCluster(clusterParam, (cluster) -> {
OpenTSDBTopology topology = new TestingTargetTopology(new TestingKafkaBolt());
StormTopology stormTopology = topology.createTopology();
Testing.completeTopology(cluster, stormTopology, completeTopologyParam);
});
//verify that request is sent to OpenTSDB server once
mockServer.verify(HttpRequest.request(), VerificationTimes.exactly(1));
}
示例5: hostShouldNotBeAbleToRescheduleNonExistingGame
import org.mockserver.verify.VerificationTimes; //导入依赖的package包/类
@Test
@DirtiesContext
public void hostShouldNotBeAbleToRescheduleNonExistingGame() {
// given
final String hostName = testDataUtils.generateHostName();
final String proposedTime = testDataUtils.getProposedTimeInTenMinutes();
// expect private Slack message about unability of rescheduling the game
mockServerClient.when(requestUtils.getUnableToRescheduleGamePrivateMessageRequest()).respond(response().withStatusCode(200));
// when
slashCommandUtils.slashRescheduleCommand(hostName, proposedTime);
// then
mockServerClient.verify(requestUtils.getUnableToRescheduleGamePrivateMessageRequest(), VerificationTimes.exactly(1));
mockServerClient.verify(requestUtils.getInternalErrorPrivateMessageBodyRequest(), VerificationTimes.exactly(0));
}
示例6: hostShouldBeAbleToCancelTheirOwnGame
import org.mockserver.verify.VerificationTimes; //导入依赖的package包/类
@Test
@DirtiesContext
public void hostShouldBeAbleToCancelTheirOwnGame() {
// given
final String hostName = testDataUtils.generateHostName();
final String hostId = testDataUtils.generateUserId();
final String proposedTime = testDataUtils.getProposedTimeInTenMinutes();
createSingleGameExpectations(hostName, proposedTime);
// expect private Slack message about canceling newly created game
mockServerClient.when(requestUtils.getSuccessfullyCanceledGamePrivateMessageRequest()).respond(response().withStatusCode(200));
// expect channel Slack message about canceling newly created game
mockServerClient.when(requestUtils.getCreateGameCanceledChannelMessageRequest(hostName)).respond(response().withStatusCode(200));
slashCommandUtils.slashNewCommand(hostName, hostId, proposedTime);
// when
slashCommandUtils.slashCancelCommand(hostName);
// then
mockServerClient.verify(requestUtils.getCreateGameCanceledChannelMessageRequest(hostName), VerificationTimes.exactly(1));
mockServerClient.verify(requestUtils.getSuccessfullyCanceledGamePrivateMessageRequest(), VerificationTimes.exactly(1));
mockServerClient.verify(requestUtils.getInternalErrorPrivateMessageBodyRequest(), VerificationTimes.exactly(0));
}
示例7: hostShouldNotBeAbleToCancelOtherGame
import org.mockserver.verify.VerificationTimes; //导入依赖的package包/类
@Test
@DirtiesContext
public void hostShouldNotBeAbleToCancelOtherGame() {
// given
final String otherHostName = testDataUtils.generateHostName();
final String originalHostName = testDataUtils.generateHostName();
final String originalHostId = testDataUtils.generateUserId();
final String proposedTime = testDataUtils.getProposedTimeInTenMinutes();
createSingleGameExpectations(originalHostName, proposedTime);
// expect private Slack message about canceling newly created game
mockServerClient.when(requestUtils.getUnableToCancelGamePrivateMessageRequest()).respond(response().withStatusCode(200));
slashCommandUtils.slashNewCommand(originalHostName, originalHostId, proposedTime);
// when
slashCommandUtils.slashCancelCommand(otherHostName);
// then
mockServerClient.verify(requestUtils.getUnableToCancelGamePrivateMessageRequest(), VerificationTimes.exactly(1));
mockServerClient.verify(requestUtils.getInternalErrorPrivateMessageBodyRequest(), VerificationTimes.exactly(0));
}
示例8: hostShouldNotBeAbleToCancelNonExistingGame
import org.mockserver.verify.VerificationTimes; //导入依赖的package包/类
@Test
@DirtiesContext
public void hostShouldNotBeAbleToCancelNonExistingGame() {
// given
final String hostName = testDataUtils.generateHostName();
// expect private Slack message about unability newly created game
mockServerClient.when(requestUtils.getUnableToCancelGamePrivateMessageRequest()).respond(response().withStatusCode(200));
// when
slashCommandUtils.slashCancelCommand(hostName);
// then
mockServerClient.verify(requestUtils.getUnableToCancelGamePrivateMessageRequest(), VerificationTimes.exactly(1));
mockServerClient.verify(requestUtils.getInternalErrorPrivateMessageBodyRequest(), VerificationTimes.exactly(0));
}
示例9: userShouldNotJoinAnyGameImplicitlyWhenNoneExists
import org.mockserver.verify.VerificationTimes; //导入依赖的package包/类
@Test
@DirtiesContext
public void userShouldNotJoinAnyGameImplicitlyWhenNoneExists() {
// given
final String playerName = testDataUtils.generatePlayerName();
final String playerId = testDataUtils.generateUserId();
// expect private Slack message about no active games available
mockServerClient.when(requestUtils.getNoActiveGamesToJoinPrivateMessageRequest()).respond(response().withStatusCode(200));
// when
slashCommandUtils.slashIaminCommand(playerName, playerId, Optional.empty());
// then
mockServerClient.verify(requestUtils.getNoActiveGamesToJoinPrivateMessageRequest(), VerificationTimes.exactly(1));
mockServerClient.verify(requestUtils.getInternalErrorPrivateMessageBodyRequest(), VerificationTimes.exactly(0));
}
示例10: userShouldNotJoinAnyGameBySpecifyingHostnameWhenNoneExists
import org.mockserver.verify.VerificationTimes; //导入依赖的package包/类
@Test
@DirtiesContext
public void userShouldNotJoinAnyGameBySpecifyingHostnameWhenNoneExists() {
// given
final String playerName = testDataUtils.generatePlayerName();
final String playerId = testDataUtils.generateUserId();
final String hostName = testDataUtils.generateHostName();
// expect private Slack message about no active games available
mockServerClient.when(requestUtils.getNoActiveGamesToJoinByHostPrivateMessageRequest(hostName)).respond(response().withStatusCode(200));
// when
slashCommandUtils.slashIaminCommand(playerName, playerId, Optional.of(hostName));
// then
mockServerClient.verify(requestUtils.getNoActiveGamesToJoinByHostPrivateMessageRequest(hostName), VerificationTimes.exactly(1));
mockServerClient.verify(requestUtils.getInternalErrorPrivateMessageBodyRequest(), VerificationTimes.exactly(0));
}
示例11: serverCalledOnceInCacheTime
import org.mockserver.verify.VerificationTimes; //导入依赖的package包/类
@Test
public void serverCalledOnceInCacheTime() throws Exception {
mockServer.when(request().withPath(ElasticsearchClient.CLUSTER_STATS_ENDPOINT))
.respond(response()
.withBody(new JsonBody(clusterStatsJson))
.withHeaders(new Header("Content-Type", "application/json"))
.withStatusCode(HttpServletResponse.SC_OK));
ElasticsearchClusterStats clusterStats = esClient.getClusterStats();
assertThat(clusterStats).isNotNull();
assertThat(clusterStats.getStatus()).isEqualTo("red");
assertThat(clusterStats.getNodes().getFileSystem().getTotalBytes()).isEqualTo(206289465344L);
assertThat(clusterStats.getNodes().getFileSystem().getFreeBytes()).isEqualTo(132861665280L);
assertThat(clusterStats.getNodes().getFileSystem().getAvailableBytes()).isEqualTo(122359132160L);
// Call again, should hit cache
clusterStats = esClient.getClusterStats();
assertThat(clusterStats).isNotNull();
assertThat(clusterStats.getStatus()).isEqualTo("red");
assertThat(clusterStats.getNodes().getFileSystem().getTotalBytes()).isEqualTo(206289465344L);
assertThat(clusterStats.getNodes().getFileSystem().getFreeBytes()).isEqualTo(132861665280L);
assertThat(clusterStats.getNodes().getFileSystem().getAvailableBytes()).isEqualTo(122359132160L);
// Verify mockServer calls
mockServer.verify(request().withPath(ElasticsearchClient.CLUSTER_STATS_ENDPOINT), VerificationTimes.once());
}
示例12: testSendBatchSuccess
import org.mockserver.verify.VerificationTimes; //导入依赖的package包/类
@Test
public void testSendBatchSuccess() {
final String batchRequest =
"{\"commonTags\":{\"what\":\"error-rate\"},\"points\":[{\"key\":\"test_key\"," +
"\"tags\":{\"what\":\"error-rate\"},\"value\":1234.0,\"timestamp\":11111}]}";
final HttpRequest request = request()
.withMethod("POST")
.withPath("/v1/batch")
.withHeader("content-type", "application/json")
.withBody(batchRequest);
mockServerClient.when(request).respond(response().withStatusCode(200));
final Batch.Point point =
new Batch.Point("test_key", ImmutableMap.of("what", "error-rate"), 1234L, 11111L);
final Batch batch =
new Batch(ImmutableMap.of("what", "error-rate"), ImmutableList.of(point));
httpClient.sendBatch(batch).toCompletable().await();
mockServerClient.verify(request, VerificationTimes.atLeast(1));
}
示例13: noDiscoveryFoundTest
import org.mockserver.verify.VerificationTimes; //导入依赖的package包/类
/**
* A test for the situation where no discovery is
* found.
*/
@Test
public void noDiscoveryFoundTest() throws Exception{
//no need to arm a mock server; just send a request to IoT Broker
String response = sendReqToServer(null, B_PORT, "GET",
"/ngsi10/contextEntities/ConferenceRoom/attributes/temperature");
/*
* verify that there was a POST on discovery
* with the right path, right method, right body parameters
*/
d_client.verify(request()
.withPath("/ngsi9/discoverContextAvailability")
.withMethod("POST")
.withBody(xpath(
"(/discoverContextAvailabilityRequest/entityIdList/entityId//id=\"ConferenceRoom\")"
+ "and"
+ "(/discoverContextAvailabilityRequest/attributeList/attribute=\"temperature\")"
))
,
VerificationTimes.exactly(1)
);
}
示例14: should_call_method_execute_on_executeCommand
import org.mockserver.verify.VerificationTimes; //导入依赖的package包/类
@Test
public void should_call_method_execute_on_executeCommand() throws Exception {
if (isUsingMockServer()) {
mockServer
.when(request().withPath("/xmlrpc/2/object")
.withBody(RegexBody.regex(".*<methodName>execute</methodName>.*")))
.respond(response().withStatusCode(200).withBody(
"<?xml version='1.0'?>\n<methodResponse>\n<params>\n<param>\n<value><int>1</int></value>\n</param>\n</params>\n</methodResponse>\n"));
} else {
session.startSession();
}
session.executeCommand("res.users", "context_get", null);
if (isUsingMockServer()) {
mockServer.verify(request().withBody(new RegexBody(".*<methodName>execute</methodName>.*")),
VerificationTimes.once());
}
}
示例15: should_call_method_exec_workflow_on_executeCommand
import org.mockserver.verify.VerificationTimes; //导入依赖的package包/类
@Test
public void should_call_method_exec_workflow_on_executeCommand() throws Exception {
if (isUsingMockServer()) {
mockServer
.when(request().withPath("/xmlrpc/2/object")
.withBody(RegexBody.regex(".*<methodName>exec_workflow</methodName>.*")))
.respond(response().withStatusCode(200).withBody(
"<?xml version='1.0'?>\n<methodResponse>\n<params>\n<param>\n<value><int>1</int></value>\n</param>\n</params>\n</methodResponse>\n"));
} else {
session.startSession();
}
session.executeWorkflow("account.invoice", "invoice_open", 42424242);
if (isUsingMockServer()) {
mockServer.verify(request().withBody(new RegexBody(".*<methodName>exec_workflow</methodName>.*")),
VerificationTimes.once());
}
}