@SuppressWarnings("unchecked") @Test public void testDefaultPatterns() throws Exception { Pattern pattern1 = Pattern.compile( TerminalProperties.constructDefaultOsPromptPattern("noops", "hillside", "aa111111"), Pattern.MULTILINE); assertThat(pattern1.matcher("aa111111:hillside@noops:/home/aa111111\r\n#").matches()).isEqualTo(true); Pattern pattern2 = Pattern.compile((String) DEFAULT_CCL_PROMPT_PATTERN.get(TerminalProperties.class), Pattern.MULTILINE); assertThat(pattern2.matcher("\n 0)").matches()).isEqualTo(false); assertThat(pattern2.matcher("\n 03)").matches()).isEqualTo(false); assertThat(pattern2.matcher("\n076)").matches()).isEqualTo(false); assertThat(pattern2.matcher("\n 1)").matches()).isEqualTo(true); assertThat(pattern2.matcher("\n 21)").matches()).isEqualTo(true); assertThat(pattern2.matcher("\n543)").matches()).isEqualTo(true); assertThat(pattern2.matcher("\n1392)").matches()).isEqualTo(true); Pattern pattern3 = Pattern.compile((String) DEFAULT_CCL_LOGIN_PROMPT_PATTERN.get(TerminalProperties.class), Pattern.MULTILINE); assertThat(pattern3.matcher("(Hit PF3 or RETURN to skip security login; this will disable Uar functions)") .matches()).isEqualTo(true); Pattern pattern4 = Pattern.compile( (String) DEFAULT_CCL_LOGIN_SUCCESS_PROMPT_PATTERN.get(TerminalProperties.class), Pattern.MULTILINE); assertThat(pattern4.matcher("Enter Y to continue Y").matches()).isEqualTo(true); Pattern pattern5 = Pattern.compile( ((List<String>) DEFAULT_CCL_LOGIN_FAILURE_PROMPT_PATTERNS.get(TerminalProperties.class)).get(0), Pattern.MULTILINE); assertThat(pattern5.matcher("V500 SECURITY LOGIN FAILURE").matches()).isEqualTo(true); Pattern pattern6 = Pattern.compile( ((List<String>) DEFAULT_CCL_LOGIN_FAILURE_PROMPT_PATTERNS.get(TerminalProperties.class)).get(1), Pattern.MULTILINE); assertThat(pattern6.matcher("V500 SECURITY LOGIN WARNING").matches()).isEqualTo(true); Pattern pattern7 = Pattern.compile( ((List<String>) DEFAULT_CCL_LOGIN_FAILURE_PROMPT_PATTERNS.get(TerminalProperties.class)).get(2), Pattern.MULTILINE); assertThat(pattern7.matcher("Retry (Y/N)").matches()).isEqualTo(true); Pattern pattern8 = Pattern.compile( ((List<String>) DEFAULT_CCL_LOGIN_FAILURE_PROMPT_PATTERNS.get(TerminalProperties.class)).get(3), Pattern.MULTILINE); assertThat(pattern8.matcher("Repeat New Password:").matches()).isEqualTo(true); }
public static String constructDefaultOsPromptPattern(final String host, final String environment, final String username) { return new StringBuilder().append(username).append(":") .append(environment != null && !environment.isEmpty() ? environment : "\\w*").append("@").append(host) .append(":").append("[^\\r\\n]*(\\r|\\n)+#\\s*").toString(); }
TerminalProperties { public static String constructDefaultOsPromptPattern(final String host, final String environment, final String username) { return new StringBuilder().append(username).append(":") .append(environment != null && !environment.isEmpty() ? environment : "\\w*").append("@").append(host) .append(":").append("[^\\r\\n]*(\\r|\\n)+#\\s*").toString(); } }
TerminalProperties { public static String constructDefaultOsPromptPattern(final String host, final String environment, final String username) { return new StringBuilder().append(username).append(":") .append(environment != null && !environment.isEmpty() ? environment : "\\w*").append("@").append(host) .append(":").append("[^\\r\\n]*(\\r|\\n)+#\\s*").toString(); } private  TerminalProperties(); private  TerminalProperties(final TerminalPropertiesBuilder builder); }
TerminalProperties { public static String constructDefaultOsPromptPattern(final String host, final String environment, final String username) { return new StringBuilder().append(username).append(":") .append(environment != null && !environment.isEmpty() ? environment : "\\w*").append("@").append(host) .append(":").append("[^\\r\\n]*(\\r|\\n)+#\\s*").toString(); } private  TerminalProperties(); private  TerminalProperties(final TerminalPropertiesBuilder builder); static String constructDefaultOsPromptPattern(final String host, final String environment,
            final String username); static TerminalPropertiesBuilder getNewBuilder(); boolean getSkipEnvset(); String getOsPromptPattern(); String getCclPromptPattern(); String getCclLoginPromptPattern(); String getCclLoginSuccessPromptPattern(); List<String> getCclLoginFailurePromptPatterns(); long getExpectationTimeout(); boolean getSpecifyDebugCcl(); String getLogfileLocation(); @Override boolean equals(final Object obj); @Override int hashCode(); static void setGlobalTerminalProperties(final TerminalProperties terminalProperties); static TerminalProperties getGlobalTerminalProperties(); }
TerminalProperties { public static String constructDefaultOsPromptPattern(final String host, final String environment, final String username) { return new StringBuilder().append(username).append(":") .append(environment != null && !environment.isEmpty() ? environment : "\\w*").append("@").append(host) .append(":").append("[^\\r\\n]*(\\r|\\n)+#\\s*").toString(); } private  TerminalProperties(); private  TerminalProperties(final TerminalPropertiesBuilder builder); static String constructDefaultOsPromptPattern(final String host, final String environment,
            final String username); static TerminalPropertiesBuilder getNewBuilder(); boolean getSkipEnvset(); String getOsPromptPattern(); String getCclPromptPattern(); String getCclLoginPromptPattern(); String getCclLoginSuccessPromptPattern(); List<String> getCclLoginFailurePromptPatterns(); long getExpectationTimeout(); boolean getSpecifyDebugCcl(); String getLogfileLocation(); @Override boolean equals(final Object obj); @Override int hashCode(); static void setGlobalTerminalProperties(final TerminalProperties terminalProperties); static TerminalProperties getGlobalTerminalProperties();  }