FileDocCategorySizeDatePackage
TestSearchModel.javaAPI DocExample1825Tue Oct 22 21:03:24 BST 2002com.oreilly.javaxp.junit

TestSearchModel

public class TestSearchModel extends TestCase
author
Eric M. Burke
version
$Id: TestSearchModel.java,v 1.1 2002/10/23 02:03:24 jepc Exp $

Fields Summary
Constructors Summary
public TestSearchModel(String name)

        super(name);
    
Methods Summary
public voidtestAsynchronousSearch()

        MockSearchModelListener mockListener = new MockSearchModelListener();
        SearchModel sm = new PersonSearchModel();
        sm.search("eric", mockListener);

        synchronized (mockListener) {
            mockListener.wait(2000);
        }

        SearchModelEvent evt = mockListener.getSearchModelEvent();
        assertNotNull("Search timed out", evt);
        List results = evt.getSearchResult();
        assertEquals("Number of results", 1, results.size());
        Person p = (Person) results.get(0);
        assertEquals("Result", "Eric", p.getFirstName());
    
public voidtestSynchronousSearch()

        SearchModel sm = new PersonSearchModel();

        // perform a search
        List results = sm.search("eric");
        assertEquals("Number of results", 1, results.size());
        Person p = (Person) results.get(0);
        assertEquals("Result", "Eric", p.getFirstName());

        // do another search
        results = sm.search("*");
        assertEquals("Number of results", 4, results.size());