You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2018/09/21 09:13:17 UTC

[directory-ldap-api] branch master updated: o Formatting tests o Using a decorator instead of a plain message

This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-ldap-api.git


The following commit(s) were added to refs/heads/master by this push:
     new 4fba86c  o Formatting tests o Using a decorator instead of a plain message
4fba86c is described below

commit 4fba86c02fd84726273831ca1bac4932e9961246
Author: Emmanuel Lécharny <el...@symas.com>
AuthorDate: Fri Sep 21 11:13:14 2018 +0200

    o Formatting tests
    o Using a decorator instead of a plain message
---
 .../directory/api/ldap/codec/LdapControlTest.java  | 190 +++++++------------
 .../directory/api/ldap/codec/LdapMessageTest.java  |  63 +++----
 .../api/ldap/codec/abandon/AbandonRequestTest.java | 185 +++++--------------
 .../api/ldap/codec/del/DelRequestTest.java         | 201 ++++-----------------
 .../api/ldap/codec/unbind/UnBindRequestTest.java   |  96 ++++------
 5 files changed, 206 insertions(+), 529 deletions(-)

diff --git a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/LdapControlTest.java b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/LdapControlTest.java
index f6e0c9e..0ca43f8 100644
--- a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/LdapControlTest.java
+++ b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/LdapControlTest.java
@@ -65,28 +65,28 @@ public class LdapControlTest extends AbstractCodecServiceTest
         ByteBuffer stream = ByteBuffer.allocate( 0x64 );
         stream.put( new byte[]
             { 
-                0x30, 0x62,                       // LDAPMessage ::=SEQUENCE {
-                  0x02, 0x01, 0x03,               // messageID MessageID
-                    0x50, 0x01, 0x02,             // CHOICE { ..., abandonRequest
-                                                // AbandonRequest,...
-                  ( byte ) 0xA0, 0x5A,            // controls [0] Controls OPTIONAL }
-                    0x30, 0x1A,                   // Control ::= SEQUENCE {
-                      0x04, 0x0D,                 // controlType LDAPOID,
+                0x30, 0x62,                         // LDAPMessage ::=SEQUENCE {
+                  0x02, 0x01, 0x03,                 // messageID MessageID
+                    0x50, 0x01, 0x02,               // CHOICE { ..., abandonRequest
+                                                    // AbandonRequest,...
+                  ( byte ) 0xA0, 0x5A,              // controls [0] Controls OPTIONAL }
+                    0x30, 0x1A,                     // Control ::= SEQUENCE {
+                      0x04, 0x0D,                   // controlType LDAPOID,
                         '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '1',
-                      0x01, 0x01, ( byte ) 0xFF,  // criticality BOOLEAN DEFAULT FALSE, 
-                      0x04, 0x06,                 // controlValue OCTET STRING OPTIONAL }
+                      0x01, 0x01, ( byte ) 0xFF,    // criticality BOOLEAN DEFAULT FALSE, 
+                      0x04, 0x06,                   // controlValue OCTET STRING OPTIONAL }
                         'a', 'b', 'c', 'd', 'e', 'f',
-                    0x30, 0x17,                   // Control ::= SEQUENCE {
-                      0x04, 0x0D,                 // controlType LDAPOID,
+                    0x30, 0x17,                     // Control ::= SEQUENCE {
+                      0x04, 0x0D,                   // controlType LDAPOID,
                         '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
-                      0x04, 0x06,                 // controlValue OCTET STRING OPTIONAL }
+                      0x04, 0x06,                   // controlValue OCTET STRING OPTIONAL }
                         'g', 'h', 'i', 'j', 'k', 'l',
-                    0x30, 0x12,                   // Control ::= SEQUENCE {
-                      0x04, 0x0D,                 // controlType LDAPOID,
+                    0x30, 0x12,                     // Control ::= SEQUENCE {
+                      0x04, 0x0D,                   // controlType LDAPOID,
                         '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '3',
-                      0x01, 0x01, ( byte ) 0xFF,  // criticality BOOLEAN DEFAULT FALSE}
-                    0x30, 0x0F,                   // Control ::= SEQUENCE {
-                      0x04, 0x0D,                 // controlType LDAPOID}
+                      0x01, 0x01, ( byte ) 0xFF,    // criticality BOOLEAN DEFAULT FALSE}
+                    0x30, 0x0F,                     // Control ::= SEQUENCE {
+                      0x04, 0x0D,                   // controlType LDAPOID}
                         '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '4' 
             } );
 
