Hi Catherine,

The beginXXX() method is executed on the client side so that's normal you
wouldn't get anything there (actually the request objet si null on the
client side).
However it should work ok in the testXXX() method. However, you'll have to
use ServletTestRequest.setURL() method in your beginXXX() method to simulate
the URL you would like to get when using request.getQueryString() and other
methods. If you don't do this, you'll get the values from the Redirector
servlet. This is why it is strange you get a null ...

Here is an example (also available as part of the sample application that is
in the distribution) :

    public void beginSimulatedURL5(ServletTestRequest theRequest)
    {
        theRequest.setURL("jakarta.apache.org", "/catalog",
            "/help/feedback.jsp", null,
"PARAM1=param1&PARAM2=&PARAM3=param3");
    }

    public void testSimulatedURL5()
    {
        assertEquals("jakarta.apache.org", request.getServerName());
        assertEquals("/catalog/help/feedback.jsp", request.getRequestURI());
        assertEquals(80, request.getServerPort());
        assertEquals("/catalog", request.getContextPath());
        assertEquals("/help/feedback.jsp", request.getServletPath());
        assert(request.getPathInfo() == null);
        assertEquals("PARAM1=param1&PARAM2=&PARAM3=param3",
request.getQueryString());
        assertEquals(request.getParameter("PARAM1"), "param1");
        assertEquals(request.getParameter("PARAM2"), "");
        assertEquals(request.getParameter("PARAM3"), "param3");
    }

Hope it helps.
Thanks
-Vincent


----- Original Message -----
From: "Catherine Jung" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 08, 2001 2:35 PM
Subject: null requests??


> Hi,
> I've just started using cactus and I'm trying to write tests for a
> servlet cache I have.
>
> This servlet caches pages using the request query string as the key,
> so I would like to be able to obtain the query string I'm sending, so the
> test can directly check the cache's hashtable for pages.
>
> The trouble I'm having is that anywhere I call
> request.getQueryString() I'm being returned null - this happens in both
the
> begin and the test method. If I call request.getParameter then the correct
> parameters are returned.
>
> I can't find anything to tell me what I'm doing wrong, the javadoc
> doesn't mention any restrictions on the getQueryString method, so I was
> hoping someone would be able to help me.
>
> Thankyou very much
>
> Catherine Jung
>

Reply via email to