directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r987606 [24/25] - in /directory/shared/trunk: ./ all/ asn1-codec/ asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/ asn1/ asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/ asn1/src/main/java/org/apache/director...
Date Fri, 20 Aug 2010 19:23:37 GMT
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java Fri Aug 20 19:23:27 2010
@@ -25,7 +25,7 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import java.nio.ByteBuffer;
-import java.util.List;
+import java.util.Map;
 
 import org.apache.directory.junit.tools.Concurrent;
 import org.apache.directory.junit.tools.ConcurrentJunitRunner;
@@ -34,7 +34,9 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.message.LdapProtocolEncoder;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.SearchResultDone;
 import org.apache.directory.shared.ldap.message.control.Control;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Test;
@@ -50,6 +52,9 @@ import org.junit.runner.RunWith;
 @Concurrent()
 public class SearchResultDoneTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
 
     /**
      * Test the decoding of a SearchResultDone
@@ -92,20 +97,20 @@ public class SearchResultDoneTest
             fail( de.getMessage() );
         }
 
-        SearchResultDoneCodec searchResultDone = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultDone();
+        SearchResultDone searchResultDone = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultDone();
 
         assertEquals( 1, searchResultDone.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, searchResultDone.getLdapResult().getResultCode() );
-        assertEquals( "", searchResultDone.getLdapResult().getMatchedDN() );
+        assertEquals( "", searchResultDone.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", searchResultDone.getLdapResult().getErrorMessage() );
 
-        // Check the length
-        assertEquals( 0x0E, searchResultDone.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = searchResultDone.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultDone );
+
+            // Check the length
+            assertEquals( 0x0E, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -130,19 +135,27 @@ public class SearchResultDoneTest
         ByteBuffer stream = ByteBuffer.allocate( 0x2B );
 
         stream.put( new byte[]
-            { 0x30, 0x29, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x65, 0x07, // CHOICE { ..., delResponse DelResponse, ...
+            { 0x30,
+                0x29, // LDAPMessage ::=SEQUENCE {
+                0x02, 0x01,
+                0x01, // messageID MessageID
+                0x65,
+                0x07, // CHOICE { ..., delResponse DelResponse, ...
                 // SearchResultDone ::= [APPLICATION 5] LDAPResult
-                0x0A, 0x01, 0x00, // LDAPResult ::= SEQUENCE {
+                0x0A,
+                0x01,
+                0x00, // LDAPResult ::= SEQUENCE {
                 // resultCode ENUMERATED {
                 // success (0), ...
                 // },
-                0x04, 0x00, // matchedDN LDAPDN,
-                0x04, 0x00, // errorMessage LDAPString,
+                0x04,
+                0x00, // matchedDN LDAPDN,
+                0x04,
+                0x00, // errorMessage LDAPString,
                 // referral [3] Referral OPTIONAL }
                 // }
-                ( byte ) 0xA0, 0x1B, // A control
+                ( 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
 
@@ -164,29 +177,29 @@ public class SearchResultDoneTest
             fail( de.getMessage() );
         }
 
-        SearchResultDoneCodec searchResultDone = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultDone();
+        SearchResultDone searchResultDone = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultDone();
 
         assertEquals( 1, searchResultDone.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, searchResultDone.getLdapResult().getResultCode() );
-        assertEquals( "", searchResultDone.getLdapResult().getMatchedDN() );
+        assertEquals( "", searchResultDone.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", searchResultDone.getLdapResult().getErrorMessage() );
 
         // Check the Control
-        List<Control> controls = searchResultDone.getControls();
+        Map<String, Control> controls = searchResultDone.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = searchResultDone.getControls( 0 );
+        Control control = controls.get( "2.16.840.1.113730.3.4.2" );
         assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
         assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) );
 
-        // Check the length
-        assertEquals( 0x2B, searchResultDone.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = searchResultDone.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultDone );
+
+            // Check the length
+            assertEquals( 0x2B, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntryTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntryTest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntryTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntryTest.java Fri Aug 20 19:23:27 2010
@@ -25,7 +25,7 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import java.nio.ByteBuffer;
-import java.util.List;
+import java.util.Map;
 
 import javax.naming.NamingException;
 
@@ -38,6 +38,8 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.message.LdapProtocolEncoder;
+import org.apache.directory.shared.ldap.message.SearchResultEntry;
 import org.apache.directory.shared.ldap.message.control.Control;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Test;
@@ -53,6 +55,10 @@ import org.junit.runner.RunWith;
 @Concurrent()
 public class SearchResultEntryTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
+
     /**
      * Test the decoding of a SearchResultEntry
      */
@@ -66,10 +72,14 @@ public class SearchResultEntryTest
         stream.put( new byte[]
             {
 
-            0x30, 0x4e, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x64, 0x49, // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+            0x30,
+                0x4e, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x64,
+                0x49, // CHOICE { ..., searchResEntry SearchResultEntry,
+                // ...
                 // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
                 // objectName LDAPDN,
                 0x04, 0x1b, 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 'i', 'k', 't',
@@ -102,7 +112,8 @@ public class SearchResultEntryTest
             fail( de.getMessage() );
         }
 
-        SearchResultEntryCodec searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultEntry();
+        SearchResultEntry searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getSearchResultEntry();
 
         assertEquals( 1, searchResultEntry.getMessageId() );
         assertEquals( "ou=contacts,dc=iktek,dc=com", searchResultEntry.getObjectName().toString() );
@@ -121,13 +132,13 @@ public class SearchResultEntryTest
             assertTrue( attribute.contains( "organizationalUnit" ) );
         }
 
