use of org.eclipse.ecf.presence.search.IUserSearchCompleteEvent 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());
}
Aggregations