Package org.apache.cactus.internal

Examples of org.apache.cactus.internal.WebRequestImpl


     * Verify that <code>getHeader</code> returns the first header
     * that was added to the request.
     */
    public void testGetHeaderOk()
    {
        WebRequest request = new WebRequestImpl(new ServletConfiguration());

        request.addHeader("header1", "value1");
        request.addHeader("header2", "value2");

        String result = request.getHeader("header1");

        assertEquals("value1", result);
    }
View Full Code Here


     * Verify that <code>getHeader</code> returns null if no header
     * of a given name was added to the request.
     */
    public void testGetHeaderNull()
    {
        WebRequest request = new WebRequestImpl(new ServletConfiguration());

        String result = request.getHeader("header1");

        assertNull(result);
    }
View Full Code Here

     * Verify that <Code>toString()</code> returns a nice string representation
     * of the <code>WebRequest</code>.
     */
    public void testToString()
    {
        WebRequest request = new WebRequestImpl(new ServletConfiguration());

        request.addHeader("header1", "value1");
        request.addHeader("header1", "value2");
        request.addParameter("param1", "value1", WebRequest.GET_METHOD);
        request.addParameter("param1", "value1", WebRequest.POST_METHOD);
        request.addCookie("cookie1", "value1");
        request.setAutomaticSession(false);
        request.setURL("jakarta.apache.org:80", "/catalog", "/garden",
            "/implements/", "param1=value1&param2=&param3=value3");

        String result = request.toString();

        assertEquals("simulation URL = [protocol = [http], host name = "
            + "[jakarta.apache.org], port = [80], context path = [/catalog], "
            + "servlet path = [/garden], path info = [/implements/], query "
            + "string = [param1=value1&param2=&param3=value3]], automatic "
View Full Code Here

     * Verify that an error in the query string of <code>setURL()</code>
     * raises an exception.
     */
    public void testSetURLBadQueryString()
    {
        WebRequest request = new WebRequestImpl(new ServletConfiguration());

        try
        {
            request.setURL("jakarta.apache.org:80", "/catalog", "/garden",
                "/implements/", "badquerystring");
            fail("Failed to recognize invalid query string");
        }
        catch (RuntimeException e)
        {
View Full Code Here

    /**
     * Verify that we can retrieve several POST parameters.
     */
    public void testGetPostParametersSeveral()
    {
        WebRequest request = new WebRequestImpl(new ServletConfiguration());

        request.addParameter("param1", "value1", WebRequest.POST_METHOD);
        request.addParameter("param2", "value2", WebRequest.POST_METHOD);
        request.addParameter("param3", "value3", WebRequest.POST_METHOD);

        Enumeration keys = request.getParameterNamesPost();
        while (keys.hasMoreElements())
        {
            String key = (String) keys.nextElement();
            String[] values = request.getParameterValuesPost(key);

            assertEquals(1, values.length);
           
            if (!values[0].equals("value1") && !values[0].equals("value2")
                && !values[0].equals("value3"))
View Full Code Here

            HttpClientConnectionHelper helper =
                new HttpClientConnectionHelper(resource);

            WebRequest request =
                new WebRequestImpl((WebConfiguration) theConfiguration);

            // Make the connection using a default web request.
            connection = helper.connect(request, theConfiguration);

            checkPreAuthResponse(connection);
View Full Code Here

     *            redirector servlet.
     */
    private WebTestResult callGetResult(WebRequest theOriginalRequest)
        throws Throwable
    {
        WebRequest resultsRequest = new WebRequestImpl(this.configuration);
        RequestDirectives directives = new RequestDirectives(resultsRequest);
        directives.setService(ServiceEnumeration.GET_RESULTS_SERVICE);

        // Use the same redirector as was used by the original request
        resultsRequest.setRedirectorName(
            theOriginalRequest.getRedirectorName());
       
        // Add authentication details
        if (theOriginalRequest.getAuthentication() != null)
        {
            resultsRequest.setAuthentication(
                theOriginalRequest.getAuthentication());
        }

        // Open the second connection to get the test results
        HttpClientConnectionHelper helper =
View Full Code Here

     * {@inheritDoc}
     * @see ProtocolHandler#createRequest()
     */
    public Request createRequest()
    {
        return new WebRequestImpl(getConfiguration());
    }
View Full Code Here

     * @exception Exception on error
     */
    public void testCreateHttpStateWhenNoCactusCookieDefined()
        throws Exception
    {
        WebRequest request = new WebRequestImpl();
        HttpState state = new HttpState();
        state.addCookies(CookieUtil.createHttpClientCookies(request,
            new URL("http://jakarta.apache.org")));
        assertEquals(0, state.getCookies().length);
    }
View Full Code Here

     * @exception Exception on error
     */
    public void testCreateHttpStateWhenSeveralCactusCookieExist()
        throws Exception
    {
        WebRequest request = new WebRequestImpl();
        request.addCookie(new Cookie("domain1", "name1", "value1"));
        request.addCookie(new Cookie("domain2", "name2", "value2"));
       
        HttpState state = new HttpState();
        state.addCookies(CookieUtil.createHttpClientCookies(request,
            new URL("http://jakarta.apache.org")));

View Full Code Here

TOP

Related Classes of org.apache.cactus.internal.WebRequestImpl

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.