Search in sources :

Example 1 with IUserSearchEvent

use of org.eclipse.ecf.presence.search.IUserSearchEvent in project ecf by eclipse.

the class XMPPSearchTest method testRetrieveBuddiesAsync.

public void testRetrieveBuddiesAsync() throws Exception {
    assertNotNull(searchManager);
    IRestriction selection = searchManager.createRestriction();
    assertNotNull(selection);
    // fields to consider on XMPP server side search
    // search field for XMPP, criterion to match the search
    ICriterion name = selection.eq(NAME, "Marcelo*");
    ICriterion email = selection.eq(EMAIL, "zx*");
    ICriterion username = selection.eq(USERNAME, "sl*");
    // create a specific criteria
    final ICriteria criteria = searchManager.createCriteria();
    assertNotNull(criteria);
    criteria.add(name);
    criteria.add(email);
    criteria.add(username);
    IUserSearchListener listenerCompleted = new IUserSearchListener() {

        public void handleUserSearchEvent(IUserSearchEvent event) {
            if (event instanceof IUserSearchCompleteEvent) {
                searchResult = ((IUserSearchCompleteEvent) event).getSearch();
            }
        }
    };
    // call the non-block search
    searchManager.search(criteria, listenerCompleted);
    assertNull(searchResult);
    Thread.sleep(5000);
    // put the completion result on the search handle
    if (searchResult == null)
        return;
    assertNotNull(searchResult);
    // check if there is at least one result
    assertTrue(0 != searchResult.getResultList().getResults().size());
}
Also used : IUserSearchListener(org.eclipse.ecf.presence.search.IUserSearchListener) IUserSearchCompleteEvent(org.eclipse.ecf.presence.search.IUserSearchCompleteEvent) IRestriction(org.eclipse.ecf.presence.search.IRestriction) IUserSearchEvent(org.eclipse.ecf.presence.search.IUserSearchEvent) ICriterion(org.eclipse.ecf.presence.search.ICriterion) ICriteria(org.eclipse.ecf.presence.search.ICriteria)

Aggregations

ICriteria (org.eclipse.ecf.presence.search.ICriteria)1 ICriterion (org.eclipse.ecf.presence.search.ICriterion)1 IRestriction (org.eclipse.ecf.presence.search.IRestriction)1 IUserSearchCompleteEvent (org.eclipse.ecf.presence.search.IUserSearchCompleteEvent)1 IUserSearchEvent (org.eclipse.ecf.presence.search.IUserSearchEvent)1 IUserSearchListener (org.eclipse.ecf.presence.search.IUserSearchListener)1