use of org.apache.directory.api.ldap.model.message.AddResponseImpl in project directory-ldap-api by apache.
the class AddRequestTest method testDecodeAddRequestNullType.
/**
* Test the decoding of a AddRequest with a empty attributeList
*/
@Test
public void testDecodeAddRequestNullType() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x2F);
stream.put(new byte[] { 0x30, // LDAPMessage ::= SEQUENCE {
0x2D, 0x02, 0x01, // messageID MessageID
0x01, 0x68, // CHOICE { ..., addRequest AddRequest, ...
0x28, // entry LDAPDN,
0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', // attributes AttributeList }
0x30, // AttributeList ::= SEQUENCE OF SEQUENCE {
0x04, 0x30, // attribute 1
0x02, 0x04, // type AttributeDescription,
0x00 });
stream.flip();
// Allocate a LdapMessage Container
Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<? extends Message>>(codec);
// Decode a AddRequest message
try {
ldapDecoder.decode(stream, ldapMessageContainer);
} catch (DecoderException de) {
assertTrue(de instanceof ResponseCarryingException);
Message response = ((ResponseCarryingException) de).getResponse();
assertTrue(response instanceof AddResponseImpl);
assertEquals(ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, ((AddResponseImpl) response).getLdapResult().getResultCode());
return;
}
fail("We should not reach this point");
}
Aggregations