@Test public void testExecuteCommandsWithoutEnvsetWithAuthentication() throws Exception { final TerminalProperties terminalProperties = TerminalProperties.getNewBuilder().setSkipEnvset(true) .setSpecifyDebugCcl(true).setOsPromptPattern("osPromptPattern").setCclPromptPattern("cclPromptPattern") .setCclLoginPromptPattern("cclLoginPromptPattern") .setCclLoginSuccessPromptPattern("cclLoginSuccessPromptPattern") .setCclLoginFailurePromptPatterns(Arrays.asList(new String[] { "pattern1", "pattern2" })) .setExpectationTimeout(333).build(); final CclCommandTerminal terminal = new CclCommandTerminal(terminalProperties, null); final String command1 = "command1 go"; terminal.executeCommands(sshTerminal, Collections.singletonList(command1), true); final ArgumentCaptor<List<CommandExpectationGroup>> commandGroupsCaptor = argumentCaptorListCommandExpectationGroup; verify(sshTerminal).executeCommandGroups(commandGroupsCaptor.capture()); final List<CommandExpectationGroup> commandExpectationGroups = commandGroupsCaptor.getValue(); assertThat(commandExpectationGroups.size()).isEqualTo(9); assertThat(commandExpectationGroups.get(0).getCommands()).isEqualTo(Collections.<String> emptyList()); assertThat(commandExpectationGroups.get(0).getExpectations()).isEqualTo(Collections.<String> emptyList()); assertThat(commandExpectationGroups.get(1).getCommands()).isEqualTo(Arrays.asList("$cer_exe/cclora_dbg")); assertThat(commandExpectationGroups.get(1).getExpectations()).isEqualTo(Arrays.asList("cclLoginPromptPattern")); assertThat(commandExpectationGroups.get(2).getCommands()).isEqualTo(Arrays.asList(domainUserName)); assertThat(commandExpectationGroups.get(2).getExpectations()).isEqualTo(Arrays.asList(domainUserName)); assertThat(commandExpectationGroups.get(3).getCommands()).isEqualTo(Arrays.asList(domainName)); assertThat(commandExpectationGroups.get(3).getExpectations()).isEqualTo(Arrays.asList(domainName)); assertThat(commandExpectationGroups.get(4).getCommands()).isEqualTo(Arrays.asList(domainPassword)); assertThat(commandExpectationGroups.get(4).getExpectations()) .isEqualTo(Arrays.asList("cclLoginSuccessPromptPattern", "pattern1", "pattern2")); assertThat(commandExpectationGroups.get(5).getCommands()).isEqualTo(Arrays.asList("", "")); assertThat(commandExpectationGroups.get(6).getCommands()).isEqualTo(Arrays.asList("reset", "%t")); assertThat(commandExpectationGroups.get(6).getExpectations()).isEqualTo(Arrays.asList("cclPromptPattern")); assertThat(commandExpectationGroups.get(7).getCommands()) .isEqualTo(Arrays.asList("set width 132 go", command1)); assertThat(commandExpectationGroups.get(7).getExpectations()).isEqualTo(Arrays.asList("cclPromptPattern", CclCommandTerminal.CCL_VIEWER_PATTERN, CclCommandTerminal.CCL_ABORT_PATTERN)); assertThat(commandExpectationGroups.get(8).getCommands()).isEqualTo(Arrays.asList("exit")); assertThat(commandExpectationGroups.get(8).getExpectations()).isEqualTo(Arrays.asList("osPromptPattern")); verify(sshTerminal).setExpectationTimeout(333); verify(sshTerminal, never()).setOutputStream(ArgumentMatchers.<OutputStream> any()); verify(jetmMock).collect(); }
public void executeCommands(final JSchSshTerminal terminal, final List<String> commands, final boolean authenticate) throws SshException { final EtmPoint point = PointFactory.getPoint(getClass(), "executeCommands"); try { final boolean hasStreamConfiguration = streamConfiguration != null; final boolean hasCclOutputStream = hasStreamConfiguration && OutputType.CCL_SESSION.equals(streamConfiguration.getOutputType()); if (hasStreamConfiguration) { terminal.setOutputStream(hasCclOutputStream ? new CclOutputStreamProxy(streamConfiguration.getOutputStream(), OUTPUT_START, OUTPUT_END) : new OutputStreamProxy(streamConfiguration.getOutputStream())); } terminal.setExpectationTimeout(terminalProperties.getExpectationTimeout()); final List<String> nonMergedCommands = new ArrayList<String>(); for (String command : commands) { final String splitCommands[] = command.split("\\n"); for (int index = 0; index < splitCommands.length; index++) { nonMergedCommands.add(splitCommands[index]); } } final List<CommandExpectationGroup> commandExpectationGroups = new ArrayList<CommandExpectationGroup>(); commandExpectationGroups.add(getSessionStartupGroup()); commandExpectationGroups.add(getCclLaunchGroup()); if (authenticate) { commandExpectationGroups.addAll(getAuthenticationGroups()); } commandExpectationGroups.add(getFinalizeLoginGroup()); commandExpectationGroups.add(getWaitForCcclReadyGroup()); commandExpectationGroups.add(getCclSessionGroup(nonMergedCommands, hasCclOutputStream)); commandExpectationGroups.add(getCclExitGroup()); terminal.executeCommandGroups(commandExpectationGroups); } finally { point.collect(); } }
CclCommandTerminal { public void executeCommands(final JSchSshTerminal terminal, final List<String> commands, final boolean authenticate) throws SshException { final EtmPoint point = PointFactory.getPoint(getClass(), "executeCommands"); try { final boolean hasStreamConfiguration = streamConfiguration != null; final boolean hasCclOutputStream = hasStreamConfiguration && OutputType.CCL_SESSION.equals(streamConfiguration.getOutputType()); if (hasStreamConfiguration) { terminal.setOutputStream(hasCclOutputStream ? new CclOutputStreamProxy(streamConfiguration.getOutputStream(), OUTPUT_START, OUTPUT_END) : new OutputStreamProxy(streamConfiguration.getOutputStream())); } terminal.setExpectationTimeout(terminalProperties.getExpectationTimeout()); final List<String> nonMergedCommands = new ArrayList<String>(); for (String command : commands) { final String splitCommands[] = command.split("\\n"); for (int index = 0; index < splitCommands.length; index++) { nonMergedCommands.add(splitCommands[index]); } } final List<CommandExpectationGroup> commandExpectationGroups = new ArrayList<CommandExpectationGroup>(); commandExpectationGroups.add(getSessionStartupGroup()); commandExpectationGroups.add(getCclLaunchGroup()); if (authenticate) { commandExpectationGroups.addAll(getAuthenticationGroups()); } commandExpectationGroups.add(getFinalizeLoginGroup()); commandExpectationGroups.add(getWaitForCcclReadyGroup()); commandExpectationGroups.add(getCclSessionGroup(nonMergedCommands, hasCclOutputStream)); commandExpectationGroups.add(getCclExitGroup()); terminal.executeCommandGroups(commandExpectationGroups); } finally { point.collect(); } } }
CclCommandTerminal { public void executeCommands(final JSchSshTerminal terminal, final List<String> commands, final boolean authenticate) throws SshException { final EtmPoint point = PointFactory.getPoint(getClass(), "executeCommands"); try { final boolean hasStreamConfiguration = streamConfiguration != null; final boolean hasCclOutputStream = hasStreamConfiguration && OutputType.CCL_SESSION.equals(streamConfiguration.getOutputType()); if (hasStreamConfiguration) { terminal.setOutputStream(hasCclOutputStream ? new CclOutputStreamProxy(streamConfiguration.getOutputStream(), OUTPUT_START, OUTPUT_END) : new OutputStreamProxy(streamConfiguration.getOutputStream())); } terminal.setExpectationTimeout(terminalProperties.getExpectationTimeout()); final List<String> nonMergedCommands = new ArrayList<String>(); for (String command : commands) { final String splitCommands[] = command.split("\\n"); for (int index = 0; index < splitCommands.length; index++) { nonMergedCommands.add(splitCommands[index]); } } final List<CommandExpectationGroup> commandExpectationGroups = new ArrayList<CommandExpectationGroup>(); commandExpectationGroups.add(getSessionStartupGroup()); commandExpectationGroups.add(getCclLaunchGroup()); if (authenticate) { commandExpectationGroups.addAll(getAuthenticationGroups()); } commandExpectationGroups.add(getFinalizeLoginGroup()); commandExpectationGroups.add(getWaitForCcclReadyGroup()); commandExpectationGroups.add(getCclSessionGroup(nonMergedCommands, hasCclOutputStream)); commandExpectationGroups.add(getCclExitGroup()); terminal.executeCommandGroups(commandExpectationGroups); } finally { point.collect(); } } CclCommandTerminal(final TerminalProperties terminalProperties,
            final OutputStreamConfiguration streamConfiguration); }
