use of io.vertx.core.Vertx in project vert.x by eclipse.
the class ContextTest method testGettingContextContextUnderContextAnotherInstanceShouldReturnDifferentContext.
@Test
public void testGettingContextContextUnderContextAnotherInstanceShouldReturnDifferentContext() throws Exception {
Vertx other = vertx();
Context context = vertx.getOrCreateContext();
context.runOnContext(v -> {
Context otherContext = other.getOrCreateContext();
assertNotSame(otherContext, context);
testComplete();
});
await();
}
use of io.vertx.core.Vertx in project vert.x by eclipse.
the class FileResolverTestBase method testDeleteCacheDir.
@Test
public void testDeleteCacheDir() throws Exception {
Vertx vertx2 = vertx();
FileResolver resolver2 = new FileResolver(vertx2);
File file = resolver2.resolveFile(webRoot + "/somefile.html");
assertTrue(file.exists());
File cacheDir = file.getParentFile().getParentFile();
assertTrue(cacheDir.exists());
resolver2.close(onSuccess(res -> {
assertFalse(cacheDir.exists());
vertx2.close(res2 -> {
testComplete();
});
}));
await();
}
use of io.vertx.core.Vertx in project vert.x by eclipse.
the class EventBusExamples method example12.
public void example12() {
VertxOptions options = new VertxOptions();
Vertx.clusteredVertx(options, res -> {
if (res.succeeded()) {
Vertx vertx = res.result();
EventBus eventBus = vertx.eventBus();
System.out.println("We now have a clustered event bus: " + eventBus);
} else {
System.out.println("Failed: " + res.cause());
}
});
}
use of io.vertx.core.Vertx in project vert.x by eclipse.
the class RunCommandTest method tearDown.
@After
public void tearDown() throws InterruptedException {
super.tearDown();
final RunCommand run = (RunCommand) cli.getExistingCommandInstance("run");
if (run != null) {
Vertx vertx = run.vertx;
close(vertx);
}
FakeClusterManager.reset();
}
use of io.vertx.core.Vertx in project vert.x by eclipse.
the class ComplexHATest method deployRandomVerticles.
protected void deployRandomVerticles(Runnable runner) {
int toDeploy = 0;
AtomicInteger deployCount = new AtomicInteger();
List<Integer> numbersToDeploy = new ArrayList<>();
for (int i = 0; i < aliveNodes.size(); i++) {
int numToDeploy = random.nextInt(maxVerticlesPerNode + 1);
numbersToDeploy.add(numToDeploy);
toDeploy += numToDeploy;
}
int index = 0;
for (int pos : aliveNodes) {
Vertx v = vertices[pos];
int numToDeploy = numbersToDeploy.get(index);
index++;
for (int j = 0; j < numToDeploy; j++) {
JsonObject config = new JsonObject();
config.put("foo", TestUtils.randomAlphaString(100));
DeploymentOptions options = new DeploymentOptions().setHa(true).setConfig(config);
String verticleName = "java:io.vertx.test.core.HAVerticle" + (random.nextInt(3) + 1);
v.deployVerticle(verticleName, options, ar -> {
assertTrue(ar.succeeded());
deployCount.incrementAndGet();
});
}
}
int ttoDeploy = toDeploy;
eventLoopWaitUntil(() -> ttoDeploy == deployCount.get(), () -> {
totDeployed += ttoDeploy;
runner.run();
});
}
Aggregations