-        // Check the length
-        assertEquals( 0x50, searchResultEntry.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = searchResultEntry.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultEntry );
+
+            // Check the length
+            assertEquals( 0x50, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -152,14 +163,20 @@ public class SearchResultEntryTest
         ByteBuffer stream = ByteBuffer.allocate( 0x7b );
 
         stream.put( new byte[]
-            { 0x30, 0x79, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x64, 0x74, // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+            {
+                0x30,
+                0x79, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x64,
+                0x74, // CHOICE { ..., searchResEntry SearchResultEntry,
+                // ...
                 // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
                 // objectName LDAPDN,
                 0x04, 0x1b, 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 'i', 'k', 't',
-                'e', 'k', ',', 'd', 'c', '=', 'c', 'o', 'm',
+                'e', 'k', ',', 'd', 'c', '=', 'c', 'o',
+                'm',
                 // attributes PartialAttributeList }
                 // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
                 0x30, 0x55, 0x30, 0x28,
@@ -196,7 +213,8 @@ public class SearchResultEntryTest
             fail( de.getMessage() );
         }
 
-        SearchResultEntryCodec searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultEntry();
+        SearchResultEntry searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getSearchResultEntry();
 
         assertEquals( 1, searchResultEntry.getMessageId() );
         assertEquals( "ou=contacts,dc=iktek,dc=com", searchResultEntry.getObjectName().toString() );
@@ -214,17 +232,17 @@ public class SearchResultEntryTest
 
             assertEquals( expectedAttributes[i].toLowerCase(), attribute.getId().toLowerCase() );
 
-            assertTrue( attribute.contains(  "top" ) );
-            assertTrue( attribute.contains(  "organizationalUnit" ) );
+            assertTrue( attribute.contains( "top" ) );
+            assertTrue( attribute.contains( "organizationalUnit" ) );
         }
 
-        // Check the length
-        assertEquals( 0x7b, searchResultEntry.computeLength() );
-
         // Check the encoding
         try
         {
-            searchResultEntry.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultEntry );
+
+            // Check the length
+            assertEquals( 0x7B, bb.limit() );
 
             // We can't compare the encodings, the order of the attributes has
             // changed
@@ -249,23 +267,34 @@ public class SearchResultEntryTest
         ByteBuffer stream = ByteBuffer.allocate( 0x66 );
 
         stream.put( new byte[]
-            { 0x30, 0x5F, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x02, // messageID MessageID
-                0x64, 0x5A, // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+            {
+                0x30,
+                0x5F, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x02, // messageID MessageID
+                0x64,
+                0x5A, // CHOICE { ..., searchResEntry SearchResultEntry,
+                // ...
                 // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
                 // objectName LDAPDN,
                 0x04, 0x13, 'u', 'i', 'd', '=', 'a', 'd', 'm', 'i', 'n', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e',
                 'm',
                 // attributes PartialAttributeList }
-                0x30, 0x43, // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
+                0x30,
+                0x43, // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
                 0x30, 0x41,
                 // type AttributeDescription,
-                0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's', 0x31, 0x32, // vals
-                                                                                                // SET
-                                                                                                // OF
-                                                                                                // AttributeValue
-                                                                                                // }
+                0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l',
+                'a',
+                's',
+                's',
+                0x31,
+                0x32, // vals
+                // SET
+                // OF
+                // AttributeValue
+                // }
                 // AttributeValue ::= OCTET STRING
                 0x04, 0x0D, 'i', 'n', 'e', 't', 'O', 'r', 'g', 'P', 'e', 'r', 's', 'o', 'n',
                 // AttributeValue ::= OCTET STRING
@@ -275,7 +304,7 @@ public class SearchResultEntryTest
                 0x04, 0x06, 'p', 'e', 'r', 's', 'o', 'n',
                 // AttributeValue ::= OCTET STRING
                 0x04, 0x03, 't', 'o', 'p', 0x30, 0x45, // Start of the next
-                                                        // message
+                // message
                 0x02, 0x01, 0x02 // messageID MessageID ...
             } );
 
@@ -295,7 +324,8 @@ public class SearchResultEntryTest
             fail( de.getMessage() );
         }
 
-        SearchResultEntryCodec searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultEntry();
+        SearchResultEntry searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getSearchResultEntry();
 
         assertEquals( 2, searchResultEntry.getMessageId() );
         assertEquals( "uid=admin,ou=system", searchResultEntry.getObjectName().toString() );
@@ -316,9 +346,6 @@ public class SearchResultEntryTest
             assertTrue( attribute.contains( "inetOrgPerson" ) );
         }
 
-        // Check the length
-        assertEquals( 0x61, searchResultEntry.computeLength() );
-
         // Check that the next bytes is the first of the next PDU
         assertEquals( 0x30, stream.get( stream.position() ) );
         assertEquals( 0x45, stream.get( stream.position() + 1 ) );
@@ -329,7 +356,10 @@ public class SearchResultEntryTest
         // Check the encoding
         try
         {
-            ByteBuffer bb = searchResultEntry.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultEntry );
+
+            // Check the length
+            assertEquals( 0x61, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -363,7 +393,7 @@ public class SearchResultEntryTest
             0x30, 0x05, // LDAPMessage ::=SEQUENCE {
                 0x02, 0x01, 0x01, // messageID MessageID
                 0x64, 0x00 // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+            // ...
             } );
 
         stream.flip();
