Hi George, you're lucky I know your architecture :) You should include a
snippet of the test module for completeness.

You'll notice the request is actually a mockito proxy setup in the @Before
of the test (in the test module).

Can you use @RequestParameter in the event (instead of
request.getParameter()?) then you can call the method and pass a value from
the test.

Otherwise you'll need to use mockito to mock request.getParameter(...)
(similar to how request.isXhr() is currently mocked). You'll need to be
careful here, there are 2 request proxies (mockito proxy wrapped by
tapestry ioc proxy). And I'm not sure mockito methods can act on the
tapestry proxy.
On 28 Aug 2014 02:47, "George Christman" <gchrist...@cardaddy.com> wrote:

> Hi everyone, I'm trying to create some unit test against a new component
> I'm working on. The new component uses request.getParameter(). I'm
> wondering how I would go about setting the request parameter in my test
> case.
>
> Component I'm testing
>
> public void keywordFacetSearch() {
>         // Get the user's search keyword(s). Get optional parameters, or
> apply default values if those parameters weren't passed.
>         String searchString = request.getParameter(SearchParam.KEY) != null
> ? request.getParameter(CarDaddyEnum.KEY).trim() : "";
> }
>
> Test case
>
> @Test
>   public void testKeywordFacetSearch() {
>         request.setAttribute(SearchParam.KEY, "foo");
>   }
>
> request.setAttribute doesn't seem to work. Any ideas?
>
> Thanks
>
> --
> George Christman
> www.CarDaddy.com
> P.O. Box 735
> Johnstown, New York
>

Reply via email to