Search in sources :

Example 21 with Launcher

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

the class RedeployTest method testStartingApplicationInRedeployMode.

@Test
public void testStartingApplicationInRedeployMode() {
    cli.dispatch(new Launcher(), new String[] { "run", HttpTestVerticle.class.getName(), "--redeploy=**" + File.separator + "*.txt", "--launcher-class=" + Launcher.class.getName() });
    assertWaitUntil(() -> {
        try {
            return RunCommandTest.getHttpCode() == 200;
        } catch (IOException e) {
            return false;
        }
    });
}
Also used : Launcher(io.vertx.core.Launcher) IOException(java.io.IOException) Test(org.junit.Test)

Example 22 with Launcher

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

the class RedeployTest method testRedeployment.

@Test
public void testRedeployment() throws IOException {
    cli.dispatch(new Launcher(), new String[] { "run", HttpTestVerticle.class.getName(), "--redeploy=**" + File.separator + "*.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 23 with Launcher

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

the class RedeployTest method testStartingApplicationInRedeployModeWithInlineOptions.

@Test
public void testStartingApplicationInRedeployModeWithInlineOptions() throws IOException {
    cli.dispatch(new Launcher(), new String[] { "run", HttpTestVerticle.class.getName(), "--redeploy=**" + File.separator + "*.txt", "--launcher-class=" + OptionsRecordingLauncher.class.getName(), "--options", "{\"metricsOptions\":{\"enabled\":true}}" });
    assertWaitUntil(() -> {
        try {
            return RunCommandTest.getHttpCode() == 200;
        } catch (IOException e) {
            return false;
        }
    });
    JsonObject conf = RunCommandTest.getContent().getJsonObject("conf");
    assertThat(conf).isNotNull().isNotEmpty();
    JsonObject vertxOptions = conf.getJsonObject(OptionsRecordingLauncher.class.getName());
    assertThat(vertxOptions).isNotNull().isNotEmpty();
    JsonObject metricsOptions = vertxOptions.getJsonObject("metricsOptions");
    assertThat(metricsOptions).isNotNull().isNotEmpty();
    assertThat(metricsOptions.getBoolean("enabled")).isEqualTo(true);
}
Also used : Launcher(io.vertx.core.Launcher) JsonObject(io.vertx.core.json.JsonObject) IOException(java.io.IOException) Test(org.junit.Test)

Example 24 with Launcher

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

the class RedeployTest method testStartingApplicationInRedeployModeWithFileConf.

@Test
public void testStartingApplicationInRedeployModeWithFileConf() 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 25 with Launcher

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

the class RunCommandTest method testFatJarWithMissingMainVerticle.

@Test
public void testFatJarWithMissingMainVerticle() throws IOException, InterruptedException {
    setManifest("MANIFEST-Launcher-Missing-Main-Verticle.MF");
    record();
    cli.dispatch(new Launcher(), new String[] {});
    assertWaitUntil(() -> error.toString().contains("ClassNotFoundException"));
    stop();
}
Also used : 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