@Test public void testConnect() throws Exception { SftpAuthenticationProvider mockProvider = Mockito.mock(SftpAuthenticationProvider.class); SftpClient mockClient = Mockito.mock(SftpClient.class); when(mockProvider.connect(any(), any())).thenReturn(mockClient); SftpAuthenticationWrapper wrapper = new SftpAuthenticationWrapper(mockProvider); assertEquals(mockClient, wrapper.connect(mockClient, null)); }
@Override public SftpClient connect(SftpClient sftp, UserInfo ui) throws FileTransferException, IOException, PasswordException { boolean connected = false; for (SftpAuthenticationProvider p : getProviders()) { if (connect(sftp, ui, p)) { connected = true; break; } } if (!connected) { throw new FileTransferException("Failed to connect via any configured authentication providers"); } return sftp; }
SftpAuthenticationWrapper implements SftpAuthenticationProvider { @Override public SftpClient connect(SftpClient sftp, UserInfo ui) throws FileTransferException, IOException, PasswordException { boolean connected = false; for (SftpAuthenticationProvider p : getProviders()) { if (connect(sftp, ui, p)) { connected = true; break; } } if (!connected) { throw new FileTransferException("Failed to connect via any configured authentication providers"); } return sftp; } }
SftpAuthenticationWrapper implements SftpAuthenticationProvider { @Override public SftpClient connect(SftpClient sftp, UserInfo ui) throws FileTransferException, IOException, PasswordException { boolean connected = false; for (SftpAuthenticationProvider p : getProviders()) { if (connect(sftp, ui, p)) { connected = true; break; } } if (!connected) { throw new FileTransferException("Failed to connect via any configured authentication providers"); } return sftp; } SftpAuthenticationWrapper();  SftpAuthenticationWrapper(SftpAuthenticationProvider... auths); }
SftpAuthenticationWrapper implements SftpAuthenticationProvider { @Override public SftpClient connect(SftpClient sftp, UserInfo ui) throws FileTransferException, IOException, PasswordException { boolean connected = false; for (SftpAuthenticationProvider p : getProviders()) { if (connect(sftp, ui, p)) { connected = true; break; } } if (!connected) { throw new FileTransferException("Failed to connect via any configured authentication providers"); } return sftp; } SftpAuthenticationWrapper();  SftpAuthenticationWrapper(SftpAuthenticationProvider... auths); @Override SftpClient connect(SftpClient sftp, UserInfo ui); List<SftpAuthenticationProvider> getProviders(); void setProviders(List<SftpAuthenticationProvider> list); Boolean getLogExceptions(); void setLogExceptions(Boolean b); }
SftpAuthenticationWrapper implements SftpAuthenticationProvider { @Override public SftpClient connect(SftpClient sftp, UserInfo ui) throws FileTransferException, IOException, PasswordException { boolean connected = false; for (SftpAuthenticationProvider p : getProviders()) { if (connect(sftp, ui, p)) { connected = true; break; } } if (!connected) { throw new FileTransferException("Failed to connect via any configured authentication providers"); } return sftp; } SftpAuthenticationWrapper();  SftpAuthenticationWrapper(SftpAuthenticationProvider... auths); @Override SftpClient connect(SftpClient sftp, UserInfo ui); List<SftpAuthenticationProvider> getProviders(); void setProviders(List<SftpAuthenticationProvider> list); Boolean getLogExceptions(); void setLogExceptions(Boolean b);  }