use of org.apache.directory.api.ldap.extras.intermediate.syncrepl.SyncInfoValue in project directory-ldap-api by apache.
the class SyncInfoValueControlTest method testDecodeSyncInfoValueControlRefreshPresentNoCookie.
/**
* Test the decoding of a SyncInfoValue control, refreshPresent choice,
* no cookie
*/
@Test
public void testDecodeSyncInfoValueControlRefreshPresentNoCookie() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x05);
bb.put(new byte[] { // syncInfoValue ::= CHOICE {
(byte) 0xA2, // syncInfoValue ::= CHOICE {
0x03, // refreshPresent [2] SEQUENCE {
0x01, 0x01, // refreshDone BOOLEAN DEFAULT TRUE
0x00 });
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("", Strings.utf8ToString(syncInfoValue.getCookie()));
assertFalse(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();
}
}
use of org.apache.directory.api.ldap.extras.intermediate.syncrepl.SyncInfoValue 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