use of org.apache.directory.api.ldap.extras.intermediate.syncrepl.SyncInfoValueDecorator in project directory-ldap-api by apache.
the class SyncInfoValueControlTest method testDecodeSyncInfoValueControlRefreshPresent.
// --------------------------------------------------------------------------------
// RefreshPresent choice tests
// --------------------------------------------------------------------------------
/**
* Test the decoding of a SyncInfoValue control, refreshPresent choice,
* refreshDone = true
*/
@Test
public void testDecodeSyncInfoValueControlRefreshPresent() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x0A);
bb.put(new byte[] { // syncInfoValue ::= CHOICE {
(byte) 0xA2, // syncInfoValue ::= CHOICE {
0x08, // refreshPresent [2] SEQUENCE {
0x04, 0x03, 'a', 'b', // cookie syncCookie OPTIONAL,
'c', 0x01, 0x01, // refreshDone BOOLEAN DEFAULT TRUE
(byte) 0xFF });
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 buffer = ByteBuffer.allocate(0x07);
buffer.put(new byte[] { // syncInfoValue ::= CHOICE {
(byte) 0xA2, // syncInfoValue ::= CHOICE {
0x05, // refreshPresent [2] SEQUENCE {
0x04, 0x03, 'a', 'b', // cookie syncCookie OPTIONAL,
'c' });
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.SyncInfoValueDecorator in project directory-ldap-api by apache.
the class SyncInfoValueControlTest method testDecodeSyncInfoValueControlSyncIdSetEmpty.
// --------------------------------------------------------------------------------
// syncIdSet choice tests
// --------------------------------------------------------------------------------
/**
* Test the decoding of a SyncInfoValue control, syncIdSet choice, empty
*/
@Test
public void testDecodeSyncInfoValueControlSyncIdSetEmpty() {
ByteBuffer bb = ByteBuffer.allocate(0x02);
bb.put(new byte[] { // syncInfoValue ::= CHOICE {
(byte) 0xA3, // syncInfoValue ::= CHOICE {
0x00 // syncIdSet [3] SEQUENCE {
});
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.SyncInfoValueDecorator in project directory-ldap-api by apache.
the class SyncInfoValueControlTest method testDecodeSyncInfoValueControlSyncIdSetCookieRefreshDeletesNoSet.
/**
* Test the decoding of a SyncInfoValue control, syncIdSet choice, a cookie
* a refreshDeletes flag, but no UUID set
*/
@Test
public void testDecodeSyncInfoValueControlSyncIdSetCookieRefreshDeletesNoSet() {
ByteBuffer bb = ByteBuffer.allocate(0x0A);
bb.put(new byte[] { // syncInfoValue ::= CHOICE {
(byte) 0xA3, // syncInfoValue ::= CHOICE {
0x08, // syncIdSet [3] SEQUENCE {
0x04, 0x03, 'a', 'b', // cookie syncCookie OPTIONAL,
'c', 0x01, 0x01, // refreshDeletes BOOLEAN DEFAULT FALSE,
0x00 });
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.SyncInfoValueDecorator in project directory-ldap-api by apache.
the class SyncInfoValueControlTest method testDecodeSyncInfoValueControlSyncIdSetCookieRefreshDeletesUUIDsSet.
/**
* Test the decoding of a SyncInfoValue control, syncIdSet choice, a cookie
* a refreshDeletes flag, a UUID set with some values
*/
@Test
public void testDecodeSyncInfoValueControlSyncIdSetCookieRefreshDeletesUUIDsSet() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x42);
bb.put(new byte[] { // syncInfoValue ::= CHOICE {
(byte) 0xA3, // syncInfoValue ::= CHOICE {
0x40, // syncIdSet [3] SEQUENCE {
0x04, 0x03, 'a', 'b', // cookie syncCookie OPTIONAL,
'c', 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("abc", 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(0x42);
buffer.put(new byte[] { // syncInfoValue ::= CHOICE {
(byte) 0xA3, // syncInfoValue ::= CHOICE {
0x40, // syncIdSet [3] SEQUENCE {
0x04, 0x03, 'a', 'b', // cookie syncCookie OPTIONAL,
'c', 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.SyncInfoValueDecorator in project directory-ldap-api by apache.
the class SyncInfoValueControlTest method testDecodeSyncInfoValueControlRefreshDeleteRefreshDoneFalse.
/**
* Test the decoding of a SyncInfoValue control, refreshDelete choice,
* refreshDone = false
*/
@Test
public void testDecodeSyncInfoValueControlRefreshDeleteRefreshDoneFalse() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x0A);
bb.put(new byte[] { // syncInfoValue ::= CHOICE {
(byte) 0xA1, // syncInfoValue ::= CHOICE {
0x08, // refreshDelete [1] SEQUENCE {
0x04, 0x03, 'a', 'b', // cookie syncCookie OPTIONAL,
'c', 0x01, 0x01, // refreshDone BOOLEAN DEFAULT TRUE
(byte) 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("abc", 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