Search in sources :

Example 6 with CommandLine

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

the class DefaultCommandTest method testCWD.

@Test
public void testCWD() throws CLIException {
    CLI cli = CLIConfigurator.define(command.getClass());
    CommandLine evaluatedCLI = parse(cli, "--name=vert.x");
    CLIConfigurator.inject(evaluatedCLI, command);
    assertThat(command.getCwd()).isEqualTo(new File("."));
    evaluatedCLI = parse(cli, "--cwd=target", "--name=vert.x");
    CLIConfigurator.inject(evaluatedCLI, command);
    assertThat(command.getCwd()).isEqualTo(new File("target"));
}
Also used : CLI(io.vertx.core.cli.CLI) CommandLine(io.vertx.core.cli.CommandLine) File(java.io.File) Test(org.junit.Test)

Example 7 with CommandLine

use of io.vertx.core.cli.CommandLine 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

CommandLine (io.vertx.core.cli.CommandLine)7 CLI (io.vertx.core.cli.CLI)4 File (java.io.File)2 Test (org.junit.Test)2 CLIException (io.vertx.core.cli.CLIException)1 Option (io.vertx.core.cli.Option)1 ExecutionContext (io.vertx.core.spi.launcher.ExecutionContext)1