Search in sources :

Example 6 with Invocation

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

the class JarCommandIT method jarCreation.

@Test
public void jarCreation() throws Exception {
    File jar = new File("target/test-app.jar");
    Invocation invocation = this.cli.invoke("jar", jar.getAbsolutePath(), "jar.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(""));
    assertThat(invocation.getStandardOutput(), containsString("Hello World!"));
    assertThat(invocation.getStandardOutput(), containsString("/BOOT-INF/classes!/public/public.txt"));
    assertThat(invocation.getStandardOutput(), containsString("/BOOT-INF/classes!/resources/resource.txt"));
    assertThat(invocation.getStandardOutput(), containsString("/BOOT-INF/classes!/static/static.txt"));
    assertThat(invocation.getStandardOutput(), containsString("/BOOT-INF/classes!/templates/template.txt"));
    assertThat(invocation.getStandardOutput(), containsString("/BOOT-INF/classes!/root.properties"));
    assertThat(invocation.getStandardOutput(), containsString("Goodbye Mama"));
}
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 7 with Invocation

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

the class JarCommandIT method jarCreationWithIncludes.

@Test
public void jarCreationWithIncludes() throws Exception {
    File jar = new File("target/test-app.jar");
    Invocation invocation = this.cli.invoke("jar", jar.getAbsolutePath(), "--include", "-public/**,-resources/**", "jar.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(""));
    assertThat(invocation.getStandardOutput(), containsString("Hello World!"));
    assertThat(invocation.getStandardOutput(), not(containsString("/public/public.txt")));
    assertThat(invocation.getStandardOutput(), not(containsString("/resources/resource.txt")));
    assertThat(invocation.getStandardOutput(), containsString("/static/static.txt"));
    assertThat(invocation.getStandardOutput(), containsString("/templates/template.txt"));
    assertThat(invocation.getStandardOutput(), containsString("Goodbye Mama"));
}
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 8 with Invocation

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

the class CommandLineIT method invokingWithNoArgumentsDisplaysHelp.

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

Example 9 with Invocation

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

the class CommandLineIT method help.

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

Example 10 with Invocation

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

the class JarCommandIT method noSources.

@Test
public void noSources() throws Exception {
    Invocation invocation = this.cli.invoke("jar", "test-app.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