Search in sources :

Example 21 with SearchResultEntryDecorator

use of org.apache.directory.api.ldap.codec.decorators.SearchResultEntryDecorator in project directory-ldap-api by apache.

the class SearchResultEntryTest method testDecodeSearchResultEntryEmpty.

// Defensive tests
/**
 * Test the decoding of an empty SearchResultEntry
 */
@Test
public void testDecodeSearchResultEntryEmpty() {
    Asn1Decoder ldapDecoder = new Asn1Decoder();
    ByteBuffer stream = ByteBuffer.allocate(0x07);
    stream.put(new byte[] { // LDAPMessage ::=SEQUENCE {
    0x30, // LDAPMessage ::=SEQUENCE {
    0x05, 0x02, 0x01, // messageID MessageID
    0x01, 0x64, // CHOICE { ..., searchResEntry SearchResultEntry,
    0x00 // ...
    });
    stream.flip();
    // Allocate a BindRequest Container
    LdapMessageContainer<SearchResultEntryDecorator> ldapMessageContainer = new LdapMessageContainer<SearchResultEntryDecorator>(codec);
    try {
        ldapDecoder.decode(stream, ldapMessageContainer);
    } catch (DecoderException de) {
        assertTrue(true);
        return;
    }
    fail("We should not reach this point");
}
Also used : LdapMessageContainer(org.apache.directory.api.ldap.codec.api.LdapMessageContainer) DecoderException(org.apache.directory.api.asn1.DecoderException) Asn1Decoder(org.apache.directory.api.asn1.ber.Asn1Decoder) SearchResultEntryDecorator(org.apache.directory.api.ldap.codec.decorators.SearchResultEntryDecorator) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test) AbstractCodecServiceTest(org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest)

Aggregations

SearchResultEntryDecorator (org.apache.directory.api.ldap.codec.decorators.SearchResultEntryDecorator)21 DecoderException (org.apache.directory.api.asn1.DecoderException)18 ByteBuffer (java.nio.ByteBuffer)16 Asn1Decoder (org.apache.directory.api.asn1.ber.Asn1Decoder)16 LdapMessageContainer (org.apache.directory.api.ldap.codec.api.LdapMessageContainer)16 AbstractCodecServiceTest (org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest)16 Test (org.junit.Test)16 SearchResultEntry (org.apache.directory.api.ldap.model.message.SearchResultEntry)10 EncoderException (org.apache.directory.api.asn1.EncoderException)9 Entry (org.apache.directory.api.ldap.model.entry.Entry)9 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)8 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)3 Control (org.apache.directory.api.ldap.model.message.Control)3 CodecControl (org.apache.directory.api.ldap.codec.api.CodecControl)2 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)2 AbandonRequestDecorator (org.apache.directory.api.ldap.codec.decorators.AbandonRequestDecorator)1 AddRequestDecorator (org.apache.directory.api.ldap.codec.decorators.AddRequestDecorator)1 AddResponseDecorator (org.apache.directory.api.ldap.codec.decorators.AddResponseDecorator)1 BindRequestDecorator (org.apache.directory.api.ldap.codec.decorators.BindRequestDecorator)1 BindResponseDecorator (org.apache.directory.api.ldap.codec.decorators.BindResponseDecorator)1