@Override public boolean isShareWar(TFile warFile) { if (!warFile.exists()) { throw new ModuleManagementToolException("The war file '" + warFile + "' does not exist."); } String title = findManifestArtibute(warFile, MANIFEST_SPECIFICATION_TITLE); if (MANIFEST_SHARE.equals(title)) return true; //It is share return false; //default }
public void testNoWar() throws Exception { String noWar = "noWar"; String ampLocation = getFileLocation(".amp", "module/test_v1.amp"); try { this.manager.installModule(ampLocation, noWar,false,false, false); } catch (ModuleManagementToolException exception) { 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.")); } }
throw new ModuleManagementToolException(error.getMessage()); manager.outputErrorMessage(e.getMessage()); System.exit(ERROR_EXIT_CODE);
public void testInstallFromDir() throws Exception { manager.setVerbose(true); String warLocation = getFileLocation(".war", "module/test.war"); String ampLocation = getFileLocation(".amp", "module/test_v1.amp"); String ampV2Location = getFileLocation(".amp", "module/test_v2.amp"); int index = ampV2Location.lastIndexOf(File.separator); System.out.println(index); String directoryLocation = ampV2Location.substring(0, index); try { this.manager.installModules(directoryLocation, warLocation); } catch (ModuleManagementToolException exception) { exception.printStackTrace(); System.out.println("Expected failure: " + exception.getMessage()); } }
public void testExistingFilesInWar() throws Exception { manager.setVerbose(true); String warLocation = getFileLocation(".war", "module/test.war"); //Version 4.0.1 String ampLocation = getFileLocation(".amp", "module/test_v4.amp"); try { this.manager.installModule(ampLocation, warLocation, false, false, true); } catch(ModuleManagementToolException exception) { assertTrue(exception.getMessage().contains("will overwrite an existing file in the war")); } 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 }
throw new ModuleManagementToolException(error.getMessage()); manager.outputErrorMessage(e.getMessage()); System.exit(ERROR_EXIT_CODE);
@Override public boolean isShareWar(TFile warFile) { if (!warFile.exists()) { throw new ModuleManagementToolException("The war file '" + warFile + "' does not exist."); } String title = findManifestArtibute(warFile, MANIFEST_SPECIFICATION_TITLE); if (MANIFEST_SHARE.equals(title)) return true; //It is share return false; //default }
assertTrue(exception.getMessage().endsWith("can only be installed in one of the following editions[CommuniT]")); assertTrue(exception.getMessage().endsWith("can only be installed in one of the following editions[Community]")); assertTrue(exception.getMessage().endsWith("can only be installed in one of the following editions[Enterprise]")); assertTrue(exception.getMessage().endsWith("can only be installed in one of the following editions[Enterprise]"));
/** * Finds a single attribute from a war manifest file. * @param war the war * @return Manifest * @throws ModuleManagementToolException */ @Override public Manifest findManifest(TFile war) throws ModuleManagementToolException { InputStream is = null; try { is = new TFileInputStream(war+MANIFEST_FILE); Manifest manifest = new Manifest(is); return manifest; } catch (IOException e) { throw new ModuleManagementToolException("Unabled to read a manifest for the war file: "+ war); } finally { if (is != null) { try { is.close(); } catch (Throwable e ) {} } } }
assertTrue(exception.getMessage().endsWith("can only be installed in one of the following editions[CommuniT]"));
/** * Finds a single attribute from a war manifest file. * @param war the war * @return Manifest * @throws ModuleManagementToolException */ @Override public Manifest findManifest(TFile war) throws ModuleManagementToolException { InputStream is = null; try { is = new TFileInputStream(war+MANIFEST_FILE); Manifest manifest = new Manifest(is); return manifest; } catch (IOException e) { throw new ModuleManagementToolException("Unabled to read a manifest for the war file: "+ war); } finally { if (is != null) { try { is.close(); } catch (Throwable e ) {} } } }
System.out.println("Expected: " + e.getMessage());
protected ModuleVersionNumber getModuleVersionNumber(Serializable moduleVersion) { if (moduleVersion instanceof ModuleVersionNumber) return (ModuleVersionNumber) moduleVersion; if (moduleVersion instanceof VersionNumber) return new ModuleVersionNumber((VersionNumber)moduleVersion); if (moduleVersion instanceof String) return new ModuleVersionNumber((String)moduleVersion); throw new ModuleManagementToolException("Invalid moduleVersion"); }
assertTrue(e.getMessage().contains("The amp will overwrite an existing file"));
protected ModuleVersionNumber getModuleVersionNumber(Serializable moduleVersion) { if (moduleVersion instanceof ModuleVersionNumber) return (ModuleVersionNumber) moduleVersion; if (moduleVersion instanceof VersionNumber) return new ModuleVersionNumber((VersionNumber)moduleVersion); if (moduleVersion instanceof String) return new ModuleVersionNumber((String)moduleVersion); throw new ModuleManagementToolException("Invalid moduleVersion"); }
assertTrue(exception.getMessage().contains("must be installed on a war version equal to or greater than 10.1")); assertTrue(exception.getMessage().contains("cannot be installed on a war version greater than 3.0")); assertTrue(exception.getMessage().contains("cannot be installed on a war version greater than 4.0.999"));
public void installModules(String directoryLocation, String warFileLocation, boolean preview, boolean forceInstall, boolean backupWAR) throws IOException { java.io.File dir = new java.io.File(directoryLocation); if (dir.exists() == true) { if (backupWAR) { backupWar(new TFile(warFileLocation),true); backupWAR = false; //Set it to false so a backup doesn't occur again. } installModules(dir, warFileLocation, preview, forceInstall,backupWAR); } else { throw new ModuleManagementToolException("Invalid directory '" + directoryLocation + "'"); } }
assertTrue(exception.getMessage().contains("must be installed on a war version equal to or greater than 10.1")); assertTrue(exception.getMessage().contains("cannot be installed on a war version greater than 3.0")); assertTrue(exception.getMessage().contains("cannot be installed on a war version greater than 3.4.10"));
public void installModules(String directoryLocation, String warFileLocation, boolean preview, boolean forceInstall, boolean backupWAR) throws IOException { java.io.File dir = new java.io.File(directoryLocation); if (dir.exists() == true) { if (backupWAR) { backupWar(new TFile(warFileLocation),true); backupWAR = false; //Set it to false so a backup doesn't occur again. } installModules(dir, warFileLocation, preview, forceInstall,backupWAR); } else { throw new ModuleManagementToolException("Invalid directory '" + directoryLocation + "'"); } }
throw new ModuleManagementToolException("Unable to load module details from property file. File Not Found, " + error.getMessage(), error); throw new ModuleManagementToolException( "Unable to load module details from property file." + exception.getMessage(), exception);