FileDocCategorySizeDatePackage
SiteSearchTest.javaAPI DocExample2169Mon Feb 23 14:16:46 GMT 2004com.develop.ss.cactus

SiteSearchTest

public class SiteSearchTest extends org.apache.cactus.ServletTestCase
In-container testing. The same sample queries are black-box tested with HTTPUnit in {@link com.develop.ss.httpunit.SearchTest }

Fields Summary
private com.develop.ss.web.SiteSearch
searchServlet
Constructors Summary
public SiteSearchTest(String s)

    super(s);
  
Methods Summary
public voidbeginOneHitRequest(org.apache.cactus.WebRequest request)

    request.addParameter("query", "January");
  
public voidbeginThreeHitRequest(org.apache.cactus.WebRequest request)

    request.addParameter("query", "spider");
  
private com.develop.ss.search.QueryBeancallServlet()

    searchServlet.doGet(request, response);
    QueryBean bean = (QueryBean) request.getAttribute("luceneQueryBean");
    assertNotNull(bean);
    return bean;
  
public voidendEmptyRequest(com.meterware.httpunit.WebResponse response)
This test duplicates functionality that already exists in the HTTPUnit tests and is just here as a demonstration of client-side result validation in Cactus.

param
response
throws
SAXException

    WebLink[] links = response.getLinks();
    assertEquals(0, links.length);
  
public voidsetUp()

    searchServlet = new SiteSearch();
    searchServlet.init(config);
  
public voidtestEmptyRequest()

    QueryBean bean = callServlet();
    assertEquals(0, bean.getResults().length);
  
public voidtestOneHitRequest()

    QueryBean bean = callServlet();
    assertEquals(1, bean.getResults().length);
  
public voidtestThreeHitRequest()

    QueryBean bean = callServlet();
    assertEquals(3, bean.getResults().length);