/** * Helper method for testing the provided LDAPSearchDetails against expected values * * @param searchDetails the LDAPSearchDetails object * @param expectedContextName the expected context name * @param expectedContextFilter the expected context filter string * @param expectedAttrNameList list of expected attribute names * @param expectedCountLimit the expected count limit * @param expectedSearchScope the expected search scope * @param expectedSortKeys the expected sortKeys list. */ public void helpTestSearchDetails( final LDAPSearchDetails searchDetails, final String expectedContextName, final String expectedContextFilter, final List<String> expectedAttrNameList, final long expectedCountLimit, final int expectedSearchScope, final SortKey[] expectedSortKeys) { // Get all of the actual values String contextName = searchDetails.getContextName(); String contextFilter = searchDetails.getContextFilter(); List<Column> attrList = searchDetails.getElementList(); long countLimit = searchDetails.getCountLimit(); int searchScope = searchDetails.getSearchScope(); SortKey[] sortKeys = searchDetails.getSortKeys(); // Compare actual with Expected assertEquals(expectedContextName, contextName); assertEquals(expectedContextFilter, contextFilter); assertEquals(attrList.size(), expectedAttrNameList.size()); Iterator<Column> iter = attrList.iterator(); Iterator<String> eIter = expectedAttrNameList.iterator(); while (iter.hasNext() && eIter.hasNext()) { String actualName = iter.next().getSourceName(); String expectedName = eIter.next(); assertEquals(actualName, expectedName); } assertEquals(expectedCountLimit, countLimit); assertEquals(expectedSearchScope, searchScope); assertArrayEquals(expectedSortKeys, sortKeys); }
/** * Perform the LDAP search against the subcontext, using the filter and search controls * appropriate to the query and model metadata. */ private void executeSearch() throws TranslatorException { String filter = searchDetails.getContextFilter(); try { searchEnumeration = this.ldapCtx.search("", filter, ctrls); // $NON-NLS-1$ } catch (NamingException ne) { final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.execSearchError"); // $NON-NLS-1$ throw new TranslatorException(ne, msg + " : " + ne.getExplanation()); // $NON-NLS-1$ } catch (Exception e) { final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.execSearchError"); // $NON-NLS-1$ throw new TranslatorException(e, msg); } }