use of org.apache.directory.api.ldap.extras.controls.syncrepl.syncDone.SyncDoneValue in project directory-ldap-api by apache.
the class SyncDoneValueControlTest method testSyncDoneValueControl.
@Test
public void testSyncDoneValueControl() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(11);
bb.put(new byte[] { 0x30, 0x09, // the cookie
0x04, // the cookie
0x04, // the cookie
'x', // the cookie
'k', // the cookie
'c', // the cookie
'd', 0x01, 0x01, // refreshDeletes flag TRUE
(byte) 0xFF });
bb.flip();
SyncDoneValue decorator = new SyncDoneValueDecorator(codec);
SyncDoneValue control = (SyncDoneValue) ((SyncDoneValueDecorator) decorator).decode(bb.array());
assertEquals("xkcd", Strings.utf8ToString(control.getCookie()));
assertTrue(control.isRefreshDeletes());
// test encoding
try {
ByteBuffer buffer = ((SyncDoneValueDecorator) control).encode(ByteBuffer.allocate(((SyncDoneValueDecorator) control).computeLength()));
String expected = Strings.dumpBytes(bb.array());
String decoded = Strings.dumpBytes(buffer.array());
assertEquals(expected, decoded);
} catch (EncoderException e) {
fail(e.getMessage());
}
}
use of org.apache.directory.api.ldap.extras.controls.syncrepl.syncDone.SyncDoneValue in project directory-ldap-api by apache.
the class SyncDoneValueControlTest method testSyncDoneValueWithSequenceOnly.
@Test
public void testSyncDoneValueWithSequenceOnly() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(2);
bb.put(new byte[] { 0x30, 0x00 });
bb.flip();
SyncDoneValue decorator = new SyncDoneValueDecorator(codec);
SyncDoneValue control = (SyncDoneValue) ((SyncDoneValueDecorator) decorator).decode(bb.array());
assertNull(control.getCookie());
assertFalse(control.isRefreshDeletes());
}
use of org.apache.directory.api.ldap.extras.controls.syncrepl.syncDone.SyncDoneValue in project directory-ldap-api by apache.
the class SyncDoneValueControlTest method testSyncDoneValueControlWithEmptyCookie.
@Test
public void testSyncDoneValueControlWithEmptyCookie() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(7);
bb.put(new byte[] { 0x30, 0x05, // empty cookie
0x04, // empty cookie
0x00, 0x01, 0x01, // refreshDeletes flag FALSE
0x00 });
bb.flip();
SyncDoneValue decorator = new SyncDoneValueDecorator(codec);
SyncDoneValue control = (SyncDoneValue) ((SyncDoneValueDecorator) decorator).decode(bb.array());
assertEquals("", Strings.utf8ToString(control.getCookie()));
assertFalse(control.isRefreshDeletes());
// test encoding
try {
ByteBuffer buffer = ((SyncDoneValueDecorator) control).encode(ByteBuffer.allocate(((SyncDoneValueDecorator) control).computeLength()));
String decoded = Strings.dumpBytes(buffer.array());
assertEquals("0x30 0x00 ", decoded);
} catch (Exception e) {
fail(e.getMessage());
}
}
use of org.apache.directory.api.ldap.extras.controls.syncrepl.syncDone.SyncDoneValue in project directory-ldap-api by apache.
the class SyncDoneValueControlTest method testSyncDoneValueControlWithoutCookie.
@Test
public void testSyncDoneValueControlWithoutCookie() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(5);
bb.put(new byte[] { 0x30, 0x03, // null cookie
0x01, 0x01, // refreshDeletes flag TRUE
(byte) 0xFF });
bb.flip();
SyncDoneValue decorator = new SyncDoneValueDecorator(codec);
SyncDoneValue control = (SyncDoneValue) ((SyncDoneValueDecorator) decorator).decode(bb.array());
assertNull(control.getCookie());
assertTrue(control.isRefreshDeletes());
// test encoding
try {
ByteBuffer buffer = ((SyncDoneValueDecorator) control).encode(ByteBuffer.allocate(((SyncDoneValueDecorator) control).computeLength()));
String expected = Strings.dumpBytes(bb.array());
String decoded = Strings.dumpBytes(buffer.array());
assertEquals(expected, decoded);
} catch (EncoderException e) {
fail(e.getMessage());
}
}
Aggregations