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 -r1.10.2.1 --- TestHarness4LAMS2/src/org/lamsfoundation/testharness/Call.java 16 Jan 2014 17:08:58 -0000 1.10 +++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/Call.java 18 Nov 2014 16:20:58 -0000 1.10.2.1 @@ -45,6 +45,7 @@ import com.meterware.httpunit.WebForm; import com.meterware.httpunit.WebRequest; import com.meterware.httpunit.WebResponse; +import com.meterware.httpunit.cookies.Cookie; import com.sun.net.ssl.HostnameVerifier; import com.sun.net.ssl.HttpsURLConnection; @@ -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,38 @@ throw new TestHarnessException(test.testName + " got HTTP code " + httpStatusCode); } } - + message = resp.getResponseMessage(); for (String headerFieldName : resp.getHeaderFieldNames()) { if (headerFieldName.equalsIgnoreCase("SET-COOKIE")) { + String cookieName = null; + 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 index = 0; index < headerFieldSplit.length; index++) { + String name = headerFieldSplit[index].trim(); + if (name.startsWith("JSESSIONID")) { + cookieName = headerFieldSplit[index]; + cookieValue = headerFieldSplit[index + 1].trim(); + } else if (name.equalsIgnoreCase("path")) { + path = headerFieldSplit[index + 1].trim(); + } } } + + String currentCookieValue = wc.getCookieValue(cookieName); + Cookie cookie = wc.getCookieDetails(cookieName); + String currentCookiePath = wc.getCookieDetails(cookieName).getPath(); + Call.log.debug("Cookie " + cookie.getName() + " value " + currentCookieValue + " (" + cookieValue + + ") and path " + currentCookiePath + " (" + path + ")"); + // either JSESSIONID or JSESSIONIDSSO + if ((cookieName != null) && currentCookiePath.equals(path) + && !cookieValue.equals(currentCookieValue)) { + Call.log.debug("Manually setting cookie " + cookieName + " with path " + path + " from value " + + currentCookieValue + " to " + cookieValue); + wc.putCookie(cookieName, cookieValue); + } } }