本文整理了Java中io.vertx.ext.unit.TestContext.verify()
方法的一些代码示例,展示了TestContext.verify()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestContext.verify()
方法的具体详情如下:
包路径:io.vertx.ext.unit.TestContext
类名称:TestContext
方法名:verify
暂无
代码示例来源:origin: vert-x3/vertx-rx
/**
* Execute the provided handler, which may contain assertions, possibly from any third-party assertion framework.
* Any {@link java.lang.AssertionError} thrown will be caught (and propagated) in order to fulfill potential expected async
* completeness.
* @param block block of code to be executed
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.ext.unit.TestContext verify(Handler<Void> block) {
delegate.verify(block);
return this;
}
代码示例来源:origin: io.vertx/vertx-rx-java
/**
* Execute the provided handler, which may contain assertions, possibly from any third-party assertion framework.
* Any {@link java.lang.AssertionError} thrown will be caught (and propagated) in order to fulfill potential expected async
* completeness.
* @param block block of code to be executed
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.ext.unit.TestContext verify(Handler<Void> block) {
delegate.verify(block);
return this;
}
代码示例来源:origin: io.vertx/vertx-unit
@Test
public void success(TestContext context) {
context.verify(v -> {
count.incrementAndGet();
assertTrue(true);
});
}
}
代码示例来源:origin: io.vertx/vertx-unit
@Test
public void simpleFail(TestContext context) {
context.verify(v -> fail("Testing failure"));
}
}
代码示例来源:origin: io.vertx/vertx-unit
@Test
public void failWithAsync(TestContext context) {
Vertx vertx = Vertx.vertx();
Async async = context.async();
vertx.runOnContext(v -> {
try {
context.verify(v2 -> fail("Testing async failure"));
} finally {
async.complete();
}
});
async.await();
}
}
代码示例来源:origin: io.vertx/vertx-micrometer-metrics
@Test
public void shouldBindExistingServer(TestContext context) {
vertx = Vertx.vertx(new VertxOptions()
.setMetricsOptions(new MicrometerMetricsOptions()
.setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true))
.setEnabled(true)));
Router router = Router.router(vertx);
router.route("/custom").handler(routingContext -> {
PrometheusMeterRegistry prometheusRegistry = (PrometheusMeterRegistry) BackendRegistries.getDefaultNow();
String response = prometheusRegistry.scrape();
routingContext.response().end(response);
});
vertx.createHttpServer().requestHandler(router).exceptionHandler(context.exceptionHandler()).listen(8081);
Async async = context.async();
PrometheusTestHelper.tryConnect(vertx, context, 8081, "localhost", "/custom", body -> {
context.verify(v -> assertThat(body.toString())
.contains("vertx_http_"));
async.complete();
});
async.awaitSuccess(10000);
}
代码示例来源:origin: io.vertx/vertx-micrometer-metrics
@Test
public void shouldPublishPercentileStats(TestContext context) throws Exception {
vertx = Vertx.vertx(new VertxOptions()
.setMetricsOptions(new MicrometerMetricsOptions()
.setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)
.setPublishQuantiles(true)
.setStartEmbeddedServer(true)
.setEmbeddedServerOptions(new HttpServerOptions().setPort(9090)))
.addLabels(Label.LOCAL, Label.HTTP_PATH, Label.REMOTE)
.setEnabled(true)));
Async async = context.async();
PrometheusTestHelper.tryConnect(vertx, context, 9090, "localhost", "/metrics", body -> {
context.verify(v -> assertThat(body.toString())
.contains("vertx_http_client_responseTime_seconds_bucket"));
async.complete();
});
async.awaitSuccess(10000);
}
}
代码示例来源:origin: io.vertx/vertx-micrometer-metrics
@Test
public void shouldStartEmbeddedServer(TestContext context) throws Exception {
vertx = Vertx.vertx(new VertxOptions()
.setMetricsOptions(new MicrometerMetricsOptions()
.setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)
.setStartEmbeddedServer(true)
.setEmbeddedServerOptions(new HttpServerOptions().setPort(9090)))
.addLabels(Label.LOCAL, Label.HTTP_PATH, Label.REMOTE)
.setEnabled(true)));
Async async = context.async();
PrometheusTestHelper.tryConnect(vertx, context, 9090, "localhost", "/metrics", body -> {
context.verify(v -> assertThat(body.toString())
.contains("vertx_http_client_requests{local=\"?\",method=\"GET\",path=\"/metrics\",remote=\"localhost:9090\",} 1.0")
.doesNotContain("vertx_http_client_responseTime_seconds_bucket"));
async.complete();
});
async.awaitSuccess(10000);
}
代码示例来源:origin: io.vertx/vertx-micrometer-metrics
@Test
public void shouldExcludeCategory(TestContext context) {
vertx = Vertx.vertx(new VertxOptions()
.setMetricsOptions(new MicrometerMetricsOptions()
.setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)
.setStartEmbeddedServer(true)
.setEmbeddedServerOptions(new HttpServerOptions().setPort(9090)))
.addDisabledMetricsCategory(MetricsDomain.HTTP_SERVER)
.addLabels(Label.LOCAL, Label.REMOTE)
.setEnabled(true)));
Async async = context.async();
PrometheusTestHelper.tryConnect(vertx, context, 9090, "localhost", "/metrics", body -> {
context.verify(v -> assertThat(body.toString())
.contains("vertx_http_client_connections{local=\"?\",remote=\"localhost:9090\",} 1.0")
.doesNotContain("vertx_http_server_connections{local=\"0.0.0.0:9090\",remote=\"_\",} 1.0"));
async.complete();
});
async.awaitSuccess(10000);
}
代码示例来源:origin: io.vertx/vertx-micrometer-metrics
InfluxDbTestHelper.simulateInfluxServer(vertxForSimulatedServer, context, 8087, body -> {
try {
context.verify(w -> assertThat(body)
.contains("vertx_eventbus_handlers,address=test-eb,metric_type=gauge value=1"));
} finally {
代码示例来源:origin: io.vertx/vertx-micrometer-metrics
@Test
public void shouldExposeEventBusMetrics(TestContext context) {
vertx = Vertx.vertx(new VertxOptions()
.setMetricsOptions(new MicrometerMetricsOptions()
.setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)
.setStartEmbeddedServer(true)
.setEmbeddedServerOptions(new HttpServerOptions().setPort(9090)))
.addLabels(Label.EB_ADDRESS)
.setEnabled(true)));
// Send something on the eventbus and wait til it's received
Async asyncEB = context.async();
vertx.eventBus().consumer("test-eb", msg -> asyncEB.complete());
vertx.eventBus().publish("test-eb", "test message");
asyncEB.awaitSuccess(15000);
// Read metrics on HTTP endpoint for eventbus metrics
Async async = context.async();
PrometheusTestHelper.tryConnect(vertx, context, 9090, "localhost", "/metrics", body -> {
context.verify(v -> assertThat(body.toString())
.contains("vertx_eventbus_published_total{address=\"test-eb\",side=\"local\",} 1.0",
"vertx_eventbus_received_total{address=\"test-eb\",side=\"local\",} 1.0",
"vertx_eventbus_handlers{address=\"test-eb\",} 1.0",
"vertx_eventbus_delivered_total{address=\"test-eb\",side=\"local\",} 1.0",
"vertx_eventbus_processingTime_seconds_count{address=\"test-eb\",} 1.0"));
async.complete();
});
async.awaitSuccess(15000);
}
内容来源于网络,如有侵权,请联系作者删除!