Search in sources :

Example 11 with Launcher

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

the class RedeployTest method testRedeploymentWithSlash.

@Test
public void testRedeploymentWithSlash() throws IOException {
    cli.dispatch(new Launcher(), new String[] { "run", // Use "/", on windows it gets replaced.
    HttpTestVerticle.class.getName(), "--redeploy=**" + "/" + "*.txt", "--launcher-class=" + Launcher.class.getName(), ExecUtils.isWindows() ? "--redeploy-termination-period=3000" : "" });
    assertWaitUntil(() -> {
        try {
            return RunCommandTest.getHttpCode() == 200;
        } catch (IOException e) {
            return false;
        }
    });
    long start1 = RunCommandTest.getContent().getLong("startTime");
    File file = new File("target/test-classes/foo.txt");
    if (file.exists()) {
        file.delete();
    }
    file.createNewFile();
    assertWaitUntil(() -> {
        try {
            return RunCommandTest.getHttpCode() == 200 && start1 != RunCommandTest.getContent().getLong("startTime");
        } catch (IOException e) {
            return false;
        }
    }, 20000);
}
Also used : Launcher(io.vertx.core.Launcher) IOException(java.io.IOException) File(java.io.File) Test(org.junit.Test)

Example 12 with Launcher

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

the class LauncherExtensibilityTest method testExtendingMainVerticle.

@Test
public void testExtendingMainVerticle() {
    Launcher myLauncher = new Launcher() {

        @Override
        protected String getMainVerticle() {
            return HttpTestVerticle.class.getName();
        }

        @Override
        public void afterStartingVertx(Vertx vertx) {
            LauncherExtensibilityTest.this.vertx = vertx;
        }
    };
    myLauncher.dispatch(new String[0]);
    assertWaitUntil(() -> {
        try {
            return RunCommandTest.getHttpCode() == 200;
        } catch (IOException e) {
            return false;
        }
    });
}
Also used : Launcher(io.vertx.core.Launcher) IOException(java.io.IOException) Vertx(io.vertx.core.Vertx) Test(org.junit.Test) RunCommandTest(io.vertx.core.impl.launcher.commands.RunCommandTest)

Example 13 with Launcher

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

the class LauncherExtensibilityTest method testThatALauncherCanAddACommand.

@Test
public void testThatALauncherCanAddACommand() {
    Launcher myLauncher = new Launcher() {

        @Override
        protected void load() {
            super.load();
            register(FooCommand.class);
        }
    };
    myLauncher.dispatch(new String[] { "foo" });
    assertThat(myLauncher.getCommandNames()).contains("foo");
    assertWaitUntil(spy::get);
}
Also used : Launcher(io.vertx.core.Launcher) Test(org.junit.Test) RunCommandTest(io.vertx.core.impl.launcher.commands.RunCommandTest)

Example 14 with Launcher

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

the class LauncherExtensibilityTest method testThatCustomLauncherCanUpdateConfigurationWhenNoneArePassed.

@Test
public void testThatCustomLauncherCanUpdateConfigurationWhenNoneArePassed() 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[0]);
    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 15 with Launcher

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

the class LauncherExtensibilityTest method testThatALauncherCanHideACommand.

@Test
public void testThatALauncherCanHideACommand() {
    Launcher myLauncher = new Launcher() {

        @Override
        protected void load() {
            super.load();
            unregister("start");
        }
    };
    record();
    myLauncher.dispatch(new String[] { "start" });
    stop();
    assertThat(output.toString()).contains("The command 'start' is not a valid command.");
    assertThat(myLauncher.getCommandNames()).doesNotContain("start");
}
Also used : Launcher(io.vertx.core.Launcher) Test(org.junit.Test) RunCommandTest(io.vertx.core.impl.launcher.commands.RunCommandTest)

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