@Test public void testCreateBundleNoOverwriteCollectionExists() throws Exception { String tarName = "testCreateBundleNoOverwriteCollectionExists.tar"; String testSubdir = "testCreateBundleNoOverwriteCollectionExists"; String bunSubdir = "testCreateBundleNoOverwriteCollectionExistsBunSubdir"; String fileName = "fileName"; int count = 200; IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties); IRODSFile irodsFile = null; String targetBunIrodsCollection = testingPropertiesHelper.buildIRODSCollectionAbsolutePathFromTestProperties( testingProperties, IRODS_TEST_SUBDIR_PATH + "/" + bunSubdir); String targetBunFileAbsPath = targetBunIrodsCollection + "/" + tarName; irodsFile = new IRODSFile(irodsFileSystem, targetBunIrodsCollection); irodsFile.mkdir(); 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()); IRODSServerProperties props = irodsFileSystem.getCommands().getIrodsServerProperties(); if (!props.isTheIrodsServerAtLeastAtTheGivenReleaseVersion( RemoteExecuteServiceImpl.STREAMING_API_CUTOFF)) { return; } BulkFileOperationsAO bulkFileOperationsAO = accessObjectFactory.getBulkFileOperationsAO(); boolean didFail = false; try { bulkFileOperationsAO.createABundleFromIrodsFilesAndStoreInIrods( targetBunFileAbsPath, targetIrodsCollection, ""); bulkFileOperationsAO.createABundleFromIrodsFilesAndStoreInIrods( targetBunFileAbsPath, targetIrodsCollection, ""); } catch (JargonException je) { didFail = true; } TestCase.assertTrue("expected this to fail with JargonException", didFail); }
@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); }
@Test public void testExtractBundleNoOverwriteWithBulk() throws Exception { String tarName = "testExtractBundleNoOverwriteWithBulk.tar"; String testSubdir = "testExtractBundleNoOverwriteWithBulk"; String bunSubdir = "testExtractBundleNoOverwriteWithBulkBunSubdir"; String testExtractTargetSubdir = "testExtractBundleNoOverwriteWithBulkTargetCollection"; String fileName = "fileName.txt"; int count = 5; 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(); 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.createABundleFromIrodsFilesAndStoreInIrods( targetBunFileAbsPath, targetIrodsCollection, ""); // extract the bun file now to a different subdir targetIrodsCollection = testingPropertiesHelper.buildIRODSCollectionAbsolutePathFromTestProperties( testingProperties, IRODS_TEST_SUBDIR_PATH + "/" + testExtractTargetSubdir); bulkFileOperationsAO.extractABundleIntoAnIrodsCollectionWithBulkOperationOptimization( targetBunFileAbsPath, targetIrodsCollection, ""); IRODSFile targetColl = new IRODSFile(irodsFileSystem, targetIrodsCollection); targetIrodsCollection = testingPropertiesHelper.buildIRODSCollectionAbsolutePathFromTestProperties( testingProperties, IRODS_TEST_SUBDIR_PATH + "/" + testSubdir); IRODSFile sourceColl = new IRODSFile(irodsFileSystem, targetIrodsCollection); // assertionHelper.assertTwoFilesAreEqualByRecursiveTreeComparison( // sourceColl, targetColl); }