Package com.volantis.shared.net.http

Examples of com.volantis.shared.net.http.SimpleHTTPMessageEntities


        //   Set Expectations
        // =====================================================================

        WebRequestHeader header = new WebRequestHeader();
        entityFactoryMock.expects.createHeader().returns(header);
        HTTPMessageEntities entities = new SimpleHTTPMessageEntities();
        entityFactoryMock.expects.createHTTPMessageEntities().returns(entities);

        expectAddSimpleElementProcess(header);

        contextMock.expects.getProperty(WebRequestHeader.class).returns(null);
View Full Code Here


        CookieSpecBase cookieSpecBase = new CookieSpecBase();
        org.apache.commons.httpclient.Cookie[] cookiesArray =
                    cookieSpecBase.parse("www.volantis.com", 843, "/index", true,
                                         "name1=value1,name2=value2");

        HTTPMessageEntities responseCookies = new SimpleHTTPMessageEntities();

        String method = "addHttpClientCookiesToWebDriverCookies";
        Class paramTypes [] = {org.apache.commons.httpclient.Cookie[].class,
                               HTTPMessageEntities.class};
        Object args [] = {cookiesArray, responseCookies};
        PrivateAccessor.invoke(manager, method, paramTypes, args);


        assertTrue("Expected two cookies.", responseCookies.size() == 2);

        CookieImpl[] cookies = new CookieImpl[2];
        int count = 0;
        Iterator cookiesIterator = responseCookies.iterator();
        while (cookiesIterator.hasNext()) {
            CookieImpl cookie = (CookieImpl) cookiesIterator.next();
            cookies[count] = cookie;
            count++;
        }
