Ejemplo n.º 1
0
  @Test(expected = CollectionNotMountedException.class)
  public void testCreateAMountedFileSystemPhyPathMissing() throws Exception {

    if (!testingPropertiesHelper.isTestFileSystemMount(testingProperties)) {
      throw new CollectionNotMountedException("thrown to honor contracts");
    }

    String targetCollectionName = "testCreateAMountedFileSystemPhyPathMissing";

    String localCollectionAbsolutePath = "/i/dont/exist";

    IRODSAccount irodsAccount =
        testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);

    String targetIrodsCollection =
        testingPropertiesHelper.buildIRODSCollectionAbsolutePathFromTestProperties(
            testingProperties, IRODS_TEST_SUBDIR_PATH + '/' + targetCollectionName);

    // do an initial unmount
    MountedCollectionAO mountedCollectionAO =
        irodsFileSystem.getIRODSAccessObjectFactory().getMountedCollectionAO(irodsAccount);

    mountedCollectionAO.unmountACollection(
        targetIrodsCollection, irodsAccount.getDefaultStorageResource());

    mountedCollectionAO.createMountedFileSystemCollection(
        localCollectionAbsolutePath,
        targetIrodsCollection,
        irodsAccount.getDefaultStorageResource());
  }
Ejemplo n.º 2
0
  /**
   * Unmount a soft link that does not exist
   *
   * @throws Exception
   */
  @Test
  public final void testUnmountSoftLinkNotExists() throws Exception {
    String targetCollectionName = "testUnmountSoftLinkNotExists";

    IRODSAccount irodsAccount =
        testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);

    String targetIrodsCollection =
        testingPropertiesHelper.buildIRODSCollectionAbsolutePathFromTestProperties(
            testingProperties, IRODS_TEST_SUBDIR_PATH + '/' + targetCollectionName);

    // do an initial unmount
    MountedCollectionAO mountedCollectionAO =
        irodsFileSystem.getIRODSAccessObjectFactory().getMountedCollectionAO(irodsAccount);
    boolean success = mountedCollectionAO.unmountACollection(targetIrodsCollection, "");
    Assert.assertFalse("should get no success", success);
  }
Ejemplo n.º 3
0
  @Test
  public void testCreateAMountedFileSystemPhyPathMissingButUnderConfiguredPath() throws Exception {

    if (!testingPropertiesHelper.isTestFileSystemMount(testingProperties)) {
      return;
    }

    String targetCollectionName =
        "testCreateAMountedFileSystemPhyPathMissingButUnderConfiguredPath";
    String localMountDir = "testCreateAMountedFileSystemPhyPathMissingButUnderConfiguredPathLocal";

    String localCollectionAbsolutePath =
        testingProperties.getProperty(TestingPropertiesHelper.IRODS_REG_BASEDIR)
            + "/"
            + localMountDir;

    IRODSAccount irodsAccount =
        testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);

    String targetIrodsCollection =
        testingPropertiesHelper.buildIRODSCollectionAbsolutePathFromTestProperties(
            testingProperties, IRODS_TEST_SUBDIR_PATH + '/' + targetCollectionName);

    // do an initial unmount
    MountedCollectionAO mountedCollectionAO =
        irodsFileSystem.getIRODSAccessObjectFactory().getMountedCollectionAO(irodsAccount);

    mountedCollectionAO.unmountACollection(
        targetIrodsCollection, irodsAccount.getDefaultStorageResource());

    mountedCollectionAO.createMountedFileSystemCollection(
        localCollectionAbsolutePath,
        targetIrodsCollection,
        irodsAccount.getDefaultStorageResource());

    // now get an objstat it should exist

    CollectionAndDataObjectListAndSearchAO searchAO =
        irodsFileSystem
            .getIRODSAccessObjectFactory()
            .getCollectionAndDataObjectListAndSearchAO(irodsAccount);
    ObjStat objStat = searchAO.retrieveObjectStatForPath(targetIrodsCollection);

    Assert.assertEquals(
        "did not get spec col in objStat", SpecColType.MOUNTED_COLL, objStat.getSpecColType());
  }
Ejemplo n.º 4
0
  @Test(expected = CollectionNotMountedException.class)
  public void testCreateMountedFileSystemTwice() throws Exception {

    if (!testingPropertiesHelper.isTestFileSystemMount(testingProperties)) {
      throw new CollectionNotMountedException("thrown to honor contracts");
    }

    String targetCollectionName = "testCreateMountedFileSystemTwice";
    String localMountDir = "testCreateMountedFileSystemTwiceLocal";

    String localCollectionAbsolutePath =
        scratchFileUtils.createAndReturnAbsoluteScratchPath(
            IRODS_TEST_SUBDIR_PATH + '/' + localMountDir);

    FileGenerator.generateManyFilesInParentCollectionByAbsolutePath(
        localCollectionAbsolutePath, "testCreateMountedFileSystemTwice", ".txt", 10, 1, 2);

    IRODSAccount irodsAccount =
        testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);

    String targetIrodsCollection =
        testingPropertiesHelper.buildIRODSCollectionAbsolutePathFromTestProperties(
            testingProperties, IRODS_TEST_SUBDIR_PATH + '/' + targetCollectionName);

    // do an initial unmount
    MountedCollectionAO mountedCollectionAO =
        irodsFileSystem.getIRODSAccessObjectFactory().getMountedCollectionAO(irodsAccount);

    mountedCollectionAO.unmountACollection(
        targetIrodsCollection, irodsAccount.getDefaultStorageResource());

    mountedCollectionAO.createMountedFileSystemCollection(
        localCollectionAbsolutePath,
        targetIrodsCollection,
        irodsAccount.getDefaultStorageResource());

    mountedCollectionAO.createMountedFileSystemCollection(
        localCollectionAbsolutePath,
        targetIrodsCollection,
        irodsAccount.getDefaultStorageResource());

    // no errors means success. will test further in
    // listing methods

  }
