Ejemplo n.º 1
0
  @Test
  public void testCreateBundleWhenTarFileAlreadyExistsForceSpecified() throws Exception {

    String tarName = "testCreateBundleWhenTarFileAlreadyExistsForceSpecified.tar";
    String testSubdir = "testCreateBundleWhenTarFileAlreadyExistsForceSpecified";
    String bunSubdir = "testCreateBundleWhenTarFileAlreadyExistsForceSpecifiedBunSubdir";
    String fileName = "fileName";
    int count = 20;

    IRODSAccount irodsAccount =
        testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);

    IRODSServerProperties props = irodsFileSystem.getCommands().getIrodsServerProperties();
    if (!props.isTheIrodsServerAtLeastAtTheGivenReleaseVersion(
        RemoteExecuteServiceImpl.STREAMING_API_CUTOFF)) {
      return;
    }

    IRODSFile irodsFile = null;

    String targetBunIrodsCollection =
        testingPropertiesHelper.buildIRODSCollectionAbsolutePathFromTestProperties(
            testingProperties, IRODS_TEST_SUBDIR_PATH + "/" + bunSubdir);
    String targetBunFileAbsPath = targetBunIrodsCollection + "/" + tarName;
    irodsFile = new IRODSFile(irodsFileSystem, targetBunIrodsCollection);
    irodsFile.mkdir();

    // create the tar file with the same name as the one I will want to
    // create later
    irodsFile = new IRODSFile(irodsFileSystem, targetBunFileAbsPath);
    irodsFile.createNewFile();

    String targetIrodsCollection =
        testingPropertiesHelper.buildIRODSCollectionAbsolutePathFromTestProperties(
            testingProperties, IRODS_TEST_SUBDIR_PATH + "/" + testSubdir);
    irodsFile = new IRODSFile(irodsFileSystem, targetIrodsCollection);
    irodsFile.mkdir();

    String myTarget = "";

    for (int i = 0; i < count; i++) {
      myTarget = targetIrodsCollection + "/c" + (10000 + i) + fileName;
      irodsFile = new IRODSFile(irodsFileSystem, myTarget);
      irodsFile.createNewFile();
    }

    IRODSAccessObjectFactory accessObjectFactory =
        IRODSAccessObjectFactoryImpl.instance(irodsFileSystem.getCommands());

    BulkFileOperationsAO bulkFileOperationsAO = accessObjectFactory.getBulkFileOperationsAO();
    bulkFileOperationsAO.createABundleFromIrodsFilesAndStoreInIrodsWithForceOption(
        targetBunFileAbsPath, targetIrodsCollection, "");
    assertionHelper.assertIrodsFileOrCollectionExists(targetBunFileAbsPath);
  }