use of io.vertx.core.Vertx in project vert.x by eclipse.
the class BlockedThreadCheckerTest method testBlockCheckWorker.
@Test
public void testBlockCheckWorker() throws Exception {
Verticle verticle = new AbstractVerticle() {
@Override
public void start() throws InterruptedException {
Thread.sleep(2000);
testComplete();
}
};
// set warning threshold to 1s and the exception threshold as well
VertxOptions vertxOptions = new VertxOptions();
vertxOptions.setMaxWorkerExecuteTime(1000000000);
vertxOptions.setWarningExceptionTime(1000000000);
Vertx newVertx = vertx(vertxOptions);
DeploymentOptions deploymentOptions = new DeploymentOptions();
deploymentOptions.setWorker(true);
newVertx.deployVerticle(verticle, deploymentOptions);
await();
}
use of io.vertx.core.Vertx in project vert.x by eclipse.
the class BlockedThreadCheckerTest method testBlockCheckExecuteBlocking.
@Test
public void testBlockCheckExecuteBlocking() throws Exception {
Verticle verticle = new AbstractVerticle() {
@Override
public void start() throws InterruptedException {
vertx.executeBlocking(fut -> {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
fail();
}
testComplete();
}, ar -> {
});
}
};
// set warning threshold to 1s and the exception threshold as well
VertxOptions vertxOptions = new VertxOptions();
vertxOptions.setMaxWorkerExecuteTime(1000000000);
vertxOptions.setWarningExceptionTime(1000000000);
Vertx newVertx = vertx(vertxOptions);
newVertx.deployVerticle(verticle);
await();
}
use of io.vertx.core.Vertx in project vert.x by eclipse.
the class BlockedThreadCheckerTest method testBlockCheckExceptionTimeLimit.
@Test
public void testBlockCheckExceptionTimeLimit() throws Exception {
Verticle verticle = new AbstractVerticle() {
@Override
public void start() throws InterruptedException {
Thread.sleep(2000);
testComplete();
}
};
// set warning threshold to 1s and the exception threshold as well
VertxOptions vertxOptions = new VertxOptions();
vertxOptions.setMaxEventLoopExecuteTime(1000000000);
vertxOptions.setWarningExceptionTime(1000000000);
Vertx newVertx = vertx(vertxOptions);
newVertx.deployVerticle(verticle);
await();
}
use of io.vertx.core.Vertx in project vert.x by eclipse.
the class VertxTest method testCloseHooksCalled.
@Test
public void testCloseHooksCalled() throws Exception {
AtomicInteger closedCount = new AtomicInteger();
Closeable myCloseable1 = completionHandler -> {
closedCount.incrementAndGet();
completionHandler.handle(Future.succeededFuture());
};
Closeable myCloseable2 = completionHandler -> {
closedCount.incrementAndGet();
completionHandler.handle(Future.succeededFuture());
};
VertxInternal vertx = (VertxInternal) Vertx.vertx();
vertx.addCloseHook(myCloseable1);
vertx.addCloseHook(myCloseable2);
// Now undeploy
vertx.close(ar -> {
assertTrue(ar.succeeded());
assertEquals(2, closedCount.get());
testComplete();
});
await();
}
use of io.vertx.core.Vertx in project vert.x by eclipse.
the class VertxTestBase method vertx.
/**
* @return create a blank new Vert.x instance with @{@code options} closed when tear down executes.
*/
protected Vertx vertx(VertxOptions options) {
if (created == null) {
created = new ArrayList<>();
}
Vertx vertx = Vertx.vertx(options);
created.add(vertx);
return vertx;
}
Aggregations