Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Merks2020-02-18 10:22:55 +0000
committerEd Merks2020-02-18 10:22:55 +0000
commit051ac55bff9a0915ecc87533ab98fbcc0fea606f (patch)
tree016ce115b04c1bf338bc59a4351d680dc8b49548 /bundles/org.eclipse.equinox.p2.tests/src/org
parent248eb861b519d8977eab449cd4131f79bf0da9fc (diff)
downloadrt.equinox.p2-051ac55bff9a0915ecc87533ab98fbcc0fea606f.tar.gz
rt.equinox.p2-051ac55bff9a0915ecc87533ab98fbcc0fea606f.tar.xz
rt.equinox.p2-051ac55bff9a0915ecc87533ab98fbcc0fea606f.zip
Bug 485939 - Remove touchpoint leaves .p2bu fileX20200221-0310
Discarding the backup store does not remove backups created via renameInPlace. These should be cleaned up in removeBackups. Of course there should be tests for this so I updated the existing tests to include testing for proper clean after calling discard. Change-Id: I6c0a8adf4a2e04e33d70a6a66d908e82380f0085 Signed-off-by: Ed Merks <ed.merks@gmail.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/BackupStoreTest.java32
1 files changed, 27 insertions, 5 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/BackupStoreTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/BackupStoreTest.java
index 9b88d9458..011c4d3cd 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/BackupStoreTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/BackupStoreTest.java
@@ -13,7 +13,11 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.touchpoint.natives;
-import java.io.*;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
import org.eclipse.equinox.internal.p2.touchpoint.natives.BackupStore;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
@@ -96,7 +100,11 @@ public class BackupStoreTest extends AbstractProvisioningTest {
public void testBackupByRenamingFile() {
String filePath = aTxt.getAbsolutePath();
- new BackupStore(null, BUPREFIX) {
+ class TestBackupByRenamingFileBackupStore extends BackupStore {
+ public TestBackupByRenamingFileBackupStore() {
+ super(null, BUPREFIX);
+ }
+
@Override
public void renameInPlace(File file) {
super.renameInPlace(file);
@@ -106,15 +114,24 @@ public class BackupStoreTest extends AbstractProvisioningTest {
protected String getTimeStamp() {
return "-123";
}
- }.renameInPlace(aTxt);
+ }
+ TestBackupByRenamingFileBackupStore backupStore = new TestBackupByRenamingFileBackupStore();
+ backupStore.renameInPlace(aTxt);
assertFalse(aTxt.exists());
assertTrue(new File(filePath + "-123.p2bu").exists());
+
+ backupStore.discard();
+ assertFalse(new File(filePath + "-123.p2bu").exists());
}
public void testRenameIfMoveToBackupFails() throws IOException {
String filePath = aTxt.getAbsolutePath();
- new BackupStore(null, BUPREFIX) {
+ class TestRenameIfMoveToBackupFailsBackupStore extends BackupStore {
+ public TestRenameIfMoveToBackupFailsBackupStore() {
+ super(null, BUPREFIX);
+ }
+
@Override
public void renameInPlace(File file) {
super.renameInPlace(file);
@@ -134,11 +151,16 @@ public class BackupStoreTest extends AbstractProvisioningTest {
protected String getTimeStamp() {
return "-123";
}
- }.moveToBackup(aTxt, bTxt);
+ }
+ TestRenameIfMoveToBackupFailsBackupStore backupStore = new TestRenameIfMoveToBackupFailsBackupStore();
+ backupStore.moveToBackup(aTxt, bTxt);
assertFalse(aTxt.exists());
assertTrue(new File(filePath + "-123.p2bu").exists());
assertFalse(bTxt.exists());
+
+ backupStore.discard();
+ assertFalse(new File(filePath + "-123.p2bu").exists());
}
public void testDoNotRenameIfMoveToBackupWorks() throws IOException {

Back to the top