use of org.apache.directory.api.ldap.extras.intermediate.syncrepl.SyncInfoValueDecorator in project directory-ldap-api by apache.
the class SyncInfoValueControlTest method testDecodeSyncInfoValueControlRefreshPresentNoRefreshDone.
/**
* Test the decoding of a SyncInfoValue control, refreshPresent choice,
* no refreshDone
*/
@Test
public void testDecodeSyncInfoValueControlRefreshPresentNoRefreshDone() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x07);
bb.put(new byte[] { // syncInfoValue ::= CHOICE {
(byte) 0xA2, // syncInfoValue ::= CHOICE {
0x05, // refreshPresent [2] SEQUENCE {
0x04, 0x03, 'a', 'b', // cookie syncCookie OPTIONAL,
'c' });
bb.flip();
SyncInfoValue decorator = new SyncInfoValueDecorator(codec);
decorator.setSyncInfoValueType(SynchronizationInfoEnum.REFRESH_PRESENT);
SyncInfoValue syncInfoValue = (SyncInfoValue) ((SyncInfoValueDecorator) decorator).decode(bb.array());
assertEquals(SynchronizationInfoEnum.REFRESH_PRESENT, syncInfoValue.getSyncInfoValueType());
assertEquals("abc", Strings.utf8ToString(syncInfoValue.getCookie()));
assertTrue(syncInfoValue.isRefreshDone());
// Check the encoding
try {
ByteBuffer encoded = ((SyncInfoValueDecorator) syncInfoValue).encode(ByteBuffer.allocate(((SyncInfoValueDecorator) syncInfoValue).computeLength()));
assertEquals(Strings.dumpBytes(bb.array()), Strings.dumpBytes(encoded.array()));
} catch (EncoderException ee) {
fail();
}
}
Aggregations