@Test public void shouldGetConnectionFromFactory() throws QueryFailedException, ErrorResultException, ErrorResultIOException { given(mockFactory.getConnection()).willReturn(mockConnection); handler.performSearch(mockRequest, mock(Collection.class)); verify(mockFactory).getConnection(); }
public Result performSearch(SearchRequest request, Collection<Entry> entries) throws QueryFailedException { Filter filter = request.getFilter(); Connection connection = null; try { connection = connectionFactory.getConnection(); result = connection.search(request, entries); return result; } catch (ErrorResultException e) { if (!entries.isEmpty()) { if (debug.warningEnabled()) { debug.warning("Partial search result has been received due to the following error:", e); } return e.getResult(); } throw new QueryFailedException(connection, constants.getTokenStoreRootSuffix(), filter, e); } finally { IOUtils.closeIfNotNull(connection); } }
LDAPSearchHandler { public Result performSearch(SearchRequest request, Collection<Entry> entries) throws QueryFailedException { Filter filter = request.getFilter(); Connection connection = null; try { connection = connectionFactory.getConnection(); result = connection.search(request, entries); return result; } catch (ErrorResultException e) { if (!entries.isEmpty()) { if (debug.warningEnabled()) { debug.warning("Partial search result has been received due to the following error:", e); } return e.getResult(); } throw new QueryFailedException(connection, constants.getTokenStoreRootSuffix(), filter, e); } finally { IOUtils.closeIfNotNull(connection); } } }
LDAPSearchHandler { public Result performSearch(SearchRequest request, Collection<Entry> entries) throws QueryFailedException { Filter filter = request.getFilter(); Connection connection = null; try { connection = connectionFactory.getConnection(); result = connection.search(request, entries); return result; } catch (ErrorResultException e) { if (!entries.isEmpty()) { if (debug.warningEnabled()) { debug.warning("Partial search result has been received due to the following error:", e); } return e.getResult(); } throw new QueryFailedException(connection, constants.getTokenStoreRootSuffix(), filter, e); } finally { IOUtils.closeIfNotNull(connection); } } @Inject  LDAPSearchHandler(ConnectionFactory connectionFactory, LDAPConfig constants,
            @Named(CoreTokenConstants.CTS_DEBUG) Debug debug); }
LDAPSearchHandler { public Result performSearch(SearchRequest request, Collection<Entry> entries) throws QueryFailedException { Filter filter = request.getFilter(); Connection connection = null; try { connection = connectionFactory.getConnection(); result = connection.search(request, entries); return result; } catch (ErrorResultException e) { if (!entries.isEmpty()) { if (debug.warningEnabled()) { debug.warning("Partial search result has been received due to the following error:", e); } return e.getResult(); } throw new QueryFailedException(connection, constants.getTokenStoreRootSuffix(), filter, e); } finally { IOUtils.closeIfNotNull(connection); } } @Inject  LDAPSearchHandler(ConnectionFactory connectionFactory, LDAPConfig constants,
            @Named(CoreTokenConstants.CTS_DEBUG) Debug debug); Result performSearch(SearchRequest request, Collection<Entry> entries); }
LDAPSearchHandler { public Result performSearch(SearchRequest request, Collection<Entry> entries) throws QueryFailedException { Filter filter = request.getFilter(); Connection connection = null; try { connection = connectionFactory.getConnection(); result = connection.search(request, entries); return result; } catch (ErrorResultException e) { if (!entries.isEmpty()) { if (debug.warningEnabled()) { debug.warning("Partial search result has been received due to the following error:", e); } return e.getResult(); } throw new QueryFailedException(connection, constants.getTokenStoreRootSuffix(), filter, e); } finally { IOUtils.closeIfNotNull(connection); } } @Inject  LDAPSearchHandler(ConnectionFactory connectionFactory, LDAPConfig constants,
            @Named(CoreTokenConstants.CTS_DEBUG) Debug debug); Result performSearch(SearchRequest request, Collection<Entry> entries);  }