jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1220552 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/control/ src/protocol/http/org/apache/jmeter/protocol/http/gui/ test/src/org/apache/jmeter/protocol/http/control/
Date Sun, 18 Dec 2011 21:55:32 GMT
Author: pmouawad
Date: Sun Dec 18 21:55:32 2011
New Revision: 1220552

URL: http://svn.apache.org/viewvc?rev=1220552&view=rev
Log:
Bug 51512 - Cookies aren't inserted into HTTP request with IPv6 Host header
First part, introduce interface CookieHandler and make CookieManager use it.

Second step will introduce HC4CookieHandler that will enable parsing of IPv6 IPs.

Added:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieHandler.java
  (with props)
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC3CookieHandler.java
  (with props)
Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java

Added: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieHandler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieHandler.java?rev=1220552&view=auto
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieHandler.java
(added)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieHandler.java
Sun Dec 18 21:55:32 2011
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.http.control;
+
+import java.net.URL;
+
+import org.apache.jmeter.testelement.property.CollectionProperty;
+
+/**
+ * Interface to be implemented by CookieHandler
+ */
+public interface CookieHandler {
+
+	/**
+	 * Add cookie to CookieManager from cookieHeader and URL
+	 * @param cookieManager CookieManager on which cookies are added
+	 * @param checkCookies boolean to indicate if cookies must be validated against spec
+	 * @param cookieHeader String cookie Header
+	 * @param url URL 
+	 */
+	public void addCookieFromHeader(CookieManager cookieManager, boolean checkCookies,
+			String cookieHeader, URL url);
+
+    /**
+     * Find cookies applicable to the given URL and build the Cookie header from
+     * them.
+     * @param cookiesCP {@link CollectionProperty} of {@link Cookie}
+     * @param url
+     *            URL of the request to which the returned header will be added.
+     * @return the value string for the cookie header (goes after "Cookie: ").
+     */
+	public String getCookieHeaderForURL(CollectionProperty cookiesCP, URL url,
+			boolean allowVariableCookie);
+
+}

Propchange: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java?rev=1220552&r1=1220551&r2=1220552&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java
Sun Dec 18 21:55:32 2011
@@ -29,14 +29,10 @@ import java.io.PrintWriter;
 import java.io.Serializable;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Date;
 
 import org.apache.commons.httpclient.cookie.CookiePolicy;
-import org.apache.commons.httpclient.cookie.CookieSpec;
-import org.apache.commons.httpclient.cookie.MalformedCookieException;
 import org.apache.jmeter.config.ConfigTestElement;
 import org.apache.jmeter.engine.event.LoopIterationEvent;
-import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
 import org.apache.jmeter.testelement.TestListener;
 import org.apache.jmeter.testelement.property.BooleanProperty;
 import org.apache.jmeter.testelement.property.CollectionProperty;
@@ -74,7 +70,8 @@ public class CookieManager extends Confi
         JMeterUtils.getPropDefault("CookieManager.delete_null_cookies", true);// $NON-NLS-1$
 
     // See bug 28715
-    private static final boolean ALLOW_VARIABLE_COOKIES
+    // Package protected for tests
+    static final boolean ALLOW_VARIABLE_COOKIES
         = JMeterUtils.getPropDefault("CookieManager.allow_variable_cookies", true);// $NON-NLS-1$
 
     private static final String COOKIE_NAME_PREFIX =
@@ -95,7 +92,7 @@ public class CookieManager extends Confi
                 + " Prefix: " + COOKIE_NAME_PREFIX
                 );
     }
-    private transient CookieSpec cookieSpec;
+    private transient CookieHandler cookieHandler;
 
     private transient CollectionProperty initialCookies;
 
@@ -111,7 +108,7 @@ public class CookieManager extends Confi
     public Object clone(){
         CookieManager clone = (CookieManager) super.clone();
         clone.initialCookies = initialCookies;
-        clone.cookieSpec = cookieSpec;
+        clone.cookieHandler = cookieHandler;
         return clone;
     }
 
@@ -304,57 +301,6 @@ public class CookieManager extends Confi
         return (Cookie) getCookies().get(i).getObjectValue();
     }
 
