use of org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulDisconnect.GracefulDisconnectContainer in project directory-ldap-api by apache.
the class GracefulDisconnectResponseTest method testDecodeGracefulDisconnectTimeOfflineEmpty.
/**
* Test the decoding of a GracefulDisconnect with an empty TimeOffline
*/
@Test
public void testDecodeGracefulDisconnectTimeOfflineEmpty() {
Asn1Decoder decoder = new GracefulDisconnectDecoder();
ByteBuffer bb = ByteBuffer.allocate(0x0b);
bb.put(new byte[] { // GracefulDisconnect ::= SEQUENCE {
0x30, // GracefulDisconnect ::= SEQUENCE {
0x02, 0x02, // timeOffline INTEGER (0..720) DEFAULT 0,
0x00 });
bb.flip();
GracefulDisconnectContainer container = new GracefulDisconnectContainer();
try {
decoder.decode(bb, container);
} catch (DecoderException de) {
assertTrue(true);
return;
}
fail("We should not reach this point");
}
use of org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulDisconnect.GracefulDisconnectContainer in project directory-ldap-api by apache.
the class GracefulDisconnectResponseTest method testDecodeGracefulDisconnectTimeOfflineOffLimit.
// Defensive tests
/**
* Test the decoding of a GracefulDisconnect with a timeOffline off limit
*/
@Test
public void testDecodeGracefulDisconnectTimeOfflineOffLimit() {
Asn1Decoder decoder = new GracefulDisconnectDecoder();
ByteBuffer bb = ByteBuffer.allocate(0x0b);
bb.put(new byte[] { // GracefulDisconnect ::= SEQUENCE {
0x30, // GracefulDisconnect ::= SEQUENCE {
0x04, 0x02, 0x02, 0x03, // timeOffline INTEGER (0..720)
(byte) 0xE8 // DEFAULT 0,
});
bb.flip();
GracefulDisconnectContainer container = new GracefulDisconnectContainer();
try {
decoder.decode(bb, container);
} catch (DecoderException de) {
assertTrue(true);
return;
}
fail("We should not reach this point");
}
use of org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulDisconnect.GracefulDisconnectContainer in project directory-ldap-api by apache.
the class GracefulDisconnectResponseTest method testDecodeGracefulDisconnectReplicatedContextsEmpty.
/**
* Test the decoding of a GracefulDisconnect with an empty replicated
* contexts
*/
@Test
public void testDecodeGracefulDisconnectReplicatedContextsEmpty() {
Asn1Decoder decoder = new GracefulDisconnectDecoder();
ByteBuffer bb = ByteBuffer.allocate(0x04);
bb.put(new byte[] { // GracefulDisconnect ::= SEQUENCE {
0x30, // GracefulDisconnect ::= SEQUENCE {
0x02, 0x30, // replicatedContexts Referral OPTIONAL
0x00 });
bb.flip();
GracefulDisconnectContainer container = new GracefulDisconnectContainer();
try {
decoder.decode(bb, container);
} catch (DecoderException de) {
assertTrue(true);
return;
}
fail("We should not reach this point");
}
use of org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulDisconnect.GracefulDisconnectContainer in project directory-ldap-api by apache.
the class GracefulDisconnectResponseTest method testDecodeGracefulDisconnectTimeOfflineDelay.
/**
* Test the decoding of a GracefulDisconnect with a timeOffline and a delay
*/
@Test
public void testDecodeGracefulDisconnectTimeOfflineDelay() {
Asn1Decoder decoder = new GracefulDisconnectDecoder();
ByteBuffer bb = ByteBuffer.allocate(0x08);
bb.put(new byte[] { // GracefulDisconnect ::= SEQUENCE {
0x30, // GracefulDisconnect ::= SEQUENCE {
0x06, 0x02, 0x01, // timeOffline INTEGER (0..720) DEFAULT 0,
0x01, (byte) 0x80, 0x01, // timeOffline INTEGER (0..720)
0x01 // DEFAULT 0,
});
String decodedPdu = Strings.dumpBytes(bb.array());
bb.flip();
GracefulDisconnectContainer container = new GracefulDisconnectContainer();
try {
decoder.decode(bb, container);
} catch (DecoderException de) {
de.printStackTrace();
fail(de.getMessage());
}
GracefulDisconnectResponseDecorator gracefulDisconnect = container.getGracefulDisconnectResponse();
assertEquals(1, gracefulDisconnect.getTimeOffline());
assertEquals(1, gracefulDisconnect.getDelay());
assertEquals(0, gracefulDisconnect.getReplicatedContexts().getLdapUrls().size());
// Check the length
assertEquals(0x08, gracefulDisconnect.computeLengthInternal());
// Check the encoding
try {
ByteBuffer bb2 = gracefulDisconnect.encodeInternal();
String encodedPdu = Strings.dumpBytes(bb2.array());
assertEquals(encodedPdu, decodedPdu);
} catch (EncoderException ee) {
ee.printStackTrace();
fail(ee.getMessage());
}
}
use of org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulDisconnect.GracefulDisconnectContainer in project directory-ldap-api by apache.
the class GracefulDisconnectResponseTest method testDecodeGracefulDisconnectDelayEmpty.
/**
* Test the decoding of a GracefulDisconnect with an empty delay
*/
@Test
public void testDecodeGracefulDisconnectDelayEmpty() {
Asn1Decoder decoder = new GracefulDisconnectDecoder();
ByteBuffer bb = ByteBuffer.allocate(0x0b);
bb.put(new byte[] { // GracefulDisconnect ::= SEQUENCE {
0x30, // GracefulDisconnect ::= SEQUENCE {
0x02, (byte) 0x80, // delay INTEGER (0..86400) DEFAULT 0
0x00 });
bb.flip();
GracefulDisconnectContainer container = new GracefulDisconnectContainer();
try {
decoder.decode(bb, container);
} catch (DecoderException de) {
assertTrue(true);
return;
}
fail("We should not reach this point");
}
Aggregations