Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Unit test component with request parameter

$
0
0
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

Viewing all articles
Browse latest Browse all 5648

Trending Articles