From aaa1357100777155dfae9a2617b24e5931543420 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Thu, 18 Oct 2012 09:35:15 +0000 Subject: [PATCH] Fix backup deletion issue identified by RM-516 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@42788 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../module/tool/ModuleManagementTool.java | 2 +- .../module/tool/ModuleManagementToolTest.java | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java b/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java index 1fc70beba5..d4ddd87501 100644 --- a/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java +++ b/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java @@ -478,7 +478,7 @@ public class ModuleManagementTool implements LogOutput TFile modified = new TFile(warFileLocation + update.getKey()); TFile backup = new TFile(warFileLocation + update.getValue()); backup.cp_rp(modified); - backup.deleteOnExit(); + backup.rm(); } outputVerboseMessage("Recovering file '" + update.getKey() + "' from backup '" + update.getValue() + "'", true); diff --git a/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java b/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java index 9f6c175b5d..43721f5e1f 100644 --- a/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java +++ b/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java @@ -241,11 +241,20 @@ public class ModuleManagementToolTest extends TestCase manager.setVerbose(true); String warLocation = getFileLocation(".war", "module/test.war"); - String ampLocation = getFileLocation(".amp", "module/test_v1.amp"); - - // Initial install of module - this.manager.installModule(ampLocation, warLocation, false, false, false); - this.manager.installModule(ampLocation, warLocation, false, true, false); + String ampLocation = getFileLocation(".amp", "module/test_v4.amp"); + + try + { + // Initial install of module + this.manager.installModule(ampLocation, warLocation, false, false, false); //not forced + fail("Failed to detect existing files in the amp"); + } + catch (ModuleManagementToolException e) + { + assertTrue(e.getMessage().contains("The amp will overwrite an existing file")); + } + this.manager.installModule(ampLocation, warLocation, false, true, false); //install it again + this.manager.installModule(ampLocation, warLocation, false, true, false); //install it again, just to be sure } public void testInstallFromDir() @@ -281,7 +290,7 @@ public class ModuleManagementToolTest extends TestCase try { - this.manager.installModule(ampLocation, warLocation, false, false, true); + this.manager.installModule(ampLocation, warLocation, false, false, true); } catch(ModuleManagementToolException exception) { @@ -291,6 +300,7 @@ public class ModuleManagementToolTest extends TestCase this.manager.installModule(ampLocation, warLocation, false, true, true); //Now force it checkContentsOfFile(warLocation + "/jsp/relogin.jsp", "VERSIONONE"); checkContentsOfFile(warLocation + "/css/main.css", "p{margin-bottom:1em;}"); + this.manager.installModule(ampLocation, warLocation, false, true, false); //install it again }