@@ -399,7 +429,7 @@ public class SearchResultEntryTest
             { 0x30, 0x07, // LDAPMessage ::=SEQUENCE {
                 0x02, 0x01, 0x01, // messageID MessageID
                 0x64, 0x02, // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+                // ...
                 // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
                 // objectName LDAPDN,
                 0x04, 0x00
@@ -436,10 +466,14 @@ public class SearchResultEntryTest
         ByteBuffer stream = ByteBuffer.allocate( 0x24 );
 
         stream.put( new byte[]
-            { 0x30, 0x22, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x64, 0x1D, // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+            { 0x30,
+                0x22, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x64,
+                0x1D, // CHOICE { ..., searchResEntry SearchResultEntry,
+                // ...
                 // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
                 // objectName LDAPDN,
                 0x04, 0x1B, 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 'i', 'k', 't',
@@ -477,10 +511,14 @@ public class SearchResultEntryTest
         ByteBuffer stream = ByteBuffer.allocate( 0x26 );
 
         stream.put( new byte[]
-            { 0x30, 0x24, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x64, 0x1F, // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+            { 0x30,
+                0x24, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x64,
+                0x1F, // CHOICE { ..., searchResEntry SearchResultEntry,
+                // ...
                 // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
                 // objectName LDAPDN,
                 0x04, 0x1B, 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 'i', 'k', 't',
@@ -505,7 +543,8 @@ public class SearchResultEntryTest
             fail( de.getMessage() );
         }
 
-        SearchResultEntryCodec searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultEntry();
+        SearchResultEntry searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getSearchResultEntry();
 
         assertEquals( 1, searchResultEntry.getMessageId() );
         assertEquals( "ou=contacts,dc=iktek,dc=com", searchResultEntry.getObjectName().toString() );
@@ -514,13 +553,13 @@ public class SearchResultEntryTest
 
         assertEquals( 0, entry.size() );
 
-        // Check the length
-        assertEquals( 0x26, searchResultEntry.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = searchResultEntry.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultEntry );
+
+            // Check the length
+            assertEquals( 0x26, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -545,10 +584,14 @@ public class SearchResultEntryTest
         ByteBuffer stream = ByteBuffer.allocate( 0x28 );
 
         stream.put( new byte[]
-            { 0x30, 0x26, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x64, 0x21, // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+            { 0x30,
+                0x26, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x64,
+                0x21, // CHOICE { ..., searchResEntry SearchResultEntry,
+                // ...
                 // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
                 // objectName LDAPDN,
                 0x04, 0x1B, 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 'i', 'k', 't',
@@ -588,25 +631,26 @@ public class SearchResultEntryTest
         ByteBuffer stream = ByteBuffer.allocate( 0x45 );
 
         stream.put( new byte[]
-            { 
-            0x30, 0x43,                 // LDAPMessage ::=SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x64, 0x21,               // CHOICE { ..., searchResEntry SearchResultEntry,
-                                        // ...
-                                        // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
-                                        // objectName LDAPDN,
-                0x04, 0x1B, 
-                  'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 
-                  'i', 'k', 't', 'e', 'k', ',', 'd', 'c', '=', 'c', 'o', 'm',
-                                        // attributes PartialAttributeList }
-                                        // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
-                0x30, 0x02, 
-                  0x30, 0x00, 
-              ( 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,
+                0x43, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x64,
+                0x21, // CHOICE { ..., searchResEntry SearchResultEntry,
+                // ...
+                // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
+                // objectName LDAPDN,
+                0x04, 0x1B, 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 'i', 'k', 't',
+                'e', 'k', ',', 'd', 'c', '=', 'c', 'o',
+                'm',
+                // attributes PartialAttributeList }
+                // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
+                0x30, 0x02, 0x30, 0x00, ( 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' } );
 
         stream.flip();
 
@@ -640,10 +684,14 @@ public class SearchResultEntryTest
         stream.put( new byte[]
             {
 
-            0x30, 0x28, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x64, 0x23, // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+            0x30,
+                0x28, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x64,
+                0x23, // CHOICE { ..., searchResEntry SearchResultEntry,
+                // ...
                 // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
                 // objectName LDAPDN,
                 0x04, 0x1b, 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 'i', 'k', 't',
@@ -686,10 +734,14 @@ public class SearchResultEntryTest
         stream.put( new byte[]
             {
 
-            0x30, 0x33, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x64, 0x2E, // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+            0x30,
+                0x33, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x64,
+                0x2E, // CHOICE { ..., searchResEntry SearchResultEntry,
+                // ...
                 // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
                 // objectName LDAPDN,
                 0x04, 0x1b, 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 'i', 'k', 't',
@@ -732,10 +784,14 @@ public class SearchResultEntryTest
         stream.put( new byte[]
             {
 
-            0x30, 0x35, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x64, 0x30, // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+            0x30,
+                0x35, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x64,
+                0x30, // CHOICE { ..., searchResEntry SearchResultEntry,
+                // ...
                 // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
                 // objectName LDAPDN,
                 0x04, 0x1b, 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 'i', 'k', 't',
@@ -762,7 +818,8 @@ public class SearchResultEntryTest
             fail( de.getMessage() );
         }
 
-        SearchResultEntryCodec searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultEntry();
+        SearchResultEntry searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getSearchResultEntry();
 
         assertEquals( 1, searchResultEntry.getMessageId() );
         assertEquals( "ou=contacts,dc=iktek,dc=com", searchResultEntry.getObjectName().toString() );
@@ -779,13 +836,13 @@ public class SearchResultEntryTest
             assertEquals( 0, attribute.size() );
         }
 
-        // Check the length
-        assertEquals( 0x37, searchResultEntry.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = searchResultEntry.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultEntry );
+
+            // Check the length
+            assertEquals( 0x37, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -812,10 +869,14 @@ public class SearchResultEntryTest
         stream.put( new byte[]
             {
 
-            0x30, 0x46, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x64, 0x41, // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+            0x30,
+                0x46, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x64,
+                0x41, // CHOICE { ..., searchResEntry SearchResultEntry,
+                // ...
                 // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
                 // objectName LDAPDN,
                 0x04, 0x1b, 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 'i', 'k', 't',
@@ -844,7 +905,8 @@ public class SearchResultEntryTest
             fail( de.getMessage() );
         }
 
-        SearchResultEntryCodec searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultEntry();
+        SearchResultEntry searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getSearchResultEntry();
 
         assertEquals( 1, searchResultEntry.getMessageId() );
         assertEquals( "ou=contacts,dc=iktek,dc=com", searchResultEntry.getObjectName().toString() );
@@ -861,13 +923,13 @@ public class SearchResultEntryTest
         assertEquals( "objectClazz".toLowerCase(), attribute.getId().toLowerCase() );
         assertEquals( 0, attribute.size() );
 
-        // Check the length
-        assertEquals( 0x48, searchResultEntry.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = searchResultEntry.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultEntry );
+
+            // Check the length
+            assertEquals( 0x48, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -894,20 +956,26 @@ public class SearchResultEntryTest
         stream.put( new byte[]
             {
 
-            0x30, 0x52, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x64, 0x30, // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+                0x30,
+                0x52, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x64,
+                0x30, // CHOICE { ..., searchResEntry SearchResultEntry,
+                // ...
                 // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
                 // objectName LDAPDN,
                 0x04, 0x1b, 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 'i', 'k', 't',
-                'e', 'k', ',', 'd', 'c', '=', 'c', 'o', 'm',
+                'e', 'k', ',', 'd', 'c', '=', 'c', 'o',
+                'm',
                 // attributes PartialAttributeList }
                 // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
                 0x30, 0x11, 0x30, 0x0F,
                 // type AttributeDescription,
-                0x04, 0x0b, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's', 0x31, 0x00, ( byte ) 0xA0, 0x1B, // A
-                                                                                                                    // control
+                0x04, 0x0b, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's', 0x31, 0x00, ( 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 } );
 
@@ -927,7 +995,8 @@ public class SearchResultEntryTest
             fail( de.getMessage() );
         }
 
-        SearchResultEntryCodec searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultEntry();
+        SearchResultEntry searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getSearchResultEntry();
 
         assertEquals( 1, searchResultEntry.getMessageId() );
         assertEquals( "ou=contacts,dc=iktek,dc=com", searchResultEntry.getObjectName().toString() );
@@ -946,21 +1015,21 @@ public class SearchResultEntryTest
         }
 
         // Check the Control
-        List<Control> controls = searchResultEntry.getControls();
+        Map<String, Control> controls = searchResultEntry.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = searchResultEntry.getControls( 0 );
+        Control control = controls.get( "2.16.840.1.113730.3.4.2" );
         assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
         assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) );
 
-        // Check the length
-        assertEquals( 0x54, searchResultEntry.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = searchResultEntry.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultEntry );
+
+            // Check the length
+            assertEquals( 0x54, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -985,10 +1054,14 @@ public class SearchResultEntryTest
         ByteBuffer stream = ByteBuffer.allocate( 0x39 );
 
         stream.put( new byte[]
-            { 0x30, 0x37, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x64, 0x32, // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+            { 0x30,
+                0x37, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x64,
+                0x32, // CHOICE { ..., searchResEntry SearchResultEntry,
+                // ...
                 // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
                 // objectName LDAPDN,
                 0x04, 0x1b, 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 'i', 'k', 't',
@@ -1019,7 +1092,8 @@ public class SearchResultEntryTest
             fail( de.getMessage() );
         }
 
-        SearchResultEntryCodec searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultEntry();
+        SearchResultEntry searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getSearchResultEntry();
 
         assertEquals( 1, searchResultEntry.getMessageId() );
         assertEquals( "ou=contacts,dc=iktek,dc=com", searchResultEntry.getObjectName().toString() );
@@ -1037,13 +1111,13 @@ public class SearchResultEntryTest
             assertTrue( attribute.contains( "" ) );
         }
 
-        // Check the length
-        assertEquals( 0x39, searchResultEntry.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = searchResultEntry.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultEntry );
+
+            // Check the length
+            assertEquals( 0x39, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -1069,14 +1143,20 @@ public class SearchResultEntryTest
         ByteBuffer stream = ByteBuffer.allocate( 0x56 );
 
         stream.put( new byte[]
-            { 0x30, 0x54, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x64, 0x32, // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+            {
+                0x30,
+                0x54, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x64,
+                0x32, // CHOICE { ..., searchResEntry SearchResultEntry,
+                // ...
                 // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
                 // objectName LDAPDN,
                 0x04, 0x1b, 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 'i', 'k', 't',
-                'e', 'k', ',', 'd', 'c', '=', 'c', 'o', 'm',
+                'e', 'k', ',', 'd', 'c', '=', 'c', 'o',
+                'm',
                 // attributes PartialAttributeList }
                 // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
                 0x30, 0x13, 0x30, 0x11,
@@ -1085,7 +1165,8 @@ public class SearchResultEntryTest
                 // vals SET OF AttributeValue }
                 0x31, 0x02,
                 // AttributeValue ::= OCTET STRING
-                0x04, 0x00, ( byte ) 0xA0, 0x1B, // A control
+                0x04, 0x00, ( 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 } );
 
@@ -1105,7 +1186,8 @@ public class SearchResultEntryTest
             fail( de.getMessage() );
         }
 
-        SearchResultEntryCodec searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultEntry();
+        SearchResultEntry searchResultEntry = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getSearchResultEntry();
 
         assertEquals( 1, searchResultEntry.getMessageId() );
         assertEquals( "ou=contacts,dc=iktek,dc=com", searchResultEntry.getObjectName().toString() );
@@ -1124,21 +1206,21 @@ public class SearchResultEntryTest
         }
 
         // Check the Control
-        List<Control> controls = searchResultEntry.getControls();
+        Map<String, Control> controls = searchResultEntry.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = searchResultEntry.getControls( 0 );
+        Control control = controls.get( "2.16.840.1.113730.3.4.2" );
         assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
         assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) );
 
-        // Check the length
-        assertEquals( 0x56, searchResultEntry.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = searchResultEntry.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultEntry );
+
+            // Check the length
+            assertEquals( 0x56, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultReferenceTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultReferenceTest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultReferenceTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultReferenceTest.java Fri Aug 20 19:23:27 2010
@@ -21,12 +21,13 @@ package org.apache.directory.shared.ldap
 
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.nio.ByteBuffer;
 import java.util.HashSet;
-import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.directory.junit.tools.Concurrent;
@@ -36,9 +37,10 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
-import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
+import org.apache.directory.shared.ldap.message.LdapProtocolEncoder;
+import org.apache.directory.shared.ldap.message.Referral;
+import org.apache.directory.shared.ldap.message.SearchResultReference;
 import org.apache.directory.shared.ldap.message.control.Control;
-import org.apache.directory.shared.ldap.util.LdapURL;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -53,6 +55,10 @@ import org.junit.runner.RunWith;
 @Concurrent()
 public class SearchResultReferenceTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
+
     /**
      * Test the decoding of a SearchResultReference
      */
@@ -82,12 +88,12 @@ public class SearchResultReferenceTest
             {
 
             0x30, ( byte ) 0x82, 0x03, ( byte ) 0xd4, // LDAPMessage
-                                                        // ::=SEQUENCE {
+                // ::=SEQUENCE {
                 0x02, 0x01, 0x01, // messageID MessageID
                 0x73, ( byte ) 0x82, 0x03, ( byte ) 0xcd, // CHOICE { ...,
-                                                            // searchResEntry
-                                                            // SearchResultEntry,
-                                                            // ...
+            // searchResEntry
+            // SearchResultEntry,
+            // ...
             // SearchResultReference ::= [APPLICATION 19] SEQUENCE OF LDAPURL
             } );
 
@@ -96,7 +102,7 @@ public class SearchResultReferenceTest
             stream.put( ( byte ) 0x04 );
             stream.put( ( byte ) ldapUrls[i].getBytes().length );
 
-            byte[] bytes = ldapUrls[i].getBytes();
+            byte[] bytes = StringTools.getBytesUtf8( ldapUrls[i] );
 
             for ( int j = 0; j < bytes.length; j++ )
             {
@@ -120,29 +126,27 @@ public class SearchResultReferenceTest
             fail( de.getMessage() );
         }
 
-        SearchResultReferenceCodec searchResultReference = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultReference();
+        SearchResultReference searchResultReference = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getSearchResultReference();
 
         assertEquals( 1, searchResultReference.getMessageId() );
 
         Set<String> ldapUrlsSet = new HashSet<String>();
 
-        try
-        {
-            for ( int i = 0; i < ldapUrls.length; i++ )
-            {
-                ldapUrlsSet.add( new LdapURL( ldapUrls[i].getBytes() ).toString() );
-            }
-        }
-        catch ( LdapURLEncodingException luee )
+        for ( int i = 0; i < ldapUrls.length; i++ )
         {
-            fail();
+            ldapUrlsSet.add( StringTools.utf8ToString( ldapUrls[i].getBytes() ) );
         }
 
-        for ( LdapURL ldapUrl:searchResultReference.getSearchResultReferences() )
+        Referral referral = searchResultReference.getReferral();
+
+        assertNotNull( referral );
+
+        for ( String ldapUrl : referral.getLdapUrls() )
         {
-            if ( ldapUrlsSet.contains( ldapUrl.toString() ) )
+            if ( ldapUrlsSet.contains( ldapUrl ) )
             {
-                ldapUrlsSet.remove( ldapUrl.toString() );
+                ldapUrlsSet.remove( ldapUrl );
             }
             else
             {
@@ -152,13 +156,13 @@ public class SearchResultReferenceTest
 
         assertTrue( ldapUrlsSet.size() == 0 );
 
-        // Check the length
-        assertEquals( 0x3D8, searchResultReference.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = searchResultReference.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultReference );
+
+            // Check the length
+            assertEquals( 0x3D8, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -201,12 +205,12 @@ public class SearchResultReferenceTest
             {
 
             0x30, ( byte ) 0x82, 0x03, ( byte ) 0xF1, // LDAPMessage
-                                                        // ::=SEQUENCE {
+                // ::=SEQUENCE {
                 0x02, 0x01, 0x01, // messageID MessageID
                 0x73, ( byte ) 0x82, 0x03, ( byte ) 0xcd, // CHOICE { ...,
-                                                            // searchResEntry
-                                                            // SearchResultEntry,
-                                                            // ...
+            // searchResEntry
+            // SearchResultEntry,
+            // ...
             // SearchResultReference ::= [APPLICATION 19] SEQUENCE OF LDAPURL
             } );
 
@@ -224,7 +228,8 @@ public class SearchResultReferenceTest
         }
 
         byte[] controlBytes = new byte[]
-            { ( byte ) 0xA0, 0x1B, // A control
+            { ( 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 };
 
@@ -241,7 +246,7 @@ public class SearchResultReferenceTest
 
         try
         {
-            ((LdapMessageContainer)ldapMessageContainer).clean();
+            ( ( LdapMessageContainer ) ldapMessageContainer ).clean();
             ldapDecoder.decode( stream, ldapMessageContainer );
         }
         catch ( DecoderException de )
@@ -249,32 +254,30 @@ public class SearchResultReferenceTest
             de.printStackTrace();
             fail( de.getMessage() );
         }
-        
+
         stream.flip();
-        
-        SearchResultReferenceCodec searchResultReference = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultReference();
+
+        SearchResultReference searchResultReference = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getSearchResultReference();
 
         assertEquals( 1, searchResultReference.getMessageId() );
 
         Set<String> ldapUrlsSet = new HashSet<String>();
 
-        try
-        {
-            for ( int i = 0; i < ldapUrls.length; i++ )
-            {
-                ldapUrlsSet.add( new LdapURL( ldapUrls[i].getBytes() ).toString() );
-            }
-        }
-        catch ( LdapURLEncodingException luee )
+        for ( int i = 0; i < ldapUrls.length; i++ )
         {
-            fail();
+            ldapUrlsSet.add( StringTools.utf8ToString( ldapUrls[i].getBytes() ) );
         }
 
-        for ( LdapURL ldapUrl:searchResultReference.getSearchResultReferences() )
+        Referral referral = searchResultReference.getReferral();
+
+        assertNotNull( referral );
+
+        for ( String ldapUrl : referral.getLdapUrls() )
         {
-            if ( ldapUrlsSet.contains( ldapUrl.toString() ) )
+            if ( ldapUrlsSet.contains( ldapUrl ) )
             {
-                ldapUrlsSet.remove( ldapUrl.toString() );
+                ldapUrlsSet.remove( ldapUrl );
             }
             else
             {
@@ -285,21 +288,21 @@ public class SearchResultReferenceTest
         assertTrue( ldapUrlsSet.size() == 0 );
 
         // Check the Control
-        List<Control> controls = searchResultReference.getControls();
+        Map<String, Control> controls = searchResultReference.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = searchResultReference.getControls( 0 );
+        Control control = controls.get( "2.16.840.1.113730.3.4.2" );
         assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
         assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) );
 
-        // Check the length
-        assertEquals( 0x3F5, searchResultReference.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = searchResultReference.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultReference );
+
+            // Check the length
+            assertEquals( 0x3F5, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -329,7 +332,7 @@ public class SearchResultReferenceTest
             0x30, 0x05, // LDAPMessage ::=SEQUENCE {
                 0x02, 0x01, 0x01, // messageID MessageID
                 0x73, 0x00 // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+            // ...
             // SearchResultReference ::= [APPLICATION 19] SEQUENCE OF LDAPURL
             } );
 
@@ -369,14 +372,14 @@ public class SearchResultReferenceTest
             0x30, 0x0F, // LDAPMessage ::=SEQUENCE {
                 0x02, 0x01, 0x01, // messageID MessageID
                 0x73, 0x0A, // CHOICE { ..., searchResEntry SearchResultEntry,
-                            // ...
+                // ...
                 0x04, 0x08, 'l', 'd', 'a', 'p', ':', '/', '/', '/' // SearchResultReference
-                                                                    // ::=
-                                                                    // [APPLICATION
-                                                                    // 19]
-                                                                    // SEQUENCE
-                                                                    // OF
-                                                                    // LDAPURL
+            // ::=
+            // [APPLICATION
+            // 19]
+            // SEQUENCE
+            // OF
+            // LDAPURL
             } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
@@ -395,21 +398,27 @@ public class SearchResultReferenceTest
             fail( de.getMessage() );
         }
 
-        SearchResultReferenceCodec searchResultReference = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultReference();
+        SearchResultReference searchResultReference = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getSearchResultReference();
 
         assertEquals( 1, searchResultReference.getMessageId() );
 
-        LdapURL ldapUrl = searchResultReference.getSearchResultReferences().get( 0 );
+        Referral referral = searchResultReference.getReferral();
 
-        assertEquals( "ldap:///", ldapUrl.toString() );
+        assertNotNull( referral );
 
-        // Check the length
-        assertEquals( 0x11, searchResultReference.computeLength() );
+        for ( String ldapUrl : referral.getLdapUrls() )
+        {
+            assertEquals( "ldap:///", ldapUrl );
+        }
 
         // Check the encoding
         try
         {
-            ByteBuffer bb = searchResultReference.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultReference );
+
+            // Check the length
+            assertEquals( 0x11, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java Fri Aug 20 19:23:27 2010
@@ -25,7 +25,7 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import java.nio.ByteBuffer;
-import java.util.List;
+import java.util.Map;
 
 import org.apache.directory.junit.tools.Concurrent;
 import org.apache.directory.junit.tools.ConcurrentJunitRunner;
@@ -33,8 +33,10 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.codec.EncoderException;
-import org.apache.directory.shared.ldap.codec.LdapMessageCodec;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.message.LdapProtocolEncoder;
+import org.apache.directory.shared.ldap.message.UnbindRequest;
+import org.apache.directory.shared.ldap.message.UnbindRequestImpl;
 import org.apache.directory.shared.ldap.message.control.Control;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Test;
@@ -48,6 +50,10 @@ import org.junit.runner.RunWith;
 @Concurrent()
 public class UnBindRequestTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
+
     /**
      * Test the decoding of a UnBindRequest with no controls
      */
@@ -58,11 +64,10 @@ public class UnBindRequestTest
 
         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 = StringTools.dumpBytes( stream.array() );
@@ -81,16 +86,19 @@ public class UnBindRequestTest
             fail( de.getMessage() );
         }
 
-        LdapMessageCodec ldapMessage = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+        UnbindRequest unbindRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getUnbindRequest();
 
-        assertEquals( 1, ldapMessage.getMessageId() );
+        assertEquals( 1, unbindRequest.getMessageId() );
 
-        // Check the length
-        assertEquals( 7, ldapMessage.computeLength() );
+        // Check the encoding
+        UnbindRequest internalUnbindRequest = new UnbindRequestImpl( unbindRequest.getMessageId() );
 
         try
         {
-            ByteBuffer bb = ldapMessage.encode();
+            ByteBuffer bb = encoder.encodeMessage( internalUnbindRequest );
+
+            // Check the length
+            assertEquals( 0x07, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -114,17 +122,17 @@ public class UnBindRequestTest
 
         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 = StringTools.dumpBytes( stream.array() );
         stream.flip();
@@ -142,25 +150,29 @@ public class UnBindRequestTest
             fail( de.getMessage() );
         }
 
-        LdapMessageCodec ldapMessage = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+        UnbindRequest unbindRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getUnbindRequest();
 
-        assertEquals( 1, ldapMessage.getMessageId() );
+        assertEquals( 1, unbindRequest.getMessageId() );
 
         // Check the Control
-        List<Control> controls = ldapMessage.getControls();
+        Map<String, Control> controls = unbindRequest.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = ldapMessage.getControls( 0 );
+        Control control = controls.get( "2.16.840.1.113730.3.4.2" );
         assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
         assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) );
 
-        // Check the length
-        assertEquals( 0x24, ldapMessage.computeLength() );
+        // Check the encoding
+        UnbindRequest internalUnbindRequest = new UnbindRequestImpl( unbindRequest.getMessageId() );
+        internalUnbindRequest.addControl( control );
 
         try
         {
-            ByteBuffer bb = ldapMessage.encode();
+            ByteBuffer bb = encoder.encodeMessage( internalUnbindRequest );
+
+            // Check the length
+            assertEquals( 0x24, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -184,11 +196,10 @@ public class UnBindRequestTest
 
         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
 
             } );
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractMessageTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractMessageTest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractMessageTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractMessageTest.java Fri Aug 20 19:23:27 2010
@@ -27,7 +27,6 @@ import org.apache.directory.junit.tools.
 import org.apache.directory.junit.tools.ConcurrentJunitRunner;
 import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
 import org.apache.directory.shared.ldap.codec.controls.ControlImpl;
-import org.apache.directory.shared.ldap.message.internal.InternalAbstractMessage;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -48,8 +47,8 @@ public class AbstractMessageTest
     @Test
     public void testEqualsSameObj()
     {
-        InternalAbstractMessage msg;
-        msg = new InternalAbstractMessage( 5, MessageTypeEnum.BIND_REQUEST )
+        AbstractMessage msg;
+        msg = new AbstractMessage( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
@@ -63,13 +62,13 @@ public class AbstractMessageTest
     @Test
     public void testEqualsExactCopy()
     {
-        InternalAbstractMessage msg0;
-        InternalAbstractMessage msg1;
-        msg0 = new InternalAbstractMessage( 5, MessageTypeEnum.BIND_REQUEST )
+        AbstractMessage msg0;
+        AbstractMessage msg1;
+        msg0 = new AbstractMessage( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
-        msg1 = new InternalAbstractMessage( 5, MessageTypeEnum.BIND_REQUEST )
+        msg1 = new AbstractMessage( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
@@ -84,13 +83,13 @@ public class AbstractMessageTest
     @Test
     public void testNotEqualsDiffId()
     {
-        InternalAbstractMessage msg0;
-        InternalAbstractMessage msg1;
-        msg0 = new InternalAbstractMessage( 5, MessageTypeEnum.BIND_REQUEST )
+        AbstractMessage msg0;
+        AbstractMessage msg1;
+        msg0 = new AbstractMessage( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
-        msg1 = new InternalAbstractMessage( 6, MessageTypeEnum.BIND_REQUEST )
+        msg1 = new AbstractMessage( 6, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
@@ -105,13 +104,13 @@ public class AbstractMessageTest
     @Test
     public void testNotEqualsDiffType()
     {
-        InternalAbstractMessage msg0;
-        InternalAbstractMessage msg1;
-        msg0 = new InternalAbstractMessage( 5, MessageTypeEnum.BIND_REQUEST )
+        AbstractMessage msg0;
+        AbstractMessage msg1;
+        msg0 = new AbstractMessage( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
-        msg1 = new InternalAbstractMessage( 5, MessageTypeEnum.UNBIND_REQUEST )
+        msg1 = new AbstractMessage( 5, MessageTypeEnum.UNBIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
@@ -126,15 +125,15 @@ public class AbstractMessageTest
     @Test
     public void testNotEqualsDiffControls()
     {
-        InternalAbstractMessage msg0;
-        InternalAbstractMessage msg1;
-        
-        msg0 = new InternalAbstractMessage( 5, MessageTypeEnum.BIND_REQUEST )
+        AbstractMessage msg0;
+        AbstractMessage msg1;
+
+        msg0 = new AbstractMessage( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
-        
-        msg0.add( new ControlImpl( "0.0" )
+
+        msg0.addControl( new ControlImpl( "0.0" )
         {
             private static final long serialVersionUID = 1L;
 
@@ -161,8 +160,8 @@ public class AbstractMessageTest
                 return null;
             }
         } );
-        
-        msg1 = new InternalAbstractMessage( 5, MessageTypeEnum.BIND_REQUEST )
+
+        msg1 = new AbstractMessage( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractResultResponseTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractResultResponseTest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractResultResponseTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractResultResponseTest.java Fri Aug 20 19:23:27 2010
@@ -28,9 +28,6 @@ import org.apache.directory.junit.tools.
 import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
 import org.apache.directory.shared.ldap.codec.controls.ControlImpl;
 import org.apache.directory.shared.ldap.exception.LdapException;
-import org.apache.directory.shared.ldap.message.internal.InternalAbstractResultResponse;
-import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
-import org.apache.directory.shared.ldap.message.internal.InternalReferral;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -51,8 +48,8 @@ public class AbstractResultResponseTest
     @Test
     public void testEqualsSameObj()
     {
-        InternalAbstractResultResponse msg;
-        msg = new InternalAbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
+        AbstractResultResponse msg;
+        msg = new AbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
@@ -66,16 +63,16 @@ public class AbstractResultResponseTest
     @Test
     public void testEqualsExactCopy() throws LdapException
     {
-        InternalAbstractResultResponse msg0 = new InternalAbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
+        AbstractResultResponse msg0 = new AbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
-        InternalAbstractResultResponse msg1 = new InternalAbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
+        AbstractResultResponse msg1 = new AbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
-        InternalLdapResult r0 = msg0.getLdapResult();
-        InternalLdapResult r1 = msg1.getLdapResult();
+        LdapResult r0 = msg0.getLdapResult();
+        LdapResult r1 = msg1.getLdapResult();
 
         r0.setErrorMessage( "blah blah blah" );
         r1.setErrorMessage( "blah blah blah" );
@@ -86,11 +83,11 @@ public class AbstractResultResponseTest
         r0.setResultCode( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
         r1.setResultCode( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
 
-        InternalReferral refs0 = new ReferralImpl();
+        Referral refs0 = new ReferralImpl();
         refs0.addLdapUrl( "ldap://someserver.com" );
         refs0.addLdapUrl( "ldap://anotherserver.org" );
 
-        InternalReferral refs1 = new ReferralImpl();
+        Referral refs1 = new ReferralImpl();
         refs1.addLdapUrl( "ldap://someserver.com" );
         refs1.addLdapUrl( "ldap://anotherserver.org" );
 
@@ -105,16 +102,16 @@ public class AbstractResultResponseTest
     @Test
     public void testNotEqualsDiffResult() throws LdapException
     {
-        InternalAbstractResultResponse msg0 = new InternalAbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
+        AbstractResultResponse msg0 = new AbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
-        InternalAbstractResultResponse msg1 = new InternalAbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
+        AbstractResultResponse msg1 = new AbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
-        InternalLdapResult r0 = msg0.getLdapResult();
-        InternalLdapResult r1 = msg1.getLdapResult();
+        LdapResult r0 = msg0.getLdapResult();
+        LdapResult r1 = msg1.getLdapResult();
 
         r0.setErrorMessage( "blah blah blah" );
         r1.setErrorMessage( "blah blah blah" );
@@ -125,11 +122,11 @@ public class AbstractResultResponseTest
         r0.setResultCode( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
         r1.setResultCode( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
 
-        InternalReferral refs0 = new ReferralImpl();
+        Referral refs0 = new ReferralImpl();
         refs0.addLdapUrl( "ldap://someserver.com" );
         refs0.addLdapUrl( "ldap://anotherserver.org" );
 
-        InternalReferral refs1 = new ReferralImpl();
+        Referral refs1 = new ReferralImpl();
         refs1.addLdapUrl( "ldap://someserver.com" );
         refs1.addLdapUrl( "ldap://anotherserver.org" );
 
@@ -144,13 +141,13 @@ public class AbstractResultResponseTest
     @Test
     public void testNotEqualsDiffId()
     {
-        InternalAbstractResultResponse msg0;
-        InternalAbstractResultResponse msg1;
-        msg0 = new InternalAbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
+        AbstractResultResponse msg0;
+        AbstractResultResponse msg1;
+        msg0 = new AbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
-        msg1 = new InternalAbstractResultResponse( 6, MessageTypeEnum.BIND_REQUEST )
+        msg1 = new AbstractResultResponse( 6, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
@@ -165,13 +162,13 @@ public class AbstractResultResponseTest
     @Test
     public void testNotEqualsDiffType()
     {
-        InternalAbstractResultResponse msg0;
-        InternalAbstractResultResponse msg1;
-        msg0 = new InternalAbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
+        AbstractResultResponse msg0;
+        AbstractResultResponse msg1;
+        msg0 = new AbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
-        msg1 = new InternalAbstractResultResponse( 5, MessageTypeEnum.UNBIND_REQUEST )
+        msg1 = new AbstractResultResponse( 5, MessageTypeEnum.UNBIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
@@ -186,15 +183,15 @@ public class AbstractResultResponseTest
     @Test
     public void testNotEqualsDiffControls()
     {
-        InternalAbstractResultResponse msg0;
-        InternalAbstractResultResponse msg1;
-        
-        msg0 = new InternalAbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
+        AbstractResultResponse msg0;
+        AbstractResultResponse msg1;
+
+        msg0 = new AbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };
-        
-        msg0.add( new ControlImpl( "0.0" )
+
+        msg0.addControl( new ControlImpl( "0.0" )
         {
             private static final long serialVersionUID = 1L;
 
@@ -221,8 +218,8 @@ public class AbstractResultResponseTest
                 return null;
             }
         } );
-        
-        msg1 = new InternalAbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
+
+        msg1 = new AbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST )
         {
             private static final long serialVersionUID = 1L;
         };

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AddRequestImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AddRequestImplTest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AddRequestImplTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AddRequestImplTest.java Fri Aug 20 19:23:27 2010
@@ -33,10 +33,9 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.message.control.Control;
-import org.apache.directory.shared.ldap.message.internal.InternalAddRequest;
-import org.apache.directory.shared.ldap.message.internal.InternalResultResponse;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -52,7 +51,8 @@ import org.junit.runner.RunWith;
 public class AddRequestImplTest
 {
     private static final Map<String, Control> EMPTY_CONTROL_MAP = new HashMap<String, Control>();
-    
+
+
     /**
      * Creates and populates a AttributeImpl with a specific id.
      * 
@@ -78,7 +78,7 @@ public class AddRequestImplTest
     private Entry getEntry()
     {
         Entry entry = new DefaultEntry();
-        
+
         try
         {
             entry.put( getAttribute( "attr0" ) );
@@ -89,7 +89,7 @@ public class AddRequestImplTest
         {
             // Do nothing
         }
-        
+
         return entry;
     }
 
@@ -196,7 +196,7 @@ public class AddRequestImplTest
     @Test
     public void testEqualsDiffImpl()
     {
-        InternalAddRequest req0 = new InternalAddRequest()
+        AddRequest req0 = new AddRequest()
         {
             public Entry getEntry()
             {
@@ -244,12 +244,12 @@ public class AddRequestImplTest
             }
 
 
-            public void add( Control control ) throws MessageException
+            public void addControl( Control control ) throws MessageException
             {
             }
 
 
-            public void remove( Control control ) throws MessageException
+            public void removeControl( Control control ) throws MessageException
             {
             }
 
@@ -288,13 +288,13 @@ public class AddRequestImplTest
             }
 
 
-            public InternalResultResponse getResultResponse()
+            public ResultResponse getResultResponse()
             {
                 return null;
             }
 
 
-            public void addAll( Control[] controls ) throws MessageException
+            public void addAllControls( Control[] controls ) throws MessageException
             {
             }
 
@@ -303,6 +303,71 @@ public class AddRequestImplTest
             {
                 return false;
             }
+
+
+            public void addAttributeType( String type ) throws LdapException
+            {
+            }
+
+
+            public void addAttributeValue( String value )
+            {
+            }
+
+
+            public void addAttributeValue( Value<?> value )
+            {
+            }
+
+
+            public void addAttributeValue( byte[] value )
+            {
+            }
+
+
+            public String getCurrentAttributeType()
+            {
+                return null;
+            }
+
+
+            public Control getCurrentControl()
+            {
+                return null;
+            }
+
+
+            public int getControlsLength()
+            {
+                return 0;
+            }
+
+
+            public void setControlsLength( int controlsLength )
+            {
+            }
+
+
+            public int getMessageLength()
+            {
+                return 0;
+            }
+
+
+            public void setMessageLength( int messageLength )
+            {
+            }
+
+
+            public Control getControl( String oid )
+            {
+                return null;
+            }
+
+
+            public void setMessageId( int messageId )
+            {
+            }
         };
 
         AddRequestImpl req1 = new AddRequestImpl( 5 );

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/ArrayNamingEnumerationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/ArrayNamingEnumerationTest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/ArrayNamingEnumerationTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/ArrayNamingEnumerationTest.java Fri Aug 20 19:23:27 2010
@@ -25,7 +25,6 @@ import java.util.NoSuchElementException;
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.directory.junit.tools.Concurrent;
 import org.apache.directory.junit.tools.ConcurrentJunitRunner;
-import org.apache.directory.shared.ldap.message.ArrayNamingEnumeration;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/BindRequestImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/BindRequestImplTest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/BindRequestImplTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/BindRequestImplTest.java Fri Aug 20 19:23:27 2010
@@ -31,8 +31,6 @@ import org.apache.directory.junit.tools.
 import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.message.control.Control;
-import org.apache.directory.shared.ldap.message.internal.InternalBindRequest;
-import org.apache.directory.shared.ldap.message.internal.InternalResultResponse;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -50,6 +48,7 @@ public class BindRequestImplTest
 {
     private static final Map<String, Control> EMPTY_CONTROL_MAP = new HashMap<String, Control>();
 
+
     /**
      * Tests the same object referrence for equality.
      */
@@ -199,7 +198,7 @@ public class BindRequestImplTest
     @Test
     public void testEqualsDiffImpl()
     {
-        InternalBindRequest req0 = new InternalBindRequest()
+        BindRequest req0 = new BindRequest()
         {
             public boolean isSimple()
             {
@@ -224,7 +223,12 @@ public class BindRequestImplTest
             }
 
 
-            public void setCredentials( byte[] a_credentials )
+            public void setCredentials( String credentials )
+            {
+            }
+
+
+            public void setCredentials( byte[] credentials )
             {
             }
 
@@ -281,12 +285,12 @@ public class BindRequestImplTest
             }
 
 
-            public void add( Control control ) throws MessageException
+            public void addControl( Control control ) throws MessageException
             {
             }
 
 
-            public void remove( Control control ) throws MessageException
+            public void removeControl( Control control ) throws MessageException
             {
             }
 
@@ -320,13 +324,13 @@ public class BindRequestImplTest
             }
 
 
-            public InternalResultResponse getResultResponse()
+            public ResultResponse getResultResponse()
             {
                 return null;
             }
 
 
-            public void addAll( Control[] controls ) throws MessageException
+            public void addAllControls( Control[] controls ) throws MessageException
             {
             }
 
@@ -351,6 +355,45 @@ public class BindRequestImplTest
             {
                 return false;
             }
+
+
+            public Control getCurrentControl()
+            {
+                return null;
+            }
+
+
+            public int getControlsLength()
+            {
+                return 0;
+            }
+
+
+            public void setControlsLength( int controlsLength )
+            {
+            }
+
+
+            public int getMessageLength()
+            {
+                return 0;
+            }
+
+
+            public void setMessageLength( int messageLength )
+            {
+            }
+
+
+            public Control getControl( String oid )
+            {
+                return null;
+            }
+
+
+            public void setMessageId( int messageId )
+            {
+            }
         };
 
         BindRequestImpl req1 = new BindRequestImpl( 5 );

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/BindResponseImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/BindResponseImplTest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/BindResponseImplTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/BindResponseImplTest.java Fri Aug 20 19:23:27 2010
@@ -26,8 +26,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.BindResponseImpl;
 import org.apache.directory.shared.ldap.message.LdapResultImpl;
 import org.apache.directory.shared.ldap.message.ReferralImpl;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.message.internal.InternalReferral;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -142,11 +140,11 @@ public class BindResponseImplTest
         r0.setResultCode( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
         r1.setResultCode( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
 
-        InternalReferral refs0 = new ReferralImpl();
+        Referral refs0 = new ReferralImpl();
         refs0.addLdapUrl( "ldap://someserver.com" );
         refs0.addLdapUrl( "ldap://anotherserver.org" );
 
-        InternalReferral refs1 = new ReferralImpl();
+        Referral refs1 = new ReferralImpl();
         refs1.addLdapUrl( "ldap://someserver.com" );
         refs1.addLdapUrl( "ldap://anotherserver.org" );
 
@@ -179,11 +177,11 @@ public class BindResponseImplTest
         r0.setResultCode( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
         r1.setResultCode( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
 
-        InternalReferral refs0 = new ReferralImpl();
+        Referral refs0 = new ReferralImpl();
         refs0.addLdapUrl( "ldap://someserver.com" );
         refs0.addLdapUrl( "ldap://anotherserver.org" );
 
-        InternalReferral refs1 = new ReferralImpl();
+        Referral refs1 = new ReferralImpl();
         refs1.addLdapUrl( "ldap://someserver.com" );
         refs1.addLdapUrl( "ldap://anotherserver.org" );
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/CompareRequestImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/CompareRequestImplTest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/CompareRequestImplTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/CompareRequestImplTest.java Fri Aug 20 19:23:27 2010
@@ -32,8 +32,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.message.control.Control;
-import org.apache.directory.shared.ldap.message.internal.InternalCompareRequest;
-import org.apache.directory.shared.ldap.message.internal.InternalResultResponse;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -50,6 +48,7 @@ public class CompareRequestImplTest
 {
     private static final Map<String, Control> EMPTY_CONTROL_MAP = new HashMap<String, Control>();
 
+
     /**
      * Tests the same object reference for equality.
      */
@@ -179,7 +178,7 @@ public class CompareRequestImplTest
     @Test
     public void testEqualsDiffImpl()
     {
-        InternalCompareRequest req0 = new InternalCompareRequest()
+        CompareRequest req0 = new CompareRequest()
         {
             public Value<?> getAssertionValue()
             {
@@ -246,12 +245,12 @@ public class CompareRequestImplTest
             }
 
 
-            public void add( Control a_control ) throws MessageException
+            public void addControl( Control a_control ) throws MessageException
             {
             }
 
 
-            public void remove( Control a_control ) throws MessageException
+            public void removeControl( Control a_control ) throws MessageException
             {
             }
 
@@ -290,13 +289,13 @@ public class CompareRequestImplTest
             }
 
 
-            public InternalResultResponse getResultResponse()
+            public ResultResponse getResultResponse()
             {
                 return null;
             }
 
 
-            public void addAll( Control[] controls ) throws MessageException
+            public void addAllControls( Control[] controls ) throws MessageException
             {
             }
 
@@ -305,6 +304,45 @@ public class CompareRequestImplTest
             {
                 return false;
             }
+
+
+            public Control getCurrentControl()
+            {
+                return null;
+            }
+
+
+            public int getControlsLength()
+            {
+                return 0;
+            }
+
+
+            public void setControlsLength( int controlsLength )
+            {
+            }
+
+
+            public int getMessageLength()
+            {
+                return 0;
+            }
+
+
+            public void setMessageLength( int messageLength )
+            {
+            }
+
+
+            public Control getControl( String oid )
+            {
+                return null;
+            }
+
+
+            public void setMessageId( int messageId )
+            {
+            }
         };
 
         CompareRequestImpl req1 = new CompareRequestImpl( 5 );

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/DeleteRequestImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/DeleteRequestImplTest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/DeleteRequestImplTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/DeleteRequestImplTest.java Fri Aug 20 19:23:27 2010
@@ -31,8 +31,6 @@ import org.apache.directory.junit.tools.
 import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.message.control.Control;
-import org.apache.directory.shared.ldap.message.internal.InternalDeleteRequest;
-import org.apache.directory.shared.ldap.message.internal.InternalResultResponse;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -49,6 +47,7 @@ public class DeleteRequestImplTest
 {
     private static final Map<String, Control> EMPTY_CONTROL_MAP = new HashMap<String, Control>();
 
+
     /**
      * Tests the same object reference for equality.
      */
@@ -142,7 +141,7 @@ public class DeleteRequestImplTest
     @Test
     public void testEqualsDiffImpl()
     {
-        InternalDeleteRequest req0 = new InternalDeleteRequest()
+        DeleteRequest req0 = new DeleteRequest()
         {
             public DN getName()
             {
@@ -179,12 +178,12 @@ public class DeleteRequestImplTest
             }
 
 
-            public void add( Control control ) throws MessageException
+            public void addControl( Control control ) throws MessageException
             {
             }
 
 
-            public void remove( Control control ) throws MessageException
+            public void removeControl( Control control ) throws MessageException
             {
             }
 
@@ -223,13 +222,13 @@ public class DeleteRequestImplTest
             }
 
 
-            public InternalResultResponse getResultResponse()
+            public ResultResponse getResultResponse()
             {
                 return null;
             }
 
 
-            public void addAll( Control[] controls ) throws MessageException
+            public void addAllControls( Control[] controls ) throws MessageException
             {
             }
 
@@ -238,6 +237,45 @@ public class DeleteRequestImplTest
             {
                 return false;
             }
+
+
+            public Control getCurrentControl()
+            {
+                return null;
+            }
+
+
+            public int getControlsLength()
+            {
+                return 0;
+            }
+
+
+            public void setControlsLength( int controlsLength )
+            {
+            }
+
+
+            public int getMessageLength()
+            {
+                return 0;
+            }
+
+
+            public void setMessageLength( int messageLength )
+            {
+            }
+
+
+            public Control getControl( String oid )
+            {
+                return null;
+            }
+
+
+            public void setMessageId( int messageId )
+            {
+            }
         };
 
         DeleteRequestImpl req1 = new DeleteRequestImpl( 5 );



Mime
View raw message