View Full Code Here

        final org.apache.commons.httpclient.Header header =
                    new org.apache.commons.httpclient.Header();
        header.setName(headerName);
        header.setValue(headerValue);

        HTTPMessageEntities responseHeader = new SimpleHTTPMessageEntities();

        String method = "addHttpClientHeaderToWebDriverHeaders";
        Class paramTypes [] = {org.apache.commons.httpclient.Header.class,
                               HTTPMessageEntities.class,
                               boolean.class };
        Object args [] = {header, responseHeader, Boolean.valueOf(list)};
        PrivateAccessor.invoke(manager, method, paramTypes, args);

        Iterator headers = responseHeader.iterator();
        while (headers.hasNext()) {
            HeaderImpl headerImpl = (HeaderImpl) headers.next();
            assertEquals("Unexpected header name.",
                         headerName, headerImpl.getName());
            assertEquals("Unexpected header value.",
View Full Code Here

        Object args [] = {
            response,
            new HTTPResponseAccessor() {
                public HTTPMessageEntities getCookies() {
                    HTTPMessageEntities cookies =
                                new SimpleHTTPMessageEntities();
                    cookies.add(cookieHeader);
                    return cookies;
                }

                public HTTPMessageEntities getHeaders() {
                    HTTPMessageEntities headers =
                                new SimpleHTTPMessageEntities();
                    headers.add(otherHeader);
                    return headers;
                }

                public InputStream getResponseStream() {
                    return null;
                }

                public int getStatusCode() {
                    return 200;
                }

                /**
                 * Get the HTTP version returned by the server.
                 * @return The HTTP version returned by the server.
                 */
                public HTTPVersion getHTTPVersion() {
                    return HTTPVersion.HTTP_1_1;
                }

            },
            new SimpleHTTPMessageEntities()
        };
        PrivateAccessor.invoke(manager, method, paramTypes, args);

        HTTPMessageEntities responseHeaders = response.getHeaders();
        HTTPMessageEntities responseCookies = response.getCookies();

        assertTrue("Expected one header.", responseHeaders.size() == 1);
        assertTrue("Expected one cookies.", responseCookies.size() == 1);

        Iterator headers = responseHeaders.iterator();
        while (headers.hasNext()) {
            HeaderImpl header = (HeaderImpl) headers.next();
            assertEquals("Unexpected header name.",
                         headerName, header.getName());
            assertEquals("Unexpected header value.",
                         headerValue, header.getValue());
        }
View Full Code Here

        String headerName = "Other-Header";
        String headerValue = "o-h-value";
        final Header otherHeader = new HeaderImpl(headerName);
        otherHeader.setValue(headerValue);

        HTTPMessageEntities additionalCookies = new SimpleHTTPMessageEntities();
        Cookie additionalCookie = new CookieImpl("additionalName",
                                                 "localhost",
                                                 "/");
        additionalCookie.setValue("additionalValue");
        additionalCookies.add(additionalCookie);

        String method = "populateWebDriverResponse";

        Class paramTypes [] = {
            WebDriverResponse.class,
            HTTPResponseAccessor.class,
            HTTPMessageEntities.class};

        Object[] args  = {
            response,
            new HTTPResponseAccessor() {
                public HTTPMessageEntities getCookies() {
                    HTTPMessageEntities cookies =
                                new SimpleHTTPMessageEntities();
                    cookies.add(cookie1);
                    return cookies;
                }

                public HTTPMessageEntities getHeaders() {
                    HTTPMessageEntities headers =
                                new SimpleHTTPMessageEntities();
                    headers.add(otherHeader);
                    return headers;
                }

                public InputStream getResponseStream() {
                    return null;
                }

                public int getStatusCode() {
                    return 200;
                }

                /**
                 * Get the HTTP version returned by the server.
                 * @return The HTTP version returned by the server.
                 */
                public HTTPVersion getHTTPVersion() {
                    return HTTPVersion.HTTP_1_1;
                }
            },
            additionalCookies
        };
        PrivateAccessor.invoke(manager, method, paramTypes, args);

        HTTPMessageEntities responseHeaders = response.getHeaders();
        HTTPMessageEntities responseCookies = response.getCookies();

        final int expectedCookies = 2;
        assertEquals("Expected one header.", 1, responseHeaders.size());
        assertEquals("Expected number of cookies to match", expectedCookies,
                     responseCookies.size());

        Iterator headers = responseHeaders.iterator();
        while (headers.hasNext()) {
            HeaderImpl header = (HeaderImpl) headers.next();
            assertEquals("Unexpected header name.",
                         headerName, header.getName());
            assertEquals("Unexpected header value.",
                         headerValue, header.getValue());
        }
View Full Code Here

                                                         servletResponse);
    }

    // javadoc inherited
    public HTTPMessageEntities createCookies() {
        return new SimpleHTTPMessageEntities();
    }
View Full Code Here

            // create the continaer if it does not already exist.
            if (requestHeaders == null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Creating header holder");
                }
                requestHeaders = new SimpleHTTPMessageEntities();
            }
            if (logger.isDebugEnabled()) {
                logger.debug("Adding header " + header);
            }
            requestHeaders.add(header);
View Full Code Here

            // create the continaer if it does not already exist.
            if (requestCookies == null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Creating cookie holder");
                }
                requestCookies = new SimpleHTTPMessageEntities();
            }
            if (logger.isDebugEnabled()) {
                logger.debug("Adding cookie " + cookie);
            }
            requestCookies.add(cookie);
View Full Code Here

     */
    private void setAuthenticationTokenHeader() {
        HTTPMessageEntities entities = (HTTPMessageEntities)
                context.getProperty(WebRequestHeader.class);
        if (entities == null) {
            entities = new SimpleHTTPMessageEntities();
        }
        WebRequestHeader header = new WebRequestHeader();
        header.setName(GOOGLE_AUTH_HEADER_KEY);
        header.setValue(MessageFormat.format(GOOGLE_AUTH_HEADER_VALUE, authData.getAuthToken()));
        entities.remove(header.getIdentity());
View Full Code Here

     * Create a {@link HTTPMessageEntities}.
     *
     * @return The newly created {@link HTTPMessageEntities}.
     */
    public HTTPMessageEntities createHTTPMessageEntities() {
        return new SimpleHTTPMessageEntities();
    }
View Full Code Here

TOP

Related Classes of com.volantis.shared.net.http.SimpleHTTPMessageEntities

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.