@Test public void testRetrieveCookie() { SearchCursor cursor = mock(SearchCursor.class); SearchResultDone searchResultDone = mock(SearchResultDone.class); PagedResults pagedSearchControl = mock(PagedResults.class); LdapResult ldapResult = mock(LdapResult.class); byte[] cookie = new byte[1]; cookie[0] = 1; when(cursor.getSearchResultDone()).thenReturn(searchResultDone); when(searchResultDone.getControl(PagedResults.OID)).thenReturn(pagedSearchControl); when(pagedSearchControl.getCookie()).thenReturn(cookie); when(ldapResult.getResultCode()).thenReturn(ResultCodeEnum.BUSY); when(searchResultDone.getLdapResult()).thenReturn(ldapResult); Object cookieResult = queryRequestPagedExecutor.retrieveCookie(cursor); Object firstItem = ((byte[])cookieResult)[0]; assertEquals(cookie[0],firstItem); }
Object retrieveCookie(SearchCursor cursor) { SearchResultDone result = cursor.getSearchResultDone(); PagedResults pagedSearchControl = (PagedResults) result.getControl(PagedResults.OID); LOGGER.trace("Retrieving cookie. Page control: {}", pagedSearchControl); ResultCodeEnum resultCodeEnum = result.getLdapResult().getResultCode(); LOGGER.trace("Retrieving cookie. Result Code: {}", resultCodeEnum.getMessage()); if (resultCodeEnum == ResultCodeEnum.UNWILLING_TO_PERFORM || resultCodeEnum == ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION || pagedSearchControl == null) { throw new QueryFailedException("AD can't handle paging. pagedSearchControl null?: " + (pagedSearchControl == null) + ", result.getLdapResult().getResultCode(): " + result.getLdapResult().getResultCode().name()); } Object cookie = pagedSearchControl.getCookie(); LOGGER.trace("Retrieving cookie. Cookie value: {}", cookie); return cookie; }
QueryRequestPagedExecutor extends QueryRequestExecutor { Object retrieveCookie(SearchCursor cursor) { SearchResultDone result = cursor.getSearchResultDone(); PagedResults pagedSearchControl = (PagedResults) result.getControl(PagedResults.OID); LOGGER.trace("Retrieving cookie. Page control: {}", pagedSearchControl); ResultCodeEnum resultCodeEnum = result.getLdapResult().getResultCode(); LOGGER.trace("Retrieving cookie. Result Code: {}", resultCodeEnum.getMessage()); if (resultCodeEnum == ResultCodeEnum.UNWILLING_TO_PERFORM || resultCodeEnum == ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION || pagedSearchControl == null) { throw new QueryFailedException("AD can't handle paging. pagedSearchControl null?: " + (pagedSearchControl == null) + ", result.getLdapResult().getResultCode(): " + result.getLdapResult().getResultCode().name()); } Object cookie = pagedSearchControl.getCookie(); LOGGER.trace("Retrieving cookie. Cookie value: {}", cookie); return cookie; } }
QueryRequestPagedExecutor extends QueryRequestExecutor { Object retrieveCookie(SearchCursor cursor) { SearchResultDone result = cursor.getSearchResultDone(); PagedResults pagedSearchControl = (PagedResults) result.getControl(PagedResults.OID); LOGGER.trace("Retrieving cookie. Page control: {}", pagedSearchControl); ResultCodeEnum resultCodeEnum = result.getLdapResult().getResultCode(); LOGGER.trace("Retrieving cookie. Result Code: {}", resultCodeEnum.getMessage()); if (resultCodeEnum == ResultCodeEnum.UNWILLING_TO_PERFORM || resultCodeEnum == ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION || pagedSearchControl == null) { throw new QueryFailedException("AD can't handle paging. pagedSearchControl null?: " + (pagedSearchControl == null) + ", result.getLdapResult().getResultCode(): " + result.getLdapResult().getResultCode().name()); } Object cookie = pagedSearchControl.getCookie(); LOGGER.trace("Retrieving cookie. Cookie value: {}", cookie); return cookie; } QueryRequestPagedExecutor(QueryRequest queryRequest); }
QueryRequestPagedExecutor extends QueryRequestExecutor { Object retrieveCookie(SearchCursor cursor) { SearchResultDone result = cursor.getSearchResultDone(); PagedResults pagedSearchControl = (PagedResults) result.getControl(PagedResults.OID); LOGGER.trace("Retrieving cookie. Page control: {}", pagedSearchControl); ResultCodeEnum resultCodeEnum = result.getLdapResult().getResultCode(); LOGGER.trace("Retrieving cookie. Result Code: {}", resultCodeEnum.getMessage()); if (resultCodeEnum == ResultCodeEnum.UNWILLING_TO_PERFORM || resultCodeEnum == ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION || pagedSearchControl == null) { throw new QueryFailedException("AD can't handle paging. pagedSearchControl null?: " + (pagedSearchControl == null) + ", result.getLdapResult().getResultCode(): " + result.getLdapResult().getResultCode().name()); } Object cookie = pagedSearchControl.getCookie(); LOGGER.trace("Retrieving cookie. Cookie value: {}", cookie); return cookie; } QueryRequestPagedExecutor(QueryRequest queryRequest);  }
QueryRequestPagedExecutor extends QueryRequestExecutor { Object retrieveCookie(SearchCursor cursor) { SearchResultDone result = cursor.getSearchResultDone(); PagedResults pagedSearchControl = (PagedResults) result.getControl(PagedResults.OID); LOGGER.trace("Retrieving cookie. Page control: {}", pagedSearchControl); ResultCodeEnum resultCodeEnum = result.getLdapResult().getResultCode(); LOGGER.trace("Retrieving cookie. Result Code: {}", resultCodeEnum.getMessage()); if (resultCodeEnum == ResultCodeEnum.UNWILLING_TO_PERFORM || resultCodeEnum == ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION || pagedSearchControl == null) { throw new QueryFailedException("AD can't handle paging. pagedSearchControl null?: " + (pagedSearchControl == null) + ", result.getLdapResult().getResultCode(): " + result.getLdapResult().getResultCode().name()); } Object cookie = pagedSearchControl.getCookie(); LOGGER.trace("Retrieving cookie. Cookie value: {}", cookie); return cookie; } QueryRequestPagedExecutor(QueryRequest queryRequest);   }