diff options
author | Henrik Lindberg | 2009-09-01 15:22:06 +0000 |
---|---|---|
committer | Henrik Lindberg | 2009-09-01 15:22:06 +0000 |
commit | 03b023f3b5cdc5ee94a725f0757e71b40e67af10 (patch) | |
tree | 9d6a5c001311f7dbb23c3892bf578c49d968c8ba /bundles/org.eclipse.equinox.p2.tests | |
parent | e24c5a777cbf8d825455fee0001e444a658edf80 (diff) | |
download | rt.equinox.p2-03b023f3b5cdc5ee94a725f0757e71b40e67af10.tar.gz rt.equinox.p2-03b023f3b5cdc5ee94a725f0757e71b40e67af10.tar.xz rt.equinox.p2-03b023f3b5cdc5ee94a725f0757e71b40e67af10.zip |
BugÊ283161 - [touchpoints] Backup store can not handle ".."
This adds support for non-canonical paths input to the backup store.
Includes test.
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/BackupTest.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/BackupTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/BackupTest.java index b22ad8ac8..a43211702 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/BackupTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/BackupTest.java @@ -22,6 +22,9 @@ public class BackupTest extends AbstractProvisioningTest { private File bDir; private File aTxt; private File bTxt; + private File abDir; + private File cTxt; + private File cTxtRelative; /** * Sets up directories and files under user.home @@ -47,13 +50,19 @@ public class BackupTest extends AbstractProvisioningTest { aDir.mkdirs(); aaDir = new File(aDir, "AA"); aaDir.mkdir(); + abDir = new File(aDir, "AB"); + abDir.mkdir(); + bDir = new File(sourceDir, "B"); bDir.mkdirs(); aTxt = new File(aaDir, "a.txt"); bTxt = new File(aaDir, "b.txt"); + cTxt = new File(abDir, "c.txt"); + cTxtRelative = new File(aaDir, "../AB/c.txt"); try { writeToFile(aTxt, "A\nA file with an A"); writeToFile(bTxt, "B\nA file with a B"); + writeToFile(cTxt, "C\nA file with a C"); } catch (IOException e) { fail(); } @@ -92,6 +101,39 @@ public class BackupTest extends AbstractProvisioningTest { return file.delete(); } + /** + * Test that a path containing ".." can be backed up and restored. + */ + public void testBackupRelative() { + BackupStore store = new BackupStore(null, BUPREFIX); + // backup and overwrite a.txt + try { + store.backup(cTxtRelative); + } catch (IOException e) { + e.printStackTrace(); + fail("IO Exception when backing up cTxtRelative"); + } + if (cTxt.exists()) + fail("File not moved to backup - still exists"); + try { + writeToFile(cTxt, "XXXX\n- This file should be restored with C"); + } catch (IOException e) { + e.printStackTrace(); + fail("Could not write a file for testing purposes."); + } + + // restore + try { + store.restore(); + } catch (IOException e) { + e.printStackTrace(); + fail("Restore operation failed with IOException"); + } + // assert restore + assertFileContent("Restore of C failed - not original content", cTxt, "C"); + assertNoGarbage(store); + } + public void testBackupRestore() { BackupStore store = new BackupStore(null, BUPREFIX); // backup and overwrite a.txt |