@@ -150,7 +150,7 @@ public class LdapControlTest extends AbstractCodecServiceTest
         // Check the encoding
         try
         {
-            ByteBuffer bb = encoder.encodeMessage( internalAbandonRequest );
+            ByteBuffer bb = encoder.encodeMessage( new AbandonRequestDecorator( codec, internalAbandonRequest ) );
 
             // Check the length
             assertEquals( 0x64, bb.limit() );
@@ -190,11 +190,11 @@ public class LdapControlTest extends AbstractCodecServiceTest
         ByteBuffer stream = ByteBuffer.allocate( 0x0A );
         stream.put( new byte[]
             { 
-                0x30, 0x08,                       // LDAPMessage ::=SEQUENCE {
-                  0x02, 0x01, 0x03,               // messageID MessageID
-                    0x50, 0x01, 0x02,             // CHOICE { ..., abandonRequest
-                                                // AbandonRequest,...
-                  ( byte ) 0xA0, 0x00             // controls [0] Controls OPTIONAL }
+                0x30, 0x08,                         // LDAPMessage ::=SEQUENCE {
+                  0x02, 0x01, 0x03,                 // messageID MessageID
+                    0x50, 0x01, 0x02,               // CHOICE { ..., abandonRequest
+                                                    // AbandonRequest,...
+                  ( byte ) 0xA0, 0x00               // controls [0] Controls OPTIONAL }
             } );
 
         stream.flip();
@@ -232,7 +232,7 @@ public class LdapControlTest extends AbstractCodecServiceTest
         // Check the encoding
         try
         {
-            ByteBuffer bb = encoder.encodeMessage( internalAbandonRequest );
+            ByteBuffer bb = encoder.encodeMessage( new AbandonRequestDecorator( codec, internalAbandonRequest ) );
 
             // Check the length, which should be 2 bytes shorter, as we don't encode teh empty control
             assertEquals( 0x08, bb.limit() );
@@ -271,34 +271,18 @@ public class LdapControlTest extends AbstractCodecServiceTest
 
         ByteBuffer stream = ByteBuffer.allocate( 0x19 );
         stream.put( new byte[]
-            { 0x30, 0x17, // LDAPMessage ::=SEQUENCE {
-                0x02,
-                0x01,
-                0x03, // messageID MessageID
-                0x50,
-                0x01,
-                0x02, // CHOICE { ..., abandonRequest
-                // AbandonRequest,...
-                ( byte ) 0xA0,
-                0x0F, // controls [0] Controls OPTIONAL }
-                0x30,
-                0x0D, // Control ::= SEQUENCE {
-                // controlType LDAPOID,
-                0x04,
-                0x00,
-                // criticality BOOLEAN DEFAULT FALSE,
-                0x01,
-                0x01,
-                ( byte ) 0xFF,
-                // controlValue OCTET STRING OPTIONAL }
-                0x04,
-                0x06,
-                'a',
-                'b',
-                'c',
-                'd',
-                'e',
-                'f', } );
+            { 
+                0x30, 0x17,                         // LDAPMessage ::=SEQUENCE {
+                  0x02, 0x01, 0x03,                 // messageID MessageID
+                0x50, 0x01, 0x02,                   // CHOICE { ..., abandonRequest
+                                                    // AbandonRequest,...
+                ( byte ) 0xA0, 0x0F,                // controls [0] Controls OPTIONAL }
+                  0x30, 0x0D,                       // Control ::= SEQUENCE {
+                    0x04, 0x00,                     // controlType LDAPOID,
+                    0x01, 0x01, ( byte ) 0xFF,      // criticality BOOLEAN DEFAULT FALSE,
+                    0x04, 0x06,                     // controlValue OCTET STRING OPTIONAL }
+                      'a', 'b', 'c', 'd', 'e', 'f', 
+            } );
 
         stream.flip();
 
@@ -331,41 +315,20 @@ public class LdapControlTest extends AbstractCodecServiceTest
 
         ByteBuffer stream = ByteBuffer.allocate( 0x20 );
         stream.put( new byte[]
-            { 0x30, 0x1E, // LDAPMessage ::=SEQUENCE {
-                0x02,
-                0x01,
-                0x03, // messageID MessageID
-                0x50,
-                0x01,
-                0x02, // CHOICE { ..., abandonRequest
-                // AbandonRequest,...
-                ( byte ) 0xA0,
-                0x16, // controls [0] Controls OPTIONAL }
-                0x30,
-                0x14, // Control ::= SEQUENCE {
-                // controlType LDAPOID,
-                0x04,
-                0x07,
-                'b',
-                'a',
-                'd',
-                ' ',
-                'o',
-                'i',
-                'd',
-                // criticality BOOLEAN DEFAULT FALSE,
-                0x01,
-                0x01,
-                ( byte ) 0xFF,
-                // controlValue OCTET STRING OPTIONAL }
-                0x04,
-                0x06,
-                'a',
-                'b',
-                'c',
-                'd',
-                'e',
-                'f', } );
+            { 
+                0x30, 0x1E,                         // LDAPMessage ::=SEQUENCE {
+                  0x02, 0x01, 0x03,                 // messageID MessageID
+                0x50, 0x01, 0x02,                   // CHOICE { ..., abandonRequest
+                                                    // AbandonRequest,...
+                ( byte ) 0xA0, 0x16,                // controls [0] Controls OPTIONAL }
+                  0x30, 0x14,                       // Control ::= SEQUENCE {
+                                                    // controlType LDAPOID,
+                    0x04, 0x07,                     // criticality BOOLEAN DEFAULT FALSE,
+                      'b', 'a', 'd', ' ', 'o', 'i', 'd',
+                    0x01, 0x01, ( byte ) 0xFF,
+                    0x04, 0x06,                     // controlValue OCTET STRING OPTIONAL }
+                      'a', 'b', 'c', 'd', 'e', 'f', 
+            } );
 
         stream.flip();
 
