Search in sources :

Example 6 with FileSystemFolder

use of com.axway.ats.rbv.filesystem.FileSystemFolder in project ats-framework by Axway.

the class Test_FileSystemFolder method getAllMetadataExceptionExists.

@Test(expected = RbvException.class)
public void getAllMetadataExceptionExists() throws Exception {
    // constructor
    expectNew(FileSystemOperations.class, "localhost:0000").andThrow(new RbvException("Test"));
    replayAll();
    FileSystemFolder folder = new FileSystemFolder("localhost:0000", "some.path", null, true, false);
    folder.open();
    assertEquals(folder.getAllMetaData(), new ArrayList<MetaData>());
    verifyAll();
}
Also used : RbvException(com.axway.ats.rbv.model.RbvException) MetaData(com.axway.ats.rbv.MetaData) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) FileSystemOperations(com.axway.ats.action.filesystem.FileSystemOperations) FileSystemFolder(com.axway.ats.rbv.filesystem.FileSystemFolder) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 7 with FileSystemFolder

use of com.axway.ats.rbv.filesystem.FileSystemFolder in project ats-framework by Axway.

the class Test_FileSystemFolder method openNegativeInvalidPath.

@Test
public void openNegativeInvalidPath() throws Exception {
    expectNew(SystemOperations.class, "localhost:0000").andReturn(systemOperations);
    expect(systemOperations.getOperatingSystemType()).andReturn(OperatingSystemType.LINUX);
    replayAll();
    //should pass - only warning should be logged
    FileSystemFolder folder = (FileSystemFolder) storage.getFolder(new FileSystemFolderSearchTerm(";;;", null, true));
    folder.open();
    verifyAll();
}
Also used : FileSystemOperations(com.axway.ats.action.filesystem.FileSystemOperations) SystemOperations(com.axway.ats.action.system.SystemOperations) 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)

Example 8 with FileSystemFolder

use of com.axway.ats.rbv.filesystem.FileSystemFolder in project ats-framework by Axway.

the class Test_FileSystemFolder method getMetadataCountsWithoutSubdirs.

@Test
public void getMetadataCountsWithoutSubdirs() throws Exception {
    expectNew(SystemOperations.class, "localhost:0000").andReturn(systemOperations).times(5);
    expect(systemOperations.getOperatingSystemType()).andReturn(OperatingSystemType.LINUX);
    // now we call getAllMetaData() 2 times
    expectNew(FileSystemOperations.class, "localhost:0000").andReturn(fileSystemOperations).times(5);
    expect(fileSystemOperations.findFiles(path, ".*", true, true, false)).andReturn(fileList).times(2);
    expect(fileSystemOperations.getFileUniqueId(file1)).andReturn(file1_hash).times(2);
    expect(fileSystemOperations.getFileUniqueId(file2)).andReturn(file2_hash).times(2);
    replayAll();
    FileSystemFolder folder = (FileSystemFolder) storage.getFolder(new FileSystemFolderSearchTerm(path, null, true, false));
    folder.open();
    folder.getAllMetaData();
    assertEquals("Total files: " + 2 + ", new files: " + 2, folder.getMetaDataCounts());
    folder.getAllMetaData();
    assertEquals("Total files: " + 2 + ", new files: " + 0, folder.getMetaDataCounts());
    verifyAll();
}
Also used : 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)

Example 9 with FileSystemFolder

use of com.axway.ats.rbv.filesystem.FileSystemFolder in project ats-framework by Axway.

the class Test_FileSystemFolder method openNegativeFolderAlreadyOpen.

@Test(expected = MatchableAlreadyOpenException.class)
public void openNegativeFolderAlreadyOpen() throws Exception {
    expectNew(SystemOperations.class, "localhost:0000").andReturn(systemOperations);
    expect(systemOperations.getOperatingSystemType()).andReturn(OperatingSystemType.LINUX);
    replayAll();
    FileSystemFolder folder = (FileSystemFolder) storage.getFolder(new FileSystemFolderSearchTerm(path, null, true, false));
    folder.open();
    folder.open();
    verifyAll();
}
Also used : FileSystemOperations(com.axway.ats.action.filesystem.FileSystemOperations) SystemOperations(com.axway.ats.action.system.SystemOperations) 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)

Example 10 with FileSystemFolder

use of com.axway.ats.rbv.filesystem.FileSystemFolder 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

BaseTest (com.axway.ats.rbv.BaseTest)15 FileSystemFolder (com.axway.ats.rbv.filesystem.FileSystemFolder)15 Test (org.junit.Test)15 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)15 FileSystemFolderSearchTerm (com.axway.ats.rbv.filesystem.FileSystemFolderSearchTerm)12 FileSystemOperations (com.axway.ats.action.filesystem.FileSystemOperations)8 SystemOperations (com.axway.ats.action.system.SystemOperations)7 MetaData (com.axway.ats.rbv.MetaData)3 FileSystemMetaData (com.axway.ats.rbv.filesystem.FileSystemMetaData)3 FilePackage (com.axway.ats.action.objects.FilePackage)1 PackageException (com.axway.ats.action.objects.model.PackageException)1 FileSystemStorage (com.axway.ats.rbv.filesystem.FileSystemStorage)1 RbvException (com.axway.ats.rbv.model.RbvException)1 RbvStorageException (com.axway.ats.rbv.model.RbvStorageException)1