KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > business > IndexManagerTest


1 package org.roller.business;
2
3 import junit.framework.Test;
4 import junit.framework.TestSuite;
5
6 import org.roller.RollerTestBase;
7 import org.roller.business.search.operations.AddEntryOperation;
8 import org.roller.business.search.operations.SearchOperation;
9 import org.roller.model.IndexManager;
10 import org.roller.pojos.WeblogEntryData;
11
12 /**
13  * @author Dave Johnson
14  */

15 public class IndexManagerTest extends RollerTestBase
16 {
17     public void testSearch() throws Exception JavaDoc
18     {
19         try
20         {
21             IndexManager imgr = getRoller().getIndexManager();
22             
23             WeblogEntryData wd1 = new WeblogEntryData();
24             wd1.setId("dummy");
25             wd1.setTitle("The Tholian Web");
26             wd1.setText(
27                 "When the Enterprise attempts to ascertain the fate of the U.S.S. "
28                +"Defiant which vanished 3 weeks ago, the warp engines begin to lose "
29                +"power, and Spock reports strange sensor readings.");
30             imgr.executeIndexOperationNow(
31                     new AddEntryOperation((IndexManagerImpl)imgr, wd1));
32             
33             WeblogEntryData wd2 = new WeblogEntryData();
34             wd2.setId("dummy");
35             wd2.setTitle("A Piece of the Action");
36             wd2.setText(
37                "The crew of the Enterprise attempts to make contact with "
38                +"the inhabitants of planet Sigma Iotia II, and Uhura puts Kirk "
39                +"in communication with Boss Oxmyx.");
40             imgr.executeIndexOperationNow(
41                     new AddEntryOperation((IndexManagerImpl)imgr, wd2));
42             
43             SearchOperation search = new SearchOperation(imgr);
44             search.setTerm("Enterprise");
45             imgr.executeIndexOperationNow(search);
46             assertTrue(search.getResultsCount() == 2);
47             
48             SearchOperation search2 = new SearchOperation(imgr);
49             search2.setTerm("Tholian");
50             imgr.executeIndexOperationNow(search2);
51             assertTrue(search2.getResultsCount() == 1);
52         }
53         catch (Exception JavaDoc e)
54         {
55             e.printStackTrace();
56         }
57     }
58     public static Test suite()
59     {
60         return new TestSuite(IndexManagerTest.class);
61     }
62     public static void main(String JavaDoc[] args)
63     {
64         junit.textui.TestRunner.run(IndexManagerTest.class);
65     }
66 }
67
Popular Tags