use of org.apache.directory.api.ldap.extras.extended.endTransaction.EndTransactionRequest in project directory-ldap-api by apache.
the class EndTransactionRequestTest method testEndTransactionRequestNoCommitIdentifier.
/**
* Test the decoding of a EndTransactionRequest with an identifier but no commit
* @throws EncoderException
*/
@Test
public void testEndTransactionRequestNoCommitIdentifier() throws EncoderException {
Asn1Decoder decoder = new Asn1Decoder();
ByteBuffer bb = ByteBuffer.allocate(0x08);
bb.put(new byte[] { // EndTransactionRequest ::= SEQUENCE {
0x30, // EndTransactionRequest ::= SEQUENCE {
0x06, // identifier (test)
0x04, // identifier (test)
0x04, // identifier (test)
't', // identifier (test)
'e', // identifier (test)
's', // identifier (test)
't' });
String decodedPdu = Strings.dumpBytes(bb.array());
bb.flip();
EndTransactionRequestContainer container = new EndTransactionRequestContainer();
try {
decoder.decode(bb, container);
} catch (DecoderException de) {
de.printStackTrace();
fail(de.getMessage());
}
EndTransactionRequest endTransactionRequest = container.getEndTransactionRequest();
assertTrue(endTransactionRequest.getCommit());
assertEquals("test", Strings.utf8ToString(endTransactionRequest.getTransactionId()));
// Check the length
assertEquals(0x08, ((EndTransactionRequestDecorator) endTransactionRequest).computeLengthInternal());
// Check the encoding
ByteBuffer bb1 = ((EndTransactionRequestDecorator) endTransactionRequest).encodeInternal();
String encodedPdu = Strings.dumpBytes(bb1.array());
assertEquals(encodedPdu, decodedPdu);
}
use of org.apache.directory.api.ldap.extras.extended.endTransaction.EndTransactionRequest in project directory-ldap-api by apache.
the class EndTransactionRequestTest method testEndTransactionRequesoCommitEmptyIdentifier.
/**
* Test the decoding of a EndTransactionRequest with an empty identifier and a commit
* @throws EncoderException
*/
@Test
public void testEndTransactionRequesoCommitEmptyIdentifier() throws EncoderException {
Asn1Decoder decoder = new Asn1Decoder();
ByteBuffer bb = ByteBuffer.allocate(0x07);
bb.put(new byte[] { // EndTransactionRequest ::= SEQUENCE {
0x30, // EndTransactionRequest ::= SEQUENCE {
0x05, // Commit, FALSE
0x01, // Commit, FALSE
0x01, // Commit, FALSE
0x00, // identifier (empty)
0x04, // identifier (empty)
0x00 });
String decodedPdu = Strings.dumpBytes(bb.array());
bb.flip();
EndTransactionRequestContainer container = new EndTransactionRequestContainer();
try {
decoder.decode(bb, container);
} catch (DecoderException de) {
de.printStackTrace();
fail(de.getMessage());
}
EndTransactionRequest endTransactionRequest = container.getEndTransactionRequest();
assertFalse(endTransactionRequest.getCommit());
assertEquals(0, endTransactionRequest.getTransactionId().length);
// Check the length
assertEquals(0x07, ((EndTransactionRequestDecorator) endTransactionRequest).computeLengthInternal());
// Check the encoding
ByteBuffer bb1 = ((EndTransactionRequestDecorator) endTransactionRequest).encodeInternal();
String encodedPdu = Strings.dumpBytes(bb1.array());
assertEquals(encodedPdu, decodedPdu);
}
use of org.apache.directory.api.ldap.extras.extended.endTransaction.EndTransactionRequest in project directory-ldap-api by apache.
the class EndTransactionRequestTest method testEndTransactionRequesoCommitIdentifier.
/**
* Test the decoding of a EndTransactionRequest with an identifier and a commit
* @throws EncoderException
*/
@Test
public void testEndTransactionRequesoCommitIdentifier() throws EncoderException {
Asn1Decoder decoder = new Asn1Decoder();
ByteBuffer bb = ByteBuffer.allocate(0x0B);
bb.put(new byte[] { // EndTransactionRequest ::= SEQUENCE {
0x30, // EndTransactionRequest ::= SEQUENCE {
0x09, // Commit, FALSE
0x01, // Commit, FALSE
0x01, // Commit, FALSE
0x00, // identifier (test)
0x04, // identifier (test)
0x04, // identifier (test)
't', // identifier (test)
'e', // identifier (test)
's', // identifier (test)
't' });
String decodedPdu = Strings.dumpBytes(bb.array());
bb.flip();
EndTransactionRequestContainer container = new EndTransactionRequestContainer();
try {
decoder.decode(bb, container);
} catch (DecoderException de) {
de.printStackTrace();
fail(de.getMessage());
}
EndTransactionRequest endTransactionRequest = container.getEndTransactionRequest();
assertFalse(endTransactionRequest.getCommit());
assertEquals("test", Strings.utf8ToString(endTransactionRequest.getTransactionId()));
// Check the length
assertEquals(0x0B, ((EndTransactionRequestDecorator) endTransactionRequest).computeLengthInternal());
// Check the encoding
ByteBuffer bb1 = ((EndTransactionRequestDecorator) endTransactionRequest).encodeInternal();
String encodedPdu = Strings.dumpBytes(bb1.array());
assertEquals(encodedPdu, decodedPdu);
}
Aggregations