8383import net .sourceforge .jwebunit .util .TestContext ;
8484
8585import org .apache .commons .httpclient .Cookie ;
86- import org .apache .commons .httpclient .HttpState ;
8786import org .apache .commons .httpclient .NameValuePair ;
88-
8987import org .apache .regexp .RE ;
9088import org .apache .regexp .RESyntaxException ;
9189import org .slf4j .Logger ;
@@ -217,14 +215,13 @@ public void setScriptingEnabled(boolean value) {
217215
218216 public List <javax .servlet .http .Cookie > getCookies () {
219217 List <javax .servlet .http .Cookie > result = new LinkedList <javax .servlet .http .Cookie >();
220- final HttpState stateForUrl = wc .getWebConnection ().getState ();
221- Cookie [] cookies = stateForUrl .getCookies ();
222- for (int i = 0 ; i < cookies .length ; i ++) {
218+ Set <Cookie > cookies = wc .getCookieManager ().getCookies ();
219+ for (Cookie cookie : cookies ) {
223220 javax .servlet .http .Cookie c = new javax .servlet .http .Cookie (
224- cookies [ i ] .getName (), cookies [ i ] .getValue ());
225- c .setComment (cookies [ i ] .getComment ());
226- c .setDomain (cookies [ i ] .getDomain ());
227- Date expire = cookies [ i ] .getExpiryDate ();
221+ cookie .getName (), cookie .getValue ());
222+ c .setComment (cookie .getComment ());
223+ c .setDomain (cookie .getDomain ());
224+ Date expire = cookie .getExpiryDate ();
228225 if (expire == null ) {
229226 c .setMaxAge (-1 );
230227 } else {
@@ -234,9 +231,9 @@ public List<javax.servlet.http.Cookie> getCookies() {
234231 (expire .getTime () - now .getTime ()) / 1000 );
235232 c .setMaxAge (second .intValue ());
236233 }
237- c .setPath (cookies [ i ] .getPath ());
238- c .setSecure (cookies [ i ] .getSecure ());
239- c .setVersion (cookies [ i ] .getVersion ());
234+ c .setPath (cookie .getPath ());
235+ c .setSecure (cookie .getSecure ());
236+ c .setVersion (cookie .getVersion ());
240237 result .add (c );
241238 }
242239 return result ;
@@ -839,7 +836,7 @@ public String handlePrompt(Page page, String msg) {
839836 // Deal with cookies
840837 for (javax .servlet .http .Cookie c : getTestContext ().getCookies ()) {
841838 // If Path==null, cookie is not send to the server.
842- wc .getWebConnection (). getState ().addCookie (
839+ wc .getCookieManager ().addCookie (
843840 new Cookie (c .getDomain () != null ? c .getDomain () : "" , c
844841 .getName (), c .getValue (), c .getPath () != null ? c
845842 .getPath () : "" , c .getMaxAge (), c .getSecure ()));
0 commit comments