-    /*
-     * Create an HttpClient cookie from a JMeter cookie
-     */
-    private org.apache.commons.httpclient.Cookie makeCookie(Cookie jmc){
-        long exp = jmc.getExpiresMillis();
-        org.apache.commons.httpclient.Cookie ret=
-            new org.apache.commons.httpclient.Cookie(
-                jmc.getDomain(),
-                jmc.getName(),
-                jmc.getValue(),
-                jmc.getPath(),
-                exp > 0 ? new Date(exp) : null, // use null for no expiry
-                jmc.getSecure()
-               );
-        ret.setPathAttributeSpecified(jmc.isPathSpecified());
-        ret.setDomainAttributeSpecified(jmc.isDomainSpecified());
-        ret.setVersion(jmc.getVersion());
-        return ret;
-    }
-
-    /**
-     * Get array of valid HttpClient cookies for the URL
-     *
-     * @param url the target URL
-     * @return array of HttpClient cookies
-     *
-     */
-    org.apache.commons.httpclient.Cookie[] getCookiesForUrl(URL url){
-        CollectionProperty jar=getCookies();
-        org.apache.commons.httpclient.Cookie cookies[]=
-            new org.apache.commons.httpclient.Cookie[jar.size()];
-        int i=0;
-        for (PropertyIterator iter = getCookies().iterator(); iter.hasNext();) {
-            Cookie jmcookie = (Cookie) iter.next().getObjectValue();
-            // Set to running version, to allow function evaluation for the cookie values
(bug 28715)
-            if (ALLOW_VARIABLE_COOKIES) {
-                jmcookie.setRunningVersion(true);
-            }
-            cookies[i++] = makeCookie(jmcookie);
-            if (ALLOW_VARIABLE_COOKIES) {
-                jmcookie.setRunningVersion(false);
-            }
-        }
-        String host = url.getHost();
-        String protocol = url.getProtocol();
-        int port= HTTPSamplerBase.getDefaultPort(protocol,url.getPort());
-        String path = url.getPath();
-        boolean secure = HTTPSamplerBase.isSecure(protocol);
-        return cookieSpec.match(host, port, path, secure, cookies);
-    }
-
     /**
      * Find cookies applicable to the given URL and build the Cookie header from
      * them.
@@ -364,82 +310,12 @@ public class CookieManager extends Confi
      * @return the value string for the cookie header (goes after "Cookie: ").
      */
     public String getCookieHeaderForURL(URL url) {
-        org.apache.commons.httpclient.Cookie[] c = getCookiesForUrl(url);
-        int count = c.length;
-        boolean debugEnabled = log.isDebugEnabled();
-        if (debugEnabled){
-            log.debug("Found "+count+" cookies for "+url.toExternalForm());
-        }
-        if (count <=0){
-            return null;
-        }
-        String hdr=cookieSpec.formatCookieHeader(c).getValue();
-        if (debugEnabled){
-            log.debug("Cookie: "+hdr);
-        }
-        return hdr;
+    	return cookieHandler.getCookieHeaderForURL(getCookies(), url, ALLOW_VARIABLE_COOKIES);
     }
 
 
     public void addCookieFromHeader(String cookieHeader, URL url){
-        boolean debugEnabled = log.isDebugEnabled();
-        if (debugEnabled) {
-            log.debug("Received Cookie: " + cookieHeader + " From: " + url.toExternalForm());
-        }
-        String protocol = url.getProtocol();
-        String host = url.getHost();
-        int port= HTTPSamplerBase.getDefaultPort(protocol,url.getPort());
-        String path = url.getPath();
-        boolean isSecure=HTTPSamplerBase.isSecure(protocol);
-        org.apache.commons.httpclient.Cookie[] cookies= null;
-        try {
-            cookies = cookieSpec.parse(host, port, path, isSecure, cookieHeader);
-        } catch (MalformedCookieException e) {
-            log.warn(cookieHeader+e.getLocalizedMessage());
-        } catch (IllegalArgumentException e) {
-            log.warn(cookieHeader+e.getLocalizedMessage());
-        }
-        if (cookies == null) {
-            return;
-        }
-        for(org.apache.commons.httpclient.Cookie cookie : cookies){
-            try {
-                if (CHECK_COOKIES) {
-                    cookieSpec.validate(host, port, path, isSecure, cookie);
-                }
-                Date expiryDate = cookie.getExpiryDate();
-                long exp = 0;
-                if (expiryDate!= null) {
-                    exp=expiryDate.getTime();
-                }
-                Cookie newCookie = new Cookie(
-                        cookie.getName(),
-                        cookie.getValue(),
-                        cookie.getDomain(),
-                        cookie.getPath(),
-                        cookie.getSecure(),
-                        exp / 1000,
-                        cookie.isPathAttributeSpecified(),
-                        cookie.isDomainAttributeSpecified()
-                        );
-
-                // Store session cookies as well as unexpired ones
-                if (exp == 0 || exp >= System.currentTimeMillis()) {
-                    newCookie.setVersion(cookie.getVersion());
-                    add(newCookie); // Has its own debug log; removes matching cookies
-                } else {
-                    removeMatchingCookies(newCookie);
-                    if (debugEnabled){
-                        log.debug("Dropping expired Cookie: "+newCookie.toString());
-                    }
-                }
-            } catch (MalformedCookieException e) { // This means the cookie was wrong for
the URL
-                log.debug("Not storing invalid cookie: <"+cookieHeader+"> for URL "+url+"
("+e.getLocalizedMessage()+")");
-            } catch (IllegalArgumentException e) {
-                log.warn(cookieHeader+e.getLocalizedMessage());
-            }
-        }
-
+    	cookieHandler.addCookieFromHeader(this, CHECK_COOKIES, cookieHeader, url);
     }
     /**
      * Check if cookies match, i.e. name, path and domain are equal.
@@ -458,7 +334,7 @@ public class CookieManager extends Confi
         a.getDomain().equals(b.getDomain());
     }
 
-    private void removeMatchingCookies(Cookie newCookie){
+    void removeMatchingCookies(Cookie newCookie){
         // Scan for any matching cookies
         PropertyIterator iter = getCookies().iterator();
         while (iter.hasNext()) {
@@ -479,7 +355,7 @@ public class CookieManager extends Confi
     /** {@inheritDoc} */
     public void testStarted() {
         initialCookies = getCookies();
-        cookieSpec = CookiePolicy.getCookieSpec(getPolicy());
+        cookieHandler = new HC3CookieHandler(getPolicy());
         if (log.isDebugEnabled()){
             log.debug("Policy: "+getPolicy()+" Clear: "+getClearEachIteration());
         }
@@ -507,9 +383,11 @@ public class CookieManager extends Confi
         }
     }
 
