de.printStackTrace();
fail( de.getMessage() );
}
// Check the decoded PDU
ModifyRequest modifyRequest = ldapMessageContainer.getMessage();
assertEquals( 49, modifyRequest.getMessageId() );
assertEquals( "cn=Tori Amos,ou=playground,dc=apache,dc=org", modifyRequest.getName().toString() );
Object[] modifications = modifyRequest.getModifications().toArray();
assertEquals( 3, modifications.length );
Modification modification = ( Modification ) modifications[0];
Attribute attributeValue = modification.getAttribute();
assertEquals( "description", attributeValue.getUpId().toLowerCase() );
assertEquals( 0, attributeValue.size() );
modification = ( Modification ) modifications[1];
attributeValue = modification.getAttribute();
String attrValue = attributeValue.getString();
assertEquals( "telephonenumber", attributeValue.getUpId().toLowerCase() );
assertEquals( "01234567890", attrValue );
modification = ( Modification ) modifications[2];
attributeValue = modification.getAttribute();
attrValue = attributeValue.getString();
assertEquals( "telephonenumber", attributeValue.getUpId().toLowerCase() );
attrValue = attributeValue.getString();
assertEquals( "01234567890", attrValue );
// Check the encoding, by decoding and re-encoding the result
try
{
ByteBuffer bb = encoder.encodeMessage( modifyRequest );
// Check the length
assertEquals( 0xB9, bb.limit() );
String decodedPdu1 = Strings.dumpBytes(bb.array());
try
{
ldapDecoder.decode( bb, ldapMessageContainer );
}
catch ( DecoderException de )
{
de.printStackTrace();
fail( de.getMessage() );
}
ModifyRequest modifyRequest2 = ldapMessageContainer.getMessage();
bb = encoder.encodeMessage( modifyRequest2 );
String decodedPdu2 = Strings.dumpBytes(bb.array());
assertEquals( decodedPdu1, decodedPdu2 );