Index: lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/CreateToolPackageTask.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/CreateToolPackageTask.java,v diff -u -r1.4 -r1.5 --- lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/CreateToolPackageTask.java 6 Apr 2006 06:38:41 -0000 1.4 +++ lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/CreateToolPackageTask.java 14 Apr 2006 06:09:18 -0000 1.5 @@ -67,6 +67,10 @@ * scripts to be copied from the scriptPath directory to deploy/sql. * Generates the toolInsertScriptPath, toolLibraryInsertScriptPath, * toolActivityInsertScriptPath and toolTablesScriptPath entries. + *
  • (Optional) toolApplicationContextPath: name and path to the + * tool's context file. Generates the toolApplicationContextPath entry.
  • + *
  • (Optional) toolJarFileName: name of the tool's jar file to be added to the + * classpath of the core modules.
  • *
  • (Optional) languageFileScriptPath: define the directory * containing any tool language files. On deployment, files will * be copied to the lams-dictionary jar directory. Index: lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/Deploy.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/Deploy.java,v diff -u -r1.12 -r1.13 --- lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/Deploy.java 6 Apr 2006 06:38:41 -0000 1.12 +++ lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/Deploy.java 14 Apr 2006 06:09:18 -0000 1.13 @@ -24,11 +24,13 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.deploy; +import java.util.LinkedList; import java.util.List; + /** * Tool Deployer Main Class * @@ -98,12 +100,6 @@ dbDeployTask.setToolTablesScriptPath(config.getToolTablesScriptPath()); dbDeployTask.execute(); - AddWebAppToApplicationXmlTask addWebAppTask = new AddWebAppToApplicationXmlTask(); - addWebAppTask.setLamsEarPath(config.getLamsEarPath()); - addWebAppTask.setContextRoot(config.getToolContext()); - addWebAppTask.setWebUri(config.getToolWebUri()); - addWebAppTask.execute(); - System.out.println("Deploying files to ear"); DeployFilesTask deployFilesTask = new DeployFilesTask(); deployFilesTask.setLamsEarPath(config.getLamsEarPath()); @@ -119,7 +115,25 @@ deployLanguageFilesTask.execute(); } - System.out.println("Activating Tool in LAMS"); + AddWebAppToApplicationXmlTask addWebAppTask = new AddWebAppToApplicationXmlTask(); + addWebAppTask.setLamsEarPath(config.getLamsEarPath()); + addWebAppTask.setContextRoot(config.getToolContext()); + addWebAppTask.setWebUri(config.getToolWebUri()); + addWebAppTask.execute(); + + + List warFiles = new LinkedList(); + warFiles.add("lams-central.war"); + warFiles.add("lams-learning.war"); + warFiles.add("lams-monitoring.war"); + InsertToolContextClasspathTask updateWebXmlTask = new InsertToolContextClasspathTask(); + updateWebXmlTask.setLamsEarPath(config.getLamsEarPath()); + updateWebXmlTask.setArchivesToUpdate(warFiles); + updateWebXmlTask.setApplicationContextPath(config.getToolApplicationContextPath()); + updateWebXmlTask.setJarFileName(config.getToolJarFileName()); + updateWebXmlTask.execute(); + + System.out.println("Activating Tool in LAMS"); ToolDBActivateTask dbActivateTask = new ToolDBActivateTask(); dbActivateTask.setDbUsername(config.getDbUsername()); dbActivateTask.setDbPassword(config.getDbPassword()); Index: lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/DeployToolConfig.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/DeployToolConfig.java,v diff -u -r1.6 -r1.7 --- lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/DeployToolConfig.java 6 Apr 2006 06:38:41 -0000 1.6 +++ lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/DeployToolConfig.java 14 Apr 2006 06:09:18 -0000 1.7 @@ -54,6 +54,8 @@ private static final String TOOL_LIBRARY_INSERT_SCRIPT_PATH = "toolLibraryInsertScriptPath"; private static final String TOOL_TABLES_SCRIPT_PATH = "toolTablesScriptPath"; private static final String TOOL_TABLES_DELETE_SCRIPT_PATH = "toolTablesDeleteScriptPath"; + private static final String TOOL_APP_CONTEXT_FILE_PATH = "toolApplicationContextPath"; + private static final String TOOL_JAR_FILE_NAME = "toolJarFileName"; private static final String DEPLOY_FILES= "deployFiles"; protected static final String LANGUAGE_FILES= "languageFiles"; @@ -98,6 +100,16 @@ private String toolTablesDeleteScriptPath; /** + * Holds value of property toolTablesDeleteScriptPath. + */ + private String toolApplicationContextPath; + + /** + * Holds the value of property toolJarFileName. + */ + private String toolJarFileName; + + /** * Holds value of property deployFiles. */ private ArrayList deployFiles; @@ -186,6 +198,14 @@ toolTablesDeleteScriptPath = value; } + if ( key.equalsIgnoreCase(TOOL_APP_CONTEXT_FILE_PATH) ) { + toolApplicationContextPath = value; + } + + if ( key.equalsIgnoreCase(TOOL_JAR_FILE_NAME) ) { + toolJarFileName = value; + } + if ( key.equalsIgnoreCase(DEPLOY_FILES) ) { deployFiles = convertList(value); } @@ -234,6 +254,8 @@ valid = valid && validateStringProperty(toolLibraryInsertScriptPath, TOOL_LIBRARY_INSERT_SCRIPT_PATH); valid = valid && validateStringProperty(toolActivityInsertScriptPath, TOOL_ACTIVITY_INSERT_SCRIPT_PATH); valid = valid && validateStringProperty(toolWebUri, TOOL_TABLES_SCRIPT_PATH); + valid = valid && validateStringProperty(toolApplicationContextPath, TOOL_APP_CONTEXT_FILE_PATH); + valid = valid && validateStringProperty(toolJarFileName,TOOL_JAR_FILE_NAME); valid = valid && validateStringProperty(getDbUsername(), DB_USERNAME); valid = valid && validateStringProperty(getDbPassword(), DB_PASSWORD); valid = valid && validateStringProperty(getDbDriverClass(), DB_PASSWORD); @@ -269,6 +291,10 @@ this.toolTablesScriptPath = config.getToolTablesScriptPath(); if (config.getToolTablesDeleteScriptPath() != null) this.toolTablesDeleteScriptPath = config.getToolTablesDeleteScriptPath(); + if (config.getToolApplicationContextPath() != null) + this.toolApplicationContextPath = config.getToolApplicationContextPath(); + if ( config.getToolJarFileName() != null ) + this.toolJarFileName = config.getToolJarFileName(); if (config.getDeployFiles() != null) this.deployFiles = config.getDeployFiles(); if (config.getLanguageFiles() != null) @@ -288,6 +314,8 @@ System.out.println("ToolActivityInsertScriptPath: " + this.toolActivityInsertScriptPath); System.out.println("ToolTableScriptPath: " + this.toolTablesScriptPath); System.out.println("ToolTableDeleteScriptPath: " + this.toolTablesDeleteScriptPath); + System.out.println("ToolApplicationContextPath: " + this.toolApplicationContextPath); + System.out.println("ToolJarFileName: "+this.toolJarFileName); ArrayList list = this.deployFiles; for(int i=0; i= 0 ) { + System.out.println("Application context entry "+getApplicationContextPathWithClasspath() + +" already in document."); + foundEntry = true; + } + } + } + + if ( ! foundEntry ) { + System.out.println("Adding "+getApplicationContextPathWithClasspath()+" to context"); + contextParamElement.appendChild(doc.createTextNode(" "+getApplicationContextPathWithClasspath()+"\n")); + } + } + + /** Add the jar file to the classpath in the MANIFEST.MF file */ + protected void updateClasspath(Manifest manifest) throws DeployException { + Attributes mainAttributes = manifest.getMainAttributes(); + String classpath = null; + if (mainAttributes != null) { + classpath = mainAttributes.getValue(Attributes.Name.CLASS_PATH); + } + + String newJar = getJarFileNameWithDotSlash(); + if ( classpath == null ) { + mainAttributes.put(Attributes.Name.CLASS_PATH,newJar); + System.out.println("Added "+newJar+" to classpath"); + } else if ( classpath.indexOf(newJar) < 0 ) { + mainAttributes.put(Attributes.Name.CLASS_PATH,classpath+" "+newJar); + System.out.println("Added "+newJar+" to classpath"); + } else { + System.out.println(newJar+" already on the classpath."); + } + } + + +} Fisheye: Tag 1.3 refers to a dead (removed) revision in file `lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/RemoveContextWebXmlTask.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/RemoveToolContextClasspathTask.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/RemoveToolContextClasspathTask.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/RemoveToolContextClasspathTask.java 14 Apr 2006 06:09:18 -0000 1.1 @@ -0,0 +1,89 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $$Id$$ */ +package org.lamsfoundation.lams.tool.deploy; + + +import java.util.jar.Attributes; +import java.util.jar.Manifest; + +import org.apache.commons.lang.StringUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + +/** + * Remove a tool's application context file from the web.xml of various core modules. + * + * @author Fiona Malikoff + */ +public class RemoveToolContextClasspathTask extends UpdateWarTask +{ + + /** + * Remove the tool's applicationContext entry from the param-value node of the context-param entry. + * Should find and remove all the matching entries (should it somehow have have got in there m + * @param doc + * @param children + * @param childNode + */ + protected void updateParamValue(Document doc, Node contextParamElement) { + + NodeList valueChildren = contextParamElement.getChildNodes(); + for ( int i=0; i archivesToUpdate; + + /** + * The value of the tool application context file, including the path + * e.g. /org/lamsfoundation/lams/tool/vote/voteApplicationContext.xml + * It should not include the "classpath:" prefix as this will be added + * automatically. + */ + protected String applicationContextPath; + + /** + * The name of the tool's jar file e.g. "lams-tool-lanb11.jar". + * This will be added to / removed from the classpath as ./[jarfilename] + * e.g. "./lams-tool-lanb11.jar" + */ + protected String jarFileName; + + + /** + * Sets the location of the application xml file to be modified. + * @param appxml New value of property appxml. + */ + public void setLamsEarPath(final String lamsEarPath) + { + this.lamsEarPath = lamsEarPath; + } + + public List getArchivesToUpdate() { + return archivesToUpdate; + } + + public void setArchivesToUpdate(List warsToUpdate) { + this.archivesToUpdate = warsToUpdate; + } + + /** + * Returns the value of the tool application context file, including the path + * e.g. /org/lamsfoundation/lams/tool/vote/voteApplicationContext.xml + * It should not include the "classpath:" prefix as this will be added + * automatically. + */ + public String getApplicationContextPath() { + return applicationContextPath; + } + + /** + * Returns the value of the tool application context file with the "classpath:" prepended. + * e.g. "classpath:/org/lamsfoundation/lams/tool/vote/voteApplicationContext.xml" + */ + protected String getApplicationContextPathWithClasspath() { + return "classpath:"+applicationContextPath; + } + + /** + * The value of the tool application context file, including the path + * e.g. /org/lamsfoundation/lams/tool/vote/voteApplicationContext.xml + * It should not include the "classpath:" prefix as this will be added + * automatically. + */ + public void setApplicationContextPath(String applicationContextPath) { + this.applicationContextPath = applicationContextPath; + } + + /** + * Gets the name of the tool's jar file e.g. "lams-tool-lanb11.jar". + * This will be added to / removed from the classpath as ./[jarfilename] + * e.g. "./lams-tool-lanb11.jar" + */ + public String getJarFileName() { + return jarFileName; + } + + /** + * Gets the name of the tool's jar file converted to ./[jarfilename] + * e.g. "./lams-tool-lanb11.jar" + */ + protected String getJarFileNameWithDotSlash() { + return "./"+jarFileName; + } + + /** + * Sets the name of the tool's jar file e.g. "lams-tool-lanb11.jar". + * This will be added to / removed from the classpath as ./[jarfilename] + * e.g. "./lams-tool-lanb11.jar" + */ + public void setJarFileName(String jarFileName) { + this.jarFileName = jarFileName; + } + + /** + * Execute the task + * @throws org.apache.tools.ant.DeployException In case of any problems + */ + public void execute() throws DeployException + { + if ( applicationContextPath == null ) { + throw new DeployException("UpdateWebXmTask: Unable to update web.xml as the application content path is missing (applicationContextPath)."); + } + + if ( archivesToUpdate != null ) { + + // map the old File to the new File e.g. lams_learning.war is the key, lams_learning.war.new is the value + Map filesToRename = new HashMap(archivesToUpdate.size()); + + for ( String warFileName: archivesToUpdate ) { + + File warFile = new File(lamsEarPath+File.separator+warFileName); + if ( ! warFile.canRead() || warFile.isDirectory() ) { + throw new DeployException("Unable to access war file "+warFile.getAbsolutePath()+". May be missing, a directory or not readable"); + } + String newFilename = lamsEarPath+File.separator+warFileName+".new"; + File outputFile = new File(newFilename); + JarOutputStream newWarOutputStream = null; + ZipInputStream warInputStream = null; + try { + + newWarOutputStream = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(outputFile))); + newWarOutputStream.setMethod(JarOutputStream.DEFLATED); + newWarOutputStream.setLevel(Deflater.DEFAULT_COMPRESSION); + //newWarOutputStream.setMethod(JarOutputStream.STORED); + + warInputStream = new ZipInputStream(new BufferedInputStream(new FileInputStream(warFile))); + ZipEntry entry = null; + + // work through each entry, copying across to the output stream. + // when we hit the web.xml, we have to modify it. + while( ( entry = warInputStream.getNextEntry() ) != null ) { + if ( WEBXML_PATH.equals(entry.getName()) ) { + updateWebXML(newWarOutputStream, warInputStream, entry); + } else if ( MANIFEST_PATH.equals(entry.getName()) ) { + updateManifest(newWarOutputStream, warInputStream, entry); + } else { + copyEntryToWar(newWarOutputStream, warInputStream, entry); + } + } + + warInputStream.close(); + newWarOutputStream.close(); + + } catch (IOException e) { + throw new DeployException("Unable to process war file "+warFileName,e); + } finally { + try { + if ( warInputStream != null ) + warInputStream.close(); + if ( newWarOutputStream != null ) + newWarOutputStream.close(); + } catch ( IOException e2 ) {} + } + + filesToRename.put(warFile, outputFile); + } + + copyNewFilesToOldNames(filesToRename); + } + } + + /* ********* Manage the archive updates, copy files, etc *********/ + + /** This entry in the JAR/WAR file doesn't change so copy it from the old archive to the new archive */ + protected void copyEntryToWar(JarOutputStream newWarOutputStream, ZipInputStream warInputStream, ZipEntry entry) throws IOException { + + ZipEntry newEntry = new ZipEntry(entry.getName()); + newWarOutputStream.putNextEntry(newEntry); + + byte[] data = new byte[ BUFFER_SIZE ]; + int count = -1; + while( (count = warInputStream.read( data, 0, BUFFER_SIZE ) ) != -1 ) + { + newWarOutputStream.write( data, 0, count ); + } + + newWarOutputStream.closeEntry(); + } + + + /** + * Everything worked okay so rename the files + * @param filesToRename + */ + protected void copyNewFilesToOldNames(Map filesToRename) throws DeployException { + // clean up any old backup files first. + for ( Map.Entry mapEntry : filesToRename.entrySet() ) { + File origFile = mapEntry.getKey(); + File backup = new File ( origFile.getAbsoluteFile() + ".bak"); + if ( backup.exists() ) { + backup.delete(); + } + if ( backup.exists() ) { + throw new DeployException("Error occured removing an old backup file. Please remove the file "+backup.getAbsolutePath() + +" and run the installation again."); + } + } + + // copy blah.war to blah.war.bak, and copy blah.war.new to blah.war + for ( Map.Entry mapEntry : filesToRename.entrySet() ) { + Map renamed = new HashMap(archivesToUpdate.size()); + + File origFile = mapEntry.getKey(); + File backup = new File ( origFile.getAbsoluteFile() + ".bak"); + + boolean successful = origFile.renameTo(backup); + if ( successful ) { + renamed.put(origFile, backup); + successful = mapEntry.getValue().renameTo(origFile); + } + + if ( successful ) { + System.out.println("Updated web.xml in war file "+origFile.getName()); + + } else { + // something has gone wrong so restore the backup files + for ( Map.Entry renamedMapEntry : renamed.entrySet() ) { + File updatedFile = renamedMapEntry.getKey(); + File backupFile = renamedMapEntry.getValue(); + backupFile.renameTo(updatedFile); + } + String message = "Error occured renaming the war files. Tried to go back to old files but may or may not have succeeded. Check files:"; + for ( String warFileName: archivesToUpdate ) { + message += " " + warFileName; + } + throw new DeployException(message); + } + + } + } + + protected ByteArrayInputStream copyToByteArrayInputStream(ZipInputStream warInputStream) throws IOException { + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + byte[] data = new byte[ BUFFER_SIZE ]; + int count = -1; + while( (count = warInputStream.read( data, 0, BUFFER_SIZE ) ) != -1 ) + { + os.write( data, 0, count ); + } + os.close(); + + return new ByteArrayInputStream(os.toByteArray()); + } + + /* ********* Update the web.xml etc *********/ + + /** Update the param-value entry in the contextConfigLocation entry in the web.xml file */ + protected abstract void updateParamValue(Document doc, Node contextParamElement) throws DeployException; + + /** + * Given the web.xml from the war file, update the file and write it to the new war file. + * + * @param newWarOutputStream new war file + * @param warInputStream existing war file + * @param entry web.xml entry + * @throws IOException + */ + protected void updateWebXML(JarOutputStream newWarOutputStream, ZipInputStream warInputStream, ZipEntry entry) throws IOException { + + ZipEntry newEntry = new ZipEntry(WEBXML_PATH); + newWarOutputStream.putNextEntry(newEntry); + + // can't just pass the stream to the parser, as the parser will close the stream. + InputStream copyInputStream = copyToByteArrayInputStream(warInputStream); + + Document doc = parseWebXml(copyInputStream); + updateWebXml(doc); + writeWebXml(doc, newWarOutputStream); + + newWarOutputStream.closeEntry(); + } + + protected void updateWebXml(Document doc) throws DeployException + { + + NodeList contextParamNodeList = doc.getElementsByTagName("context-param"); + Element matchingContextParamElement = findContextParamWithMatchingParamName("contextConfigLocation", contextParamNodeList); + if ( matchingContextParamElement == null ) { + throw new DeployException("No contextConfigLocation can be found in the web.xml in the war"); + } + + NodeList contextParamElements = matchingContextParamElement.getChildNodes(); + for ( int c=0; c + * contextConfigLocation + * + * classpath:/org/lamsfoundation/lams/applicationContext.xml + * + * + */ + for (int i = 0, length = nodeList.getLength(); i < length; i++) + { + Node node = nodeList.item(i); + if (node instanceof Element) + { + + NodeList children = node.getChildNodes(); + String paramName = null; + for ( int c=0; c 0) && nameChildren.item(0) instanceof Text) { + paramName = nameChildren.item(0).getNodeValue(); + if ( paramName!=null && paramName.equals(searchParamName) ) + return (Element) node; + } + } + } + } + + } + + } + + return null; + } + + /* ********* Update the MANIFEST.MF *********/ + + /** Update the classpath entry in the MANIFEST.MF file */ + protected abstract void updateClasspath(Manifest manifest) throws DeployException; + + /** + * Given the MANIFEST.MF from the war file, update the file and write it to the new war file. + * + * @param newWarOutputStream new war file + * @param warInputStream existing war file + * @param entry web.xml entry + * @throws IOException + */ + protected void updateManifest(JarOutputStream newWarOutputStream, ZipInputStream warInputStream, ZipEntry entry) throws IOException { + + ZipEntry newEntry = new ZipEntry(MANIFEST_PATH); + newWarOutputStream.putNextEntry(newEntry); + + Manifest manifest = new Manifest(warInputStream); + updateClasspath(manifest); + manifest.write(newWarOutputStream); + + newWarOutputStream.closeEntry(); + } + + +} Fisheye: Tag 1.5 refers to a dead (removed) revision in file `lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/UpdateWebXmlTask.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/templateDeploy.properties =================================================================== RCS file: /usr/local/cvsroot/lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/templateDeploy.properties,v diff -u -r1.2 -r1.3 --- lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/templateDeploy.properties 28 Mar 2006 07:57:12 -0000 1.2 +++ lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/templateDeploy.properties 14 Apr 2006 06:09:18 -0000 1.3 @@ -28,6 +28,12 @@ #name of SQL script that inserts the lams_tool record toolInsertScriptPath=test/file/sql/tool_insert.sql +#name and path to the tool's context file e.g. /org/lamsfoundation/lams/tool/package/applicationContext.xml +toolApplicationContextPath= + +#name of the tool's jar file +toolJarFileName= + #path to lams ear dir lamsEarPath=test/file/lams.ear Index: lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/templateDeployTool.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/templateDeployTool.xml,v diff -u -r1.1 -r1.2 --- lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/templateDeployTool.xml 1 Dec 2005 23:46:39 -0000 1.1 +++ lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/templateDeployTool.xml 14 Apr 2006 06:09:18 -0000 1.2 @@ -12,6 +12,8 @@ test/file/sql/activity_insert.sql test/file/sql/create_tool_tables.sql + + /some/war/file /some/jar/file Index: lams_tool_deploy/test/java/org/lamsfoundation/lams/tool/deploy/TestUpdateWebXmlTask.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_deploy/test/java/org/lamsfoundation/lams/tool/deploy/Attic/TestUpdateWebXmlTask.java,v diff -u -r1.3 -r1.4 --- lams_tool_deploy/test/java/org/lamsfoundation/lams/tool/deploy/TestUpdateWebXmlTask.java 13 Apr 2006 04:25:03 -0000 1.3 +++ lams_tool_deploy/test/java/org/lamsfoundation/lams/tool/deploy/TestUpdateWebXmlTask.java 14 Apr 2006 06:09:18 -0000 1.4 @@ -40,8 +40,10 @@ public class TestUpdateWebXmlTask extends TestCase { - public static final String dummyWarNoNBEntryPath = "test/file/test-dummy.war"; - public static final String dummyWarNBEntryPath = "test/file/test-dummy-with-nb.war"; + public static final String WAR_NO_NB_ENTRY = "test/file/test-dummy.war"; + public static final String WAR_NB_ENTRY = "test/file/test-dummy-with-nb.war"; + public static final String CONTEXT_FILE_PATH = "/org/lamsfoundation/lams/tool/noticeboard/applicationContext.xml"; + public static final String TOOL_JAR_NAME = "lams-tool-lanb11.jar"; public TestUpdateWebXmlTask(String testName) { @@ -60,35 +62,35 @@ public void testInsertExecute() throws Exception { - InsertContextWebXmlTask task = new InsertContextWebXmlTask(); + InsertToolContextClasspathTask task = new InsertToolContextClasspathTask(); webXmlFileTest(task, "test/file/web.xml"); } public void testInsertEntryAlreadyExistsExecute() throws Exception { - InsertContextWebXmlTask task = new InsertContextWebXmlTask(); + InsertToolContextClasspathTask task = new InsertToolContextClasspathTask(); webXmlFileTest(task, "test/file/web1EntryInsert.xml"); } public void testRemoveExecuteNoEntry() throws Exception { // tests removing it from the end of the list of contexts - RemoveContextWebXmlTask task = new RemoveContextWebXmlTask(); + RemoveToolContextClasspathTask task = new RemoveToolContextClasspathTask(); webXmlFileTest(task, "test/file/webNoEntry.xml"); } public void testRemoveExecuteEnd() throws Exception { // tests removing it from the end of the list of contexts - RemoveContextWebXmlTask task = new RemoveContextWebXmlTask(); + RemoveToolContextClasspathTask task = new RemoveToolContextClasspathTask(); webXmlFileTest(task, "test/file/web1Entry.xml"); } public void testRemoveExecuteBeginMidEnd() throws Exception { // tests removing it from the beginning and middle of the list of contexts - RemoveContextWebXmlTask task = new RemoveContextWebXmlTask(); + RemoveToolContextClasspathTask task = new RemoveToolContextClasspathTask(); webXmlFileTest(task, "test/file/web3Entry.xml"); } @@ -98,9 +100,9 @@ * @throws FileNotFoundException * @throws IOException */ - private void webXmlFileTest(UpdateWebXmlTask task, String filename) throws FileNotFoundException, IOException { + private void webXmlFileTest(UpdateWarTask task, String filename) throws FileNotFoundException, IOException { - task.setApplicationContextPath("/org/lamsfoundation/lams/tool/noticeboard/applicationContext.xml"); + task.setApplicationContextPath(CONTEXT_FILE_PATH); InputStream is = new FileInputStream(filename); Document doc = task.parseWebXml(is); @@ -113,23 +115,25 @@ public void testAddToWar() throws Exception { - InsertContextWebXmlTask task = new InsertContextWebXmlTask(); - task.setApplicationContextPath("/org/lamsfoundation/lams/tool/noticeboard/applicationContext.xml"); + InsertToolContextClasspathTask task = new InsertToolContextClasspathTask(); + task.setApplicationContextPath(CONTEXT_FILE_PATH); List warFiles = new LinkedList(); - warFiles.add(dummyWarNoNBEntryPath); - task.setWarsToUpdate(warFiles); - task.setLamsEarPath(""); + warFiles.add(WAR_NO_NB_ENTRY); + task.setArchivesToUpdate(warFiles); + task.setLamsEarPath("."); + task.setJarFileName(TOOL_JAR_NAME); task.execute(); } public void testRemoveFromToWar() throws Exception { - RemoveContextWebXmlTask task = new RemoveContextWebXmlTask(); - task.setApplicationContextPath("/org/lamsfoundation/lams/tool/noticeboard/applicationContext.xml"); + RemoveToolContextClasspathTask task = new RemoveToolContextClasspathTask(); + task.setApplicationContextPath(CONTEXT_FILE_PATH); List warFiles = new LinkedList(); - warFiles.add(dummyWarNBEntryPath); - task.setWarsToUpdate(warFiles); - task.setLamsEarPath(""); + warFiles.add(WAR_NB_ENTRY); + task.setArchivesToUpdate(warFiles); + task.setLamsEarPath("."); + task.setJarFileName(TOOL_JAR_NAME); task.execute(); } } \ No newline at end of file