use of org.apache.directory.api.ldap.model.message.controls.Subentries in project directory-ldap-api by apache.
the class SubEntryControlTest method testDecodeSubEntryVisibilityFalse.
/**
* Test the decoding of a SubEntryControl with a false visibility
*/
@Test
public void testDecodeSubEntryVisibilityFalse() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x03);
bb.put(new byte[] { // Visibility ::= BOOLEAN
0x01, // Visibility ::= BOOLEAN
0x01, // Visibility ::= BOOLEAN
0x00 });
bb.flip();
SubentriesDecorator decorator = new SubentriesDecorator(codec);
Subentries subentries = (Subentries) decorator.decode(bb.array());
assertFalse(subentries.isVisible());
// test encoding
try {
ByteBuffer buffer = decorator.encode(ByteBuffer.allocate(decorator.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.model.message.controls.Subentries in project directory-ldap-api by apache.
the class SubEntryControlTest method testDecodeSubEntryVisibilityTrue.
/**
* Test the decoding of a SubEntryControl with a true visibility
*/
@Test
public void testDecodeSubEntryVisibilityTrue() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x03);
bb.put(new byte[] { // Visibility ::= BOOLEAN
0x01, // Visibility ::= BOOLEAN
0x01, // Visibility ::= BOOLEAN
(byte) 0xFF });
bb.flip();
SubentriesDecorator decorator = new SubentriesDecorator(codec);
Subentries subentries = (Subentries) decorator.decode(bb.array());
assertTrue(subentries.isVisible());
// test encoding
try {
ByteBuffer buffer = decorator.encode(ByteBuffer.allocate(decorator.computeLength()));
String expected = Strings.dumpBytes(bb.array());
String decoded = Strings.dumpBytes(buffer.array());
assertEquals(expected, decoded);
} catch (EncoderException e) {
fail(e.getMessage());
}
}
Aggregations