Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/Call.java =================================================================== diff -u -r408e29149963888795b07dfe06afadb27e0f2956 -r063bb179a387387bbfd8ea9c0edb079313512583 --- TestHarness4LAMS2/src/org/lamsfoundation/testharness/Call.java (.../Call.java) (revision 408e29149963888795b07dfe06afadb27e0f2956) +++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/Call.java (.../Call.java) (revision 063bb179a387387bbfd8ea9c0edb079313512583) @@ -194,6 +194,7 @@ try { WebResponse resp = null; WebRequest req = null; + if (form != null) { SubmitButton[] submitButtons = filterCancelButton(form.getSubmitButtons()); Call.log.debug(submitButtons.length + " non-cancel submit buttons in the form"); @@ -221,10 +222,10 @@ resp = wc.getResponse(req); end = System.currentTimeMillis(); } - + httpStatusCode = resp.getResponseCode(); if (httpStatusCode >= 400) { - log.debug("Got " + httpStatusCode + " HTTP code. Retrying call: " + callee); + Call.log.debug("Got " + httpStatusCode + " HTTP code. Retrying call: " + callee); resp = wc.getResponse(req); end = System.currentTimeMillis(); httpStatusCode = resp.getResponseCode(); @@ -233,19 +234,32 @@ throw new TestHarnessException(test.testName + " got HTTP code " + httpStatusCode); } } - + message = resp.getResponseMessage(); + // set session cookie manually as the built-in mechanism can't really handle paths and domains for (String headerFieldName : resp.getHeaderFieldNames()) { if (headerFieldName.equalsIgnoreCase("SET-COOKIE")) { + String cookieValue = null; + String path = null; for (String headerFieldValue : resp.getHeaderFields(headerFieldName)) { String[] headerFieldSplit = headerFieldValue.split("=|;"); - String cookieName = headerFieldSplit[0]; - if ("JSESSIONID".equalsIgnoreCase(cookieName) && (wc.getCookieValue(cookieName) == null)) { - String cookieValue = headerFieldSplit[1]; - Call.log.debug("Manually setting cookie: " + cookieName + "=" + cookieValue); - wc.putCookie(cookieName, cookieValue); + for (int paramIndex = 0; paramIndex < headerFieldSplit.length; paramIndex++) { + String param = headerFieldSplit[paramIndex].trim(); + if ("JSESSIONID".equalsIgnoreCase(param)) { + cookieValue = headerFieldSplit[paramIndex + 1]; + paramIndex++; + } else if ("path".equalsIgnoreCase(param)) { + path = headerFieldSplit[paramIndex + 1]; + paramIndex++; + } } } + if (cookieValue != null) { + Call.log.debug("Manually setting JSESSIONID = " + cookieValue); + // "single use cookie" is misleading; it's just a cookie with a path and domain + wc.getCookieJar().putSingleUseCookie("JSESSIONID", cookieValue, + test.getTestSuite().getCookieDomain(), path); + } } } Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/TestSuite.java =================================================================== diff -u -r457bede6fb8b69e25fa9a899ed66a32407bf80e9 -r063bb179a387387bbfd8ea9c0edb079313512583 --- TestHarness4LAMS2/src/org/lamsfoundation/testharness/TestSuite.java (.../TestSuite.java) (revision 457bede6fb8b69e25fa9a899ed66a32407bf80e9) +++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/TestSuite.java (.../TestSuite.java) (revision 063bb179a387387bbfd8ea9c0edb079313512583) @@ -41,6 +41,8 @@ private int suiteIndex; private String targetServer; private String contextRoot; + private String cookieDomain; + private AdminTest adminTest; private AuthorTest authorTest; private MonitorTest monitorTest; @@ -53,6 +55,11 @@ this.suiteIndex = suiteIndex; this.targetServer = targetServer == null ? "localhost" : targetServer; this.contextRoot = (contextRoot == null) || contextRoot.equals("/") ? "" : contextRoot; + + int beginIndex = this.targetServer.lastIndexOf("/") + 1; + int endIndex = this.targetServer.lastIndexOf(":"); + this.cookieDomain = endIndex < 0 ? this.targetServer.substring(beginIndex) : this.targetServer.substring( + beginIndex, endIndex); this.adminTest = adminTest; adminTest.setTestSuite(this); @@ -82,6 +89,10 @@ return contextRoot; } + public String getCookieDomain() { + return cookieDomain; + } + /** * @return Returns the learnerTest. */