-    public static String[] getCookieSpecs(){
-        return CookiePolicy.getRegisteredCookieSpecs(); // Commons HttpClient
-        //return new DefaultHttpClient().getCookieSpecs().getSpecNames().toArray(new String[]{});
// Apache HttpClient
-    }
-
+	/**
+	 * Package protected for tests
+	 * @return the cookieHandler
+	 */
+	CookieHandler getCookieHandler() {
+		return cookieHandler;
+	}
 }
\ No newline at end of file

Added: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC3CookieHandler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC3CookieHandler.java?rev=1220552&view=auto
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC3CookieHandler.java
(added)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC3CookieHandler.java
Sun Dec 18 21:55:32 2011
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.http.control;
+
+import java.net.URL;
+import java.util.Date;
+
+import org.apache.commons.httpclient.cookie.CookiePolicy;
+import org.apache.commons.httpclient.cookie.CookieSpec;
+import org.apache.commons.httpclient.cookie.MalformedCookieException;
+import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
+import org.apache.jmeter.testelement.property.CollectionProperty;
+import org.apache.jmeter.testelement.property.PropertyIterator;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+/**
+ * HTTPClient 3.1 implementation
+ */
+public class HC3CookieHandler implements CookieHandler {
+   private static final Logger log = LoggingManager.getLoggerForClass();
+
+	private transient CookieSpec cookieSpec;
+	 
+	/**
+	 * 
+	 */
+	public HC3CookieHandler(String policy) {
+		super();
+		this.cookieSpec = CookiePolicy.getCookieSpec(policy);
+	}
+
+    /**
+     * Create an HttpClient cookie from a JMeter cookie
+     */
+	private org.apache.commons.httpclient.Cookie makeCookie(Cookie jmc){
+        long exp = jmc.getExpiresMillis();
+        org.apache.commons.httpclient.Cookie ret=
+            new org.apache.commons.httpclient.Cookie(
+                jmc.getDomain(),
+                jmc.getName(),
+                jmc.getValue(),
+                jmc.getPath(),
+                exp > 0 ? new Date(exp) : null, // use null for no expiry
+                jmc.getSecure()
+               );
+        ret.setPathAttributeSpecified(jmc.isPathSpecified());
+        ret.setDomainAttributeSpecified(jmc.isDomainSpecified());
+        ret.setVersion(jmc.getVersion());
+        return ret;
+    }
+	/**
+     * Get array of valid HttpClient cookies for the URL
+     *
+     * @param url the target URL
+     * @return array of HttpClient cookies
+     *
+     */
+	org.apache.commons.httpclient.Cookie[] getCookiesForUrl(
+    		CollectionProperty cookiesCP,
+    		URL url, 
+    		boolean allowVariableCookie){
+        org.apache.commons.httpclient.Cookie cookies[]=
+            new org.apache.commons.httpclient.Cookie[cookiesCP.size()];
+        int i=0;
+        for (PropertyIterator iter = cookiesCP.iterator(); iter.hasNext();) {
+            Cookie jmcookie = (Cookie) iter.next().getObjectValue();
+            // Set to running version, to allow function evaluation for the cookie values
(bug 28715)
+            if (allowVariableCookie) {
+                jmcookie.setRunningVersion(true);
+            }
+            cookies[i++] = makeCookie(jmcookie);
+            if (allowVariableCookie) {
+                jmcookie.setRunningVersion(false);
+            }
+        }
+        String host = url.getHost();
+        String protocol = url.getProtocol();
+        int port= HTTPSamplerBase.getDefaultPort(protocol,url.getPort());
+        String path = url.getPath();
+        boolean secure = HTTPSamplerBase.isSecure(protocol);
+        return cookieSpec.match(host, port, path, secure, cookies);
+    }
+    
+    /**
+     * Find cookies applicable to the given URL and build the Cookie header from
+     * them.
+     *
+     * @param url
+     *            URL of the request to which the returned header will be added.
+     * @return the value string for the cookie header (goes after "Cookie: ").
+     */
+	public String getCookieHeaderForURL(
+    		CollectionProperty cookiesCP,
+    		URL url,
+    		boolean allowVariableCookie) {
+        org.apache.commons.httpclient.Cookie[] c = 
+        		getCookiesForUrl(cookiesCP, url, allowVariableCookie);
+        int count = c.length;
+        boolean debugEnabled = log.isDebugEnabled();
+        if (debugEnabled){
+            log.debug("Found "+count+" cookies for "+url.toExternalForm());
+        }
+        if (count <=0){
+            return null;
+        }
+        String hdr=cookieSpec.formatCookieHeader(c).getValue();
+        if (debugEnabled){
+            log.debug("Cookie: "+hdr);
+        }
+        return hdr;
+    }
+    
+	/**
+	 * {@inheritDoc}
+	 */
+	public void addCookieFromHeader(CookieManager cookieManager,
+    		boolean checkCookies,String cookieHeader, URL url){
+        boolean debugEnabled = log.isDebugEnabled();
+        if (debugEnabled) {
+            log.debug("Received Cookie: " + cookieHeader + " From: " + url.toExternalForm());
+        }
+        String protocol = url.getProtocol();
+        String host = url.getHost();
+        int port= HTTPSamplerBase.getDefaultPort(protocol,url.getPort());
+        String path = url.getPath();
+        boolean isSecure=HTTPSamplerBase.isSecure(protocol);
+        org.apache.commons.httpclient.Cookie[] cookies= null;
+        try {
+            cookies = cookieSpec.parse(host, port, path, isSecure, cookieHeader);
+        } catch (MalformedCookieException e) {
+            log.warn(cookieHeader+e.getLocalizedMessage());
+        } catch (IllegalArgumentException e) {
+            log.warn(cookieHeader+e.getLocalizedMessage());
+        }
+        if (cookies == null) {
+            return;
+        }
+        for(org.apache.commons.httpclient.Cookie cookie : cookies){
+            try {
+                if (checkCookies) {
+                    cookieSpec.validate(host, port, path, isSecure, cookie);
+                }
+                Date expiryDate = cookie.getExpiryDate();
+                long exp = 0;
+                if (expiryDate!= null) {
+                    exp=expiryDate.getTime();
+                }
+                Cookie newCookie = new Cookie(
+                        cookie.getName(),
+                        cookie.getValue(),
+                        cookie.getDomain(),
+                        cookie.getPath(),
+                        cookie.getSecure(),
+                        exp / 1000,
+                        cookie.isPathAttributeSpecified(),
+                        cookie.isDomainAttributeSpecified()
+                        );
+
+                // Store session cookies as well as unexpired ones
+                if (exp == 0 || exp >= System.currentTimeMillis()) {
+                    newCookie.setVersion(cookie.getVersion());
+                    cookieManager.add(newCookie); // Has its own debug log; removes matching
cookies
+                } else {
+                	cookieManager.removeMatchingCookies(newCookie);
+                    if (debugEnabled){
+                        log.debug("Dropping expired Cookie: "+newCookie.toString());
+                    }
+                }
+            } catch (MalformedCookieException e) { // This means the cookie was wrong for
the URL
+                log.debug("Not storing invalid cookie: <"+cookieHeader+"> for URL "+url+"
("+e.getLocalizedMessage()+")");
+            } catch (IllegalArgumentException e) {
+                log.warn(cookieHeader+e.getLocalizedMessage());
+            }
+        }
+
+    }
+}

Propchange: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC3CookieHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java?rev=1220552&r1=1220551&r2=1220552&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java Sun
Dec 18 21:55:32 2011
@@ -101,12 +101,19 @@ public class CookiePanel extends Abstrac
 
     private JButton saveButton;
 
-    /*
+    /**
      * List of cookie policies.
      *
      * These are used both for the display, and for setting the policy
     */
-    private final String[] policies = CookieManager.getCookieSpecs();
+    private final String[] policies = new String[] {
+    	"default",
+    	"compatibility",
+    	"rfc2109",	
+    	"rfc2965",
+    	"ignorecookies",
+    	"netscape"
+    };
 
     private JLabeledChoice policy;
 

Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java?rev=1220552&r1=1220551&r2=1220552&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java Sun
Dec 18 21:55:32 2011
@@ -21,7 +21,6 @@ package org.apache.jmeter.protocol.http.
 import java.net.URL;
 
 import org.apache.commons.httpclient.cookie.CookiePolicy;
-
 import org.apache.jmeter.junit.JMeterTestCase;
 import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler;
 import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
@@ -284,7 +283,11 @@ public class TestCookieManager extends J
             assertEquals("/",man.get(2).getPath());
             String s = man.getCookieHeaderForURL(url);
             assertNotNull(s);
-            org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
+            HC3CookieHandler hc3CookieHandler = (HC3CookieHandler) man.getCookieHandler();
+            org.apache.commons.httpclient.Cookie[] c = 
+            		(org.apache.commons.httpclient.Cookie[]) 
+            		hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, 
+            				CookieManager.ALLOW_VARIABLE_COOKIES);
             assertEquals("/sub1",c[0].getPath());
             assertFalse(c[0].isPathAttributeSpecified());
             assertEquals("/sub1",c[1].getPath());
