use of io.vertx.core.impl.VertxInternal in project vert.x by eclipse.
the class ComplexHATest method kill.
protected void kill(int pos) {
// Save the deploymentIDs first
takeDeploymentSnapshots();
VertxInternal v = (VertxInternal) vertices[pos];
killedNode = pos;
v.executeBlocking(fut -> {
v.simulateKill();
fut.complete();
}, false, ar -> {
assertTrue(ar.succeeded());
});
}
use of io.vertx.core.impl.VertxInternal in project vert.x by eclipse.
the class ComplexHATest method checkDeployments.
protected void checkDeployments() {
int totalDeployed = 0;
for (int i = 0; i < vertices.length; i++) {
VertxInternal v = (VertxInternal) vertices[i];
if (!v.isKilled()) {
totalDeployed += checkHasDeployments(i, i);
}
}
assertEquals(totDeployed, totalDeployed);
}
use of io.vertx.core.impl.VertxInternal in project vert.x by eclipse.
the class VertxTest method testCloseHookFailure1.
@Test
public void testCloseHookFailure1() throws Exception {
AtomicInteger closedCount = new AtomicInteger();
class Hook implements Closeable {
@Override
public void close(Handler<AsyncResult<Void>> completionHandler) {
if (closedCount.incrementAndGet() == 1) {
throw new RuntimeException();
} else {
completionHandler.handle(Future.succeededFuture());
}
}
}
VertxInternal vertx = (VertxInternal) Vertx.vertx();
vertx.addCloseHook(new Hook());
vertx.addCloseHook(new Hook());
// Now undeploy
vertx.close(ar -> {
assertTrue(ar.succeeded());
assertEquals(2, closedCount.get());
testComplete();
});
await();
}
use of io.vertx.core.impl.VertxInternal in project vertx-web by vert-x3.
the class MVELTemplateEngineImpl method render.
@Override
public void render(RoutingContext context, String templateDirectory, String templateFileName, Handler<AsyncResult<Buffer>> handler) {
try {
templateFileName = templateDirectory + templateFileName;
CompiledTemplate template = isCachingEnabled() ? cache.get(templateFileName) : null;
if (template == null) {
// real compile
String loc = adjustLocation(templateFileName);
String templateText = Utils.readFileToString(context.vertx(), loc);
if (templateText == null) {
throw new IllegalArgumentException("Cannot find template " + loc);
}
template = TemplateCompiler.compileTemplate(templateText);
if (isCachingEnabled()) {
cache.put(templateFileName, template);
}
}
Map<String, RoutingContext> variables = new HashMap<>(1);
variables.put("context", context);
final VertxInternal vertxInternal = (VertxInternal) context.vertx();
String directoryName = vertxInternal.resolveFile(templateFileName).getParent();
handler.handle(Future.succeededFuture(Buffer.buffer((String) new TemplateRuntime(template.getTemplate(), null, template.getRoot(), directoryName).execute(new StringAppender(), variables, new ImmutableDefaultFactory()))));
} catch (Exception ex) {
handler.handle(Future.failedFuture(ex));
}
}
use of io.vertx.core.impl.VertxInternal in project vertx-auth by vert-x3.
the class StormpathTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
// Setup our shiro+stormpath+vertx integration
File file = ((VertxInternal) vertx).resolveFile("stormpath.properties");
ApiKey apiKey = ApiKeys.builder().setFileLocation(file.getAbsolutePath()).build();
Client client = Clients.builder().setApiKey(apiKey).build();
ApplicationRealm stormpathAppRealm = new ApplicationRealm();
stormpathAppRealm.setClient(client);
stormpathAppRealm.setApplicationRestUrl("https://api.stormpath.com/v1/applications/2oFtzixwgN0wYKt25euKpg");
authProvider = ShiroAuth.create(vertx, stormpathAppRealm);
}
Aggregations