Index: TestHarness4LAMS2/.classpath
===================================================================
diff -u
--- TestHarness4LAMS2/.classpath (revision 0)
+++ TestHarness4LAMS2/.classpath (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: TestHarness4LAMS2/.project
===================================================================
diff -u
--- TestHarness4LAMS2/.project (revision 0)
+++ TestHarness4LAMS2/.project (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,17 @@
+
+
+ TestHarness4LAMS2
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
Index: TestHarness4LAMS2/20bs.zip
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/2nbs.zip
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/5tools.zip
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/AllInOneBenchmark.zip
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/adminTest1.properties
===================================================================
diff -u
--- TestHarness4LAMS2/adminTest1.properties (revision 0)
+++ TestHarness4LAMS2/adminTest1.properties (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,62 @@
+#------------------------------------------------------
+# CallType has 3 valid values: RMI,WS and WEB
+# RMI means Remote Method Invocation call; EJB remote interface call is an example.
+# WS means Web Service call.
+# WEB means URL call.
+#-------------------------------------------------------
+CallType = WEB
+#CallType = WS
+#CallType = RMI
+
+#-----------------------------------------------------------------------
+# The value of RMIRegistryName is used when CallType is RMI.
+#-----------------------------------------------------------------------
+# RMIRegistryName = UserManagementService
+
+#-----------------------------------------------------------------
+# This WebServiceAddress value is used when CallType is WS.
+#-----------------------------------------------------------------
+# WebServiceAddress = /services/UserManagementService
+
+#-----------------------------------------------------------------
+# 2 URLs to be used have to be defined if CallType is WEB
+# Don't change %orgId% as the part to be replaced with the real course Id
+#-----------------------------------------------------------------
+CreateCourseURL = /admin/organisation.do?method=edit&typeId=2&parentId=1&parentName=Root
+CreateUserURL = /admin/user.do?method=edit&orgId=%orgId%
+
+#---------------------------------------------------------------
+# Set course name for this test.
+# The course name created will be prefixed with _
+# If it's not specified, "Course" will be used
+#---------------------------------------------------------------
+# CourseName = Course
+
+#-----------------------------------------------------------------
+# If CourseId is set,
+# All the settings regarding course creation will be ignored
+# This property is used to test against an existing course
+#-----------------------------------------------------------------
+# CourseId = 1
+
+#-----------------------------------------------------------------
+# If UserCreated is set to true, all the settings regarding user creation will be ignored
+# If not specified, the value of the property will be false.
+# If CourseId is not set, this value will be always considered false
+#-----------------------------------------------------------------
+# UserCreated = true
+
+#--------------------------------------------------------------
+# sysadmin login info
+#--------------------------------------------------------------
+SysadminUsername=sysadmin
+SysadminPassword=sysadmin
+
+#------------------------------------------------------------
+# Set delays (in secounds) which are the amount of idle time between calls to the server
+# Delay is used to emulate the time admins spent on viewing other users' age, gender and address ;-)
+# delay = MinDelay*1000 + random.nextInt((MaxDelay-MinDelay+1)*1000)
+# If not specified, 0 will be used for both.
+#------------------------------------------------------------
+# MinDelay = 1
+# MaxDelay = 5
Index: TestHarness4LAMS2/authorTest1.properties
===================================================================
diff -u
--- TestHarness4LAMS2/authorTest1.properties (revision 0)
+++ TestHarness4LAMS2/authorTest1.properties (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,52 @@
+#------------------------------------------------------
+# CallType has 3 valid values: RMI,WS and WEB
+# RMI means Remote Method Invocation call; EJB remote interface call is an example.
+# WS means Web Service call.
+# WEB means URL call.
+#-------------------------------------------------------
+CallType = WEB
+#CallType = WS
+#CallType = RMI
+
+#-----------------------------------------------------------------------
+# The value of RMIRegistryName is used when CallType is RMI.
+#-----------------------------------------------------------------------
+# RMIRegistryName = AuthorService
+
+#-----------------------------------------------------------------
+# This WebServiceAddress value is used when CallType is WS.
+#-----------------------------------------------------------------
+# WebServiceAddress = /services/LearningDesignService
+
+#-----------------------------------------------------------------
+# This LearningDesignUploadURL value is used when CallType is WEB.
+#-----------------------------------------------------------------
+LearningDesignUploadURL = /authoring/importToolContent.do?method=import
+
+#-----------------------------------------------------------------
+# This LearningDesignFile is uploaded to import a Learning Design
+# It could be relative path or absolute path or any valid URL
+#-----------------------------------------------------------------
+LearningDesignFile = 2nbs.zip
+
+#-----------------------------------------------------------------
+# If LearningDesignId is set,
+# All the settings above will be ignored
+# This property is used to test against an existing learning design
+#-----------------------------------------------------------------
+# LearningDesignId = 1
+
+#------------------------------------------------------------------
+# Set the base name of the author
+# If it's not specified, "Author" will be used
+#------------------------------------------------------------------
+# BaseAuthorName = Shaun
+
+#------------------------------------------------------------
+# Set delays (in secounds) which are the amount of idle time between calls to the server
+# Delay is used to emulate the time authors spent on going to toilet during composing sequences ;-)
+# delay = MinDelay*1000 + random.nextInt((MaxDelay-MinDelay+1)*1000)
+# If not specified, 0 will be used for both.
+#------------------------------------------------------------
+# MinDelay = 1
+# MaxDelay = 5
Index: TestHarness4LAMS2/build.xml
===================================================================
diff -u
--- TestHarness4LAMS2/build.xml (revision 0)
+++ TestHarness4LAMS2/build.xml (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: TestHarness4LAMS2/learnerTest1.properties
===================================================================
diff -u
--- TestHarness4LAMS2/learnerTest1.properties (revision 0)
+++ TestHarness4LAMS2/learnerTest1.properties (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,71 @@
+#------------------------------------------------------
+# CallType has 3 valid values: RMI,WS and WEB
+# RMI means Remote Method Invocation call; EJB remote interface call is an example.
+# WS means Web Service call.
+# WEB means URL call.
+#-------------------------------------------------------
+CallType = WEB
+#CallType = WS
+#CallType = RMI
+
+#-----------------------------------------------------------------------
+# The value of RMIRegistryName is used when CallType is RMI.
+#-----------------------------------------------------------------------
+# RMIRegistryName = LearnerService
+
+#-----------------------------------------------------------------
+# This WebServiceAddress value is used when CallType is WS.
+#-----------------------------------------------------------------
+# WebServiceAddress = /services/LearnerService
+
+#-------------------------------------------------------------------
+# A bunch of URLs to be used have to be defined if CallType is WEB
+#-------------------------------------------------------------------
+GetLessonURL = /learning/learner.do?method=getLesson&lessonID=%lsId%
+GetLearningDesignURL = /authoring/author.do?method=getLearningDesignDetails&learningDesignID=%ldId%
+JoinLessonURL = /learning/learner.do?method=joinLesson&lessonID=%lsId%
+GetFlashProgressDataURL = /learning/learner.do?method=getFlashProgressData&lessonID=%lsId%
+LessonEntryURL = /learning/DisplayActivity.do?lessonID=%lsId%
+
+#-------------------------------------------------------------------
+# Paths of the files for learner to choose from when he/she need
+# upload a file to finish any activity.
+# They could be relative or absolute path and are seperated by a semicolon
+#-------------------------------------------------------------------
+FilesToUpload = lib/wddx.jar;lib/js.jar;lib/httpunit.jar;test.properties;AllInOneBenchmark.zip;readme.txt
+
+#------------------------------------------------------------------
+# Set the number of learners to be created or updated for this test
+# If it's not specified, 1 will be used
+#------------------------------------------------------------------
+# NumberOfLearners = 3
+
+#------------------------------------------------------------------
+# Set the starting number in numbering the learners
+# If it's not specified, 1 will be used
+#------------------------------------------------------------------
+# LearnerOffset = 101
+
+#------------------------------------------------------------------
+# Set the base name of the learners
+# If it's not specified, "Learner" will be used
+#------------------------------------------------------------------
+# BaseLearnerName = Dolly
+
+#-----------------------------------------------------------------------
+# If you have defined 3 learners (see NumberOfLearners) you will have
+# user password
+# _Learner1 _Learner1
+# _Learner2 _Learner2
+# _Learner3 _Learner3
+#
+#-----------------------------------------------------------------------
+
+#------------------------------------------------------------
+# Set delays (in secounds) which are the amount of idle time between calls to the server
+# Delay is used to emulate the time learners spent on thinking over how to answer the questions :-(
+# delay = MinDelay*1000 + random.nextInt((MaxDelay-MinDelay+1)*1000)
+# If not specified, 0 will be used for both.
+#------------------------------------------------------------
+MinDelay = 1
+MaxDelay = 5
Index: TestHarness4LAMS2/lib/BrowserLauncher2-all-10rc4.jar
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/lib/Tidy.jar
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/lib/commons-codec-1.1.jar
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/lib/httpunit.jar
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/lib/jars.txt
===================================================================
diff -u
--- TestHarness4LAMS2/lib/jars.txt (revision 0)
+++ TestHarness4LAMS2/lib/jars.txt (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,8 @@
+Jars used:
+
+(runtime)
+httpunit 1.6
+junit 3.8.1
+servlet 2.3
+jtidy 04aug2000r7-dev
+rhino(js.jar) 1.5R4.1
Index: TestHarness4LAMS2/lib/js.jar
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/lib/junit.jar
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/lib/log4j-1.2.13.jar
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/lib/nekohtml-0.9.5.jar
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/lib/servlet.jar
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/lib/wddx.jar
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/lib/xercesImpl.jar
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/lib/xml-apis.jar
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/log.properties
===================================================================
diff -u
--- TestHarness4LAMS2/log.properties (revision 0)
+++ TestHarness4LAMS2/log.properties (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,19 @@
+# default: log all messages ERROR and FATAL to the console and to file
+log4j.rootLogger=ERROR, A1, R
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %p [%t] %c{1} - %m%n
+
+# test.log
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=test.log
+log4j.appender.R.MaxFileSize=4096KB
+log4j.appender.R.MaxBackupIndex=5
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%d{HH:mm:ss,SSS} %p [%t] %c{1} - %m%n
+
+# package overrides
+# change INFO to DEBUG to see more detailed output in log
+log4j.logger.org.lamsfoundation.testharness=INFO
+
+
Index: TestHarness4LAMS2/monitorTest1.properties
===================================================================
diff -u
--- TestHarness4LAMS2/monitorTest1.properties (revision 0)
+++ TestHarness4LAMS2/monitorTest1.properties (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,65 @@
+#------------------------------------------------------
+# CallType has 3 valid values: RMI,WS and WEB
+# RMI means Remote Method Invocation call; EJB remote interface call is an example.
+# WS means Web Service call.
+# WEB means URL call.
+#-------------------------------------------------------
+CallType = WEB
+# CallType = WS
+# CallType = RMI
+
+#-----------------------------------------------------------------------
+# The value of RMIRegistryName is used CallType is RMI.
+#-----------------------------------------------------------------------
+# RMIRegistryName = StaffService
+
+#-----------------------------------------------------------------
+# This WebServiceAddress value is used when CallType is WS.
+#-----------------------------------------------------------------
+# WebServiceAddress = /services/LearningSessionService
+
+#-----------------------------------------------------------------------
+# If not specified, "Lesson" will be used
+#-----------------------------------------------------------------------
+# LessonName = BenchmarkLesson
+
+#-----------------------------------------------------------------
+# A few URLs have to be defined when CallType is WEB.
+#-----------------------------------------------------------------
+InitLessonURL = /monitoring/monitoring.do?method=initializeLesson&learningDesignID=%ldId%&userID=%uid%&lessonName=%name%&lessonDescription=
+CreateLessonClassURL = /monitoring/createLessonClass?userID=%uid%
+StartLessonURL = /monitoring/monitoring.do?method=startLesson&lessonID=%lsId%&userID=%uid%
+
+GetLessonDetailsURL = /monitoring/monitoring.do?method=getLessonDetails&lessonID=%lsId%
+GetContributeActivitiesURL = /monitoring/monitoring.do?method=getAllContributeActivities&lessonID=%lsId%
+GetLearningDesignDetailsURL = /authoring/author.do?method=getLearningDesignDetails&learningDesignID=%ldId%
+GetAllLearnersProgressURL = /monitoring/monitoring.do?method=getAllLearnersProgress&lessonID=%lsId%
+
+
+#-----------------------------------------------------------------
+# If LessonId is set,
+# All the settings above and AuthorTest will be ignored
+# This property is used to test against an existing lesson
+#-----------------------------------------------------------------
+# LessonId = 1
+
+#------------------------------------------------------------------
+# Set the base name of the monitor
+# If it's not specified, "Monitor" will be used
+#------------------------------------------------------------------
+# BaseMonitorName = Ernie
+
+#------------------------------------------------------------------
+# Set the user id of the monitor.
+# It should be set if and only if LessonId is not set and UserCreated is true in adminTest
+#------------------------------------------------------------------
+# UserId = 100
+
+#------------------------------------------------------------
+# Set delays (in secounds) which are the amount of idle time between calls to the server
+# Delay is used to emulate the time monitors spent on watching where the learners are stuck ;-)
+# delay = MinDelay*1000 + random.nextInt((MaxDelay-MinDelay+1)*1000)
+# If not specified, 0 will be used for both.
+#------------------------------------------------------------
+MinDelay = 2
+MaxDelay = 10
Index: TestHarness4LAMS2/optional.zip
===================================================================
diff -u
Binary files differ
Index: TestHarness4LAMS2/readme.txt
===================================================================
diff -u
--- TestHarness4LAMS2/readme.txt (revision 0)
+++ TestHarness4LAMS2/readme.txt (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,54 @@
+Usage steps:
+
+1.Take a look at the properties files in this folder first and edit them as you need.
+ Usually you need only modify the following properties :
+ * TargetServer and httpPort in the master test properties file called test.properties usually
+ * NumberOfLearners in learner test properties file
+ * LearningDesignFile in author test properties file
+
+2.Execute "run" ant target on any platform with Apache Ant installed,
+ or go to TestHarness4LAMS2 dir in windows explorer or on command line,
+ and execute run.bat if you are on Microsoft Windows platform.
+
+* Modify log.properties according to the comments in it to change level of log details
+
+Disclaimer :
+
+ This program is created in the hope that it will help estimate how many concurrent
+ users a LAMS 2.x server can handle, but WITHOUT ANY GARANTEE the server can support
+ that number of users in service use.
+
+ This program is more a load test tool than a functional test tool,
+ so it does NOT GARANTEE there is no functional bug in the target server.
+
+
+TODO list:
+
+1. Add support for any kind of activitis.
+
+ Currently only support activities which consists of pages only with only one
+ "standard" form whose submit are not triggered by javascript.
+ These activities include:
+
+ 1) noticeboard
+ 2) grouping
+ 3) notebook
+ 4) multiple choice
+
+ Not supported are parallel activities and activities which has pages without
+ forms (such as Share Resources) or forms whose submission are triggered by
+ javascript or with multiple forms ( such as Chat and Optional)
+
+2. Generate formal test report document
+
+
+TODO JUST FOR FUN list:
+
+1. Add Master/Slave mode support so that a few PCs can collaborate on one testsuite.
+ Persisting test records in Master PC's database could be the easiest way to
+ implement that.
+
+2. Implement GUI based test manager
+
+3. Implement RMI and WS tests if they are implemented in LAMS 2 in future.
+
\ No newline at end of file
Index: TestHarness4LAMS2/run.bat
===================================================================
diff -u
--- TestHarness4LAMS2/run.bat (revision 0)
+++ TestHarness4LAMS2/run.bat (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,61 @@
+@echo off
+rem -------------------------------------------------------------------------
+rem TestHarness Bootstrap Script for Win32
+rem -------------------------------------------------------------------------
+
+rem $Id$
+
+set JVM_MEM=-Xms256m -Xmx512m
+
+@if not "%ECHO%" == "" echo %ECHO%
+@if "%OS%" == "Windows_NT" setlocal
+
+set DIRNAME=.\
+if "%OS%" == "Windows_NT" set DIRNAME=%~dp0%
+
+rem Read all command line arguments
+
+set ARGS=
+:loop
+if [%1] == [] goto endloop
+ set ARGS=%ARGS% %1
+ shift
+ goto loop
+:endloop
+
+if not "%JAVA_HOME%" == "" goto ADD_TOOLS
+
+set JAVA=java
+
+echo JAVA_HOME is not set. Unexpected results may occur.
+echo Set JAVA_HOME to the directory of your local JDK to avoid this message.
+
+:ADD_TOOLS
+
+set JAVA=%JAVA_HOME%\bin\java
+
+rem Setup TestHarness sepecific properties
+set TESTHARNESS_HOME=%DIRNAME%
+set JAVA_OPTS=%JAVA_OPTS% %JVM_MEM%
+set TESTHARNESS_CLASSPATH=;%TESTHARNESS_HOME%build\;%TESTHARNESS_HOME%lib\BrowserLauncher2-all-10rc4.jar;%TESTHARNESS_HOME%lib\commons-codec-1.1.jar;%TESTHARNESS_HOME%lib\httpunit.jar;%TESTHARNESS_HOME%lib\js.jar;%TESTHARNESS_HOME%lib\junit.jar;%TESTHARNESS_HOME%lib\log4j-1.2.13.jar;%TESTHARNESS_HOME%lib\nekohtml-0.9.5.jar;%TESTHARNESS_HOME%lib\Tidy.jar;%TESTHARNESS_HOME%lib\wddx.jar;%TESTHARNESS_HOME%lib\xercesImpl.jar;%TESTHARNESS_HOME%lib\xml-apis.jar
+
+echo ===============================================================================
+echo .
+echo TestHarness Bootstrap Environment
+echo .
+echo JAVA: %JAVA%
+echo .
+echo JAVA_OPTS: %JAVA_OPTS%
+echo .
+echo CLASSPATH: %TESTHARNESS_CLASSPATH%
+echo .
+echo TESTHARNESS_HOME: %TESTHARNESS_HOME%
+echo ===============================================================================
+echo .
+
+"%JAVA%" %JAVA_OPTS% -classpath "%TESTHARNESS_CLASSPATH%" org.lamsfoundation.testharness.Main test.properties
+
+:END
+if "%NOPAUSE%" == "" pause
+
+:END_NO_PAUSE
Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/AbstractTest.java
===================================================================
diff -u
--- TestHarness4LAMS2/src/org/lamsfoundation/testharness/AbstractTest.java (revision 0)
+++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/AbstractTest.java (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,144 @@
+/****************************************************************
+ * Copyright (C) 2006 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.testharness;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.testharness.Call.CallType;
+
+
+/**
+ * @version
+ *
+ *
+ *
+ * @author Fei Yang
+ */
+public abstract class AbstractTestManager {
+
+ private static final Logger log = Logger.getLogger(AbstractTestManager.class);
+
+ protected List testSuites = new LinkedList();
+
+ protected static final Integer MAX_USERNAME_LENGTH = 20;
+
+ protected CountDownLatch allDoneSignal;
+
+ /**
+ * This is where test manager initializes the test suites.
+ * Must set TestReport's reportFileName and reportFileTemplate here.
+ */
+ protected abstract void init();
+
+ protected final void kickOff(){
+ init();
+ if(!TestReporter.initialized()){
+ throw new TestHarnessException("TestReport class is not initialized! It should be a bug in the AbstractTestManager implementation");
+ }
+ log.info(composeStartInfo());
+ for (int i = 0; i < testSuites.size(); i++) {
+ new Thread(testSuites.get(i),"TestSuite-"+testSuites.get(i).getSuiteIndex()).start();
+ }
+ if(testSuites.size()>0){
+ allDoneSignal = new CountDownLatch(testSuites.size());
+ try{
+ allDoneSignal.await();
+ }catch(InterruptedException e){
+ log.fatal(e.getMessage(), e);
+ //what to do?
+ }
+ }
+ log.info(composeEndInfo());
+ }
+
+ private String composeStartInfo() {
+ switch (testSuites.size()) {
+ case 0:
+ return "There is no test suite found on the list";
+ case 1:
+ return "Kicking off the test suite...";
+ default:
+ return "Kicking off the " + testSuites.size() + " test suites...";
+ }
+ }
+
+ private String composeEndInfo() {
+ switch (testSuites.size()) {
+ case 0:
+ return "So we can play the game now";
+ case 1:
+ if(countAborted()==0)
+ return "The only test suite is finished";
+ else
+ return "The only test suite aborted";
+ case 2:
+ switch(countAborted()){
+ case 0:
+ return "Both the test suites are finished";
+ case 1:
+ return "One test suite is finished, and the other aborted";
+ case 2:
+ return "Both the test suites aborted";
+ default:
+ return "Impossible! "+countAborted()+" out of "+testSuites.size()+" testSuites aborted!";
+ }
+ default:
+ if(countAborted() == 0)
+ return "All the test suites are finished";
+ else if(countAborted() == testSuites.size())
+ return "All the test suites aborted";
+ else{
+ int abortedCounter = countAborted();
+ int finishedCounter = testSuites.size()-countAborted();
+ return finishedCounter+" test suite"+(finishedCounter>1? "s are finished and " : " is finished and ")
+ + abortedCounter + "test suite"+(abortedCounter>1? "s aborted":" aborted");
+ }
+ }
+ }
+
+ protected final void addTestSuite(TestSuite suite) {
+ testSuites.add(suite);
+ }
+
+ protected final int countAborted(){
+ int amount = 0;
+ for(TestSuite suite : testSuites){
+ if (!suite.isFinished())
+ amount++;
+ }
+ return amount;
+ }
+}
Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/Call.java
===================================================================
diff -u
--- TestHarness4LAMS2/src/org/lamsfoundation/testharness/Call.java (revision 0)
+++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/Call.java (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,339 @@
+/****************************************************************
+ * Copyright (C) 2006 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.testharness;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.xml.sax.SAXException;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.PostMethodWebRequest;
+import com.meterware.httpunit.SubmitButton;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebForm;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+
+/**
+ * @version
+ *
+ *
+ *
+ * @author Fei Yang
+ *
+ */
+public class Main {
+
+ static {
+ // configure log4j
+ PropertyConfigurator.configure("log.properties");
+ // configure HttpUnit
+ // stops the unsupported javascript stuff from throwing an exception
+ HttpUnitOptions.setExceptionsThrownOnScriptError(false);
+ //WebClient.getResponse does not throw an exception when it receives an error status.
+ HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
+ }
+
+ private static final Logger log = Logger.getLogger(Main.class);
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ log.info("Starting...");
+ if (args.length == 0) {
+ log.error("No argument supplied! Please refer to readme.txt");
+ System.exit(1);
+ }
+ // create test manager and hand over the control to him.
+ AbstractTestManager manager = new PropertyFileTestManager(args[0]);
+ try{
+ manager.kickOff();
+ TestReporter.generateReport(manager);
+ log.info("It's done, anyway");
+ }catch(Exception e){
+ log.error(e.getMessage(),e);
+ System.exit(1);
+ }
+ }
+}
Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/MockUser.java
===================================================================
diff -u
--- TestHarness4LAMS2/src/org/lamsfoundation/testharness/MockUser.java (revision 0)
+++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/MockUser.java (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,194 @@
+/****************************************************************
+ * Copyright (C) 2006 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.testharness;
+
+import java.io.File;
+import java.io.IOException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.codec.binary.Hex;
+import org.apache.log4j.Logger;
+import org.xml.sax.SAXException;
+
+import com.meterware.httpunit.UploadFileSpec;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebForm;
+import com.meterware.httpunit.WebResponse;
+
+/**
+ * @version
+ *
+ *
+ *
+ * @author Fei Yang
+ */
+public class TestHarnessException extends RuntimeException {
+
+ private static final long serialVersionUID = 6481839981681761094L;
+
+ /**
+ * Constructor for TestHarnessException.
+ */
+ public TestHarnessException() {
+ super();
+ }
+
+ /**
+ * Constructor for TestHarnessException.
+ * @param message
+ */
+ public TestHarnessException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor for TestHarnessException.
+ * @param message
+ * @param cause
+ */
+ public TestHarnessException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Constructor for TestHarnessException.
+ * @param cause
+ */
+ public TestHarnessException(Throwable cause) {
+ super(cause);
+ }
+
+}
Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/TestReporter.java
===================================================================
diff -u
--- TestHarness4LAMS2/src/org/lamsfoundation/testharness/TestReporter.java (revision 0)
+++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/TestReporter.java (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,139 @@
+/****************************************************************
+ * Copyright (C) 2006 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.testharness;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.testharness.Call.CallRecord;
+import org.lamsfoundation.testharness.learner.LearnerTest;
+
+/**
+ * @version
+ *
+ *
+ *
+ * @author Fei Yang
+ */
+public class TestReporter {
+
+ private static final Logger log = Logger.getLogger(TestReporter.class);
+ private static List callRecords = new LinkedList();
+ private static String fileName;
+ private static String fileTemplate;
+
+ public static boolean initialized(){
+ return ((fileName!=null)&&(fileTemplate!=null));
+ }
+
+ public static List getCallRecords() {
+ return callRecords;
+ }
+
+
+ public static void setCallRecords(List callRecords) {
+ TestReporter.callRecords = callRecords;
+ }
+
+
+ public static String getFileName() {
+ return fileName;
+ }
+
+
+ public static void setFileName(String fileName) {
+ TestReporter.fileName = fileName;
+ }
+
+
+ public static String getFileTemplate() {
+ return fileTemplate;
+ }
+
+
+ public static void setFileTemplate(String fileTemplate) {
+ TestReporter.fileTemplate = fileTemplate;
+ }
+
+
+ public static synchronized void addCallRecord(CallRecord callRecord){
+ callRecords.add(callRecord);
+ }
+
+ public static void report(AbstractTestManager manager) {
+ final String NEW_LINE = "\n* ";
+ final String NEW_LINE_INDENT = "\n* ";
+ StringBuilder report = new StringBuilder();
+ report.append("See below\n\n**********************************Brief Report*******************************************");
+
+ //disclaimer
+ report.append(NEW_LINE);
+ report.append(NEW_LINE).append("Disclaimer:");
+ report.append(NEW_LINE_INDENT).append("This program is created in the hope that it will help estimate how many concurrent");
+ report.append(NEW_LINE_INDENT).append("users a LAMS 2.x server can handle, but WITHOUT ANY GARANTEE the server can support");
+ report.append(NEW_LINE_INDENT).append("that number of users in service use.");
+ report.append(NEW_LINE);
+ report.append(NEW_LINE_INDENT).append("This program is more a load test tool than a functional test tool, ");
+ report.append(NEW_LINE_INDENT).append("so it does NOT GARANTEE there is no functional bug in the target server.");
+ report.append(NEW_LINE);
+
+ report.append(NEW_LINE).append("Test Result Summary:");
+ report.append(NEW_LINE_INDENT).append(manager.testSuites.size()).append(" test suite(s) launched. ");
+ report.append(manager.testSuites.size()-manager.countAborted()).append(" test suite(s) finished, and ").append(manager.countAborted()).append(" test suite(s) aborted.");
+ for (TestSuite testSuite : manager.testSuites){
+ report.append(NEW_LINE_INDENT).append("Test Suite ").append(testSuite.getSuiteIndex()).append(testSuite.isFinished()? " finished" : " aborted").append(", in which");
+ report.append(NEW_LINE_INDENT);
+ AbstractTest[] tests = new AbstractTest[]{testSuite.getAdminTest(),testSuite.getAuthorTest(),testSuite.getMonitorTest(),testSuite.getLearnerTest()};
+ boolean first = true;
+ for(AbstractTest test : tests){
+ if(test!=null){
+ if(!first)
+ report.append(", ");
+ report.append(test.getTestName()).append(test.isFinished()? " finished" : " aborted");
+ first = false;
+ }
+ }
+ report.append(NEW_LINE_INDENT);
+ LearnerTest learnerTest = testSuite.getLearnerTest();
+ report.append("In ").append(learnerTest.getTestName()).append(", ");
+ report.append(learnerTest.countLearners()).append(" learner(s) attended, ");
+ report.append(learnerTest.countLearners()-learnerTest.countAborted()).append(" finished and ");
+ report.append(learnerTest.countAborted()).append(" aborted.");
+ report.append(NEW_LINE);
+ }
+ report.append(NEW_LINE).append("Refer to the formal test report document for the details.");
+ report.append(NEW_LINE).append("\n*****************************************************************************************\n");
+ log.info(report.toString());
+ }
+
+ public static void generateReport(AbstractTestManager manager) {
+ report(manager);
+ log.info("Generating the formal test report document...");
+ //TODO implement me
+ log.info("Sorry, this feature is not ready yet. It should come soon.");
+ }
+
+}
Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/TestSuite.java
===================================================================
diff -u
--- TestHarness4LAMS2/src/org/lamsfoundation/testharness/TestSuite.java (revision 0)
+++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/TestSuite.java (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,176 @@
+/****************************************************************
+ * Copyright (C) 2006 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.testharness;
+
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.testharness.admin.AdminTest;
+import org.lamsfoundation.testharness.author.AuthorTest;
+import org.lamsfoundation.testharness.learner.LearnerTest;
+import org.lamsfoundation.testharness.monitor.MonitorTest;
+
+/**
+ * @version
+ *
+ *
+ *
+ * @author Fei Yang
+ */
+public class MockAuthor extends MockUser {
+
+ private static final Logger log = Logger.getLogger(MockAuthor.class);
+
+ public static final String DEFAULT_NAME = "Author";
+
+ private static final String IMPORT_FORM_FLAG = "UPLOAD_FILE";
+ private static final String UPLOAD_FILE_PARAM = "UPLOAD_FILE";
+ private static final String IMPORT_SUCCESS_FLAG = "movie";
+ private static final String LD_START_TAG = "learningDesignID=";
+ private static final char LD_END_TAG = '&';
+
+ /**
+ * MockAuthor Constructor
+ *
+ * @param
+ */
+ public MockAuthor(AuthorTest test, String username, String password, String userId) {
+ super(test, username, password, userId);
+ }
+
+ public String importLearningDesign(String learningDesignUploadURL, File file){
+ try{
+ delay();
+ WebResponse resp = (WebResponse)new Call(wc, test,"Import Learning Design", learningDesignUploadURL).execute();
+ if(!checkPageContains(resp,IMPORT_FORM_FLAG)){
+ log.debug(resp.getText());
+ throw new TestHarnessException(username+" did not get learning design import page with the url:"+learningDesignUploadURL);
+ }
+ Map params = new HashMap();
+ params.put(UPLOAD_FILE_PARAM,file);
+ resp = (WebResponse)new Call(wc, test,"Submit Learning Design Import Form", fillForm(resp,0,params)).execute();
+ if(!checkPageContains(resp,IMPORT_SUCCESS_FLAG)){
+ log.debug(resp.getText());
+ throw new TestHarnessException(username+" failed to upload file:"+file.getAbsolutePath());
+ }
+ String text = resp.getText();
+ int startIndex = text.indexOf(LD_START_TAG);
+ int endIndex = text.indexOf(LD_END_TAG,startIndex);
+ String idAsString = text.substring(startIndex+LD_START_TAG.length(),endIndex);
+ log.info(username + " imported learning design " + file.getName()+" and the id is " + idAsString);
+ return idAsString;
+ }catch(IOException e){
+ throw new RuntimeException(e);
+ } catch (SAXException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/learner/LearnerTest.java
===================================================================
diff -u
--- TestHarness4LAMS2/src/org/lamsfoundation/testharness/learner/LearnerTest.java (revision 0)
+++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/learner/LearnerTest.java (revision 37d07da894922569d79ce4f517c45f8cbed4c452)
@@ -0,0 +1,136 @@
+/****************************************************************
+ * Copyright (C) 2006 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.testharness.learner;
+
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.testharness.AbstractTest;
+import org.lamsfoundation.testharness.Call.CallType;
+
+/**
+ * @version
+ *
+ *