use of org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulShutdown.GracefulShutdownContainer in project directory-ldap-api by apache.
the class GracefulShutdownTest method testDecodeGracefulShutdownTimeOffline.
/**
* Test the decoding of a GracefulShutdown with a timeOffline only
*/
@Test
public void testDecodeGracefulShutdownTimeOffline() {
Asn1Decoder decoder = new Asn1Decoder();
ByteBuffer bb = ByteBuffer.allocate(0x05);
bb.put(new byte[] { // GracefulShutdown ::= SEQUENCE {
0x30, // GracefulShutdown ::= SEQUENCE {
0x03, 0x02, 0x01, // timeOffline INTEGER (0..720) DEFAULT 0,
0x01 });
String decodedPdu = Strings.dumpBytes(bb.array());
bb.flip();
GracefulShutdownContainer container = new GracefulShutdownContainer();
try {
decoder.decode(bb, container);
} catch (DecoderException de) {
de.printStackTrace();
fail(de.getMessage());
}
GracefulShutdownRequestDecorator gracefulShutdownRequest = container.getGracefulShutdownRequest();
assertEquals(1, gracefulShutdownRequest.getTimeOffline());
assertEquals(0, gracefulShutdownRequest.getDelay());
// Check the length
assertEquals(0x05, gracefulShutdownRequest.computeLengthInternal());
// Check the encoding
try {
ByteBuffer bb1 = gracefulShutdownRequest.encodeInternal();
String encodedPdu = Strings.dumpBytes(bb1.array());
assertEquals(encodedPdu, decodedPdu);
} catch (EncoderException ee) {
ee.printStackTrace();
fail(ee.getMessage());
}
}
Aggregations