use of org.apache.directory.api.ldap.extras.intermediate.syncrepl.SyncInfoValue in project directory-ldap-api by apache.
the class SyncInfoValueControlTest method testDecodeSyncInfoValueControlRefreshDeleteNoCookieNoRefreshDone.
/**
* Test the decoding of a SyncInfoValue control, refreshDelete choice,
* no cookie, no refreshDone
*/
@Test
public void testDecodeSyncInfoValueControlRefreshDeleteNoCookieNoRefreshDone() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x02);
bb.put(new byte[] { // syncInfoValue ::= CHOICE {
(byte) 0xA1, // syncInfoValue ::= CHOICE {
0x00 });
bb.flip();
SyncInfoValue decorator = new SyncInfoValueDecorator(codec);
decorator.setSyncInfoValueType(SynchronizationInfoEnum.REFRESH_DELETE);
SyncInfoValue syncInfoValue = (SyncInfoValue) ((SyncInfoValueDecorator) decorator).decode(bb.array());
assertEquals(SynchronizationInfoEnum.REFRESH_DELETE, syncInfoValue.getSyncInfoValueType());
assertEquals("", 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();
}
}
use of org.apache.directory.api.ldap.extras.intermediate.syncrepl.SyncInfoValue in project directory-ldap-api by apache.
the class SyncInfoValueControlTest method testDecodeSyncInfoValueControlSyncIdSetNoCookieRefreshDeletesUUIDsSet.
/**
* Test the decoding of a SyncInfoValue control, syncIdSet choice, a cookie
* no refreshDeletes flag, a UUID set with some values
*/
@Test
public void testDecodeSyncInfoValueControlSyncIdSetNoCookieRefreshDeletesUUIDsSet() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x3D);
bb.put(new byte[] { // syncInfoValue ::= CHOICE {
(byte) 0xA3, // syncInfoValue ::= CHOICE {
0x3B, // syncIdSet [3] SEQUENCE {
0x01, 0x01, // refreshDeletes BOOLEAN DEFAULT FALSE,
0x10, 0x31, // syncUUIDs SET OF syncUUID
0x36, 0x04, // syncUUID
0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, // syncUUID
0x10, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, // syncUUID
0x10, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 });
bb.flip();
SyncInfoValue decorator = new SyncInfoValueDecorator(codec);
decorator.setSyncInfoValueType(SynchronizationInfoEnum.SYNC_ID_SET);
SyncInfoValue syncInfoValue = (SyncInfoValue) ((SyncInfoValueDecorator) decorator).decode(bb.array());
assertEquals(SynchronizationInfoEnum.SYNC_ID_SET, syncInfoValue.getSyncInfoValueType());
assertEquals("", Strings.utf8ToString(syncInfoValue.getCookie()));
assertTrue(syncInfoValue.isRefreshDeletes());
assertEquals(3, syncInfoValue.getSyncUUIDs().size());
for (int i = 0; i < 3; i++) {
byte[] uuid = syncInfoValue.getSyncUUIDs().get(i);
for (int j = 0; j < 16; j++) {
assertEquals(i + 1, uuid[j]);
}
}
// Check the encoding
try {
ByteBuffer buffer = ByteBuffer.allocate(0x3D);
buffer.put(new byte[] { // syncInfoValue ::= CHOICE {
(byte) 0xA3, // syncInfoValue ::= CHOICE {
0x3B, // syncIdSet [3] SEQUENCE {
0x01, 0x01, // refreshDeletes BOOLEAN DEFAULT FALSE,
(byte) 0xFF, 0x31, // syncUUIDs SET OF syncUUID
0x36, 0x04, // syncUUID
0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, // syncUUID
0x10, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, // syncUUID
0x10, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 });
buffer.flip();
ByteBuffer encoded = ((SyncInfoValueDecorator) syncInfoValue).encode(ByteBuffer.allocate(((SyncInfoValueDecorator) syncInfoValue).computeLength()));
assertEquals(Strings.dumpBytes(buffer.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 testDecodeSyncInfoValueControlSyncIdSetTooSmallUUID.
/**
* Test the decoding of a SyncInfoValue control, syncIdSet choice, with some
* invalid UUID
*/
@Test
public void testDecodeSyncInfoValueControlSyncIdSetTooSmallUUID() {
ByteBuffer bb = ByteBuffer.allocate(0x1D);
bb.put(new byte[] { // syncInfoValue ::= CHOICE {
(byte) 0xA3, // syncInfoValue ::= CHOICE {
0x1B, // syncIdSet [3] SEQUENCE {
0x04, 0x03, 'a', 'b', // cookie syncCookie OPTIONAL,
'c', 0x01, 0x01, // refreshDeletes BOOLEAN DEFAULT FALSE,
0x10, 0x31, // syncUUIDs SET OF syncUUID
0x11, 0x04, // syncUUID
0x0F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 });
bb.flip();
SyncInfoValue decorator = new SyncInfoValueDecorator(codec);
decorator.setSyncInfoValueType(SynchronizationInfoEnum.SYNC_ID_SET);
try {
((SyncInfoValueDecorator) decorator).decode(bb.array());
fail("Should not be there");
} catch (DecoderException de) {
assertTrue(true);
}
}
use of org.apache.directory.api.ldap.extras.intermediate.syncrepl.SyncInfoValue in project directory-ldap-api by apache.
the class SyncInfoValueControlTest method testDecodeSyncInfoValueControlSyncIdSetCookieNoSet.
/**
* Test the decoding of a SyncInfoValue control, syncIdSet choice, cookie
* but no UUID set
*/
@Test
public void testDecodeSyncInfoValueControlSyncIdSetCookieNoSet() {
ByteBuffer bb = ByteBuffer.allocate(0x07);
bb.put(new byte[] { // syncInfoValue ::= CHOICE {
(byte) 0xA3, // syncInfoValue ::= CHOICE {
0x05, // syncIdSet [3] SEQUENCE {
0x04, 0x03, 'a', 'b', // cookie syncCookie OPTIONAL,
'c' });
bb.flip();
SyncInfoValue decorator = new SyncInfoValueDecorator(codec);
decorator.setSyncInfoValueType(SynchronizationInfoEnum.SYNC_ID_SET);
try {
((SyncInfoValueDecorator) decorator).decode(bb.array());
fail("Should not get there");
} catch (DecoderException de) {
assertTrue(true);
}
}
use of org.apache.directory.api.ldap.extras.intermediate.syncrepl.SyncInfoValue in project directory-ldap-api by apache.
the class SyncInfoValueControlTest method testDecodeSyncInfoValueControlRefreshDeleteNoCookie.
/**
* Test the decoding of a SyncInfoValue control, refreshDelete choice,
* no cookie
*/
@Test
public void testDecodeSyncInfoValueControlRefreshDeleteNoCookie() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x05);
bb.put(new byte[] { // syncInfoValue ::= CHOICE {
(byte) 0xA1, // syncInfoValue ::= CHOICE {
0x03, // refreshDelete [1] SEQUENCE {
0x01, 0x01, // refreshDone BOOLEAN DEFAULT TRUE
0x00 });
bb.flip();
SyncInfoValue decorator = new SyncInfoValueDecorator(codec);
decorator.setSyncInfoValueType(SynchronizationInfoEnum.REFRESH_DELETE);
SyncInfoValue syncInfoValue = (SyncInfoValue) ((SyncInfoValueDecorator) decorator).decode(bb.array());
assertEquals(SynchronizationInfoEnum.REFRESH_DELETE, 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();
}
}
Aggregations