CLITaskConnector { public void createConnection() throws JSchException { if ( this.ipAddress != null && this.sshPort > 0 && this.sshPort < 65535 ) { Properties config = new java.util.Properties(); config.put( "StrictHostKeyChecking", "no" ); session = SshUtil.getSessionObject( this.sshUser, this.sshPwd, this.ipAddress, this.sshPort, config ); try { session.connect( 30000 ); } catch ( JSchException e ) { if ( session != null ) { session.disconnect(); session = null; throw e; } logger.error( "Unable to create jsch CLI session: ", e ); } } } CLITaskConnector( String sshUser, String sshPwd, String ipAddress, int sshPort ); Session getSession(); void createConnection(); void destroy();  }
@Test @Ignore public void testCreateConnection() throws Exception { logger.info( "[TS] : testCreateConnection" ); String username = "root"; String password = "root123"; String hostname = "10.28.197.24"; int port = 22; CLITaskConnector instance = new CLITaskConnector( username, password, hostname, port ); instance.createConnection(); logger.info( "[TS] : Expected Result: Session = NOT NULL, Actual Result: Session=" + instance.getSession() ); assertNotNull( instance.getSession() ); }