Search in sources :

Example 1 with ExecutionContext

use of io.vertx.core.spi.launcher.ExecutionContext in project vert.x by eclipse.

the class ClasspathHandlerTest method testCPInRunCommand.

@Test
public void testCPInRunCommand() {
    run = new RunCommand();
    run.setExecutionContext(new ExecutionContext(run, null, null));
    run.setClasspath("." + File.pathSeparator + "target/externals");
    run.setMainVerticle(VERTICLE);
    run.setInstances(1);
    run.run();
    waitUntil(() -> {
        try {
            return getHttpCode() == 200;
        } catch (IOException e) {
            return false;
        }
    });
}
Also used : ExecutionContext(io.vertx.core.spi.launcher.ExecutionContext) IOException(java.io.IOException) Test(org.junit.Test)

Example 2 with ExecutionContext

use of io.vertx.core.spi.launcher.ExecutionContext in project vert.x by eclipse.

the class ClasspathHandlerTest method testCPInBareCommand.

@Test
public void testCPInBareCommand() {
    bare = new BareCommand();
    bare.setExecutionContext(new ExecutionContext(bare, null, null));
    bare.setClasspath("." + File.pathSeparator + "target/externals");
    bare.setQuorum(1);
    bare.run();
    waitUntil(() -> bare.vertx != null);
    // Do reproduce the verticle fail-over, set the TCCL
    final ClassLoader originalClassloader = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(bare.createClassloader());
        bare.vertx.deployVerticle(VERTICLE, new DeploymentOptions().setHa(true));
    } finally {
        Thread.currentThread().setContextClassLoader(originalClassloader);
    }
    waitUntil(() -> {
        try {
            return getHttpCode() == 200;
        } catch (IOException e) {
            return false;
        }
    });
}
Also used : ExecutionContext(io.vertx.core.spi.launcher.ExecutionContext) DeploymentOptions(io.vertx.core.DeploymentOptions) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with ExecutionContext

use of io.vertx.core.spi.launcher.ExecutionContext in project vert.x by eclipse.

the class DefaultCommandTest method testSystemProperties.

@Test
public void testSystemProperties() throws CLIException {
    CLI cli = CLIConfigurator.define(command.getClass());
    VertxCommandLauncher launcher = new VertxCommandLauncher();
    CommandLine evaluatedCLI = parse(cli, "--name=vert.x", "-Dfoo=bar", "--systemProp=x=y");
    CLIConfigurator.inject(evaluatedCLI, command);
    command.setUp(new ExecutionContext(command, launcher, evaluatedCLI));
    assertThat(System.getProperty("foo")).isEqualToIgnoringCase("bar");
    assertThat(System.getProperty("x")).isEqualToIgnoringCase("y");
    command.tearDown();
    // System properties are not removed by the tearDown.
    assertThat(System.getProperty("foo")).isEqualToIgnoringCase("bar");
    assertThat(System.getProperty("x")).isEqualToIgnoringCase("y");
}
Also used : CLI(io.vertx.core.cli.CLI) CommandLine(io.vertx.core.cli.CommandLine) ExecutionContext(io.vertx.core.spi.launcher.ExecutionContext) Test(org.junit.Test)

Aggregations

ExecutionContext (io.vertx.core.spi.launcher.ExecutionContext)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 DeploymentOptions (io.vertx.core.DeploymentOptions)1 CLI (io.vertx.core.cli.CLI)1 CommandLine (io.vertx.core.cli.CommandLine)1