use of io.vertx.core.Launcher in project vert.x by eclipse.
the class LauncherExtensibilityTest method testThatCustomLauncherCanCustomizeClusterManager.
@Test
public void testThatCustomLauncherCanCustomizeClusterManager() throws Exception {
FakeClusterManager clusterManager = new FakeClusterManager();
Launcher myLauncher = new Launcher() {
@Override
protected String getMainVerticle() {
return HttpTestVerticle.class.getName();
}
@Override
public void afterStartingVertx(Vertx vertx) {
LauncherExtensibilityTest.this.vertx = vertx;
}
@Override
public void beforeStartingVertx(VertxOptions options) {
options.setClusterManager(clusterManager);
}
};
myLauncher.dispatch(new String[] { "-cluster" });
assertWaitUntil(() -> {
try {
return RunCommandTest.getHttpCode() == 200;
} catch (IOException e) {
return false;
}
});
assertThat(RunCommandTest.getContent().getBoolean("clustered")).isEqualTo(true);
assertSame(clusterManager, ((VertxInternal) vertx).getClusterManager());
}
use of io.vertx.core.Launcher in project vert.x by eclipse.
the class LauncherExtensibilityTest method testThatCustomLauncherCanUpdateConfiguration.
@Test
public void testThatCustomLauncherCanUpdateConfiguration() throws IOException {
long time = System.nanoTime();
Launcher myLauncher = new Launcher() {
@Override
protected String getMainVerticle() {
return HttpTestVerticle.class.getName();
}
@Override
public void afterStartingVertx(Vertx vertx) {
LauncherExtensibilityTest.this.vertx = vertx;
}
@Override
public void afterConfigParsed(JsonObject config) {
config.put("time", time);
}
};
myLauncher.dispatch(new String[] { "-conf=\"{\"time\":345667}" });
assertWaitUntil(() -> {
try {
return RunCommandTest.getHttpCode() == 200;
} catch (IOException e) {
return false;
}
});
assertThat(RunCommandTest.getContent().getJsonObject("conf").getLong("time")).isEqualTo(time);
}
use of io.vertx.core.Launcher in project vert.x by eclipse.
the class LauncherExtensibilityTest method testThatCustomLauncherCanCustomizeMetricsOption.
@Test
public void testThatCustomLauncherCanCustomizeMetricsOption() throws Exception {
Launcher myLauncher = new Launcher() {
@Override
protected String getMainVerticle() {
return HttpTestVerticle.class.getName();
}
@Override
public void afterStartingVertx(Vertx vertx) {
LauncherExtensibilityTest.this.vertx = vertx;
}
@Override
public void beforeStartingVertx(VertxOptions options) {
options.getMetricsOptions().setEnabled(true).setFactory(new FakeMetricsFactory());
}
};
myLauncher.dispatch(new String[0]);
assertWaitUntil(() -> {
try {
return RunCommandTest.getHttpCode() == 200;
} catch (IOException e) {
return false;
}
});
assertThat(RunCommandTest.getContent().getBoolean("metrics")).isEqualTo(true);
}
use of io.vertx.core.Launcher in project vert.x by eclipse.
the class RedeployTest method testStartingApplicationInRedeployModeWithFileConf2.
@Test
public void testStartingApplicationInRedeployModeWithFileConf2() throws IOException {
cli.dispatch(new Launcher(), new String[] { "run", HttpTestVerticle.class.getName(), "--redeploy=**" + File.separator + "*.txt", "--launcher-class=" + Launcher.class.getName(), "--conf=" + new File("src/test/resources/conf.json").getAbsolutePath() });
assertWaitUntil(() -> {
try {
return RunCommandTest.getHttpCode() == 200;
} catch (IOException e) {
return false;
}
});
JsonObject conf = RunCommandTest.getContent().getJsonObject("conf");
assertThat(conf).isNotNull().isNotEmpty();
assertThat(conf.getString("name")).isEqualTo("vertx");
}
use of io.vertx.core.Launcher in project vert.x by eclipse.
the class RedeployTest method testStartingApplicationInRedeployModeWithCluster.
@Test
public void testStartingApplicationInRedeployModeWithCluster() throws IOException {
cli.dispatch(new Launcher(), new String[] { "run", HttpTestVerticle.class.getName(), "--redeploy=**" + File.separator + "*.txt", "--launcher-class=" + Launcher.class.getName(), "--cluster", ExecUtils.isWindows() ? "--redeploy-termination-period=3000" : "" });
assertWaitUntil(() -> {
try {
return RunCommandTest.getHttpCode() == 200;
} catch (IOException e) {
return false;
}
}, 20000);
assertThat(RunCommandTest.getContent().getBoolean("clustered")).isTrue();
}
Aggregations