use of com.axway.ats.common.filetransfer.FileTransferException in project ats-framework by Axway.
the class FileTransferClient method connect.
/**
* Connect to a remote host using secure authentication
*
* @param hostname
* the host to connect to
* @param keystoreFile
* the file containing the key store
* @param keystorePassword
* the key store password
* @param privateKeyAlias
* the private key alias
*/
@PublicAtsApi
public void connect(@Validate(name = "hostname", type = ValidationType.STRING_SERVER_ADDRESS) String hostname, @Validate(name = "keystoreFile", type = ValidationType.STRING_NOT_EMPTY) String keystoreFile, @Validate(name = "keystorePassword", type = ValidationType.STRING_NOT_EMPTY) String keystorePassword, @Validate(name = "privateKeyAlias", type = ValidationType.STRING_NOT_EMPTY) String privateKeyAlias) {
// validate input parameters
new Validator().validateMethodParameters(new Object[] { hostname, keystoreFile, keystorePassword, privateKeyAlias });
// connect using base authentication
Throwable throwable = null;
try {
this.client.connect(hostname, keystoreFile, keystorePassword, privateKeyAlias);
return;
} catch (FileTransferException e) {
throwable = e;
log.error("Connection attempt failed", e);
}
throw new FileTransferException("Could not connect. Look up the reason in the log.", (Exception) throwable);
}
use of com.axway.ats.common.filetransfer.FileTransferException in project ats-framework by Axway.
the class ClientFactory method loadCustomClient.
/**
* Instantiates the custom file transfer client
*
* @param customFileTransferClient the class name of the custom client
* @return
* @throws FileTransferException
*/
private IFileTransferClient loadCustomClient(String customFileTransferClient) throws FileTransferException {
try {
// load the custom client class
Class<?> customFileTransferClientClass = this.getClass().getClassLoader().loadClass(customFileTransferClient);
// make an instance of the custom client
IFileTransferClient client = (IFileTransferClient) customFileTransferClientClass.newInstance();
log.info("Loaded custom file transfer client: " + customFileTransferClient);
return client;
} catch (ClassNotFoundException e) {
throw new FileTransferException("Custom file transfer client not found in the classpath: " + customFileTransferClient);
} catch (ClassCastException e) {
throw new FileTransferException("Wrong type of the custom file transfer client: " + customFileTransferClient);
} catch (InstantiationException e) {
throw new FileTransferException("Unable to create an instance of the custom file transfer client: " + customFileTransferClient);
} catch (IllegalAccessException e) {
throw new FileTransferException("Unable to create an instance of the custom file transfer client: " + customFileTransferClient);
}
}
use of com.axway.ats.common.filetransfer.FileTransferException in project ats-framework by Axway.
the class Test_GenericTransferClient method testDisconnectNegative.
/**
* Test case
* @throws Exception
*/
@Test(expected = FileTransferException.class)
public void testDisconnectNegative() throws Exception {
// setup expectations
ftpMock.disconnect();
expectLastCall().andThrow(new FileTransferException("Exception"));
replay(ftpMock);
// execute operations
mockedTestObject.disconnect();
// verify results
verify(ftpMock);
}
use of com.axway.ats.common.filetransfer.FileTransferException in project ats-framework by Axway.
the class Test_GenericTransferClient method testFileUploadAltException.
/**
* Test case
* @throws Exception
*/
@Test(expected = FileTransferException.class)
public void testFileUploadAltException() throws Exception {
// setup expectations
File fileMock = createMockAndExpectNew(File.class, SAMPLE_LOCAL_DIRECTORY + SAMPLE_LOCAL_FILE);
expect(fileMock.getName()).andReturn(SAMPLE_LOCAL_FILE);
ftpMock.uploadFile(SAMPLE_LOCAL_DIRECTORY + SAMPLE_LOCAL_FILE, SAMPLE_REMOTE_DIRECTORY, SAMPLE_LOCAL_FILE);
expectLastCall().andThrow(new FileTransferException(SAMPLE_EXCEPTION_MESSAGE));
replayAll();
// execute operations
mockedTestObject.uploadFile(SAMPLE_LOCAL_DIRECTORY + SAMPLE_LOCAL_FILE, SAMPLE_REMOTE_DIRECTORY);
// verify results
verify(ftpMock);
}
use of com.axway.ats.common.filetransfer.FileTransferException in project ats-framework by Axway.
the class Test_GenericTransferClient method testResumePausedTransferException.
@Test(expected = FileTransferException.class)
public void testResumePausedTransferException() throws Exception {
// setup expectations
ftpMock.resumePausedTransfer();
expectLastCall().andThrow(new FileTransferException(SAMPLE_EXCEPTION_MESSAGE));
replay(ftpMock);
// execute operations
mockedTestObject.resumePausedTransfer();
// verify results
verify(ftpMock);
}
Aggregations