@@ -398,46 +361,19 @@ public class LdapControlTest extends AbstractCodecServiceTest
 
         ByteBuffer stream = ByteBuffer.allocate( 0x25 );
         stream.put( new byte[]
-            { 0x30, 0x23, // LDAPMessage ::=SEQUENCE {
-                0x02,
-                0x01,
-                0x03, // messageID MessageID
-                0x50,
-                0x01,
-                0x02, // CHOICE { ..., abandonRequest
-                // AbandonRequest,...
-                ( byte ) 0xA0,
-                0x1B, // controls [0] Controls OPTIONAL }
-                0x30,
-                0x19, // Control ::= SEQUENCE {
-                // controlType LDAPOID,
-                0x04,
-                0x0D,
-                '1',
-                '.',
-                '3',
-                '.',
-                '6',
-                '.',
-                '1',
-                '.',
-                '5',
-                '.',
-                '5',
-                '.',
-                '1',
-                // criticality BOOLEAN DEFAULT FALSE,
-                0x01,
-                0x00,
-                // controlValue OCTET STRING OPTIONAL }
-                0x04,
-                0x06,
-                'a',
-                'b',
-                'c',
-                'd',
-                'e',
-                'f', } );
+            { 
+                0x30, 0x23,                         // LDAPMessage ::=SEQUENCE {
+                  0x02, 0x01, 0x03,                 // messageID MessageID
+                0x50, 0x01, 0x02,                   // CHOICE { ..., abandonRequest
+                                                    // AbandonRequest,...
+                ( byte ) 0xA0, 0x1B,                // controls [0] Controls OPTIONAL }
+                  0x30, 0x19,                       // Control ::= SEQUENCE {
+                                                    // controlType LDAPOID,
+                    0x04, 0x0D,
+                      '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '1',
+                    0x01, 0x00,                     // criticality BOOLEAN DEFAULT FALSE,
+                    0x04, 0x06,                     // controlValue OCTET STRING OPTIONAL }
+                    'a', 'b', 'c', 'd', 'e', 'f', } );
 
         stream.flip();
 
diff --git a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/LdapMessageTest.java b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/LdapMessageTest.java
index 80f6c7f..ade1b5a 100644
--- a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/LdapMessageTest.java
+++ b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/LdapMessageTest.java
@@ -65,7 +65,8 @@ public class LdapMessageTest extends AbstractCodecServiceTest
 
         ByteBuffer stream = ByteBuffer.allocate( 0x02 );
         stream.put( new byte[]
-            { 0x30, 0x00, // LDAPMessage ::=SEQUENCE {
+            { 
+                0x30, 0x00, // LDAPMessage ::=SEQUENCE {
             } );
 
         stream.flip();
@@ -99,10 +100,10 @@ public class LdapMessageTest extends AbstractCodecServiceTest
 
         ByteBuffer stream = ByteBuffer.allocate( 0x04 );
         stream.put( new byte[]
-            { 0x30, 0x02, // LDAPMessage ::=SEQUENCE {
-                0x02,
-                0x00 // messageID MessageID
-        } );
+            { 
+                0x30, 0x02,                         // LDAPMessage ::=SEQUENCE {
+                  0x02, 0x00                        // messageID MessageID
+            } );
 
         stream.flip();
 
