Package org.springframework.shell

Examples of org.springframework.shell.Bootstrap


import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    Bootstrap bootstrap = new Bootstrap("META-INF/spring/spring-shell-plugin.xml");
  }
View Full Code Here


    RandomConfigurationSupport randomConfigSupport = new RandomConfigurationSupport();
    if (application == null) {
      application = new SingleNodeApplication().run("--transport", "local", "--analytics", "redis");
      integrationTestSupport = new SingleNodeIntegrationTestSupport(application);
      integrationTestSupport.addModuleRegistry(new ArchiveModuleRegistry("classpath:/spring-xd/xd/modules"));
      Bootstrap bootstrap = new Bootstrap(new String[] { "--port", randomConfigSupport.getAdminServerPort() });
      shell = bootstrap.getJLineShellComponent();
    }
    if (!shell.isRunning()) {
      shell.start();
    }
  }
View Full Code Here

    adminPort = singleNodeApplication.adminContext().getEnvironment().resolvePlaceholders("${server.port}");
  }

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

  public void testShellWithPasswordFlag() throws Exception {
    try {
      // Simulate user input by replacing the system input stream
      SimulatedInputStream simulatedInputStream = new SimulatedInputStream("whosThere\n");
      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));
View Full Code Here

  public void testShellWithPasswordFlagFailsIfPasswordIsWrong() throws Exception {
    try {
      // Simulate user input by replacing the system input stream
      SimulatedInputStream simulatedInputStream = new SimulatedInputStream("aWrongPassword\n");
      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));
      assertThat(((HttpClientErrorException) configuration.getTarget().getTargetException()).getStatusCode(), equalTo(HttpStatus.UNAUTHORIZED));
      commandResult = shell.executeCommand("module list");
      assertThat(commandResult.isSuccess(), is(false));
    }
View Full Code Here

  public void testShellNoPromptWithoutPasswordFlag() throws Exception {
    try {
      // Simulate user input by replacing the system input stream
      SimulatedInputStream simulatedInputStream = new SimulatedInputStream("whosThere\n");
      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));
      assertThat(((HttpClientErrorException) configuration.getTarget().getTargetException()).getStatusCode(), equalTo(HttpStatus.UNAUTHORIZED));
      commandResult = shell.executeCommand("module list");
      assertThat(commandResult.isSuccess(), is(false));
    }
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");
    assertThat(commandResult.isSuccess(), is(false));
  }
View Full Code Here

    assertThat(commandResult.isSuccess(), is(false));
  }

  @Test
  public void testShellWithMissingUsername() throws Exception {
    Bootstrap bootstrap = new Bootstrap();
    JLineShellComponent shell = bootstrap.getJLineShellComponent();
    CommandResult commandResult = shell.executeCommand("admin config server --uri http://localhost:" + adminPort + " --password whosThere");
    assertThat(commandResult.isSuccess(), is(true));
    Configuration configuration = bootstrap.getApplicationContext().getBean(Configuration.class);
    assertThat(configuration.getTarget().getTargetException(), instanceOf(IllegalArgumentException.class));
    assertThat(configuration.getTarget().getTargetException().getMessage(), equalTo("A password may be specified only together with a user name"));
    commandResult = shell.executeCommand("module list");
    assertThat(commandResult.isSuccess(), is(false));
  }
View Full Code Here

public class HelloWorldCommandTests {

  @Test
  public void testSimple() {
    Bootstrap bootstrap = new Bootstrap();
   
    JLineShellComponent shell = bootstrap.getJLineShellComponent();
   
    CommandResult cr = shell.executeCommand("hw simple --message hello");
    assertEquals(true, cr.isSuccess());
    assertEquals("Message = [hello] Location = [null]", cr.getResult());
  }
View Full Code Here

  private static JLineShellComponent shell;
 
  @BeforeClass
  public static void startUp() throws InterruptedException {
    Bootstrap bootstrap = new Bootstrap();   
    shell = bootstrap.getJLineShellComponent();
  }
View Full Code Here

TOP

Related Classes of org.springframework.shell.Bootstrap

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.