Search in sources :

Example 1 with Invocation

use of org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation in project spring-boot by spring-projects.

the class CommandLineIT method version.

@Test
public void version() throws IOException, InterruptedException {
    Invocation cli = this.cli.invoke("version");
    assertThat(cli.await(), equalTo(0));
    assertThat(cli.getErrorOutput().length(), equalTo(0));
    assertThat(cli.getStandardOutput(), startsWith("Spring CLI v"));
}
Also used : Invocation(org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation) Test(org.junit.Test)

Example 2 with Invocation

use of org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation in project spring-boot by spring-projects.

the class CommandLineIT method hintProducesListOfValidCommands.

@Test
public void hintProducesListOfValidCommands() throws IOException, InterruptedException {
    Invocation cli = this.cli.invoke("hint");
    assertThat(cli.await(), equalTo(0));
    assertThat("Unexpected error: \n" + cli.getErrorOutput(), cli.getErrorOutput().length(), equalTo(0));
    assertThat(cli.getStandardOutputLines().size(), equalTo(11));
}
Also used : Invocation(org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation) Test(org.junit.Test)

Example 3 with Invocation

use of org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation in project spring-boot by spring-projects.

the class CommandLineIT method unrecognizedCommandsAreHandledGracefully.

@Test
public void unrecognizedCommandsAreHandledGracefully() throws IOException, InterruptedException {
    Invocation cli = this.cli.invoke("not-a-real-command");
    assertThat(cli.await(), equalTo(1));
    assertThat(cli.getErrorOutput(), containsString("'not-a-real-command' is not a valid command"));
    assertThat(cli.getStandardOutput().length(), equalTo(0));
}
Also used : Invocation(org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation) Test(org.junit.Test)

Example 4 with Invocation

use of org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation in project spring-boot by spring-projects.

the class JarCommandIT method jarCreationWithGrabResolver.

@Test
public void jarCreationWithGrabResolver() throws Exception {
    File jar = new File("target/test-app.jar");
    Invocation invocation = this.cli.invoke("run", jar.getAbsolutePath(), "bad.groovy");
    invocation.await();
    assertThat(invocation.getErrorOutput(), equalTo(""));
    invocation = this.cli.invoke("jar", jar.getAbsolutePath(), "bad.groovy");
    invocation.await();
    assertEquals(invocation.getErrorOutput(), 0, invocation.getErrorOutput().length());
    assertTrue(jar.exists());
    Process process = new JavaExecutable().processBuilder("-jar", jar.getAbsolutePath()).start();
    invocation = new Invocation(process);
    invocation.await();
    assertThat(invocation.getErrorOutput(), equalTo(""));
}
Also used : Invocation(org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation) File(java.io.File) JavaExecutable(org.springframework.boot.loader.tools.JavaExecutable) Test(org.junit.Test)

Example 5 with Invocation

use of org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation in project spring-boot by spring-projects.

the class JarCommandIT method noArguments.

@Test
public void noArguments() throws Exception {
    Invocation invocation = this.cli.invoke("jar");
    invocation.await();
    assertThat(invocation.getStandardOutput(), equalTo(""));
    assertThat(invocation.getErrorOutput(), containsString("The name of the " + "resulting jar and at least one source file must be specified"));
}
Also used : Invocation(org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)11 Invocation (org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation)11 File (java.io.File)4 JavaExecutable (org.springframework.boot.loader.tools.JavaExecutable)4