Package org.springframework.shell.core

Examples of org.springframework.shell.core.JLineShellComponent.executeCommand()


  @Test
  public void testShellWithCredentials() throws Exception {
    Bootstrap bootstrap = new Bootstrap();
    JLineShellComponent shell = bootstrap.getJLineShellComponent();
    CommandResult commandResult = shell.executeCommand("admin config server --uri http://localhost:" + adminPort + " --username admin --password whosThere");
    assertThat(commandResult.isSuccess(), is(true));
    commandResult = shell.executeCommand("module list");
    assertThat(commandResult.isSuccess(), is(true));
    assertThat(commandResult.getResult(), instanceOf(Table.class));
    assertThat(((Table) commandResult.getResult()).getHeaders().size(), greaterThan(0));
View Full Code Here


  public void testShellWithCredentials() throws Exception {
    Bootstrap bootstrap = new Bootstrap();
    JLineShellComponent shell = bootstrap.getJLineShellComponent();
    CommandResult commandResult = shell.executeCommand("admin config server --uri http://localhost:" + adminPort + " --username admin --password whosThere");
    assertThat(commandResult.isSuccess(), is(true));
    commandResult = shell.executeCommand("module list");
    assertThat(commandResult.isSuccess(), is(true));
    assertThat(commandResult.getResult(), instanceOf(Table.class));
    assertThat(((Table) commandResult.getResult()).getHeaders().size(), greaterThan(0));
  }
View Full Code Here

      System.setIn(simulatedInputStream);
      Bootstrap bootstrap = new Bootstrap();
      JLineShellComponent shell = bootstrap.getJLineShellComponent();
      assertThat(simulatedInputStream.isReadPerformed(), is(false));
      assertThat(simulatedInputStream.hasUnreadData(), is(true));
      CommandResult commandResult = shell.executeCommand("admin config server --uri http://localhost:" + adminPort + " --username admin --password");
      assertThat(simulatedInputStream.isReadPerformed(), is(true));
      assertThat(simulatedInputStream.hasUnreadData(), is(false));
      assertThat(commandResult.isSuccess(), is(true));
      commandResult = shell.executeCommand("module list");
      assertThat(commandResult.isSuccess(), is(true));
View Full Code Here

      assertThat(simulatedInputStream.hasUnreadData(), is(true));
      CommandResult commandResult = shell.executeCommand("admin config server --uri http://localhost:" + adminPort + " --username admin --password");
      assertThat(simulatedInputStream.isReadPerformed(), is(true));
      assertThat(simulatedInputStream.hasUnreadData(), is(false));
      assertThat(commandResult.isSuccess(), is(true));
      commandResult = shell.executeCommand("module list");
      assertThat(commandResult.isSuccess(), is(true));
      assertThat(commandResult.getResult(), instanceOf(Table.class));
      assertThat(((Table) commandResult.getResult()).getHeaders().size(), greaterThan(0));
    }
    finally {
View Full Code Here

      System.setIn(simulatedInputStream);
      Bootstrap bootstrap = new Bootstrap();
      JLineShellComponent shell = bootstrap.getJLineShellComponent();
      assertThat(simulatedInputStream.isReadPerformed(), is(false));
      assertThat(simulatedInputStream.hasUnreadData(), is(true));
      CommandResult commandResult = shell.executeCommand("admin config server --uri http://localhost:" + adminPort + " --username admin --password");
      assertThat(simulatedInputStream.isReadPerformed(), is(true));
      assertThat(simulatedInputStream.hasUnreadData(), is(false));
      assertThat(commandResult.isSuccess(), is(true));
      Configuration configuration = bootstrap.getApplicationContext().getBean(Configuration.class);
      assertThat(configuration.getTarget().getTargetException(), instanceOf(HttpClientErrorException.class));
View Full Code Here

      assertThat(simulatedInputStream.hasUnreadData(), is(false));
      assertThat(commandResult.isSuccess(), is(true));
      Configuration configuration = bootstrap.getApplicationContext().getBean(Configuration.class);
      assertThat(configuration.getTarget().getTargetException(), instanceOf(HttpClientErrorException.class));
      assertThat(((HttpClientErrorException) configuration.getTarget().getTargetException()).getStatusCode(), equalTo(HttpStatus.UNAUTHORIZED));
      commandResult = shell.executeCommand("module list");
      assertThat(commandResult.isSuccess(), is(false));
    }
    finally {
      // restore the system input stream
      System.setIn(System.in);
View Full Code Here

      System.setIn(simulatedInputStream);
      Bootstrap bootstrap = new Bootstrap();
      JLineShellComponent shell = bootstrap.getJLineShellComponent();
      assertThat(simulatedInputStream.isReadPerformed(), is(false));
      assertThat(simulatedInputStream.hasUnreadData(), is(true));
      CommandResult commandResult = shell.executeCommand("admin config server --uri http://localhost:" + adminPort + " --username admin");
      assertThat(simulatedInputStream.isReadPerformed(), is(false)); // without the --password flag, the shell doesn't prompt and doesn't read from input
      assertThat(simulatedInputStream.hasUnreadData(), is(true));
      assertThat(commandResult.isSuccess(), is(true));
      Configuration configuration = bootstrap.getApplicationContext().getBean(Configuration.class);
      assertThat(configuration.getTarget().getTargetException(), instanceOf(HttpClientErrorException.class));
View Full Code Here

      assertThat(simulatedInputStream.hasUnreadData(), is(true));
      assertThat(commandResult.isSuccess(), is(true));
      Configuration configuration = bootstrap.getApplicationContext().getBean(Configuration.class);
      assertThat(configuration.getTarget().getTargetException(), instanceOf(HttpClientErrorException.class));
      assertThat(((HttpClientErrorException) configuration.getTarget().getTargetException()).getStatusCode(), equalTo(HttpStatus.UNAUTHORIZED));
      commandResult = shell.executeCommand("module list");
      assertThat(commandResult.isSuccess(), is(false));
    }
    finally {
      // restore the system input stream
      System.setIn(System.in);
View Full Code Here

  @Test
  public void testShellWithWrongCredentials() throws Exception {
    Bootstrap bootstrap = new Bootstrap();
    JLineShellComponent shell = bootstrap.getJLineShellComponent();
    CommandResult commandResult = shell.executeCommand("admin config server --uri http://localhost:" + adminPort + " --username admin --password whosThere2");
    assertThat(commandResult.isSuccess(), is(true));
    Configuration configuration = bootstrap.getApplicationContext().getBean(Configuration.class);
    assertThat(configuration.getTarget().getTargetException(), instanceOf(HttpClientErrorException.class));
    assertThat(((HttpClientErrorException) configuration.getTarget().getTargetException()).getStatusCode(), equalTo(HttpStatus.UNAUTHORIZED));
    commandResult = shell.executeCommand("module list");
View Full Code Here

    CommandResult commandResult = shell.executeCommand("admin config server --uri http://localhost:" + adminPort + " --username admin --password whosThere2");
    assertThat(commandResult.isSuccess(), is(true));
    Configuration configuration = bootstrap.getApplicationContext().getBean(Configuration.class);
    assertThat(configuration.getTarget().getTargetException(), instanceOf(HttpClientErrorException.class));
    assertThat(((HttpClientErrorException) configuration.getTarget().getTargetException()).getStatusCode(), equalTo(HttpStatus.UNAUTHORIZED));
    commandResult = shell.executeCommand("module list");
    assertThat(commandResult.isSuccess(), is(false));
  }

  @Test
  public void testShellWithMissingUsername() throws Exception {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.