@Test(expected = JargonException.class) public void testExtractBundleNoOverwriteNoBulkWhenTargetCollectionAlreadyExists() throws Exception { // gets a SYS_COPY_ALREADY_IN_RESC -46000 String tarName = "testExtractBundleNoOverwriteNoBulkWhenTargetCollectionAlreadyExists.tar"; String testSubdir = "testExtractBundleNoOverwriteNoBulkWhenTargetCollectionAlreadyExists"; String bunSubdir = "testExtractBundleNoOverwriteNoBulkWhenTargetCollectionAlreadyExistsBunSubdir"; String testExtractTargetSubdir = "testExtractBundleNoOverwriteNoBulkWhenTargetCollectionAlreadyExistsTargetCollection"; String fileName = "fileName.txt"; int count = 5; 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()); 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.extractABundleIntoAnIrodsCollection( targetBunFileAbsPath, targetIrodsCollection, ""); // repeat the same operation, causing an overwrite situation, should get // an error bulkFileOperationsAO.extractABundleIntoAnIrodsCollection( targetBunFileAbsPath, targetIrodsCollection, ""); }
@Test public void testExtractBundleWithOverwriteNoBulkWhenTargetCollectionAlreadyExists() throws Exception { String tarName = "testExtractBundleWithOverwriteNoBulkWhenTargetCollectionAlreadyExists.tar"; String testSubdir = "testExtractBundleWithOverwriteNoBulkWhenTargetCollectionAlreadyExists"; String bunSubdir = "testExtractBundleWithOverwriteNoBulkWhenTargetCollectionAlreadyExistsBunSubdir"; String testExtractTargetSubdir = "testExtractBundleWithOverwriteNoBulkWhenTargetCollectionAlreadyExistsTargetCollection"; 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.extractABundleIntoAnIrodsCollection( targetBunFileAbsPath, targetIrodsCollection, ""); // repeat the same operation, causing an overwrite situation, should get // an error bulkFileOperationsAO.extractABundleIntoAnIrodsCollectionWithForceOption( 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); }