1 4 package com.openedit.search; 5 6 import java.io.File ; 7 import java.util.List ; 8 9 import com.openedit.BaseTestCase; 10 import com.openedit.WebPageRequest; 11 12 16 public class SearchTest extends BaseTestCase 17 { 18 19 public void testIndex() throws Exception 20 { 21 System.setProperty("oe.root.path", "webapp"); 22 23 SearchModule mod = (SearchModule)getModule("Search"); 25 WebPageRequest req = getFixture().createPageRequest(); 26 27 assertTrue( mod.crawlWebSite(req) ); 28 } 29 30 public void testSearch() throws Exception 31 { 32 File index = new File ( getRoot().getAbsolutePath() + "/search/index" ); 33 if ( !index.exists() ) 34 { 35 crawl(); 36 } 37 SearchModule mod = (SearchModule)getModule("Search"); 38 WebPageRequest req = getFixture().createPageRequest(); 39 req.setRequestParameter("query","catalog"); 40 41 mod.search(req); 42 43 List hits = (List )req.getPageValue("hits"); 44 assertTrue(hits.size() > 0); 45 } 46 47 public void crawl() throws Exception 48 { 49 SearchModule mod = (SearchModule)getModule("Search"); 50 WebPageRequest req = getFixture().createPageRequest(); 51 mod.crawlWebSite(req); 52 } 53 } 54 | Popular Tags |