@@ -306,7 +309,11 @@ public class TestCookieManager extends J
             assertEquals("/",man.get(2).getPath());
             String s = man.getCookieHeaderForURL(url);
             assertNotNull(s);
-            org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
+            HC3CookieHandler hc3CookieHandler = (HC3CookieHandler) man.getCookieHandler();
+            org.apache.commons.httpclient.Cookie[] c = 
+            		(org.apache.commons.httpclient.Cookie[]) 
+            		hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, 
+            				CookieManager.ALLOW_VARIABLE_COOKIES);
             assertEquals("/sub1",c[0].getPath());
             assertFalse(c[0].isPathAttributeSpecified());
             assertEquals("/sub1",c[1].getPath());
@@ -329,7 +336,12 @@ public class TestCookieManager extends J
             assertEquals("/",man.get(2).getPath());
             String s = man.getCookieHeaderForURL(url);
             assertNotNull(s);
-            org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
+            HC3CookieHandler hc3CookieHandler = (HC3CookieHandler) man.getCookieHandler();
+           
+            org.apache.commons.httpclient.Cookie[] c = 
+            		(org.apache.commons.httpclient.Cookie[])
+            		hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, 
+            				CookieManager.ALLOW_VARIABLE_COOKIES);
             assertEquals("/sub1",c[0].getPath());
             assertFalse(c[0].isPathAttributeSpecified());
             assertEquals("/sub1",c[1].getPath());
@@ -360,7 +372,11 @@ public class TestCookieManager extends J
             assertEquals("/",man.get(2).getPath());
             String s = man.getCookieHeaderForURL(url);
             assertNull(s);
-            org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
+            HC3CookieHandler hc3CookieHandler = (HC3CookieHandler) man.getCookieHandler();
+            org.apache.commons.httpclient.Cookie[] c = 
+            		(org.apache.commons.httpclient.Cookie[]) 
+            		hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, 
+            				CookieManager.ALLOW_VARIABLE_COOKIES);
             assertEquals(0,c.length); // Cookies again ignored
         }
 



Mime
View raw message