Search in sources :

Example 6 with EntryChange

use of org.apache.directory.api.ldap.model.message.controls.EntryChange in project directory-ldap-api by apache.

the class EntryChangeControlTest method testDecodeEntryChangeControlSuccess.

/**
 * Test the decoding of a EntryChangeControl
 */
@Test
public void testDecodeEntryChangeControlSuccess() throws Exception {
    ByteBuffer bb = ByteBuffer.allocate(0x0D);
    bb.put(new byte[] { // EntryChangeNotification ::= SEQUENCE {
    0x30, // EntryChangeNotification ::= SEQUENCE {
    0x0B, 0x0A, 0x01, // changeType ENUMERATED {
    0x08, // }
    0x04, 0x03, 'a', '=', // previousDN LDAPDN OPTIONAL, -- modifyDN ops. only
    'b', 0x02, 0x01, // changeNumber INTEGER OPTIONAL } -- if supported
    0x10 });
    bb.flip();
    EntryChangeDecorator decorator = new EntryChangeDecorator(codec);
    EntryChange entryChange = (EntryChange) decorator.decode(bb.array());
    assertEquals(ChangeType.MODDN, entryChange.getChangeType());
    assertEquals("a=b", entryChange.getPreviousDn().toString());
    assertEquals(16, entryChange.getChangeNumber());
}
Also used : EntryChangeDecorator(org.apache.directory.api.ldap.codec.controls.search.entryChange.EntryChangeDecorator) EntryChange(org.apache.directory.api.ldap.model.message.controls.EntryChange) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test) AbstractCodecServiceTest(org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest)

Aggregations

ByteBuffer (java.nio.ByteBuffer)6 EntryChangeDecorator (org.apache.directory.api.ldap.codec.controls.search.entryChange.EntryChangeDecorator)6 AbstractCodecServiceTest (org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest)6 EntryChange (org.apache.directory.api.ldap.model.message.controls.EntryChange)6 Test (org.junit.Test)6 Dn (org.apache.directory.api.ldap.model.name.Dn)2