Package org.springframework.boot.cli.infrastructure.CommandLineInvoker

Examples of org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation


  private final CommandLineInvoker cli = new CommandLineInvoker();

  @Test
  public void hintProducesListOfValidCommands() throws IOException,
      InterruptedException {
    Invocation cli = this.cli.invoke("hint");
    assertThat(cli.await(), equalTo(0));
    assertThat(cli.getErrorOutput().length(), equalTo(0));
    assertThat(cli.getStandardOutputLines().size(), equalTo(10));
  }
View Full Code Here


  }

  @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:"));
  }
View Full Code Here

  }

  @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));
  }
View Full Code Here

    assertThat(cli.getStandardOutput().length(), equalTo(0));
  }

  @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"));
  }
View Full Code Here

    assertThat(cli.getStandardOutput(), startsWith("Spring CLI v"));
  }

  @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:"));
  }
View Full Code Here

  private final CommandLineInvoker cli = new CommandLineInvoker(new File(
      "src/it/resources/jar-command"));

  @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"));
  }
View Full Code Here

        + "resulting jar and at least one source file must be specified"));
  }

  @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"));
  }
View Full Code Here

  }

  @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(""));
  }
View Full Code Here

  }

  @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("/public/public.txt"));
    assertThat(invocation.getStandardOutput(),
        containsString("/resources/resource.txt"));
    assertThat(invocation.getStandardOutput(), containsString("/static/static.txt"));
    assertThat(invocation.getStandardOutput(),
        containsString("/templates/template.txt"));
    assertThat(invocation.getStandardOutput(), containsString("Goodbye Mama"));
  }
View Full Code Here

  }

  @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"));
  }
View Full Code Here

TOP

Related Classes of org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.