Search in sources :

Example 36 with FileSystemOperationException

use of com.axway.ats.common.filesystem.FileSystemOperationException in project ats-framework by Axway.

the class RemoteFileSystemOperations method copyDirectory.

@Override
public void copyDirectory(String fromDirName, String toDirName, boolean isRecursive, boolean failOnError) {
    try {
        int port = remoteFileSystemOperations.openFileTransferSocket();
        localFileSystemOperations.sendDirectoryTo(fromDirName, toDirName, HostUtils.splitAddressHostAndPort(atsAgent)[0], port, isRecursive, failOnError);
        remoteFileSystemOperations.waitForFileTransferCompletion(port);
    } catch (Exception e) {
        String message = new StringBuilder().append("Unable to copy directory ").append(fromDirName).append(" to ").append(toDirName).append(" on host ").append(this.atsAgent).toString();
        throw new FileSystemOperationException(message, e);
    }
}
Also used : FileSystemOperationException(com.axway.ats.common.filesystem.FileSystemOperationException) FileSystemOperationException(com.axway.ats.common.filesystem.FileSystemOperationException)

Example 37 with FileSystemOperationException

use of com.axway.ats.common.filesystem.FileSystemOperationException in project ats-framework by Axway.

the class Test_FileSystemOperations method testPurgeDirectoryRemoteException.

/**
 * Test case
 * @throws Exception
 */
@Test(expected = FileSystemOperationException.class)
public void testPurgeDirectoryRemoteException() throws Exception {
    // setup expectations
    expectNew(RemoteFileSystemOperations.class, REMOTE_HOST_NAME_VALID).andReturn(remoteFSOperationsMock);
    remoteFSOperationsMock.purgeDirectoryContents(SOURCE_DIRECTORY_NAME_VALID);
    expectLastCall().andThrow(new FileSystemOperationException("Test"));
    replayAll();
    // execute operation
    fileSystemOperationsRemote.deleteDirectoryContent(SOURCE_DIRECTORY_NAME_VALID);
    // verify results
    verifyAll();
}
Also used : FileSystemOperationException(com.axway.ats.common.filesystem.FileSystemOperationException) RemoteFileSystemOperations(com.axway.ats.action.filesystem.RemoteFileSystemOperations) BaseTest(com.axway.ats.action.BaseTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 38 with FileSystemOperationException

use of com.axway.ats.common.filesystem.FileSystemOperationException in project ats-framework by Axway.

the class Test_FileSystemOperations method computeMD5NegativeExceptionRemote.

/**
 * Test case
 * @throws Exception
 */
@Test(expected = FileSystemOperationException.class)
public void computeMD5NegativeExceptionRemote() throws Exception {
    // setup expectations
    expectNew(RemoteFileSystemOperations.class, REMOTE_HOST_NAME_VALID).andReturn(remoteFSOperationsMock);
    expect(remoteFSOperationsMock.computeMd5Sum(SOURCE_FILE_NAME_VALID, Md5SumMode.BINARY)).andThrow(new FileSystemOperationException("Test"));
    replayAll();
    // execute operation
    fileSystemOperationsRemote.computeMd5Sum(SOURCE_FILE_NAME_VALID, Md5SumMode.BINARY);
    // verify results
    verifyAll();
}
Also used : FileSystemOperationException(com.axway.ats.common.filesystem.FileSystemOperationException) RemoteFileSystemOperations(com.axway.ats.action.filesystem.RemoteFileSystemOperations) BaseTest(com.axway.ats.action.BaseTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 39 with FileSystemOperationException

use of com.axway.ats.common.filesystem.FileSystemOperationException in project ats-framework by Axway.

the class Test_FileSystemOperations method testDeleteDirectoryRemoteException.

/**
 * Test case
 * @throws Exception
 */
@Test(expected = FileSystemOperationException.class)
public void testDeleteDirectoryRemoteException() throws Exception {
    // setup expectations
    expectNew(RemoteFileSystemOperations.class, REMOTE_HOST_NAME_VALID).andReturn(remoteFSOperationsMock);
    remoteFSOperationsMock.deleteDirectory(SOURCE_DIRECTORY_NAME_VALID, true);
    expectLastCall().andThrow(new FileSystemOperationException("Test"));
    replayAll();
    // execute operation
    fileSystemOperationsRemote.deleteDirectory(SOURCE_DIRECTORY_NAME_VALID);
    // verify results
    verifyAll();
}
Also used : FileSystemOperationException(com.axway.ats.common.filesystem.FileSystemOperationException) RemoteFileSystemOperations(com.axway.ats.action.filesystem.RemoteFileSystemOperations) BaseTest(com.axway.ats.action.BaseTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 40 with FileSystemOperationException

use of com.axway.ats.common.filesystem.FileSystemOperationException in project ats-framework by Axway.

the class Test_FileSystemOperations method testCreateFileLocalAltNegativeException.

/**
 * Test case
 * @throws Exception
 */
@Test(expected = FileSystemOperationException.class)
public void testCreateFileLocalAltNegativeException() throws Exception {
    // setup expectations
    expectNew(LocalFileSystemOperations.class).andReturn(localFSOperationsMock);
    localFSOperationsMock.createFile(SOURCE_FILE_NAME_VALID, FILE_SIZE_VALID, true, EndOfLineStyle.UNIX);
    expectLastCall().andThrow(new FileSystemOperationException("Test"));
    replayAll();
    // execute operation
    fileSystemOperationsLocal.createFile(SOURCE_FILE_NAME_VALID, FILE_SIZE_VALID, EndOfLineStyle.UNIX, true);
    // verify results
    verifyAll();
}
Also used : LocalFileSystemOperations(com.axway.ats.core.filesystem.LocalFileSystemOperations) FileSystemOperationException(com.axway.ats.common.filesystem.FileSystemOperationException) BaseTest(com.axway.ats.action.BaseTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

FileSystemOperationException (com.axway.ats.common.filesystem.FileSystemOperationException)58 IOException (java.io.IOException)32 File (java.io.File)31 RandomAccessFile (java.io.RandomAccessFile)29 ZipFile (org.apache.commons.compress.archivers.zip.ZipFile)29 FileDoesNotExistException (com.axway.ats.core.filesystem.exceptions.FileDoesNotExistException)16 FileNotFoundException (java.io.FileNotFoundException)16 SocketTimeoutException (java.net.SocketTimeoutException)14 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)14 AttributeNotSupportedException (com.axway.ats.core.filesystem.exceptions.AttributeNotSupportedException)13 EOFException (java.io.EOFException)13 OverlappingFileLockException (java.nio.channels.OverlappingFileLockException)13 FileOutputStream (java.io.FileOutputStream)10 FileInputStream (java.io.FileInputStream)9 BufferedOutputStream (java.io.BufferedOutputStream)8 DataOutputStream (java.io.DataOutputStream)8 BaseTest (com.axway.ats.action.BaseTest)7 LocalFileSystemOperations (com.axway.ats.core.filesystem.LocalFileSystemOperations)7 Test (org.junit.Test)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7