CclCommandTerminal { public void executeCommands(final JSchSshTerminal terminal, final List<String> commands, final boolean authenticate) throws SshException { final EtmPoint point = PointFactory.getPoint(getClass(), "executeCommands"); try { final boolean hasStreamConfiguration = streamConfiguration != null; final boolean hasCclOutputStream = hasStreamConfiguration && OutputType.CCL_SESSION.equals(streamConfiguration.getOutputType()); if (hasStreamConfiguration) { terminal.setOutputStream(hasCclOutputStream ? new CclOutputStreamProxy(streamConfiguration.getOutputStream(), OUTPUT_START, OUTPUT_END) : new OutputStreamProxy(streamConfiguration.getOutputStream())); } terminal.setExpectationTimeout(terminalProperties.getExpectationTimeout()); final List<String> nonMergedCommands = new ArrayList<String>(); for (String command : commands) { final String splitCommands[] = command.split("\\n"); for (int index = 0; index < splitCommands.length; index++) { nonMergedCommands.add(splitCommands[index]); } } final List<CommandExpectationGroup> commandExpectationGroups = new ArrayList<CommandExpectationGroup>(); commandExpectationGroups.add(getSessionStartupGroup()); commandExpectationGroups.add(getCclLaunchGroup()); if (authenticate) { commandExpectationGroups.addAll(getAuthenticationGroups()); } commandExpectationGroups.add(getFinalizeLoginGroup()); commandExpectationGroups.add(getWaitForCcclReadyGroup()); commandExpectationGroups.add(getCclSessionGroup(nonMergedCommands, hasCclOutputStream)); commandExpectationGroups.add(getCclExitGroup()); terminal.executeCommandGroups(commandExpectationGroups); } finally { point.collect(); } } CclCommandTerminal(final TerminalProperties terminalProperties,
            final OutputStreamConfiguration streamConfiguration); void executeCommands(final JSchSshTerminal terminal, final List<String> commands, final boolean authenticate); TerminalProperties getTerminalProperties(); }
