's',
't' // cookie OCTET STRING,
} );
bb.flip();
PagedResultsDecorator decorator = new PagedResultsDecorator( codec );
PagedResults pagedSearch = ( PagedResults ) decorator.decode( bb.array() );
assertEquals( Integer.MAX_VALUE, pagedSearch.getSize() );
assertTrue( Arrays.equals( Strings.getBytesUtf8( "test" ),
pagedSearch.getCookie() ) );
bb.flip();
PagedResultsDecorator ctrl = new PagedResultsDecorator( codec );
ctrl.setSize( -1 );
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 );
}