Fixed : ALF-12532: MMT should fail with an error if the target war file doesn't exist

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@33725 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gethin James
2012-02-07 14:57:24 +00:00
parent c458861b73
commit c4a10bfe0c
2 changed files with 26 additions and 18 deletions

View File

@@ -201,7 +201,12 @@ public class ModuleManagementTool
try try
{ {
outputMessage("Installing AMP '" + ampFileLocation + "' into WAR '" + warFileLocation + "'"); outputMessage("Installing AMP '" + ampFileLocation + "' into WAR '" + warFileLocation + "'");
java.io.File theWar = new File(warFileLocation, DETECTOR_AMP_AND_WAR); java.io.File theWar = new File(warFileLocation, DETECTOR_AMP_AND_WAR);
if (!theWar.exists())
{
throw new ModuleManagementToolException("The war file '" + warFileLocation + "' does not exist.");
}
if (preview == false) if (preview == false)
{ {
// Make sure the module and backup directory exisits in the WAR file // Make sure the module and backup directory exisits in the WAR file
@@ -220,10 +225,6 @@ public class ModuleManagementTool
if (backupWAR == true) if (backupWAR == true)
{ {
java.io.File warFile = new java.io.File(warFileLocation); java.io.File warFile = new java.io.File(warFileLocation);
if (warFile.exists() == false)
{
throw new ModuleManagementToolException("The war file '" + warFileLocation + "' does not exist.");
}
String backupLocation = warFileLocation + "-" + System.currentTimeMillis() + ".bak"; String backupLocation = warFileLocation + "-" + System.currentTimeMillis() + ".bak";
java.io.File backup = new java.io.File(backupLocation); java.io.File backup = new java.io.File(backupLocation);
copyFile(warFile, backup); copyFile(warFile, backup);

View File

@@ -294,20 +294,27 @@ public class ModuleManagementToolTest extends TestCase
return file.getPath(); return file.getPath();
} }
// public void testNoWar() throws Exception public void testNoWar() throws Exception
// { {
// File noWar = new File("noWar"); String noWar = "noWar";
// File amp = getFile(".amp", "module/test_v1.amp"); String ampLocation = getFileLocation(".amp", "module/test_v1.amp");
// try try
// { {
// this.manager.installModule(amp, noWar,false,false); this.manager.installModule(ampLocation, noWar,false,false, false);
// } }
// catch (ModuleManagementToolException exception) catch (ModuleManagementToolException exception)
// { {
// assertTrue(exception.getMessage().endsWith("does not exist.")); assertTrue(exception.getMessage().endsWith("does not exist."));
// } }
// try
// } {
this.manager.installModule(ampLocation, noWar,false,false, true); //backup war
}
catch (ModuleManagementToolException exception)
{
assertTrue(exception.getMessage().endsWith("does not exist."));
}
}
private void checkForFileExistance(String warLocation, List<String> files) private void checkForFileExistance(String warLocation, List<String> files)
{ {