Search in sources :

Example 16 with Launcher

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());
}
Also used : Launcher(io.vertx.core.Launcher) IOException(java.io.IOException) Vertx(io.vertx.core.Vertx) VertxOptions(io.vertx.core.VertxOptions) FakeClusterManager(io.vertx.test.fakecluster.FakeClusterManager) Test(org.junit.Test) RunCommandTest(io.vertx.core.impl.launcher.commands.RunCommandTest)

Example 17 with Launcher

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);
}
Also used : Launcher(io.vertx.core.Launcher) JsonObject(io.vertx.core.json.JsonObject) IOException(java.io.IOException) Vertx(io.vertx.core.Vertx) Test(org.junit.Test) RunCommandTest(io.vertx.core.impl.launcher.commands.RunCommandTest)

Example 18 with Launcher

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);
}
Also used : FakeMetricsFactory(io.vertx.test.fakemetrics.FakeMetricsFactory) Launcher(io.vertx.core.Launcher) IOException(java.io.IOException) Vertx(io.vertx.core.Vertx) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test) RunCommandTest(io.vertx.core.impl.launcher.commands.RunCommandTest)

Example 19 with Launcher

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");
}
Also used : Launcher(io.vertx.core.Launcher) JsonObject(io.vertx.core.json.JsonObject) IOException(java.io.IOException) File(java.io.File) Test(org.junit.Test)

Example 20 with Launcher

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();
}
Also used : Launcher(io.vertx.core.Launcher) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

Launcher (io.vertx.core.Launcher)31 Test (org.junit.Test)31 IOException (java.io.IOException)16 JsonObject (io.vertx.core.json.JsonObject)9 RunCommandTest (io.vertx.core.impl.launcher.commands.RunCommandTest)8 Vertx (io.vertx.core.Vertx)6 File (java.io.File)4 VertxOptions (io.vertx.core.VertxOptions)3 FakeClusterManager (io.vertx.test.fakecluster.FakeClusterManager)1 FakeMetricsFactory (io.vertx.test.fakemetrics.FakeMetricsFactory)1 Random (java.util.Random)1