@Test
  public void testSendFileWithSftpException() throws Exception {
    mockJSch = createMock(JSch.class);
    mockSession = createMock(Session.class);
    mockChannelSftp = createMock(ChannelSftp.class);
    expect(mockJSch.getSession(USERNAME, HOSTNAME, PORT)).andReturn(mockSession);
    mockSession.setPassword(PASSWORD);
    mockSession.setConfig(STRICTHOSTKEYCHECKING, STRICTHOSTKEYCHECKING_VALUE);
    mockSession.connect();
    expect(mockSession.openChannel("sftp")).andReturn(mockChannelSftp);
    mockChannelSftp.connect();
    mockChannelSftp.put(isA(InputStream.class), eq(FTPDESTINATIONFILENAME));
    expectLastCall().andThrow(new SftpException(1, "Test"));
    replay(mockJSch, mockSession, mockChannelSftp);

    sftpClientImpl.setJsch(mockJSch);

    assertEquals(false, sftpClientImpl.sendFile(FILE_CONTENT));
    assertEquals("Error in SftpClient\n", logFactoryMock.getError(true));
  }
 @Before
 public void setup() throws JSchException, SftpException {
   mockJSch = createMock(JSch.class);
   mockSession = createMock(Session.class);
   mockChannelSftp = createMock(ChannelSftp.class);
   expect(mockJSch.getSession(USERNAME, HOSTNAME, PORT)).andReturn(mockSession);
   mockSession.setPassword(PASSWORD);
   mockSession.setConfig(STRICTHOSTKEYCHECKING, STRICTHOSTKEYCHECKING_VALUE);
   mockSession.connect();
   expect(mockSession.openChannel("sftp")).andReturn(mockChannelSftp);
   mockChannelSftp.connect();
   mockChannelSftp.put(isA(InputStream.class), eq(FTPDESTINATIONFILENAME));
   mockChannelSftp.disconnect();
   mockSession.disconnect();
   replay(mockJSch, mockSession, mockChannelSftp);
   sftpClientImpl.setJsch(mockJSch);
   sftpClientImpl.setFtpDestinationFileName(FTPDESTINATIONFILENAME);
   sftpClientImpl.setHostname(HOSTNAME);
   sftpClientImpl.setPassword(PASSWORD);
   sftpClientImpl.setUsername(USERNAME);
   sftpClientImpl.setPort(PORT);
   logFactoryMock.getError(true);
 }