Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/Call.java =================================================================== RCS file: /usr/local/cvsroot/TestHarness4LAMS2/src/org/lamsfoundation/testharness/Call.java,v diff -u -r1.10.2.2 -r1.10.2.3 --- TestHarness4LAMS2/src/org/lamsfoundation/testharness/Call.java 20 Nov 2014 15:10:40 -0000 1.10.2.2 +++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/Call.java 4 Dec 2014 14:59:47 -0000 1.10.2.3 @@ -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); + } } }