CclCommandTerminal { public void executeCommands(final JSchSshTerminal terminal, final List<String> commands, final boolean authenticate) throws SshException { final EtmPoint point = PointFactory.getPoint(getClass(), "executeCommands"); try { final boolean hasStreamConfiguration = streamConfiguration != null; final boolean hasCclOutputStream = hasStreamConfiguration && OutputType.CCL_SESSION.equals(streamConfiguration.getOutputType()); if (hasStreamConfiguration) { terminal.setOutputStream(hasCclOutputStream ? new CclOutputStreamProxy(streamConfiguration.getOutputStream(), OUTPUT_START, OUTPUT_END) : new OutputStreamProxy(streamConfiguration.getOutputStream())); } terminal.setExpectationTimeout(terminalProperties.getExpectationTimeout()); final List<String> nonMergedCommands = new ArrayList<String>(); for (String command : commands) { final String splitCommands[] = command.split("\\n"); for (int index = 0; index < splitCommands.length; index++) { nonMergedCommands.add(splitCommands[index]); } } final List<CommandExpectationGroup> commandExpectationGroups = new ArrayList<CommandExpectationGroup>(); commandExpectationGroups.add(getSessionStartupGroup()); commandExpectationGroups.add(getCclLaunchGroup()); if (authenticate) { commandExpectationGroups.addAll(getAuthenticationGroups()); } commandExpectationGroups.add(getFinalizeLoginGroup()); commandExpectationGroups.add(getWaitForCcclReadyGroup()); commandExpectationGroups.add(getCclSessionGroup(nonMergedCommands, hasCclOutputStream)); commandExpectationGroups.add(getCclExitGroup()); terminal.executeCommandGroups(commandExpectationGroups); } finally { point.collect(); } } CclCommandTerminal(final TerminalProperties terminalProperties,
            final OutputStreamConfiguration streamConfiguration); void executeCommands(final JSchSshTerminal terminal, final List<String> commands, final boolean authenticate); TerminalProperties getTerminalProperties(); static final String CCL_VIEWER_PATTERN; static final String CCL_ABORT_PATTERN; }