use of org.apache.directory.api.ldap.codec.controls.search.entryChange.EntryChangeDecorator in project directory-ldap-api by apache.
the class EntryChangeControlTest method testDecodeEntryChangeControlWithADD.
/**
* Test the decoding of a EntryChangeControl with a add and nothing else
*/
@Test
public void testDecodeEntryChangeControlWithADD() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x05);
bb.put(new byte[] { // EntryChangeNotification ::= SEQUENCE {
0x30, // EntryChangeNotification ::= SEQUENCE {
0x03, 0x0A, 0x01, // changeType ENUMERATED {
0x01 // ADD (1)
// }
// }
});
bb.flip();
EntryChangeDecorator decorator = new EntryChangeDecorator(codec);
EntryChange entryChange = (EntryChange) decorator.decode(bb.array());
assertEquals(ChangeType.ADD, entryChange.getChangeType());
assertNull(entryChange.getPreviousDn());
assertEquals(EntryChangeDecorator.UNDEFINED_CHANGE_NUMBER, entryChange.getChangeNumber());
}
use of org.apache.directory.api.ldap.codec.controls.search.entryChange.EntryChangeDecorator 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());
}
use of org.apache.directory.api.ldap.codec.controls.search.entryChange.EntryChangeDecorator in project directory-ldap-api by apache.
the class EntryChangeControlTest method testDecodeEntryChangeControlWithADDAndPreviousDNBad.
/**
* Test the decoding of a EntryChangeControl with a add so we should not
* have a PreviousDN
*/
@Test(expected = DecoderException.class)
public void testDecodeEntryChangeControlWithADDAndPreviousDNBad() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x0D);
bb.put(new byte[] { // EntryChangeNotification ::= SEQUENCE {
0x30, // EntryChangeNotification ::= SEQUENCE {
0x0B, 0x0A, 0x01, // changeType ENUMERATED {
0x01, // }
0x04, 0x03, 'a', '=', // previousDN LDAPDN OPTIONAL, --
'b', // modifyDN ops. only
0x02, 0x01, // changeNumber INTEGER OPTIONAL -- if supported
0x10 // }
});
bb.flip();
EntryChangeDecorator decorator = new EntryChangeDecorator(codec);
decorator.decode(bb.array());
}
use of org.apache.directory.api.ldap.codec.controls.search.entryChange.EntryChangeDecorator in project directory-ldap-api by apache.
the class EntryChangeControlTest method testDecodeEntryChangeControlWithWrongChangeNumber.
/**
* Test the decoding of a EntryChangeControl with a wrong changeNumber
*/
@Test(expected = DecoderException.class)
public void testDecodeEntryChangeControlWithWrongChangeNumber() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x1C);
bb.put(new byte[] { // EntryChangeNotification ::= SEQUENCE {
0x30, // EntryChangeNotification ::= SEQUENCE {
0x1A, 0x0A, 0x01, // changeType ENUMERATED {
0x08, // }
0x04, 0x03, 'a', '=', // previousDN LDAPDN OPTIONAL, -- modifyDN ops. only
'b', 0x02, // changeNumber INTEGER OPTIONAL -- if supported
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
bb.flip();
EntryChangeDecorator decorator = new EntryChangeDecorator(codec);
decorator.decode(bb.array());
}
Aggregations