Examples of HttpFactory


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

     */
    private void addHttpClientHeaderToWebDriverHeaders(
            org.apache.commons.httpclient.Header httpClientHeader,
            HTTPMessageEntities headers, boolean valueList) throws HttpException {

        HTTPFactory factory = HTTPFactory.getDefaultInstance();
        final String headerName = httpClientHeader.getName();
        final List values = HttpClientUtils.getHeaderValueList(httpClientHeader);
        if (values.size() == 0) {
            Header header = factory.createHeader(headerName);
            headers.add(header);
        } else {
            if (valueList) {
                for (Iterator iter = values.iterator(); iter.hasNext(); ) {
                    final Header header = factory.createHeader(headerName);
                    final String value = (String) iter.next();
                    header.setValue(value);
                    headers.add(header);
                }
            } else {
                StringBuffer reconstitutedHeader = new StringBuffer();
                Iterator it = values.iterator();
                while (it.hasNext()) {
                    if (reconstitutedHeader.length() > 0) {
                        reconstitutedHeader.append(',');
                    }
                    reconstitutedHeader.append(it.next());
                }
                final Header header = factory.createHeader(headerName);
                header.setValue(reconstitutedHeader.toString());
                headers.add(header);
            }
        }
    }
View Full Code Here

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

     * Must be non-null.
     */
    private void addHttpClientCookiesToWebDriverCookies(
            org.apache.commons.httpclient.Cookie httpClientCookies [],
            HTTPMessageEntities webDriverCookies) {
        HTTPFactory factory = HTTPFactory.getDefaultInstance();
        for (int i = 0; i < httpClientCookies.length; i++) {
            org.apache.commons.httpclient.Cookie httpClientCookie =
                    httpClientCookies[i];
            Cookie cookie = factory.createCookie(httpClientCookie.getName(),
                    httpClientCookie.getDomain(),
                    httpClientCookie.getPath());
            cookie.setComment(httpClientCookie.getComment());

            // Need to work out max age from the HttpClient expiry date and
View Full Code Here

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

         * members
         * @throws MalformedCookieException if an error occurs
         */
        private void populateMessageEntities() throws HttpException {
            // extract the headers and cookies from the the HttpMethod
            HTTPFactory factory = HTTPFactory.getDefaultInstance();
            cookies = factory.createHTTPMessageEntities();
            headers = factory.createHTTPMessageEntities();
            if (method != null) {
                org.apache.commons.httpclient.Header responseHeaders [] =
                        method.getResponseHeaders();
                if (responseHeaders != null && responseHeaders.length > 0) {

View Full Code Here

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

     * Test the addRequestCookiesToRequest method with cookies from the
     * context only.
     */
    public void testAddRequestCookiesToHttpMethodNoWebRequest()
            throws Throwable {
        HTTPFactory factory = HTTPFactory.getDefaultInstance();
        String name1 = "name1";
        String name2 = "name2";
        String value1a = "value1a";
        String value1b = "value1b";
        String value2 = "value2";

        HTTPMessageEntities entities = factory.createHTTPMessageEntities();
        WebRequestCookie cookie1 = new WebRequestCookie();
        cookie1.setName(name1);
        cookie1.setValue(value1a);
        entities.add(cookie1);

View Full Code Here

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

     * that contains cookies that are referenced from the markup but where the
     * markup cookies do not overlap with the WebDriverRequest cookies.
     */
    public void testAddRequestCookiesToHttpMethodWithWebRequest()
            throws Throwable {
        HTTPFactory factory = HTTPFactory.getDefaultInstance();
        String name1 = "name1";
        String name2 = "name2";
        String value1 = "value1";
        String value2 = "value2";

        HTTPMessageEntities entities = factory.createHTTPMessageEntities();
        WebRequestCookie cookie1 = new WebRequestCookie();
        cookie1.setName(name1);
        cookie1.setFrom(name1);
        entities.add(cookie1);

        WebRequestCookie cookie2 = new WebRequestCookie();
        cookie2.setName(name2);
        cookie2.setFrom(name2);
        entities.add(cookie2);

        AbstractPluggableHTTPManagerTestAbstract.MockXMLPipelineContext context =
                new AbstractPluggableHTTPManagerTestAbstract.MockXMLPipelineContext();
        context.setProperty(WebRequestCookie.class, entities, false);

        WebDriverRequest request = new WebDriverRequestImpl();
     //   WebDriverAccessor accessor = createWebDriverAccessor(request, null);

    //    context.setProperty(WebDriverAccessor.class, accessor, false);

        HTTPMessageEntities requestEntities =
                factory.createHTTPMessageEntities();
        request.setCookies(requestEntities);

        WebRequestCookie cookie3 = new WebRequestCookie();
        cookie3.setName(name1);
        cookie3.setValue(value1);
View Full Code Here

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

     * Test the addRequestHeadersToRequest method with headers from the
     * context only.
     */
    public void testAddRequestHeadersToHttpMethodNoWebRequest()
            throws Throwable {
        HTTPFactory factory = HTTPFactory.getDefaultInstance();
        String name1 = "name1";
        String name2 = "name2";
        String value1a = "value1a";
        String value1b = "value1b";
        String value2 = "value2";

        HTTPMessageEntities entities = factory.createHTTPMessageEntities();
        WebRequestHeader header1 = new WebRequestHeader();
        header1.setName(name1);
        header1.setValue(value1a);
        entities.add(header1);

View Full Code Here

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

     * that contains headers that are referenced from the markup but where the
     * markup headers do not overlap with the WebDriverRequest headers.
     */
    public void testAddRequestHeadersToHttpMethodWithWebRequest()
            throws Throwable {
        HTTPFactory factory = HTTPFactory.getDefaultInstance();
        String name1 = "name1";
        String name2 = "name2";
        String value1a = "value1a";
        String value1b = "value1b";
        String value2 = "value2";

        HTTPMessageEntities entities = factory.createHTTPMessageEntities();
        WebRequestHeader header1 = new WebRequestHeader();
        header1.setName(name1);
        header1.setFrom(name1);
        entities.add(header1);

        WebRequestHeader header2 = new WebRequestHeader();
        header2.setName(name1);
        header2.setFrom(name1);
        entities.add(header2);

        WebRequestHeader header3 = new WebRequestHeader();
        header3.setName(name2);
        header3.setFrom(name2);
        entities.add(header3);

//       PluggableHTTPManager manager = createTestablePluggableHTTPManager();
        AbstractPluggableHTTPManagerTestAbstract.MockXMLPipelineContext context =
                new AbstractPluggableHTTPManagerTestAbstract.MockXMLPipelineContext();
        context.setProperty(WebRequestHeader.class, entities, false);
  //      WebDriverConfiguration config = createTestWebDriverConfig();

        WebDriverRequest request = new WebDriverRequestImpl();
  //      WebDriverAccessor accessor = createWebDriverAccessor(request, null);

   //     context.setProperty(WebDriverAccessor.class, accessor, false);
  //      manager.initialize(config);

        HTTPMessageEntities requestEntities =
                factory.createHTTPMessageEntities();
        request.setHeaders(requestEntities);

        WebRequestHeader header4 = new WebRequestHeader();
        header4.setName(name1);
        header4.setValue(value1a);
View Full Code Here

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

            String remoteProjectName,
            GenericURLRemapper urlRemapper) {

        WebDriverRequest request = new WebDriverRequestImpl();

        final HTTPFactory httpFactory = HTTPFactory.getDefaultInstance();

        HTTPMessageEntities headers = httpFactory.createHTTPMessageEntities();
        Enumeration headerNames = httpRequest.getHeaderNames();
        while (headerNames.hasMoreElements()) {
            final String name = (String) headerNames.nextElement();
            final Header header = httpFactory.createHeader(name);
            header.setValue(httpRequest.getHeader(name));
            headers.add(header);
        }

        HTTPMessageEntities parameters = httpFactory.createHTTPMessageEntities();
        // get parameters from marinerRequestContext if available
        // ported from 4.2.0, see vbm 2007070313
        Enumeration parameterNames = (marinerRequestContext != null) ?
            marinerRequestContext.getParameterNames() :
            httpRequest.getParameterNames();
        while (parameterNames.hasMoreElements()) {
            final String name = (String) parameterNames.nextElement();
            final RequestParameter parameter =
                    httpFactory.createRequestParameter(name);
            final String value = (marinerRequestContext != null) ?
                    marinerRequestContext.getParameter(name) :
                    httpRequest.getParameter(name);  
            parameter.setValue(value);
            parameters.add(parameter);
        }

        // HTTP-Client will only send cookies if a domain and path is supplied.
        // Unfortunately when using Netscape cookies, (Version 0), domain
        // and path information is not sent in the COOKIE header, hence when
        // Netscape cookies are used we do not have values for the domain
        // and path.
        URL remoteMCSProjectLocation =
                urlRemapper.getRemoteSiteRootURL(remoteProjectName);

        // However, the fact that non JSESSIONID cookies have been sent to
        // MCS indicates that they should be sent to the target server.  So
        // we can just set the domain equal to the remote target host
        // and the path to "/".
        final String defaultDomain = remoteMCSProjectLocation.getHost();
        final String defaultPath = "/";

        HTTPMessageEntities cookies = httpFactory.createHTTPMessageEntities();
        javax.servlet.http.Cookie[] httpCookies = httpRequest.getCookies();

        if (httpCookies != null) {
            for (int i = 0; i < httpCookies.length; i++) {
                javax.servlet.http.Cookie httpCookie = httpCookies[i];
                final Cookie cookie = httpFactory.createCookie(httpCookie.getName(),
                        defaultDomain, defaultPath);
                cookie.setMaxAge(httpCookie.getMaxAge());
                cookie.setSecure(httpCookie.getSecure());

                cookie.setValue(httpCookie.getValue());
View Full Code Here

Examples of org.apache.axis2.transport.http.server.HttpFactory

    /**
     * Create a SimpleHTTPServer using default HttpFactory settings
     */
    public SimpleHTTPServer(ConfigurationContext configurationContext, int port) throws AxisFault {
        this(new HttpFactory(configurationContext, port));
    }
View Full Code Here

Examples of org.apache.axis2.transport.http.server.HttpFactory

            if (param != null) {
                this.port = Integer.parseInt((String) param.getValue());
            }

            if (httpFactory == null) {
                httpFactory = new HttpFactory(configurationContext, port);
            }
        } catch (Exception e1) {
            throw AxisFault.makeFault(e1);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.