@@ -135,11 +136,10 @@ public class LdapMessageTest extends AbstractCodecServiceTest
 
         ByteBuffer stream = ByteBuffer.allocate( 0x05 );
         stream.put( new byte[]
-            { 0x30, 0x03, // LDAPMessage ::=SEQUENCE {
-                0x02,
-                0x01,
-                ( byte ) 0xff // messageID MessageID = -1
-        } );
+            { 
+                0x30, 0x03,                         // LDAPMessage ::=SEQUENCE {
+                  0x02, 0x01, ( byte ) 0xff         // messageID MessageID = -1
+            } );
 
         stream.flip();
 
@@ -172,14 +172,11 @@ public class LdapMessageTest extends AbstractCodecServiceTest
 
         ByteBuffer stream = ByteBuffer.allocate( 0x08 );
         stream.put( new byte[]
-            { 0x30, 0x06, // LDAPMessage ::=SEQUENCE {
-                // messageID MessageID = -1
-                0x02,
-                0x04,
-                ( byte ) 0x7f,
-                ( byte ) 0xff,
-                ( byte ) 0xff,
-                ( byte ) 0xff } );
+            { 
+                0x30, 0x06,                         // LDAPMessage ::=SEQUENCE {
+                  0x02, 0x04,                       // messageID MessageID = -1
+                    ( byte ) 0x7f,( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff 
+            } );
 
         stream.flip();
 