Ejemplo n.º 5
0
  @Test
  public void testCreateAndRemoveMountedFileSystem() throws Exception {

    if (!testingPropertiesHelper.isTestFileSystemMount(testingProperties)) {
      return;
    }

    String targetCollectionName = "testCreateAndRemoveMountedFileSystem";
    String localMountDir = "testCreateAndRemoveMountedFileSystemLocal";

    String localCollectionAbsolutePath =
        testingProperties.getProperty(TestingPropertiesHelper.IRODS_REG_BASEDIR)
            + "/"
            + localMountDir;

    File localFile = new File(localCollectionAbsolutePath);
    localFile.mkdirs();

    FileGenerator.generateManyFilesInParentCollectionByAbsolutePath(
        localCollectionAbsolutePath, "testCreateAndRemoveMountedFileSystem", ".txt", 10, 1, 2);

    IRODSAccount irodsAccount =
        testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);

    String targetIrodsCollection =
        testingPropertiesHelper.buildIRODSCollectionAbsolutePathFromTestProperties(
            testingProperties, IRODS_TEST_SUBDIR_PATH + '/' + targetCollectionName);

    // do an initial unmount
    MountedCollectionAO mountedCollectionAO =
        irodsFileSystem.getIRODSAccessObjectFactory().getMountedCollectionAO(irodsAccount);

    mountedCollectionAO.unmountACollection(
        targetIrodsCollection, irodsAccount.getDefaultStorageResource());

    mountedCollectionAO.createMountedFileSystemCollection(
        localCollectionAbsolutePath,
        targetIrodsCollection,
        irodsAccount.getDefaultStorageResource());
  }
Ejemplo n.º 6
0
  /**
   * Create a soft link to an iRODS collection in nominal mode, target does not exist and will be
   * created
   *
   * @throws Exception
   */
  @Test
  public final void testCreateASoftLink() throws Exception {

    String sourceCollectionName = "testCreateASoftLinkSource";
    String targetCollectionName = "testCreateASoftLinkTarget";
    String subfileName = "testCreateASoftLink.txt";

    IRODSAccount irodsAccount =
        testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);

    String sourceIrodsCollection =
        testingPropertiesHelper.buildIRODSCollectionAbsolutePathFromTestProperties(
            testingProperties, IRODS_TEST_SUBDIR_PATH + '/' + sourceCollectionName);

    String targetIrodsCollection =
        testingPropertiesHelper.buildIRODSCollectionAbsolutePathFromTestProperties(
            testingProperties, IRODS_TEST_SUBDIR_PATH + '/' + targetCollectionName);

    // do an initial unmount
    MountedCollectionAO mountedCollectionAO =
        irodsFileSystem.getIRODSAccessObjectFactory().getMountedCollectionAO(irodsAccount);

    mountedCollectionAO.unmountACollection(
        targetIrodsCollection, irodsAccount.getDefaultStorageResource());

    // set up source collection
    IRODSFile sourceFile =
        irodsFileSystem.getIRODSFileFactory(irodsAccount).instanceIRODSFile(sourceIrodsCollection);
    sourceFile.mkdirs();
    IRODSFile subFile =
        irodsFileSystem
            .getIRODSFileFactory(irodsAccount)
            .instanceIRODSFile(sourceIrodsCollection, subfileName);
    subFile.createNewFile();

    // add a subfile to this collection

    // create the soft link

    mountedCollectionAO.createASoftLink(sourceIrodsCollection, targetIrodsCollection);

    IRODSFile mountedCollectionTargetFile =
        irodsFileSystem.getIRODSFileFactory(irodsAccount).instanceIRODSFile(targetIrodsCollection);
    Assert.assertTrue("target collection does not exist", mountedCollectionTargetFile.exists());
    String softLinkedSourceFileName =
        mountedCollectionTargetFile.getAbsolutePath() + "/" + subFile.getName();

    CollectionAndDataObjectListAndSearchAO listAndSearchAO =
        irodsFileSystem
            .getIRODSAccessObjectFactory()
            .getCollectionAndDataObjectListAndSearchAO(irodsAccount);

    ObjStat statForSoftLinkedFile =
        listAndSearchAO.retrieveObjectStatForPath(softLinkedSourceFileName);

    Assert.assertEquals(
        "did not set the objPath",
        targetIrodsCollection,
        statForSoftLinkedFile.getCollectionPath());
    Assert.assertEquals(
        "did not identify as a linked coll",
        ObjStat.SpecColType.LINKED_COLL,
        statForSoftLinkedFile.getSpecColType());

    Assert.assertTrue(
        "did not get the soft linked file",
        statForSoftLinkedFile.getObjectType() == ObjectType.DATA_OBJECT);
  }