Index: TestHarness4LAMS2/.classpath
===================================================================
diff -u -r457bede6fb8b69e25fa9a899ed66a32407bf80e9 -r044d2c0977e88053366db9cecba68192a6cebe5a
--- TestHarness4LAMS2/.classpath (.../.classpath) (revision 457bede6fb8b69e25fa9a899ed66a32407bf80e9)
+++ TestHarness4LAMS2/.classpath (.../.classpath) (revision 044d2c0977e88053366db9cecba68192a6cebe5a)
@@ -3,7 +3,6 @@
-
Index: TestHarness4LAMS2/learnerTest1.properties
===================================================================
diff -u -r159c15ed2f6cc7c8f273367d199b196effd5f340 -r044d2c0977e88053366db9cecba68192a6cebe5a
--- TestHarness4LAMS2/learnerTest1.properties (.../learnerTest1.properties) (revision 159c15ed2f6cc7c8f273367d199b196effd5f340)
+++ TestHarness4LAMS2/learnerTest1.properties (.../learnerTest1.properties) (revision 044d2c0977e88053366db9cecba68192a6cebe5a)
@@ -1,18 +1,16 @@
#-------------------------------------------------------------------
# A bunch of URLs to be used have to be defined
#-------------------------------------------------------------------
-GetLessonURL = /learning/learner.do?method=getLesson&lessonID=%lsId%
-GetLearningDesignURL = /authoring/author.do?method=getLearningDesignDetails&learningDesignID=%ldId%
+GetLessonURL = /monitoring/monitoring.do?method=getLessonDetailsJSON&lessonID=%lsId%
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
+FilesToUpload = lib/js-1.6R5.jar;lib/httpunit.jar;test.properties;AllInOneBenchmark.zip;readme.txt
#------------------------------------------------------------------
# Set the number of learners to be created or updated for this test
Fisheye: Tag 044d2c0977e88053366db9cecba68192a6cebe5a refers to a dead (removed) revision in file `TestHarness4LAMS2/lib/jars.txt'.
Fisheye: No comparison available. Pass `N' to diff?
Index: TestHarness4LAMS2/lib/wddx.jar
===================================================================
diff -u -r37d07da894922569d79ce4f517c45f8cbed4c452 -r044d2c0977e88053366db9cecba68192a6cebe5a
Binary files differ
Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/Call.java
===================================================================
diff -u -r457bede6fb8b69e25fa9a899ed66a32407bf80e9 -r044d2c0977e88053366db9cecba68192a6cebe5a
--- TestHarness4LAMS2/src/org/lamsfoundation/testharness/Call.java (.../Call.java) (revision 457bede6fb8b69e25fa9a899ed66a32407bf80e9)
+++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/Call.java (.../Call.java) (revision 044d2c0977e88053366db9cecba68192a6cebe5a)
@@ -120,7 +120,6 @@
private String url;
private WebForm form;
private InputStream is;
- private String contentType; // for WEB POST method
static {
@@ -165,14 +164,12 @@
this.url = url;
}
- public Call(WebConversation wc, AbstractTest test, String description, String url, InputStream is,
- String contentType) {
+ public Call(WebConversation wc, AbstractTest test, String description, String url, InputStream is) {
this.wc = wc;
this.test = test;
this.description = description;
this.url = url;
this.is = is;
- this.contentType = contentType;
}
public Call(WebConversation wc, AbstractTest test, String description, WebForm form) {
@@ -218,7 +215,7 @@
req = new GetMethodWebRequest(absoluteURL);
} else {
callee = "POST " + url;
- req = new PostMethodWebRequest(absoluteURL, is, contentType);
+ req = new PostMethodWebRequest(absoluteURL, is, "application/x-www-form-urlencoded;charset=utf-8");
}
Call.log.debug(callee);
start = System.currentTimeMillis();
Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/TestManager.java
===================================================================
diff -u -r159c15ed2f6cc7c8f273367d199b196effd5f340 -r044d2c0977e88053366db9cecba68192a6cebe5a
--- TestHarness4LAMS2/src/org/lamsfoundation/testharness/TestManager.java (.../TestManager.java) (revision 159c15ed2f6cc7c8f273367d199b196effd5f340)
+++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/TestManager.java (.../TestManager.java) (revision 044d2c0977e88053366db9cecba68192a6cebe5a)
@@ -108,9 +108,7 @@
private static final String LEARNER_OFFSET = "LearnerOffset";
private static final String BASE_LEARNER_NAME = "BaseLearnerName";
private static final String GET_LESSON_URL = "GetLessonURL";
- private static final String GET_LD_URL = "GetLearningDesignURL";
private static final String JOIN_LESSON_URL = "JoinLessonURL";
- private static final String GET_PROGRESS_URL = "GetFlashProgressDataURL";
private static final String LESSON_ENTRY_URL = "LessonEntryURL";
private static final String FILES_TO_UPLOAD = "FilesToUpload";
@@ -295,19 +293,15 @@
TestManager.BASE_LEARNER_NAME, true);
String getLessonURL = TestManager.getStringProperty(learnerTestPropertyFileName, learnerTestProperties,
TestManager.GET_LESSON_URL, false);
- String getLearningDesignURL = TestManager.getStringProperty(learnerTestPropertyFileName, learnerTestProperties,
- TestManager.GET_LD_URL, false);
String joinLessonURL = TestManager.getStringProperty(learnerTestPropertyFileName, learnerTestProperties,
TestManager.JOIN_LESSON_URL, false);
- String getProgressURL = TestManager.getStringProperty(learnerTestPropertyFileName, learnerTestProperties,
- TestManager.GET_PROGRESS_URL, false);
String lessonEntryURL = TestManager.getStringProperty(learnerTestPropertyFileName, learnerTestProperties,
TestManager.LESSON_ENTRY_URL, false);
String filesToUpload = TestManager.getStringProperty(learnerTestPropertyFileName, learnerTestProperties,
TestManager.FILES_TO_UPLOAD, false);
- LearnerTest test = new LearnerTest(testName, minDelay, maxDelay, getLessonURL, getLearningDesignURL,
- joinLessonURL, getProgressURL, lessonEntryURL, filesToUpload == null ? null : filesToUpload.split(";"));
+ LearnerTest test = new LearnerTest(testName, minDelay, maxDelay, getLessonURL, joinLessonURL, lessonEntryURL,
+ filesToUpload == null ? null : filesToUpload.split(";"));
MockLearner[] learners = new MockLearner[numberOfLearners];
for (int i = 0; i < numberOfLearners; i++) {
Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/TestUtil.java
===================================================================
diff -u -r41955af92f3e17f2f11c07d94ae1a5f92b0d998f -r044d2c0977e88053366db9cecba68192a6cebe5a
--- TestHarness4LAMS2/src/org/lamsfoundation/testharness/TestUtil.java (.../TestUtil.java) (revision 41955af92f3e17f2f11c07d94ae1a5f92b0d998f)
+++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/TestUtil.java (.../TestUtil.java) (revision 044d2c0977e88053366db9cecba68192a6cebe5a)
@@ -22,20 +22,12 @@
*/
package org.lamsfoundation.testharness;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Random;
import org.apache.log4j.Logger;
-import org.xml.sax.InputSource;
-import com.allaire.wddx.WddxDeserializationException;
-import com.allaire.wddx.WddxDeserializer;
-import com.allaire.wddx.WddxSerializer;
-
/**
* @author Fei Yang, Marcin Cieslak
*/
@@ -53,28 +45,6 @@
return TestUtil.truncate(TestUtil.buildName(TestUtil.truncate(testName, 1, true), simpleName), maxLength, true);
}
- public static Object deserialize(String wddxPacket) throws WddxDeserializationException {
-
- TestUtil.log.debug("WDDX packet from the server:" + wddxPacket);
-
- // Create an input source (org.xml.sax.InputSource) bound to the packet
- InputSource tempSource = new InputSource(new StringReader(wddxPacket));
-
- // Create a WDDX deserializer (com.allaire.wddx.WddxDeserializer)
- WddxDeserializer tempDeserializer = new WddxDeserializer("org.apache.xerces.parsers.SAXParser");
-
- // Deserialize the WDDX packet
- Object result;
- try {
- result = tempDeserializer.deserialize(tempSource);
- TestUtil.log.debug("Object deserialized from the WDDX packet:" + result);
- } catch (IOException e) {
- throw new WddxDeserializationException(e);
- }
-
- return result;
- }
-
public static String extractString(String text, String startFlag, char endFlag) {
String target = null;
try {
@@ -107,13 +77,6 @@
}
}
- public static String serialize(Object data) throws IOException {
- WddxSerializer tempws = new WddxSerializer();
- StringWriter tempsw = new StringWriter();
- tempws.serialize(data, tempsw);
- return tempsw.toString();
- }
-
private static String truncate(String name, int length, boolean leftToRight) {
if (name.length() <= length) {
return name;
Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/learner/LearnerTest.java
===================================================================
diff -u -r41955af92f3e17f2f11c07d94ae1a5f92b0d998f -r044d2c0977e88053366db9cecba68192a6cebe5a
--- TestHarness4LAMS2/src/org/lamsfoundation/testharness/learner/LearnerTest.java (.../LearnerTest.java) (revision 41955af92f3e17f2f11c07d94ae1a5f92b0d998f)
+++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/learner/LearnerTest.java (.../LearnerTest.java) (revision 044d2c0977e88053366db9cecba68192a6cebe5a)
@@ -41,28 +41,21 @@
private static final Logger log = Logger.getLogger(LearnerTest.class);
protected String getLessonURL;
- protected String getLearningDesignURL;
protected String joinLessonURL;
- protected String getFlashProgressDataURL;
protected String lessonEntryURL;
protected String[] filesToUpload;
- protected String subContextRoot; // usually "/learning/", this is set to figure out passon.swf url
protected CountDownLatch allDoneSignal;
/**
* LearnerTest Constructor
*
*/
- public LearnerTest(String testName,
- Integer minDelay, Integer maxDelay, String getLessonURL, String getLearningDesignURL, String joinLessonURL,
- String getFlashProgressDataURL, String lessonEntryURL, String[] filesToUpload) {
+ public LearnerTest(String testName, Integer minDelay, Integer maxDelay, String getLessonURL, String joinLessonURL,
+ String lessonEntryURL, String[] filesToUpload) {
super(testName, minDelay, maxDelay);
this.getLessonURL = getLessonURL;
- this.getLearningDesignURL = getLearningDesignURL;
this.joinLessonURL = joinLessonURL;
- this.getFlashProgressDataURL = getFlashProgressDataURL;
this.lessonEntryURL = lessonEntryURL;
- this.subContextRoot = '/' + getLessonURL.split("/")[1] + '/';
this.filesToUpload = filesToUpload;
}
Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/learner/MockLearner.java
===================================================================
diff -u -r159c15ed2f6cc7c8f273367d199b196effd5f340 -r044d2c0977e88053366db9cecba68192a6cebe5a
--- TestHarness4LAMS2/src/org/lamsfoundation/testharness/learner/MockLearner.java (.../MockLearner.java) (revision 159c15ed2f6cc7c8f273367d199b196effd5f340)
+++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/learner/MockLearner.java (.../MockLearner.java) (revision 044d2c0977e88053366db9cecba68192a6cebe5a)
@@ -26,7 +26,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Random;
@@ -35,14 +34,15 @@
import java.util.regex.Pattern;
import org.apache.log4j.Logger;
+import org.apache.tomcat.util.json.JSONException;
+import org.apache.tomcat.util.json.JSONObject;
import org.lamsfoundation.testharness.Call;
import org.lamsfoundation.testharness.MockUser;
import org.lamsfoundation.testharness.TestHarnessException;
import org.lamsfoundation.testharness.TestUtil;
import org.lamsfoundation.testharness.admin.MockAdmin;
import org.xml.sax.SAXException;
-import com.allaire.wddx.WddxDeserializationException;
import com.meterware.httpunit.Button;
import com.meterware.httpunit.FormControl;
import com.meterware.httpunit.WebForm;
@@ -134,9 +134,7 @@
LearnerTest learnerTest = (LearnerTest) test;
String lsId = test.getTestSuite().getMonitorTest().getLsId();
String ldId = getLesson(learnerTest.getLessonURL, lsId);
- getLearningDesign(learnerTest.getLearningDesignURL, ldId);
joinLesson(learnerTest.joinLessonURL, lsId);
- getFlashProgessData(learnerTest.getFlashProgressDataURL, lsId);
progressThroughActivities(learnerTest.lessonEntryURL, lsId);
finished = true;
MockLearner.log.info(username + " finished the lesson");
@@ -147,12 +145,12 @@
// other RuntimeException will still get propagated so that the
// application will halt, but that's expected, since those exceptions
// should be serious system errors
- } catch (WddxDeserializationException e) {
- throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
} catch (SAXException e) {
throw new RuntimeException(e);
+ } catch (JSONException e) {
+ throw new RuntimeException(e);
} finally {
((LearnerTest) test).allDoneSignal.countDown();
}
@@ -285,26 +283,13 @@
return null;
}
- private void getFlashProgessData(String getFlashProgressDataURL, String lsId) {
+ private String getLesson(String getLessonURL, String lsId) throws IOException, JSONException {
delay();
- String url = getFlashProgressDataURL.replace(MockLearner.LESSON_ID_PATTERN, lsId);
- new Call(wc, test, username + " get flash progress data", url).execute();
- }
-
- private void getLearningDesign(String getLearningDesignURL, String ldId) {
- delay();
- String url = getLearningDesignURL.replace(MockLearner.LD_ID_PATTERN, ldId);
- new Call(wc, test, username + " get learning design", url).execute();
- }
-
- @SuppressWarnings("rawtypes")
- private String getLesson(String getLessonURL, String lsId) throws WddxDeserializationException, IOException {
- delay();
String url = getLessonURL.replace(MockLearner.LESSON_ID_PATTERN, lsId);
WebResponse resp = (WebResponse) new Call(wc, test, username + " get lesson", url).execute();
- Hashtable hashtable = (Hashtable) TestUtil.deserialize(resp.getText());
- hashtable = (Hashtable) hashtable.get(MockLearner.MESSAGE_VALUE_KEY);
- return new Integer(((Double) hashtable.get(MockLearner.LD_ID_KEY)).intValue()).toString();
+ JSONObject responseJson = new JSONObject(resp.getText());
+
+ return responseJson.getString(MockLearner.LD_ID_KEY);
}
private Map> groupButtonsByName(Button[] btns, String buttonType) {
Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/monitor/MockMonitor.java
===================================================================
diff -u -r159c15ed2f6cc7c8f273367d199b196effd5f340 -r044d2c0977e88053366db9cecba68192a6cebe5a
--- TestHarness4LAMS2/src/org/lamsfoundation/testharness/monitor/MockMonitor.java (.../MockMonitor.java) (revision 159c15ed2f6cc7c8f273367d199b196effd5f340)
+++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/monitor/MockMonitor.java (.../MockMonitor.java) (revision 044d2c0977e88053366db9cecba68192a6cebe5a)
@@ -25,19 +25,15 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Hashtable;
+import java.net.URLEncoder;
import java.util.concurrent.CountDownLatch;
import org.apache.log4j.Logger;
-import org.apache.tomcat.util.json.JSONException;
-import org.apache.tomcat.util.json.JSONObject;
import org.lamsfoundation.testharness.Call;
import org.lamsfoundation.testharness.MockUser;
import org.lamsfoundation.testharness.TestHarnessException;
-import org.lamsfoundation.testharness.TestUtil;
import org.lamsfoundation.testharness.admin.MockAdmin;
-import com.allaire.wddx.WddxDeserializationException;
import com.meterware.httpunit.WebResponse;
/**
@@ -55,8 +51,6 @@
public static final String DEFAULT_NAME = "Monitor";
- private static final String WDDX_CONTENT_TYPE = "text/xml; charset=utf-8";
-
private static final String LDID_PATTERN = "%ldId%";
private static final String USER_ID_PATTERN = "%uid%";
@@ -89,8 +83,21 @@
public void createLessonClass(String createLessonClassURL, String userId) {
try {
String url = createLessonClassURL.replace(MockMonitor.USER_ID_PATTERN, userId);
- InputStream postBodyIS = buildPostBody();
- new Call(wc, test, "Create Lesson Class", url, postBodyIS, MockMonitor.WDDX_CONTENT_TYPE).execute();
+ StringBuilder bodyBuilder = new StringBuilder();
+ bodyBuilder.append("lessonID=").append(((MonitorTest) test).getLsId()).append("&organisationID=")
+ .append(test.getTestSuite().getAdminTest().getCourseId()).append("&userID=").append(userId)
+ .append("&learners=");
+
+ MockUser[] mockLearners = test.getTestSuite().getLearnerTest().getUsers();
+
+ for (MockUser mockLearner : mockLearners) {
+ bodyBuilder.append(mockLearner.getUserId()).append(",");
+ }
+ bodyBuilder.append("&monitors=").append(test.getTestSuite().getMonitorTest().getUsers()[0].getUserId());
+
+ String body = URLEncoder.encode(bodyBuilder.toString(), "UTF-8");
+ InputStream is = new ByteArrayInputStream(body.getBytes("UTF-8"));
+ new Call(wc, test, "Create Lesson Class", url, is).execute();
MockMonitor.log.info(username + " set the lesson class");
} catch (IOException e) {
throw new RuntimeException(e);
@@ -110,12 +117,10 @@
.replace(MockMonitor.ORGANISATION_ID_PATTERN, organisationID)
.replace(MockMonitor.USER_ID_PATTERN, userId).replace(MockMonitor.LESSON_NAME_PATTERN, name);
WebResponse resp = (WebResponse) new Call(wc, test, "Init Lesson", url).execute();
- Hashtable hashtable = (Hashtable) TestUtil.deserialize(resp.getText());
- String idAsString = new Integer(((Double) hashtable.get(MockMonitor.LESSON_ID_KEY)).intValue()).toString();
+
+ String idAsString = resp.getText().trim();
MockMonitor.log.info(username + " initialized the lesson " + name + " and the id is " + idAsString);
return idAsString;
- } catch (WddxDeserializationException e) {
- throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -126,9 +131,7 @@
try {
MockMonitor.log.info(username + " is monitoring...");
MonitorTest monitorTest = (MonitorTest) test;
- String ldId = getLessonDetails(monitorTest.getGetLessonDetailsURL(), monitorTest.getLsId());
- getContributeActivities(monitorTest.getGetContributeActivitiesURL(), monitorTest.getLsId());
- getLearningDesignDetails(monitorTest.getGetLearningDesignDetailsURL(), ldId);
+
while (stopSignal == null) {
delay();
MockMonitor.log.info(username + " is refreshing all learners progress");
@@ -161,54 +164,9 @@
}
}
- private InputStream buildPostBody() throws IOException {
- Hashtable learners = new Hashtable();
- MockUser[] mockLearners = test.getTestSuite().getLearnerTest().getUsers();
- String courseName = test.getTestSuite().getAdminTest().getCourseName();
- Integer[] users = new Integer[mockLearners.length];
- for (int i = 0; i < mockLearners.length; i++) {
- users[i] = new Integer(mockLearners[i].getUserId());
- }
- learners.put("users", users);
- learners.put("groupName", courseName + "_learners");
- Hashtable staff = new Hashtable();
- staff.put("users",
- new Integer[] { new Integer(test.getTestSuite().getMonitorTest().getUsers()[0].getUserId()) });
- staff.put("groupName", courseName + "_staff");
- Hashtable lessonClassInfo = new Hashtable();
- lessonClassInfo.put("learners", learners);
- lessonClassInfo.put("staff", staff);
- lessonClassInfo.put("organisationID", new Integer(test.getTestSuite().getAdminTest().getCourseId()));
- lessonClassInfo.put("lessonID", new Integer(((MonitorTest) test).getLsId()));
- String lessonClassWDDX = TestUtil.serialize(lessonClassInfo);
- MockMonitor.log.debug("Generated LessonClass WDDX packet:" + lessonClassWDDX);
- return new ByteArrayInputStream(lessonClassWDDX.getBytes("UTF-8"));
- }
-
private void getAllLearnersProgress(String getAllLearnersProgressURL, String lsId) throws IOException {
String url = getAllLearnersProgressURL.replace(MockMonitor.LESSON_ID_PATTERN, lsId);
WebResponse resp = (WebResponse) new Call(wc, test, username + " get all learners progress", url).execute();
MockMonitor.log.debug("Learner progress: " + resp.getText());
}
-
- private void getContributeActivities(String getContributeActivitiesURL, String lsId) throws IOException {
- String url = getContributeActivitiesURL.replace(MockMonitor.LESSON_ID_PATTERN, lsId);
- WebResponse resp = (WebResponse) new Call(wc, test, username + " get contribute activities", url).execute();
- MockMonitor.log.debug("Contribute activities: " + resp.getText());
- }
-
- private void getLearningDesignDetails(String getLearningDesignDetailsURL, String ldId)
- throws WddxDeserializationException, IOException {
- String url = getLearningDesignDetailsURL.replace(MockMonitor.LDID_PATTERN, ldId);
- WebResponse resp = (WebResponse) new Call(wc, test, username + " get learning design details", url).execute();
- TestUtil.deserialize(resp.getText());
- }
-
- private String getLessonDetails(String getLessonDetailsURL, String lsId) throws JSONException, IOException {
- String url = getLessonDetailsURL.replace(MockMonitor.LESSON_ID_PATTERN, lsId);
- WebResponse resp = (WebResponse) new Call(wc, test, username + " get lesson", url).execute();
- MockMonitor.log.debug("Lesson details: " + resp.getText());
- JSONObject jsonObject = new JSONObject(resp.getText());
- return String.valueOf(jsonObject.getLong(MockMonitor.LD_ID_KEY));
- }
}
\ No newline at end of file