LDAP-66 NullPointerException when getting PagedResultsRequestControl response

This commit is contained in:
Ulrik Sandberg
2007-05-01 18:41:57 +00:00
parent d00304c7a1
commit 1f730f6cae
2 changed files with 20 additions and 0 deletions

View File

@@ -116,6 +116,9 @@ public class PagedResultsRequestControl extends
LdapContext ldapContext = (LdapContext) ctx;
Control[] responseControls = ldapContext.getResponseControls();
if (responseControls == null) {
responseControls = new Control[0];
}
// Go through response controls and get info, regardless of class
for (int i = 0; i < responseControls.length; i++) {

View File

@@ -137,6 +137,23 @@ public class PagedResultsRequestControlTest extends TestCase {
assertEquals(0, tested.getResultSize());
}
public void testPostProcess_NoResponseControls() throws Exception {
ldapContextControl.expectAndDefaultReturn(ldapContextMock
.getResponseControls(), null);
PagedResultsRequestControl tested = new PagedResultsRequestControl(20);
replay();
tested.postProcess(ldapContextMock);
verify();
assertNull(tested.getCookie());
assertEquals(20, tested.getPageSize());
assertEquals(0, tested.getResultSize());
}
public void testBerDecoding() throws Exception {
byte[] value = new byte[1];
value[0] = 8;