* Test the decoding of two messages in a PDU
*/
@Test
public void testDecode2Messages() throws Exception
{
LdapDecoder ldapDecoder = new LdapDecoder();
LdapMessageContainer<MessageDecorator<? extends Message>> container =
new LdapMessageContainer<MessageDecorator<? extends Message>>( codec );
IoSession dummySession = new DummySession();
dummySession.setAttribute( "messageContainer", container );
ByteBuffer stream = ByteBuffer.allocate( 0x6A );
stream.put( new byte[]
{
0x30, 0x33, // LDAPMessage ::=SEQUENCE {
0x02, 0x01, 0x01, // messageID MessageID
0x60, 0x2E, // CHOICE { ..., bindRequest BindRequest, ...
// BindRequest ::= APPLICATION[0] SEQUENCE {
0x02, 0x01, 0x03, // version INTEGER (1..127),
0x04, 0x1F, // name LDAPDN,
'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
( byte ) 0x80, 0x08, // authentication
// AuthenticationChoice
// AuthenticationChoice ::= CHOICE { simple [0] OCTET STRING,
// ...
'p', 'a', 's', 's', 'w', 'o', 'r', 'd',
0x30, 0x33, // LDAPMessage ::=SEQUENCE {
0x02, 0x01, 0x02, // messageID MessageID
0x60, 0x2E, // CHOICE { ..., bindRequest BindRequest, ...
// BindRequest ::= APPLICATION[0] SEQUENCE {
0x02, 0x01, 0x03, // version INTEGER (1..127),
0x04, 0x1F, // name LDAPDN,
'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
( byte ) 0x80, 0x08, // authentication
// AuthenticationChoice
// AuthenticationChoice ::= CHOICE { simple [0] OCTET STRING,
// ...
'p', 'a', 's', 's', 'w', 'o', 'r', 'd'
} );
stream.flip();
List<Message> result = new ArrayList<Message>();
// Decode a BindRequest PDU
try
{
ldapDecoder.decode( stream, container, result );
}
catch ( DecoderException de )
{
de.printStackTrace();
fail( de.getMessage() );