FileDocCategorySizeDatePackage
TestSearchModel.javaAPI DocExample1733Wed Nov 20 17:21:36 GMT 2002com.oreilly.javaxp.junitperf

TestSearchModel

public class TestSearchModel extends TestCase
author
Eric M. Burke
version
$Id: TestSearchModel.java,v 1.8 2002/11/20 20:09:02 jepc Exp $

Fields Summary
Constructors Summary
public TestSearchModel(String name)

        super(name);
    
Methods Summary
public voidtestAsynchronousSearch()

junitperf.timedtest
maxElapsedTime="3000" waitForCompletion="false"

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

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

        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()

junitperf.loadtest
numberOfUsers="100" numberOfIterations="3"

        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());