Index: lams_tool_deploy/build.xml
===================================================================
diff -u -r922473f5ee7930d8f2ddbf3f3e2d1d00cd9deee9 -r8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5
--- lams_tool_deploy/build.xml (.../build.xml) (revision 922473f5ee7930d8f2ddbf3f3e2d1d00cd9deee9)
+++ lams_tool_deploy/build.xml (.../build.xml) (revision 8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5)
@@ -88,7 +88,7 @@
-
+
@@ -99,6 +99,7 @@
+
Index: lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/Deploy.java
===================================================================
diff -u -ra4ffc995ef80182d5703c580c641f69a4b9a8250 -r8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5
--- lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/Deploy.java (.../Deploy.java) (revision a4ffc995ef80182d5703c580c641f69a4b9a8250)
+++ lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/Deploy.java (.../Deploy.java) (revision 8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5)
@@ -23,28 +23,60 @@
*/
public static void main(String[] args) throws Exception
{
- if (args.length != 1)
- {
- throw new Exception("Usage: Deployer ");
- }
- DeployConfig config = new DeployConfig(args[1]);
-
- //db deploy
-
- //add required elements to the application xml
- AddWebAppToApplicationXmlTask addWebAppTask = new AddWebAppToApplicationXmlTask();
- addWebAppTask.setLamsEarPath(config.getLamsEarPath());
- addWebAppTask.setContextRoot(config.getToolContextRoot());
- addWebAppTask.setWebUri(config.getToolWebUri());
- addWebAppTask.execute();
-
- //deploy files
- DeployFilesTask deployFilesTask = new DeployFilesTask();
- deployFilesTask.setLamsEarPath(config.getLamsEarPath());
- deployFilesTask.setDeployFiles(config.getDeployFiles());
- deployFilesTask.execute();
-
- //db activation
+
+ if ((args.length != 1) || (args[0] == null))
+ {
+ throw new IllegalArgumentException("Usage: Deployer ");
+ }
+
+ System.out.println("Starting Tool Deploy");
+ try
+ {
+ System.out.println("Reading Configuration File");
+ DeployConfig config = new DeployConfig(args[0]);
+
+ System.out.println("Running Tool DB Deploy");
+ ToolDBDeployTask dbDeployTask = new ToolDBDeployTask();
+ dbDeployTask.setDbUsername(config.getDbUsername());
+ dbDeployTask.setDbPassword(config.getDbPassword());
+ dbDeployTask.setDbDriverClass(config.getDbDriverClass());
+ dbDeployTask.setDbDriverUrl(config.getDbDriverUrl());
+ dbDeployTask.setToolInsertScriptPath(config.getToolInsertScriptPath());
+ dbDeployTask.setToolLibraryInsertScriptPath(config.getToolLibraryInsertScriptPath());
+ dbDeployTask.setToolActivityInsertScriptPath(config.getToolActivityInsertScriptPath());
+ dbDeployTask.setToolTablesScriptPath(config.getToolTablesScriptPath());
+ dbDeployTask.execute();
+
+ System.out.println("Updating application.xml");
+ AddWebAppToApplicationXmlTask addWebAppTask = new AddWebAppToApplicationXmlTask();
+ addWebAppTask.setLamsEarPath(config.getLamsEarPath());
+ addWebAppTask.setContextRoot(config.getToolContextRoot());
+ addWebAppTask.setWebUri(config.getToolWebUri());
+ addWebAppTask.execute();
+
+ System.out.println("Deploying files to ear");
+ DeployFilesTask deployFilesTask = new DeployFilesTask();
+ deployFilesTask.setLamsEarPath(config.getLamsEarPath());
+ deployFilesTask.setDeployFiles(config.getDeployFiles());
+ deployFilesTask.execute();
+
+ System.out.println("Activating Tool in LAMS");
+ ToolDBActivateTask dbActivateTask = new ToolDBActivateTask();
+ dbActivateTask.setDbUsername(config.getDbUsername());
+ dbActivateTask.setDbPassword(config.getDbPassword());
+ dbActivateTask.setDbDriverClass(config.getDbDriverClass());
+ dbActivateTask.setDbDriverUrl(config.getDbDriverUrl());
+ dbActivateTask.setLearningLibraryId(dbDeployTask.getLearningLibraryId());
+ dbActivateTask.setToolId(dbDeployTask.getToolId());
+ dbActivateTask.execute();
+
+ System.out.println("Tool Deployed");
+ }
+ catch (Exception ex)
+ {
+ System.out.println("TOOL DEPLOY FAILED");
+ ex.printStackTrace();
+ }
}
}
Index: lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/ToolDBDeployTask.java
===================================================================
diff -u -r922473f5ee7930d8f2ddbf3f3e2d1d00cd9deee9 -r8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5
--- lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/ToolDBDeployTask.java (.../ToolDBDeployTask.java) (revision 922473f5ee7930d8f2ddbf3f3e2d1d00cd9deee9)
+++ lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/ToolDBDeployTask.java (.../ToolDBDeployTask.java) (revision 8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5)
@@ -24,19 +24,19 @@
{
/**
- * Holds value of property toolInsertScript.
+ * Holds value of property toolInsertScriptPath.
*/
- private File toolInsertScript;
+ private String toolInsertScriptPath;
/**
- * Holds value of property toolLibraryInsertScript.
+ * Holds value of property toolLibraryInsertScriptPath.
*/
- private File toolLibraryInsertScript;
+ private String toolLibraryInsertScriptPath;
/**
- * Holds value of property toolTablesScript.
+ * Holds value of property toolTablesScriptPath.
*/
- private File toolTablesScript;
+ private String toolTablesScriptPath;
/**
* Holds value of property toolId.
@@ -49,9 +49,9 @@
private long learningLibraryId;
/**
- * Holds value of property toolActivityInsertScript.
+ * Holds value of property toolActivityInsertScriptPath.
*/
- private File toolActivityInsertScript;
+ private String toolActivityInsertScriptPath;
private long defaultContentId;
@@ -64,42 +64,47 @@
* Setter for property toolInsertFile.
* @param toolInsertFile New value of property toolInsertFile.
*/
- public void setToolInsertScript(java.io.File toolInsertScript)
+ public void setToolInsertScriptPath(String toolInsertScriptPath)
+
{
-
- this.toolInsertScript = toolInsertScript;
+
+ this.toolInsertScriptPath = toolInsertScriptPath;
}
/**
* Setter for property toolLibraryInsertFile.
* @param toolLibraryInsertFile New value of property toolLibraryInsertFile.
*/
- public void setToolLibraryInsertScript(java.io.File toolLibraryInsertScript)
+ public void setToolLibraryInsertScriptPath(String toolLibraryInsertScriptPath)
+
{
-
- this.toolLibraryInsertScript = toolLibraryInsertScript;
+
+ this.toolLibraryInsertScriptPath = toolLibraryInsertScriptPath;
}
/**
* Setter for property toolTablesCreatScript.
* @param toolTablesCreatScript New value of property toolTablesCreatScript.
*/
- public void setToolTablesScript(java.io.File toolTablesScript)
+ public void setToolTablesScriptPath(String toolTablesScriptPath)
+
{
- this.toolTablesScript = toolTablesScript;
+ this.toolTablesScriptPath = toolTablesScriptPath;
}
public void execute() throws DeployException
{
+ toolInsertScript = new File(toolInsertScriptPath);
+ toolLibraryInsertScript = new File(toolLibraryInsertScriptPath);
+ toolActivityInsertScript = new File(toolActivityInsertScriptPath);
+ toolTablesScript = new File(toolTablesScriptPath);
//get a connection
Connection conn = getConnection();
-
-
try
{
conn.setAutoCommit(false);
@@ -202,10 +207,11 @@
* Setter for property toolActivityInsertScript.
* @param toolActivityInsertScript New value of property toolActivityInsertScript.
*/
- public void setToolActivityInsertScript(File toolActivityInsertScript)
+ public void setToolActivityInsertScriptPath(String toolActivityInsertScriptPath)
+
{
-
- this.toolActivityInsertScript = toolActivityInsertScript;
+
+ this.toolActivityInsertScriptPath = toolActivityInsertScriptPath;
}
private long getNewToolContentId(long toolId, Connection conn) throws DeployException
@@ -357,4 +363,12 @@
return this.defaultContentId;
}
+
+ private File toolInsertScript;
+
+ private File toolActivityInsertScript;
+
+ private File toolLibraryInsertScript;
+
+ private File toolTablesScript;
}
Index: lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/UpdateApplicationXmlTask.java
===================================================================
diff -u -ra4ffc995ef80182d5703c580c641f69a4b9a8250 -r8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5
--- lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/UpdateApplicationXmlTask.java (.../UpdateApplicationXmlTask.java) (revision a4ffc995ef80182d5703c580c641f69a4b9a8250)
+++ lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/UpdateApplicationXmlTask.java (.../UpdateApplicationXmlTask.java) (revision 8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5)
@@ -49,7 +49,7 @@
/**
* The application.xml file.
*/
- protected File lamsEarPath;
+ protected String lamsEarPath;
/**
* The value of the web-uri element.
@@ -74,7 +74,7 @@
* Sets the location of the application xml file to be modified.
* @param appxml New value of property appxml.
*/
- public void setLamsEarPath(final String lasmEarPath)
+ public void setLamsEarPath(final String lamsEarPath)
{
this.lamsEarPath = lamsEarPath;
this.applicationXmlPath = lamsEarPath+"/META-INF/application.xml";
Index: lams_tool_deploy/test/file/deploy.properties
===================================================================
diff -u -r3e1c3cc5291e781560fe935140c6c985229df7e4 -r8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5
--- lams_tool_deploy/test/file/deploy.properties (.../deploy.properties) (revision 3e1c3cc5291e781560fe935140c6c985229df7e4)
+++ lams_tool_deploy/test/file/deploy.properties (.../deploy.properties) (revision 8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5)
@@ -3,37 +3,37 @@
#Password for Install DB
-dbPassword=lamsdemo
+dbPassword=dag.Quiz
#user for install db
-dbUsername=lams
+dbUsername=root
#Driver Connection URL
-dbDriverUrl=jdbc:mysql://localhost:3306/lams
+dbDriverUrl=jdbc:mysql://localhost:3306/scratch
#Classname of JDBC driver
dbDriverClass=com.mysql.jdbc.Driver
#List of files to move to the deploy directory
-deployFiles=lams_tool_imscp.war,lams_tool_imscp.jar
+deployFiles=test/file/test-dummy.war,test/file/test-dummy.jar
#nameof SQL script file to create and populate the tool tables
-toolTablesScriptPath=create_imscp_db.sql
+toolTablesScriptPath=test/file/sql/create_tool_tables.sql
#Path of SQL script file to create the tool library activity
-toolActivityInsertScriptPath=insert_imscp_activity.sql
+toolActivityInsertScriptPath=test/file/sql/activity_insert.sql
#Path of SQL script to insert the library record
-toolLibraryInsertScriptPath=insert_imscp_library.sql
+toolLibraryInsertScriptPath=test/file/sql/library_insert.sql
#name of SQL script that inserts the lams_tool record
-toolInsertScriptPath=insert_imscp_tool.sql
+toolInsertScriptPath=test/file/sql/tool_insert.sql
#path to lams ear dir
-lamsEarPath=/var/jboss/server/default/deploy/lams.ear
+lamsEarPath=test/file/lams.ear
#Context path to deploy the tool under
-toolContext=/lams/tool/imscp
+toolContext=/lams/tool/test
#URI of tool web app location
-toolWebUri=lams_tool_imscp.war
+toolWebUri=test-dummy.war
Fisheye: Tag 8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5 refers to a dead (removed) revision in file `lams_tool_deploy/test/file/lams.ear/application.xml'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_deploy/test/file/test.properties
===================================================================
diff -u -r3e1c3cc5291e781560fe935140c6c985229df7e4 -r8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5
--- lams_tool_deploy/test/file/test.properties (.../test.properties) (revision 3e1c3cc5291e781560fe935140c6c985229df7e4)
+++ lams_tool_deploy/test/file/test.properties (.../test.properties) (revision 8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5)
@@ -10,4 +10,30 @@
dbDriverUrl=jdbc:mysql://localhost:3306/scratch
#Classname of JDBC driver
-dbDriverClass=com.mysql.jdbc.Driver
\ No newline at end of file
+dbDriverClass=com.mysql.jdbc.Driver
+
+#test tool insert script
+toolInsertScriptPath=test/file/sql/tool_insert.sql
+
+#test tool library insert script
+toolLibraryInsertScriptPath=test/file/sql/library_insert.sql
+
+#test tool activity insert script
+toolActivityInsertScriptPath=test/file/sql/activity_insert.sql
+
+#test tool tables script
+toolTablesScriptPath=test/file/sql/create_tool_tables.sql
+#path to test Ear directory
+testEarPath=test/file/lams.ear
+
+#path to test application xml
+testAppXmlPath=test/file/application.xml
+
+#path to test deploy properties file
+testDeployPropertiesPath=test/file/deploy.properties
+
+#Destination path of test war
+testWarPath=test/file/lams.ear/test-dummy.war
+
+#destination path of the test jar
+testJarPath=test/file/lams.ear/test-dummy.jar
Index: lams_tool_deploy/test/java/org/lamsfoundation/lams/tool/deploy/DeployConfigTest.java
===================================================================
diff -u -r3e1c3cc5291e781560fe935140c6c985229df7e4 -r8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5
--- lams_tool_deploy/test/java/org/lamsfoundation/lams/tool/deploy/DeployConfigTest.java (.../DeployConfigTest.java) (revision 3e1c3cc5291e781560fe935140c6c985229df7e4)
+++ lams_tool_deploy/test/java/org/lamsfoundation/lams/tool/deploy/DeployConfigTest.java (.../DeployConfigTest.java) (revision 8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5)
@@ -47,78 +47,76 @@
public void testGetDbUsername()
{
- assertEquals(config.getDbUsername(), "lams");
+ assertEquals(config.getDbUsername(), "root");
}
public void testGetDbPassword()
{
- assertEquals(config.getDbPassword(), "lamsdemo");
+ assertEquals(config.getDbPassword(), "dag.Quiz");
}
public void testGetDbDriverUrl()
{
- assertEquals(config.getDbDriverUrl(), "jdbc:mysql://localhost:3306/lams");
+ assertEquals(config.getDbDriverUrl(), "jdbc:mysql://localhost:3306/scratch");
}
public void testGetDbDriverClass()
{
assertEquals(config.getDbDriverClass(), "com.mysql.jdbc.Driver");
}
- // #List of files to move to the deploy directory
- //deployFiles=lams_tool_imscp.war,lams_tool_imscp.jar
+
public void testDeployFiles()
{
List deployFiles = config.getDeployFiles();
assertNotNull(deployFiles);
assertEquals(deployFiles.size(),2);
- assertEquals(deployFiles.get(0), "lams_tool_imscp.war");
- assertEquals(deployFiles.get(1), "lams_tool_imscp.jar");
+ assertEquals(deployFiles.get(0), "test/file/test-dummy.war");
+ assertEquals(deployFiles.get(1), "test/file/test-dummy.jar");
}
- //#nameof SQL script file to create and populate the tool tables
- //toolTablesScriptPath=create_imscp_db.sql
+
public void testGetToolTablesScriptPath()
{
- assertEquals(config.getToolTablesScriptPath(), "create_imscp_db.sql");
+ assertEquals(config.getToolTablesScriptPath(), "test/file/sql/create_tool_tables.sql");
}
//#Path of SQL script file to create the tool library activity
//toolActivityInsertScriptPath=insert_imscp_activity.sql
public void testGetToolActivityInsertScriptPath()
{
- assertEquals(config.getToolActivityInsertScriptPath(), "insert_imscp_activity.sql");
+ assertEquals(config.getToolActivityInsertScriptPath(), "test/file/sql/activity_insert.sql");
}
//#Path of SQL script to insert the library record
//toolLibraryInsertScriptPath=insert_imscp_library.sql
public void testGetToolLibraryInsertScriptPath()
{
- assertEquals(config.getToolLibraryInsertScriptPath(), "insert_imscp_library.sql");
+ assertEquals(config.getToolLibraryInsertScriptPath(), "test/file/sql/library_insert.sql");
}
//#name of SQL script that inserts the lams_tool record
//toolInsertScriptPath=insert_imscp_tool.sql
public void testGetToolInsertScriptPath()
{
- assertEquals(config.getToolInsertScriptPath(), "insert_imscp_tool.sql");
+ assertEquals(config.getToolInsertScriptPath(), "test/file/sql/tool_insert.sql");
}
//#path to lams ear dir
//lamsEarPath=/var/jboss/server/default/deploy/lams.ear
public void testGetLamsEarPath()
{
- assertEquals(config.getLamsEarPath(), "/var/jboss/server/default/deploy/lams.ear");
+ assertEquals(config.getLamsEarPath(), "test/file/lams.ear");
}
//#Context path to deploy the tool under
//toolContext=/lams/tool/imscp
public void testGetToolContextRoot()
{
- assertEquals(config.getToolContextRoot(), "/lams/tool/imscp");
+ assertEquals(config.getToolContextRoot(), "/lams/tool/test");
}
//#URI of tool web app location
//toolWebUri=lams_tool_imscp.war
public void testGetToolWebUri()
{
- assertEquals(config.getToolWebUri(), "lams_tool_imscp.war");
+ assertEquals(config.getToolWebUri(), "test-dummy.war");
}
}
Index: lams_tool_deploy/test/java/org/lamsfoundation/lams/tool/deploy/DeployTest.java
===================================================================
diff -u
--- lams_tool_deploy/test/java/org/lamsfoundation/lams/tool/deploy/DeployTest.java (revision 0)
+++ lams_tool_deploy/test/java/org/lamsfoundation/lams/tool/deploy/DeployTest.java (revision 8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5)
@@ -0,0 +1,66 @@
+/*
+ * DeployTest.java
+ * JUnit based test
+ *
+ * Created on 08 April 2005, 10:55
+ */
+
+package org.lamsfoundation.lams.tool.deploy;
+
+import junit.framework.*;
+import org.apache.commons.io.FileUtils;
+import java.io.IOException;
+import java.io.File;
+/**
+ *
+ * @author chris
+ */
+public class DeployTest extends ToolDBTest
+{
+
+ public DeployTest(String testName)
+ {
+ super(testName);
+ }
+
+ protected void setUp() throws java.lang.Exception
+ {
+ super.setUp();
+ File testedApplicationXml = new File(props.getString("testEarPath")+"/META-INF/application.xml");
+ if (testedApplicationXml.exists())
+ {
+ FileUtils.forceDelete(testedApplicationXml);
+ }
+ File testedWar = new File(props.getString("testWarPath"));
+ if (testedWar.exists())
+ {
+ FileUtils.forceDelete(testedWar);
+ }
+ File testedJar = new File(props.getString("testJarPath"));
+ if (testedJar.exists())
+ {
+ FileUtils.forceDelete(testedJar);
+ }
+ FileUtils.copyFileToDirectory(new File(props.getString("testAppXmlPath")), new File(props.getString("testEarPath")+"/META-INF"));
+ }
+
+ protected void tearDown() throws java.lang.Exception
+ {
+ //super.tearDown();
+ //FileUtils.forceDelete(new File(props.getString("testEarPath")+"/META-INF/application.xml"));
+ }
+
+ public static junit.framework.Test suite()
+ {
+ junit.framework.TestSuite suite = new junit.framework.TestSuite(DeployTest.class);
+
+ return suite;
+ }
+
+ public void testMain() throws Exception
+ {
+ String[] args = {props.getString("testDeployPropertiesPath")};
+ Deploy.main(args);
+ }
+
+}
Index: lams_tool_deploy/test/java/org/lamsfoundation/lams/tool/deploy/ToolDBDeployTaskTest.java
===================================================================
diff -u -r922473f5ee7930d8f2ddbf3f3e2d1d00cd9deee9 -r8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5
--- lams_tool_deploy/test/java/org/lamsfoundation/lams/tool/deploy/ToolDBDeployTaskTest.java (.../ToolDBDeployTaskTest.java) (revision 922473f5ee7930d8f2ddbf3f3e2d1d00cd9deee9)
+++ lams_tool_deploy/test/java/org/lamsfoundation/lams/tool/deploy/ToolDBDeployTaskTest.java (.../ToolDBDeployTaskTest.java) (revision 8ad3ce44f05fdb00f6c9e7e2bbb6d65c70ca20c5)
@@ -39,27 +39,8 @@
protected void setUp() throws java.lang.Exception
{
super.setUp();
- toolInsertScript = new File("test/file/sql/tool_insert.sql");
- if (!toolInsertScript.exists())
- {
- throw new Exception("can't find test tool insert script!");
- }
- libraryInsertScript = new File("test/file/sql/library_insert.sql");
- if (!libraryInsertScript.exists())
- {
- throw new Exception("can't find test library insert script!");
- }
- toolCreateScript = new File("test/file/sql/create_tool_tables.sql");
- if (!toolCreateScript.exists())
- {
- throw new Exception("can't find test tool create script!");
- }
- activityInsertScript = new File("test/file/sql/activity_insert.sql");
- if (!activityInsertScript.exists())
- {
- throw new Exception("can't find test activity insert script!");
- }
+
}
protected void tearDown() throws java.lang.Exception
@@ -83,10 +64,10 @@
task.setDbPassword(props.getString("dbPassword"));
task.setDbDriverClass(props.getString("dbDriverClass"));
task.setDbDriverUrl(props.getString("dbDriverUrl"));
- task.setToolInsertScript(toolInsertScript);
- task.setToolLibraryInsertScript(libraryInsertScript);
- task.setToolActivityInsertScript(activityInsertScript);
- task.setToolTablesScript(toolCreateScript);
+ task.setToolInsertScriptPath(props.getString("toolInsertScriptPath"));
+ task.setToolLibraryInsertScriptPath(props.getString("toolLibraryInsertScriptPath"));
+ task.setToolActivityInsertScriptPath(props.getString("toolActivityInsertScriptPath"));
+ task.setToolTablesScriptPath(props.getString("toolTablesScriptPath"));
task.execute();
assertTrue(task.getToolId() > 0L);
assertTrue(task.getLearningLibraryId() > 0L);