Search in sources :

Example 1 with RbvStorageException

use of com.axway.ats.rbv.model.RbvStorageException in project ats-framework by Axway.

the class FileMd5Rule method performMatch.

@Override
public boolean performMatch(MetaData metaData) throws RbvException {
    boolean actualResult = false;
    if (metaData instanceof FileSystemMetaData) {
        //get the file from the meta data
        FilePackage file = ((FileSystemMetaData) metaData).getFilePackage();
        try {
            String destMD5 = file.getMd5sum(this.binaryMode);
            actualResult = !StringUtils.isNullOrEmpty(destMD5) && destMD5.equals(this.srcMD5);
        } catch (PackageException pe) {
            throw new RbvStorageException(pe);
        }
    }
    return actualResult;
}
Also used : FilePackage(com.axway.ats.action.objects.FilePackage) PackageException(com.axway.ats.action.objects.model.PackageException) RbvStorageException(com.axway.ats.rbv.model.RbvStorageException) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData)

Example 2 with RbvStorageException

use of com.axway.ats.rbv.model.RbvStorageException in project ats-framework by Axway.

the class FileSizeRule method performMatch.

@Override
public boolean performMatch(MetaData metaData) throws RbvException {
    boolean actuaResult = false;
    if (metaData instanceof FileSystemMetaData) {
        //get the file from the meta data
        FilePackage file = ((FileSystemMetaData) metaData).getFilePackage();
        try {
            //get destination file's size
            long destSize = file.getSize();
            actuaResult = this.srcSize == destSize;
        } catch (PackageException pe) {
            throw new RbvStorageException(pe);
        }
    }
    return actuaResult;
}
Also used : FilePackage(com.axway.ats.action.objects.FilePackage) PackageException(com.axway.ats.action.objects.model.PackageException) RbvStorageException(com.axway.ats.rbv.model.RbvStorageException) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData)

Example 3 with RbvStorageException

use of com.axway.ats.rbv.model.RbvStorageException in project ats-framework by Axway.

the class ImapFolder method open.

/**
     *
     * @see com.axway.ats.rbv.storage.Matchable#open()
     */
public void open() throws RbvStorageException {
    //first check if the folder is already open
    if (isOpen) {
        throw new MatchableAlreadyOpenException(getDescription() + " is already open");
    }
    try {
        isInitialPass = true;
        // create and connect to the user's imap folder
        if (!store.isConnected()) {
            store.connect(serverHost, userName, password);
            log.debug("Connected to store '" + serverHost + "' with user '" + userName + "' and password '" + password + "'");
        }
        if (folder == null || !folder.isOpen()) {
            folder = store.getFolder(folderName);
            folder.open(Folder.READ_WRITE);
        }
        allMetaDataList.clear();
        newMetaDataList.clear();
        isOpen = true;
        log.info("Opened " + getDescription());
    } catch (MessagingException me) {
        throw new RbvStorageException("Could not open " + getDescription(), me);
    }
}
Also used : MatchableAlreadyOpenException(com.axway.ats.rbv.model.MatchableAlreadyOpenException) MessagingException(javax.mail.MessagingException) RbvStorageException(com.axway.ats.rbv.model.RbvStorageException)

Example 4 with RbvStorageException

use of com.axway.ats.rbv.model.RbvStorageException in project ats-framework by Axway.

the class Test_RBVStorageException method constructors.

@Test
public void constructors() {
    RbvStorageException exception;
    exception = new RbvStorageException("test");
    assertEquals("test", exception.getMessage());
    assertNull(exception.getCause());
    Exception helperException = new Exception();
    exception = new RbvStorageException("test", helperException);
    assertEquals("test", exception.getMessage());
    assertEquals(helperException, exception.getCause());
    exception = new RbvStorageException(helperException);
    assertEquals("java.lang.Exception", exception.getMessage());
    assertEquals(helperException, exception.getCause());
}
Also used : RbvStorageException(com.axway.ats.rbv.model.RbvStorageException) RbvStorageException(com.axway.ats.rbv.model.RbvStorageException) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 5 with RbvStorageException

use of com.axway.ats.rbv.model.RbvStorageException in project ats-framework by Axway.

the class Test_FileSystemFolder method openNegativeInvalidHost.

@Test(expected = InvalidInputArgumentsException.class)
public void openNegativeInvalidHost() throws Exception {
    expectNew(SystemOperations.class, "invalid hosttt").andThrow(new RbvStorageException("Could not open File system folder '/tmp/test/' on server 'invalid hosttt'"));
    replayAll();
    FileSystemStorage invalidStorage = new FileSystemStorage("invalid hosttt");
    FileSystemFolder folder = (FileSystemFolder) invalidStorage.getFolder(new FileSystemFolderSearchTerm(path, null, true));
    folder.open();
    verifyAll();
}
Also used : FileSystemOperations(com.axway.ats.action.filesystem.FileSystemOperations) SystemOperations(com.axway.ats.action.system.SystemOperations) FileSystemStorage(com.axway.ats.rbv.filesystem.FileSystemStorage) RbvStorageException(com.axway.ats.rbv.model.RbvStorageException) FileSystemFolder(com.axway.ats.rbv.filesystem.FileSystemFolder) FileSystemFolderSearchTerm(com.axway.ats.rbv.filesystem.FileSystemFolderSearchTerm) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Aggregations

RbvStorageException (com.axway.ats.rbv.model.RbvStorageException)13 PackageException (com.axway.ats.action.objects.model.PackageException)5 MatchableNotOpenException (com.axway.ats.rbv.model.MatchableNotOpenException)5 MessagingException (javax.mail.MessagingException)5 FilePackage (com.axway.ats.action.objects.FilePackage)3 FileSystemMetaData (com.axway.ats.rbv.filesystem.FileSystemMetaData)3 PublicAtsApi (com.axway.ats.common.PublicAtsApi)2 BaseTest (com.axway.ats.rbv.BaseTest)2 MatchableAlreadyOpenException (com.axway.ats.rbv.model.MatchableAlreadyOpenException)2 Message (javax.mail.Message)2 MimeMessage (javax.mail.internet.MimeMessage)2 Test (org.junit.Test)2 FileSystemOperations (com.axway.ats.action.filesystem.FileSystemOperations)1 MimePackage (com.axway.ats.action.objects.MimePackage)1 SystemOperations (com.axway.ats.action.system.SystemOperations)1 FileSystemFolder (com.axway.ats.rbv.filesystem.FileSystemFolder)1 FileSystemFolderSearchTerm (com.axway.ats.rbv.filesystem.FileSystemFolderSearchTerm)1 FileSystemStorage (com.axway.ats.rbv.filesystem.FileSystemStorage)1 RbvException (com.axway.ats.rbv.model.RbvException)1 Flags (javax.mail.Flags)1