@@ -207,15 +204,12 @@ public class LdapMessageTest extends AbstractCodecServiceTest
     @Test
     public void testDecodeWrongProtocolOpMaxInt()
     {
-
         byte[] buffer = new byte[]
-            { 0x30, 0x05, // LDAPMessage ::=SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID = 1
-                0x42,
-                0x00 // ProtocolOp
-        };
+            { 
+                0x30, 0x05,                         // LDAPMessage ::=SEQUENCE {
+                  0x02, 0x01, 0x01,                 // messageID MessageID = 1
+                  0x42, 0x00                        // ProtocolOp
+            };
 
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
@@ -298,15 +292,12 @@ public class LdapMessageTest extends AbstractCodecServiceTest
 
         ByteBuffer stream = ByteBuffer.allocate( 0x08 );
         stream.put( new byte[]
-            { 0x30, 0x06, // LDAPMessage ::=SEQUENCE {
-                0x02,
-                0x02,
-                0x01,
-                ( byte ) 0xF4, // messageID MessageID (500)
-                0x42,
-                0x00, // CHOICE { ..., unbindRequest UnbindRequest,...
-            // UnbindRequest ::= [APPLICATION 2] NULL
-        } );
+            { 
+                0x30, 0x06,                         // LDAPMessage ::=SEQUENCE {
+                  0x02, 0x02, 0x01, ( byte ) 0xF4,  // messageID MessageID (500)
+                  0x42, 0x00,                       // CHOICE { ..., unbindRequest UnbindRequest,...
+                                                    // UnbindRequest ::= [APPLICATION 2] NULL
+            } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
@@ -335,7 +326,7 @@ public class LdapMessageTest extends AbstractCodecServiceTest
 
         try
         {
-            ByteBuffer bb = encoder.encodeMessage( internalUnbindRequest );
+            ByteBuffer bb = encoder.encodeMessage( new UnbindRequestDecorator( codec, internalUnbindRequest ) );
 
             // Check the length
             assertEquals( 0x08, bb.limit() );
diff --git a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/abandon/AbandonRequestTest.java b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/abandon/AbandonRequestTest.java
index 0527bd7..732189c 100644
--- a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/abandon/AbandonRequestTest.java
+++ b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/abandon/AbandonRequestTest.java
@@ -67,114 +67,30 @@ public class AbandonRequestTest extends AbstractCodecServiceTest
 
         ByteBuffer stream = ByteBuffer.allocate( 0x64 );
         stream.put( new byte[]
-            { 0x30, 0x62, // LDAPMessage ::=SEQUENCE {
-                0x02,
-                0x01,
-                0x03, // messageID MessageID
-                0x50,
-                0x01,
-                0x02, // CHOICE { ..., abandonRequest
-                // AbandonRequest,...
-                ( byte ) 0xA0,
-                0x5A, // controls [0] Controls OPTIONAL }
-                0x30,
-                0x1A, // Control ::= SEQUENCE {
-                      // controlType LDAPOID,
-                0x04,
-                0x0D,
-                '1',
-                '.',
-                '3',
-                '.',
-                '6',
-                '.',
-                '1',
-                '.',
-                '5',
-                '.',
-                '5',
-                '.',
-                '1',
-                // criticality BOOLEAN DEFAULT FALSE,
-                0x01,
-                0x01,
-                ( byte ) 0xFF,
-                // controlValue OCTET STRING OPTIONAL }
-                0x04,
-                0x06,
-                'a',
-                'b',
-                'c',
-                'd',
-                'e',
-                'f',
-                0x30,
-                0x17, // Control ::= SEQUENCE {
-                      // controlType LDAPOID,
-                0x04,
-                0x0D,
-                '1',
-                '.',
-                '3',
-                '.',
-                '6',
-                '.',
-                '1',
-                '.',
-                '5',
-                '.',
-                '5',
-                '.',
-                '2',
-                // controlValue OCTET STRING OPTIONAL }
-                0x04,
-                0x06,
-                'g',
-                'h',
-                'i',
-                'j',
-                'k',
-                'l',
-                0x30,
-                0x12, // Control ::= SEQUENCE {
-                      // controlType LDAPOID,
-                0x04,
-                0x0D,
-                '1',
-                '.',
-                '3',
-                '.',
-                '6',
-                '.',
-                '1',
-                '.',
-                '5',
-                '.',
-                '5',
-                '.',
-                '3',
-                // criticality BOOLEAN DEFAULT FALSE }
-                0x01,
-                0x01,
-                ( byte ) 0xFF,
-                0x30,
-                0x0F, // Control ::= SEQUENCE {
-                      // controlType LDAPOID}
-                0x04,
-                0x0D,
-                '1',
-                '.',
-                '3',
-                '.',
-                '6',
-                '.',
-                '1',
-                '.',
-                '5',
-                '.',
-                '5',
-                '.',
-                '4' } );
+            {
+              0x30, 0x62,                               // LDAPMessage ::=SEQUENCE {
+                0x02, 0x01, 0x03,                       // messageID MessageID
+                0x50, 0x01, 0x02,                       // CHOICE { ..., abandonRequest
+                ( byte ) 0xA0, 0x5A,                    // controls [0] Controls OPTIONAL }
+                  0x30, 0x1A,                           // Control ::= SEQUENCE {
+                    0x04, 0x0D,                         // controlType LDAPOID,
+                      '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '1',
+                    0x01, 0x01, ( byte ) 0xFF,          // criticality BOOLEAN DEFAULT FALSE,
+                    0x04, 0x06,                         // controlValue OCTET STRING OPTIONAL }
+                      'a', 'b', 'c', 'd', 'e', 'f',
+                  0x30, 0x17,                           // Control ::= SEQUENCE {
+                    0x04, 0x0D,                         // controlType LDAPOID,
+                      '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+                    0x04, 0x06,                         // controlValue OCTET STRING OPTIONAL }
+                      'g', 'h', 'i', 'j', 'k', 'l',
+                  0x30, 0x12,                           // Control ::= SEQUENCE {
+                    0x04, 0x0D,                         // controlType LDAPOID,
+                      '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '3',
+                    0x01, 0x01, ( byte ) 0xFF,          // criticality BOOLEAN DEFAULT FALSE }
+                  0x30, 0x0F,                           // Control ::= SEQUENCE {
+                    0x04, 0x0D,                         // controlType LDAPOID}
+                      '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '4' 
+            } );
 
         stream.flip();
 
@@ -236,7 +152,7 @@ public class AbandonRequestTest extends AbstractCodecServiceTest
         // Check the encoding
         try
         {
-            ByteBuffer bb = encoder.encodeMessage( internalAbandonRequest );
+            ByteBuffer bb = encoder.encodeMessage( new AbandonRequestDecorator( codec, internalAbandonRequest ) );
 
             // Check the length
             assertEquals( 0x64, bb.limit() );
@@ -274,19 +190,13 @@ public class AbandonRequestTest extends AbstractCodecServiceTest
 
         ByteBuffer stream = ByteBuffer.allocate( 0x0A );
         stream.put( new byte[]
-            { 0x30, 0x08, // LDAPMessage ::=SEQUENCE {
-                // messageID MessageID
-                0x02,
-                0x03,
-                0x00,
-                ( byte ) 0x80,
-                0x13,
-                0x50,
-                0x01,
-                0x02 // CHOICE { ..., abandonRequest
-            // AbandonRequest,...
-            // AbandonRequest ::= [APPLICATION 16] MessageID
-        } );
+            { 
+              0x30, 0x08,                                   // LDAPMessage ::=SEQUENCE {
+                0x02, 0x03, 0x00, ( byte ) 0x80, 0x13,      // messageID MessageID
+                0x50, 0x01, 0x02                            // CHOICE { ..., abandonRequest
+                                                            // AbandonRequest,...
+                                                            // AbandonRequest ::= [APPLICATION 16] MessageID
+            } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
@@ -319,7 +229,7 @@ public class AbandonRequestTest extends AbstractCodecServiceTest
         // Check the encoding
         try
         {
-            ByteBuffer bb = encoder.encodeMessage( internalAbandonRequest );
+            ByteBuffer bb = encoder.encodeMessage(  new AbandonRequestDecorator( codec, internalAbandonRequest )  );
 
             // Check the length
             assertEquals( 0x0A, bb.limit() );
@@ -346,14 +256,12 @@ public class AbandonRequestTest extends AbstractCodecServiceTest
 
         ByteBuffer stream = ByteBuffer.allocate( 0x0A );
         stream.put( new byte[]
-            { 0x30, 0x08, // LDAPMessage ::=SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                0x50,
-                0x00 // CHOICE { ..., abandonRequest AbandonRequest,...
-            // AbandonRequest ::= [APPLICATION 16] MessageID
-        } );
+            {
+              0x30, 0x08,               // LDAPMessage ::=SEQUENCE {
+                0x02, 0x01, 0x01,       // messageID MessageID
+                0x50, 0x00              // CHOICE { ..., abandonRequest AbandonRequest,...
+                                        // AbandonRequest ::= [APPLICATION 16] MessageID
+            } );
 
         stream.flip();
 
@@ -386,15 +294,12 @@ public class AbandonRequestTest extends AbstractCodecServiceTest
 
         ByteBuffer stream = ByteBuffer.allocate( 0x0B );
         stream.put( new byte[]
-            { 0x30, 0x09, // LDAPMessage ::=SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                0x50,
-                0x01,
-                ( byte ) 0xFF // CHOICE { ..., abandonRequest AbandonRequest,...
-            // AbandonRequest ::= [APPLICATION 16] MessageID
-        } );
+            { 
+              0x30, 0x09,                   // LDAPMessage ::=SEQUENCE {
+                0x02, 0x01, 0x01,           // messageID MessageID
+                0x50, 0x01, ( byte ) 0xFF   // CHOICE { ..., abandonRequest AbandonRequest,...
+                                            // AbandonRequest ::= [APPLICATION 16] MessageID
+            } );
 
         stream.flip();
 
diff --git a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/del/DelRequestTest.java b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/del/DelRequestTest.java
index 9e5f4a3..89f348d 100644
--- a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/del/DelRequestTest.java
+++ b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/del/DelRequestTest.java
@@ -69,47 +69,15 @@ public class DelRequestTest extends AbstractCodecServiceTest
         ByteBuffer stream = ByteBuffer.allocate( 0x27 );
 
         stream.put( new byte[]
-            { 0x30,
-                0x25, // LDAPMessage ::= SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                // CHOICE { ..., delRequest DelRequest, ...
-                // DelRequest ::= [APPLICATION 10] LDAPDN;
-                0x4A,
-                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' } );
+            { 
+              0x30, 0x25,               // LDAPMessage ::= SEQUENCE {
+                0x02, 0x01, 0x01,       // messageID MessageID
+                                        // CHOICE { ..., delRequest DelRequest, ...
+                                        // DelRequest ::= [APPLICATION 10] LDAPDN;
+                0x4A, 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' 
+            } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
@@ -143,7 +111,7 @@ public class DelRequestTest extends AbstractCodecServiceTest
         // Check the encoding
         try
         {
-            ByteBuffer bb = encoder.encodeMessage( internalDeleteRequest );
+            ByteBuffer bb = encoder.encodeMessage( new DeleteRequestDecorator( codec, internalDeleteRequest ) );
 
             // Check the length
             assertEquals( 0x27, bb.limit() );
@@ -171,47 +139,15 @@ public class DelRequestTest extends AbstractCodecServiceTest
         ByteBuffer stream = ByteBuffer.allocate( 0x27 );
 
         stream.put( new byte[]
-            { 0x30,
-                0x25, // LDAPMessage ::= SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                // CHOICE { ..., delRequest DelRequest, ...
-                // DelRequest ::= [APPLICATION 10] LDAPDN;
-                0x4A,
-                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' } );
+            {
+              0x30, 0x25,               // LDAPMessage ::= SEQUENCE {
+                0x02, 0x01, 0x01,       // messageID MessageID
+                                        // CHOICE { ..., delRequest DelRequest, ...
+                                        // DelRequest ::= [APPLICATION 10] LDAPDN;
+                0x4A, 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' 
+            } );
 
         stream.flip();
 
@@ -249,14 +185,12 @@ public class DelRequestTest extends AbstractCodecServiceTest
         ByteBuffer stream = ByteBuffer.allocate( 0x07 );
 
         stream.put( new byte[]
-            { 0x30, 0x05, // LDAPMessage ::= SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                // CHOICE { ..., delRequest DelRequest, ...
-                // DelRequest ::= [APPLICATION 10] LDAPDN;
-                0x4A,
-                0x00 // Empty Dn
+            { 
+              0x30, 0x05,               // LDAPMessage ::= SEQUENCE {
+                0x02, 0x01, 0x01,       // messageID MessageID
+                                        // CHOICE { ..., delRequest DelRequest, ...
+                                        // DelRequest ::= [APPLICATION 10] LDAPDN;
+                0x4A, 0x00              // Empty Dn
         } );
 
         stream.flip();
@@ -290,76 +224,19 @@ public class DelRequestTest extends AbstractCodecServiceTest
 
         stream.put( new byte[]
             {
-                0x30,
-                0x42, // LDAPMessage ::= SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                // CHOICE { ..., delRequest DelRequest, ...
-                // DelRequest ::= [APPLICATION 10] LDAPDN;
-                0x4A,
-                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',
-                ( byte ) 0xA0,
-                0x1B, // A control
-                0x30,
-                0x19,
-                0x04,
-                0x17,
-                0x32,
-                0x2E,
-                0x31,
-                0x36,
-                0x2E,
-                0x38,
-                0x34,
-                0x30,
-                0x2E,
-                0x31,
-                0x2E,
-                0x31,
-                0x31,
-                0x33,
-                0x37,
-                0x33,
-                0x30,
-                0x2E,
-                0x33,
-                0x2E,
-                0x34,
-                0x2E,
-                0x32 } );
+              0x30, 0x42,               // LDAPMessage ::= SEQUENCE {
+                0x02, 0x01, 0x01,       // messageID MessageID
+                                        // CHOICE { ..., delRequest DelRequest, ...
+                                        // DelRequest ::= [APPLICATION 10] LDAPDN;
+                0x4A, 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',
+                ( byte ) 0xA0, 0x1B,    // A control
+                  0x30, 0x19,
+                    0x04, 0x17,
+                      '2', '.', '1', '6', '.', '8', '4', '0', '.', '1', '.', '1', '1', '3', 
+                      '7', '3', '0', '.', '3', '.', '4', '.', '2'
+            } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
@@ -404,7 +281,7 @@ public class DelRequestTest extends AbstractCodecServiceTest
         // Check the encoding
         try
         {
-            ByteBuffer bb = encoder.encodeMessage( internalDeleteRequest );
+            ByteBuffer bb = encoder.encodeMessage( new DeleteRequestDecorator( codec, internalDeleteRequest ) );
 
             // Check the length
             assertEquals( 0x44, bb.limit() );
diff --git a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/unbind/UnBindRequestTest.java b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/unbind/UnBindRequestTest.java
index 3c36e67..6956276 100644
--- a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/unbind/UnBindRequestTest.java
+++ b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/unbind/UnBindRequestTest.java
@@ -62,21 +62,19 @@ public class UnBindRequestTest extends AbstractCodecServiceTest
 
         ByteBuffer stream = ByteBuffer.allocate( 0x07 );
         stream.put( new byte[]
-            { 0x30, 0x05, // LDAPMessage ::=SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                0x42,
-                0x00, // CHOICE { ..., unbindRequest UnbindRequest,...
-            // UnbindRequest ::= [APPLICATION 2] NULL
-        } );
+            { 
+              0x30, 0x05,               // LDAPMessage ::=SEQUENCE {
+                0x02, 0x01, 0x01,       // messageID MessageID
+                0x42, 0x00,             // CHOICE { ..., unbindRequest UnbindRequest,...
+                                        // UnbindRequest ::= [APPLICATION 2] NULL
+            } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
-        LdapMessageContainer<UnbindRequestDecorator> ldapMessageContainer = new LdapMessageContainer<UnbindRequestDecorator>(
-            codec );
+        LdapMessageContainer<UnbindRequestDecorator> ldapMessageContainer = 
+                new LdapMessageContainer<UnbindRequestDecorator>( codec );
 
         try
         {
@@ -98,7 +96,7 @@ public class UnBindRequestTest extends AbstractCodecServiceTest
 
         try
         {
-            ByteBuffer bb = encoder.encodeMessage( internalUnbindRequest );
+            ByteBuffer bb = encoder.encodeMessage( new UnbindRequestDecorator( codec, internalUnbindRequest ) );
 
             // Check the length
             assertEquals( 0x07, bb.limit() );
@@ -125,50 +123,24 @@ public class UnBindRequestTest extends AbstractCodecServiceTest
 
         ByteBuffer stream = ByteBuffer.allocate( 0x24 );
         stream.put( new byte[]
-            { 0x30,
-                0x22, // LDAPMessage ::=SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                0x42,
-                0x00, // CHOICE { ..., unbindRequest UnbindRequest,...
-                // UnbindRequest ::= [APPLICATION 2] NULL
-                ( byte ) 0xA0,
-                0x1B, // A control
-                0x30,
-                0x19,
-                0x04,
-                0x17,
-                '2',
-                '.',
-                '1',
-                '6',
-                '.',
-                '8',
-                '4',
-                '0',
-                '.',
-                '1',
-                '.',
-                '1',
-                '1',
-                '3',
-                '7',
-                '3',
-                '0',
-                '.',
-                '3',
-                '.',
-                '4',
-                '.',
-                '2' } );
+            { 
+              0x30, 0x22,               // LDAPMessage ::=SEQUENCE {
+                0x02, 0x01, 0x01,       // messageID MessageID
+                0x42, 0x00,             // CHOICE { ..., unbindRequest UnbindRequest,...
+                                        // UnbindRequest ::= [APPLICATION 2] NULL
+                ( byte ) 0xA0, 0x1B,    // A control
+                  0x30, 0x19,
+                    0x04, 0x17,
+                      '2', '.', '1', '6', '.', '8', '4', '0', '.', '1', '.', 
+                      '1', '1', '3', '7', '3', '0', '.', '3', '.', '4', '.', '2'
+            } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
-        LdapMessageContainer<UnbindRequestDecorator> ldapMessageContainer = new LdapMessageContainer<UnbindRequestDecorator>(
-            codec );
+        LdapMessageContainer<UnbindRequestDecorator> ldapMessageContainer = 
+                new LdapMessageContainer<UnbindRequestDecorator>( codec );
 
         try
         {
@@ -190,7 +162,7 @@ public class UnBindRequestTest extends AbstractCodecServiceTest
         assertEquals( 1, controls.size() );
 
         @SuppressWarnings("unchecked")
-        CodecControl<Control> control = ( org.apache.directory.api.ldap.codec.api.CodecControl<Control> ) controls
+        CodecControl<Control> control = ( CodecControl<Control> ) controls
             .get( "2.16.840.1.113730.3.4.2" );
         assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
         assertEquals( "", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
@@ -202,7 +174,7 @@ public class UnBindRequestTest extends AbstractCodecServiceTest
 
         try
         {
-            ByteBuffer bb = encoder.encodeMessage( internalUnbindRequest );
+            ByteBuffer bb = encoder.encodeMessage( new UnbindRequestDecorator( codec, internalUnbindRequest ) );
 
             // Check the length
             assertEquals( 0x24, bb.limit() );
@@ -229,22 +201,18 @@ public class UnBindRequestTest extends AbstractCodecServiceTest
 
         ByteBuffer stream = ByteBuffer.allocate( 0x09 );
         stream.put( new byte[]
-            { 0x30, 0x07, // LDAPMessage ::=SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                0x42,
-                0x02, // CHOICE { ..., unbindRequest UnbindRequest,...
-                0x04,
-                0x00 // UnbindRequest ::= [APPLICATION 2] NULL
-
-        } );
+            { 
+              0x30, 0x07,               // LDAPMessage ::=SEQUENCE {
+                0x02, 0x01, 0x01,       // messageID MessageID
+                0x42, 0x02,             // CHOICE { ..., unbindRequest UnbindRequest,...
+                  0x04, 0x00            // UnbindRequest ::= [APPLICATION 2] NULL
+            } );
 
         stream.flip();
 
         // Allocate a LdapMessage Container
-        LdapMessageContainer<UnbindRequestDecorator> ldapMessageContainer = new LdapMessageContainer<UnbindRequestDecorator>(
-            codec );
+        LdapMessageContainer<UnbindRequestDecorator> ldapMessageContainer = 
+                new LdapMessageContainer<UnbindRequestDecorator>( codec );
 
         // Decode a UnbindRequest message
         try