Search in sources :

Example 1 with Launcher

use of io.vertx.core.Launcher in project vert.x by eclipse.

the class LauncherExtensibilityTest method testThatCustomLauncherCanCustomizeTheClusteredOption.

@Test
public void testThatCustomLauncherCanCustomizeTheClusteredOption() {
    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.setClustered(true);
        }
    };
    myLauncher.dispatch(new String[0]);
    waitUntil(() -> {
        try {
            return RunCommandTest.getHttpCode() == 200;
        } catch (IOException e) {
            return false;
        }
    });
    assertThat(this.vertx.isClustered()).isTrue();
}
Also used : 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 2 with Launcher

use of io.vertx.core.Launcher in project vert.x by eclipse.

the class RunCommandTest method testFatJarWithHTTPVerticle.

@Test
public void testFatJarWithHTTPVerticle() throws IOException, InterruptedException {
    setManifest("MANIFEST-Launcher-Http-Verticle.MF");
    cli.dispatch(new Launcher(), new String[] {});
    assertWaitUntil(() -> {
        try {
            return getHttpCode() == 200;
        } catch (IOException e) {
            return false;
        }
    });
    assertThat(getContent().getBoolean("clustered")).isFalse();
}
Also used : Launcher(io.vertx.core.Launcher) Test(org.junit.Test)

Example 3 with Launcher

use of io.vertx.core.Launcher in project vert.x by eclipse.

the class RunCommandTest method testThatHADeploysVerticle.

@Test
public void testThatHADeploysVerticle() throws IOException {
    setManifest("MANIFEST-Launcher-Http-Verticle.MF");
    cli.dispatch(new Launcher(), new String[] { "-ha", "-cluster" });
    assertWaitUntil(() -> {
        try {
            return getHttpCode() == 200;
        } catch (IOException e) {
            return false;
        }
    });
    assertThat(getContent().getBoolean("clustered")).isTrue();
}
Also used : Launcher(io.vertx.core.Launcher) Test(org.junit.Test)

Example 4 with Launcher

use of io.vertx.core.Launcher in project vert.x by eclipse.

the class RunCommandTest method testMetricsEnabledFromCommandLine.

@Test
public void testMetricsEnabledFromCommandLine() throws IOException {
    setManifest("MANIFEST-Launcher-Http-Verticle.MF");
    cli.dispatch(new Launcher(), new String[] { "-Dvertx.metrics.options.enabled=true" });
    assertWaitUntil(() -> {
        try {
            return getHttpCode() == 200;
        } catch (IOException e) {
            return false;
        }
    });
    // Check that the metrics are enabled
    // We cannot use the response from the verticle as it uses the DymmyVertxMetrics (no metrics provider)
    assertThat(((RunCommand) cli.getExistingCommandInstance("run")).options.getMetricsOptions().isEnabled()).isTrue();
}
Also used : Launcher(io.vertx.core.Launcher) Test(org.junit.Test)

Example 5 with Launcher

use of io.vertx.core.Launcher in project vert.x by eclipse.

the class RunCommandTest method testWithConfProvidedInline.

@Test
public void testWithConfProvidedInline() throws IOException {
    long someNumber = new Random().nextLong();
    setManifest("MANIFEST-Launcher-Http-Verticle.MF");
    cli.dispatch(new Launcher(), new String[] { "--conf={\"random\":" + someNumber + "}" });
    assertWaitUntil(() -> {
        try {
            return getHttpCode() == 200;
        } catch (IOException e) {
            return false;
        }
    });
    assertThat(getContent().getJsonObject("conf").getLong("random")).isEqualTo(someNumber);
}
Also used : Random(java.util.Random) Launcher(io.vertx.core.Launcher) 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