Package org.apache.cactus

Examples of org.apache.cactus.Cookie


     * @exception Exception for backward compatibility with JDK 1.2.2 (not
     *            needed for JDK 1.3+, but needed for URLDecoder.decode())
     */
    public void endReceiveCookie(WebResponse theResponse) throws Exception
    {
        Cookie cookie = theResponse.getCookie("responsecookie");

        assertNotNull("Cannot find [responsecookie]", cookie);
        assertEquals("responsecookie", cookie.getName());

        // Some servers may encode the cookie value (ex: the latest
        // version of Tomcat 4.0). In order for this test to succeed on
        // all servlet engine, we URL decode the cookie value before
        // comparing it.
        assertEquals("this is a response cookie",
            URLDecoder.decode(cookie.getValue()));

        assertEquals("jakarta.apache.org", cookie.getDomain());
    }
View Full Code Here


     * @exception Exception for backward compatibility with JDK 1.2.2 (not
     *            needed for JDK 1.3+, but needed for URLDecoder.decode())
     */
    public void endReceiveCookie(WebResponse theResponse) throws Exception
    {
        Cookie cookie = theResponse.getCookie("responsecookie");

        assertNotNull("Cannot find [responsecookie]", cookie);
        assertEquals("responsecookie", cookie.getName());


        // Some servers may encode the cookie value (ex: the latest
        // version of Tomcat 4.0). In order for this test to succeed on
        // all servlet engine, we URL decode the cookie value before
        // comparing it.
        assertEquals("this is a response cookie",
            URLDecoder.decode(cookie.getValue()));

        assertEquals("jakarta.apache.org", cookie.getDomain());
    }
View Full Code Here

     */
    public void testCreateHttpStateWhenSeveralCactusCookieExist()
        throws Exception
    {
        WebRequest request = new WebRequest();
        request.addCookie(new Cookie("domain1", "name1", "value1"));
        request.addCookie(new Cookie("domain2", "name2", "value2"));
       
        HttpState state = CookieUtil.createHttpState(request,
            new URL("http://jakarta.apache.org"));
        assertEquals(2, state.getCookies().length);
    }
View Full Code Here

        org.apache.commons.httpclient.Cookie[] httpclientCookies =
            new org.apache.commons.httpclient.Cookie[cactusCookies.size()];

        for (int i = 0; i < cactusCookies.size(); i++)
        {
            Cookie cactusCookie = (Cookie) cactusCookies.elementAt(i);
            httpclientCookies[i] = CookieUtil.createHttpClientCookie(
                theRequest, theUrl, cactusCookie);
        }

        return httpclientCookies;
View Full Code Here

            // transform the Cactus cookies into HttpClient cookies
            org.apache.commons.httpclient.Cookie[] httpclientCookies =
                new org.apache.commons.httpclient.Cookie[cookies.size()];
            for (int i = 0; i < cookies.size(); i++) {
                Cookie cactusCookie = (Cookie) cookies.elementAt(i);

                // If no domain has been specified, use a default one
                String domain;
                if (cactusCookie.getDomain() == null) {
                    domain = Cookie.getCookieDomain(theRequest,
                        theUrl.getHost());
                } else {
                    domain = cactusCookie.getDomain();
                }

                // If not path has been specified , use a default one
                String path;
                if (cactusCookie.getPath() == null) {
                    path = Cookie.getCookiePath(theRequest, theUrl.getFile());
                } else {
                    path = cactusCookie.getPath();
                }

                httpclientCookies[i] =
                    new org.apache.commons.httpclient.Cookie(
                        domain, cactusCookie.getName(),
                        cactusCookie.getValue());

                httpclientCookies[i].setComment(cactusCookie.getComment());
                httpclientCookies[i].setExpiryDate(
                        cactusCookie.getExpiryDate());
                httpclientCookies[i].setPath(path);
                httpclientCookies[i].setSecure(cactusCookie.isSecure());
            }

            // and create the cookie header to send
            Header cookieHeader =
                org.apache.commons.httpclient.Cookie.createCookieHeader(
View Full Code Here

     */
    public void testCreateHttpStateWhenSeveralCactusCookieExist()
        throws Exception
    {
        WebRequest request = new WebRequest();
        request.addCookie(new Cookie("domain1", "name1", "value1"));
        request.addCookie(new Cookie("domain2", "name2", "value2"));
       
        HttpState state = CookieUtil.createHttpState(request,
            new URL("http://jakarta.apache.org"));
        assertEquals(2, state.getCookies().length);
    }
View Full Code Here

        org.apache.commons.httpclient.Cookie[] httpclientCookies =
            new org.apache.commons.httpclient.Cookie[cactusCookies.size()];

        for (int i = 0; i < cactusCookies.size(); i++)
        {
            Cookie cactusCookie = (Cookie) cactusCookies.elementAt(i);
            httpclientCookies[i] = CookieUtil.createHttpClientCookie(
                theRequest, theUrl, cactusCookie);
        }

        return httpclientCookies;
View Full Code Here

     * @exception Exception for backward compatibility with JDK 1.2.2 (not
     *            needed for JDK 1.3+, but needed for URLDecoder.decode())
     */
    public void endReceiveCookie(WebResponse theResponse) throws Exception
    {
        Cookie cookie = theResponse.getCookie("responsecookie");

        assertNotNull("Cannot find [responsecookie]", cookie);
        assertEquals("responsecookie", cookie.getName());


        // Some servers may encode the cookie value (ex: the latest
        // version of Tomcat 4.0). In order for this test to succeed on
        // all servlet engine, we URL decode the cookie value before
        // comparing it.
        assertEquals("this is a response cookie",
            URLDecoder.decode(cookie.getValue()));

        assertEquals("jakarta.apache.org", cookie.getDomain());
    }
View Full Code Here

                int equalsChar = nameValue.indexOf("=");
                String name = nameValue.substring(0, equalsChar);
                String value = nameValue.substring(equalsChar + 1);
                if (name.equalsIgnoreCase(theTarget))
                {
                    return new Cookie(theConnection.getURL().getHost(),
                        name, value);
                }
            }
            key = theConnection.getHeaderFieldKey(++i);
        }
View Full Code Here

    /**
     * @see WebRequest#addCookie(String, String, String)
     */
    public void addCookie(String theDomain, String theName, String theValue)
    {
        addCookie(new Cookie(theDomain, theName, theValue));
    }
View Full Code Here

TOP

Related Classes of org.apache.cactus.Cookie

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.