package doc.test;import java.util.ArrayList;import doc.bo.Document;import doc.bo.DocumentSearcher;import junit.framework.TestCase;/** * Test class of the DocumentSearcher * @author Michael Glatter-Götz * <PRE> * ID date description * michael 02.10.2006 creation * </PRE> **/public class TestDocumentSearcher extends TestCase{ /** * Constructor of the TestDocumentSearcher class * @param sTitle Title of the Document **/ public TestDocumentSearcher(String sTitle) { super(sTitle); } /** * Tests if the findAll method of the DocumentSearcher returns five documents **/ public void testFindAll() { DocumentSearcher oCarSearcher = new DocumentSearcher(); ArrayList aoCars = null; aoCars = oCarSearcher.findAll(); assertTrue("findAll-Methode liefert nicht fünf Dokumente", aoCars.size() == 5); } /** * Tests if the findByAuthor method works correctly **/ public void testFindByAuthor() { DocumentSearcher oDocumentSearcher = new DocumentSearcher(); ArrayList<Document> aoFoundGrimm = oDocumentSearcher.findByAuthor("Grimm"); assertTrue("Bei einer Suche nach 'Grimm' wird nicht nur ein Dokument gefunden", aoFoundGrimm.size() == 1); ArrayList<Document> aoFoundAndersen = oDocumentSearcher.findByAuthor("Andersen"); assertTrue("Bei einer Suche nach 'Andersen' werden nicht zwei Dokumente gefunden", aoFoundAndersen.size() == 2); ArrayList<Document> aoFoundMayer = oDocumentSearcher.findByAuthor("Andersen"); assertNotNull("Es wird bei der Suche nach 'Mayer' keine leere Collection zurückgegeben", aoFoundMayer); } /** * Main method of the Test class, launches the GUI * @param sArgs Parameters **/ public static void main(String[] sArgs) { junit.swingui.TestRunner.run(TestDocumentSearcher.class); }}