Index: TestHarness4LAMS2/.classpath =================================================================== diff -u -r4845924e4c50c859a4e230872c3f1629f9224380 -r0fea6612262a9934db549a1272d73243e6fd0584 --- TestHarness4LAMS2/.classpath (.../.classpath) (revision 4845924e4c50c859a4e230872c3f1629f9224380) +++ TestHarness4LAMS2/.classpath (.../.classpath) (revision 0fea6612262a9934db549a1272d73243e6fd0584) @@ -1,24 +1,25 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + Index: TestHarness4LAMS2/learnerTest1.properties =================================================================== diff -u -r883c4cc054a636dc8017da1b244b89bdaf0ff974 -r0fea6612262a9934db549a1272d73243e6fd0584 --- TestHarness4LAMS2/learnerTest1.properties (.../learnerTest1.properties) (revision 883c4cc054a636dc8017da1b244b89bdaf0ff974) +++ TestHarness4LAMS2/learnerTest1.properties (.../learnerTest1.properties) (revision 0fea6612262a9934db549a1272d73243e6fd0584) @@ -9,7 +9,7 @@ # upload a file to finish any activity. # They could be relative or absolute path and are seperated by a semicolon #------------------------------------------------------------------- -FilesToUpload = lib/js-1.6R5.jar;lib/httpunit.jar;test.properties;AllInOneBenchmark.zip;readme.txt +FilesToUpload = lib/rhino-1.7.7.1.jar;lib/httpunit.jar;test.properties;AllInOneBenchmark.zip;readme.txt #------------------------------------------------------------------ # Set the number of learners to be created or updated for this test Index: TestHarness4LAMS2/lib/BrowserLauncher2-all-10rc4.jar =================================================================== diff -u -r37d07da894922569d79ce4f517c45f8cbed4c452 -r0fea6612262a9934db549a1272d73243e6fd0584 Binary files differ Index: TestHarness4LAMS2/lib/BrowserLauncher2-all-1_3.jar =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/lib/commons-codec-1.1.jar =================================================================== diff -u -r37d07da894922569d79ce4f517c45f8cbed4c452 -r0fea6612262a9934db549a1272d73243e6fd0584 Binary files differ Index: TestHarness4LAMS2/lib/commons-codec-1.10.jar =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/lib/jackson-core-2.7.4.jar =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/lib/jackson-databind-2.7.4.jar =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/lib/jboss-servlet-api_3.1_spec-1.0.0.Final.jar =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/lib/jbossweb.jar =================================================================== diff -u -r8e1ed196bfc1c28860729d8b0a23878bb3ecf1e7 -r0fea6612262a9934db549a1272d73243e6fd0584 Binary files differ Index: TestHarness4LAMS2/lib/js-1.6R5.jar =================================================================== diff -u -r7f004df92bf884af26247547f7a05978a6504041 -r0fea6612262a9934db549a1272d73243e6fd0584 Binary files differ Index: TestHarness4LAMS2/lib/jtidy-4aug2000r7-dev.jar =================================================================== diff -u -r7f004df92bf884af26247547f7a05978a6504041 -r0fea6612262a9934db549a1272d73243e6fd0584 Binary files differ Index: TestHarness4LAMS2/lib/jtidy-r938.jar =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/lib/junit-3.8.1.jar =================================================================== diff -u -r7f004df92bf884af26247547f7a05978a6504041 -r0fea6612262a9934db549a1272d73243e6fd0584 Binary files differ Index: TestHarness4LAMS2/lib/junit-4.10.jar =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/lib/log4j-1.2.13.jar =================================================================== diff -u -r37d07da894922569d79ce4f517c45f8cbed4c452 -r0fea6612262a9934db549a1272d73243e6fd0584 Binary files differ Index: TestHarness4LAMS2/lib/log4j-1.2.17.jar =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/lib/nekohtml-0.9.5.jar =================================================================== diff -u -r37d07da894922569d79ce4f517c45f8cbed4c452 -r0fea6612262a9934db549a1272d73243e6fd0584 Binary files differ Index: TestHarness4LAMS2/lib/nekohtml.jar =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/lib/rhino-1.7.7.1.jar =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/lib/servlet-api-2.4.jar =================================================================== diff -u -r7f004df92bf884af26247547f7a05978a6504041 -r0fea6612262a9934db549a1272d73243e6fd0584 Binary files differ Index: TestHarness4LAMS2/lib/undertow-websockets-jsr-1.1.8.Final.jar =================================================================== diff -u -rd1613469baf410358fffc018b070d1a726df5391 -r0fea6612262a9934db549a1272d73243e6fd0584 Binary files differ Index: TestHarness4LAMS2/lib/undertow-websockets-jsr-1.4.0.Final.jar =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/lib/xercesImpl-2.6.1.jar =================================================================== diff -u -r7f004df92bf884af26247547f7a05978a6504041 -r0fea6612262a9934db549a1272d73243e6fd0584 Binary files differ Index: TestHarness4LAMS2/lib/xercesImpl.jar =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/JsonUtil.java =================================================================== diff -u --- TestHarness4LAMS2/src/org/lamsfoundation/testharness/JsonUtil.java (revision 0) +++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/JsonUtil.java (revision 0fea6612262a9934db549a1272d73243e6fd0584) @@ -0,0 +1,125 @@ +/**************************************************************** + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.testharness; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +/** + * Helper for JSON objects. + * + * @author Marcin Cieslak + * + */ +public class JsonUtil { + public static final ObjectMapper objectMapper = new ObjectMapper(); + + public static JsonNode opt(JsonNode object, String field) { + return opt(object, field, null); + } + + public static JsonNode opt(JsonNode object, String field, JsonNode defaultValue) { + return object.hasNonNull(field) ? object.get(field) : defaultValue; + } + + public static ObjectNode optObject(JsonNode object, String field) { + return object.hasNonNull(field) ? (ObjectNode) object.get(field) : null; + } + + public static ArrayNode optArray(JsonNode object, String field) { + return object.hasNonNull(field) ? (ArrayNode) object.get(field) : null; + } + + public static Boolean optBoolean(JsonNode object, String field) { + return optBoolean(object, field, null); + } + + public static Boolean optBoolean(JsonNode object, String field, Boolean defaultValue) { + return object.hasNonNull(field) ? (Boolean) object.get(field).asBoolean() : defaultValue; + } + + public static Long optLong(JsonNode object, String field) { + return optLong(object, field, null); + } + + public static Long optLong(JsonNode object, String field, Long defaultValue) { + return object.hasNonNull(field) ? (Long) object.get(field).asLong() : null; + } + + public static Double optDouble(JsonNode object, String field, Double defaultValue) { + return object.hasNonNull(field) ? (Double) object.get(field).asDouble() : defaultValue; + } + + public static Integer optDouble(JsonNode object, String field) { + return optInt(object, field, null); + } + + public static Integer optInt(JsonNode object, String field) { + return optInt(object, field, null); + } + + public static Integer optInt(JsonNode object, String field, Integer defaultValue) { + return object.hasNonNull(field) ? (Integer) object.get(field).asInt() : defaultValue; + } + + public static String optString(JsonNode object, String field) { + return optString(object, field, null); + } + + public static String optString(JsonNode object, String field, String defaultValue) { + return object.hasNonNull(field) ? object.get(field).asText() : defaultValue; + } + + public static ArrayNode readArray(String content) throws JsonProcessingException, IOException { + return (ArrayNode) objectMapper.readTree(content); + } + + public static ObjectNode readObject(String content) throws JsonProcessingException, IOException { + return (ObjectNode) objectMapper.readTree(content); + } + + public static ArrayNode readArray(Object object) throws JsonProcessingException, IOException { + return (ArrayNode) objectMapper.valueToTree(object); + } + + public static ObjectNode readObject(Object object) throws JsonProcessingException, IOException { + return (ObjectNode) objectMapper.valueToTree(object); + } + + public static String toString(Object object) throws JsonProcessingException { + return objectMapper.writeValueAsString(object); + } + + public static ObjectNode putOpt(ObjectNode object, String field, Object value) throws JsonProcessingException { + if (value != null) { + object.set(field, objectMapper.valueToTree(value)); + } + return object; + } +} \ No newline at end of file Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/MockUser.java =================================================================== diff -u -r797ce058f0a0a06bf182256999c0ef24cc3ea735 -r0fea6612262a9934db549a1272d73243e6fd0584 --- TestHarness4LAMS2/src/org/lamsfoundation/testharness/MockUser.java (.../MockUser.java) (revision 797ce058f0a0a06bf182256999c0ef24cc3ea735) +++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/MockUser.java (.../MockUser.java) (revision 0fea6612262a9934db549a1272d73243e6fd0584) @@ -102,12 +102,18 @@ resp = (WebResponse) new Call(wc, test, username + " login", fillForm(resp, 0, params)).execute(); if (!MockUser.checkPageContains(resp, MockUser.INDEX_PAGE_FLAG)) { MockUser.log.debug(resp.getText()); + Thread.sleep(1000); + resp = (WebResponse) new Call(wc, test, username + " ping again", "").execute(); + MockUser.log.debug(resp.getText()); throw new TestHarnessException(username + " failed to login with password " + password); } } catch (IOException e) { throw new RuntimeException(e); } catch (SAXException e) { throw new RuntimeException(e); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } } @@ -119,7 +125,7 @@ try { int seconds = 0; if (test.getMaxDelay() <= test.getMinDelay()) {// to avoid IllegalArgumentException in nextInt method on - // Random object + // Random object seconds = test.getMinDelay(); } else { seconds = test.getMinDelay() Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/learner/MockLearner.java =================================================================== diff -u -r9218936edd87260de73e773054cb605a336133b1 -r0fea6612262a9934db549a1272d73243e6fd0584 --- TestHarness4LAMS2/src/org/lamsfoundation/testharness/learner/MockLearner.java (.../MockLearner.java) (revision 9218936edd87260de73e773054cb605a336133b1) +++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/learner/MockLearner.java (.../MockLearner.java) (revision 0fea6612262a9934db549a1272d73243e6fd0584) @@ -39,16 +39,17 @@ import javax.websocket.MessageHandler; import org.apache.log4j.Logger; - - - import org.lamsfoundation.testharness.Call; +import org.lamsfoundation.testharness.JsonUtil; 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.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.meterware.httpunit.Button; import com.meterware.httpunit.FormControl; import com.meterware.httpunit.WebForm; @@ -98,7 +99,7 @@ private static final String SCRATCHIE_IS_LEADER_SUBSTRING = "isUserLeader=true"; private static final Pattern SCRATCHIE_TOOL_SESSION_ID_PATTERN = Pattern.compile("toolSessionID=' \\+ (\\d+)\\)"); private static final String SCRATCHIE_FINISH_SESSION_SUBSTRING = "return finishSession()"; - private static final Set SCRATCHIE_FINISHED_TOOL_CONTENT = new TreeSet(); + private static final Set SCRATCHIE_FINISHED_TOOL_CONTENT = new TreeSet<>(); private static final String CHAT_FINISH_SUBSTRING = "/lams/tool/lachat11/learning.do"; private static final int CHAT_REPLIES = 3; @@ -150,7 +151,7 @@ private static final String SCRIBE_SUBMIT_REFLECTION_SUBSTRING = "value=\"submitReflection\""; private static final Pattern SCRIBE_REPORT_ENTRY_PATTERN = Pattern.compile("id=\"report-(\\d+)\""); private static final Pattern SCRIBE_TOOL_SESSION_ID_PATTERN = Pattern.compile("toolSessionID=' \\+ (\\d+)\\)"); - private static final Set SCRIBE_FINISHED_TOOL_CONTENT = new TreeSet(); + private static final Set SCRIBE_FINISHED_TOOL_CONTENT = new TreeSet<>(); private static final short SCRIBE_SUBMIT_REPORT_ATTEMPTS = 3; private static int joinLessonUserCount = 0; @@ -229,7 +230,7 @@ } private static Map> groupButtonsByName(Button[] btns, String buttonType) { - Map> buttonGroups = new HashMap>(); + Map> buttonGroups = new HashMap<>(); if (btns != null) { for (Button btn : btns) { if (buttonType.equals(btn.getType())) { @@ -238,7 +239,7 @@ if (!buttonGroups.containsKey(name)) { buttonGroups.get(name).add(btn); } else { - List