Examples of ShellOperation


Examples of com.cisco.telnet.server.domain.command.shell.operation.ShellOperation

  public CommandFactory() {
    shellOperationParser = new ShellOperationParser();
  }

  public TelnetCommand getCommand(String command) {
    ShellOperation shellOperation = shellOperationParser.getShellOperation(command);
    return commandsMap.get(shellOperation.getName());
  }
View Full Code Here

Examples of com.cisco.telnet.server.domain.command.shell.operation.ShellOperation

  }

  @Override
  public CommandResponse execute(CommandRequest commandRequest, SessionContext sessionContext) {
    System.out.println(sessionContext.getCurrentDirectory());
    ShellOperation shellOperation = shellOperationParser.getShellOperation(commandRequest.getRequestAsString());
    return executeOperation(shellOperation, sessionContext);
  }
View Full Code Here

Examples of com.cisco.telnet.server.domain.command.shell.operation.ShellOperation

  @Mock
  private SessionContext sessionContext;

  @Test
  public void testExecute() throws IOException {
    shellOperation = new ShellOperation(CommandFactory.PWD);
    Mockito.when(sessionContext.getCurrentDirectory()).thenReturn(CURRENT_DIR);
    response = pwdCommand.executeOperation(shellOperation, sessionContext);

    assertEquals(sessionContext.getCurrentDirectory(), response.getResultAsString());
    assertEquals(ResponseStatusEnum.OK, response.getResponseStatus());
View Full Code Here

Examples of com.cisco.telnet.server.domain.command.shell.operation.ShellOperation

    FileUtils.touch(new File(TMP_DIR + "/" + TMP_FILE1));
    FileUtils.touch(new File(TMP_DIR + "/" + TMP_FILE2));
    FileUtils.forceMkdir(new File(TMP_DIR + "/" + TMP_DIR1));
    String currentUserDir = System.getProperty("user.dir");
    Mockito.when(sessionContext.getCurrentDirectory()).thenReturn(currentUserDir);
    shellOperation = new ShellOperation(CommandFactory.LS, Arrays.asList(TMP_DIR));

    response = lsCommand.executeOperation(shellOperation, sessionContext);
    assertEquals(ResponseStatusEnum.OK, response.getResponseStatus());
    Assert.assertTrue(response.getResultAsString().contains(FILE + TAB + TMP_FILE1));
    Assert.assertTrue(response.getResultAsString().contains(FILE + TAB + TMP_FILE2));
View Full Code Here

Examples of com.cisco.telnet.server.domain.command.shell.operation.ShellOperation

  @Mock
  private SessionContext sessionContext;

  @Test
  public void testExecute() throws IOException {
    shellOperation = new ShellOperation(CommandFactory.MKDIR, Arrays.asList(TMP_DIR));
    String currentUserDir = System.getProperty("user.dir");
    Mockito.when(sessionContext.getCurrentDirectory()).thenReturn(currentUserDir);

    response = mkdirCommand.executeOperation(shellOperation, sessionContext);
View Full Code Here

Examples of com.cisco.telnet.server.domain.command.shell.operation.ShellOperation

  public void testExecute() throws IOException {
    File tmpDir = new File(TMP_DIR);
    FileUtils.forceMkdir(tmpDir);
    String currentUserDir = System.getProperty("user.dir");
    Mockito.when(sessionContext.getCurrentDirectory()).thenReturn(currentUserDir);
    shellOperation = new ShellOperation(CommandFactory.CD, Arrays.asList(TMP_DIR));

    response = cdCommand.executeOperation(shellOperation, sessionContext);

    assertEquals(ResponseStatusEnum.OK, response.getResponseStatus());
    // assertEquals(new File(TMP_DIR).getAbsoluteFile(),
View Full Code Here

Examples of com.cisco.telnet.server.domain.command.shell.operation.ShellOperation

    FileUtils.deleteDirectory(tmpDir);
  }

  @Test
  public void testExecuteNotFound() throws IOException {
    shellOperation = new ShellOperation(CommandFactory.CD, Arrays.asList(TMP_DIR));
    String currentUserDir = System.getProperty("user.dir");
    Mockito.when(sessionContext.getCurrentDirectory()).thenReturn(currentUserDir);
    CommandResponse commandResponse = cdCommand.executeOperation(shellOperation, sessionContext);

    assertEquals(ResponseStatusEnum.ERROR, commandResponse.getResponseStatus());
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.