use of org.apache.directory.api.ldap.codec.controls.search.pagedSearch.PagedResultsDecorator in project directory-ldap-api by apache.
the class PagedSearchControlTest method testDecodePagedSearchRequestNoSize.
/**
* Test the decoding of a PagedSearchControl with no size
*/
@Test(expected = DecoderException.class)
public void testDecodePagedSearchRequestNoSize() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x08);
bb.put(new byte[] { // realSearchControlValue ::= SEQUENCE {
0x30, // realSearchControlValue ::= SEQUENCE {
0x06, 0x04, 0x04, 't', 'e', 's', // cookie OCTET STRING,
't' });
bb.flip();
PagedResultsDecorator decorator = new PagedResultsDecorator(codec);
decorator.decode(bb.array());
}
use of org.apache.directory.api.ldap.codec.controls.search.pagedSearch.PagedResultsDecorator in project directory-ldap-api by apache.
the class PagedSearchControlTest method testEncodePagedSearchControl.
/**
* Test encoding of a PagedSearchControl.
*/
@Test
public void testEncodePagedSearchControl() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x0B);
bb.put(new byte[] { // realSearchControlValue ::= SEQUENCE {
0x30, // realSearchControlValue ::= SEQUENCE {
0x09, 0x02, 0x01, // size INTEGER,
0x20, 0x04, 0x04, 't', 'e', 's', // cookie OCTET STRING,
't' });
bb.flip();
PagedResultsDecorator decorator = new PagedResultsDecorator(codec);
PagedResults pagedSearch = (PagedResults) decorator.decode(bb.array());
assertEquals(32, pagedSearch.getSize());
assertTrue(Arrays.equals(Strings.getBytesUtf8("test"), pagedSearch.getCookie()));
bb.flip();
PagedResultsDecorator ctrl = new PagedResultsDecorator(codec);
ctrl.setSize(32);
ctrl.setCookie(Strings.getBytesUtf8("test"));
ByteBuffer buffer = ctrl.encode(ByteBuffer.allocate(ctrl.computeLength()));
String decoded = Strings.dumpBytes(buffer.array());
String expected = Strings.dumpBytes(bb.array());
assertEquals(expected, decoded);
}
use of org.apache.directory.api.ldap.codec.controls.search.pagedSearch.PagedResultsDecorator in project directory-ldap-api by apache.
the class PagedSearchControlTest method testDecodePagedSearchRequestNoSizeNoCookie.
/**
* Test the decoding of a PagedSearchControl with no size and no cookie
*/
@Test(expected = DecoderException.class)
public void testDecodePagedSearchRequestNoSizeNoCookie() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x02);
bb.put(new byte[] { // realSearchControlValue ::= SEQUENCE
0x30, // realSearchControlValue ::= SEQUENCE
0x00 });
bb.flip();
PagedResultsDecorator decorator = new PagedResultsDecorator(codec);
decorator.decode(bb.array());
}
Aggregations