directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r479688 - in /directory/trunks/shared/ldap/src: main/java/org/apache/directory/shared/ldap/codec/ main/java/org/apache/directory/shared/ldap/codec/add/ main/java/org/apache/directory/shared/ldap/codec/bind/ main/java/org/apache/directory/sh...
Date Mon, 27 Nov 2006 16:53:32 GMT
Author: elecharny
Date: Mon Nov 27 08:53:30 2006
New Revision: 479688

URL: http://svn.apache.org/viewvc?view=rev&rev=479688
Log:
Ported modifications made this moring in 1.0 to 1.5 : added some defensive test in the toString methods
to avoid a NPE. Also added a test for rootDSE searching.

Modified:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/AttributeValueAssertion.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessage.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResponse.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponse.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnect.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdown.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultReference.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControl.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/AttributeValueAssertion.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/AttributeValueAssertion.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/AttributeValueAssertion.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/AttributeValueAssertion.java Mon Nov 27 08:53:30 2006
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.shared.ldap.codec;
 
+import org.apache.directory.shared.ldap.util.StringTools;
+
 
 /**
  * A class to store an attribute value assertion. 
@@ -101,12 +103,13 @@
      */
     public String toString( String tabs )
     {
-
         StringBuffer sb = new StringBuffer();
 
         sb.append( tabs ).append( "AttributeValueAssertion\n" );
-        sb.append( tabs ).append( "    Assertion description : '" ).append( attributeDesc.toString() ).append( "'\n" );
-        sb.append( tabs ).append( "    Assertion value : '" ).append( assertionValue.toString() ).append( "'\n" );
+        sb.append( tabs ).append( "    Assertion description : '" );
+        sb.append( attributeDesc != null ? attributeDesc : "null" );
+        sb.append( "'\n" );
+        sb.append( tabs ).append( "    Assertion value : '" ).append( StringTools.dumpObject( assertionValue ) ).append( "'\n" );
 
         return sb.toString();
     }
@@ -121,10 +124,9 @@
      */
     public String toStringRFC2254( int filterType )
     {
-
         StringBuffer sb = new StringBuffer();
 
-        sb.append( attributeDesc.toString() );
+        sb.append( attributeDesc );
 
         switch ( filterType )
         {
@@ -145,7 +147,7 @@
                 break;
         }
 
-        sb.append( assertionValue.toString() );
+        sb.append( StringTools.dumpObject( assertionValue ) );
 
         return sb.toString();
     }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java Mon Nov 27 08:53:30 2006
@@ -296,7 +296,7 @@
         StringBuffer sb = new StringBuffer();
 
         sb.append( "    Control\n" );
-        sb.append( "        Control type : '" ).append( controlType != null ? controlType.toString() : "null" ).append(
+        sb.append( "        Control type : '" ).append( controlType ).append(
             "'\n" );
         sb.append( "        Criticality : '" ).append( criticality ).append( "'\n" );
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessage.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessage.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessage.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessage.java Mon Nov 27 08:53:30 2006
@@ -50,7 +50,7 @@
 import java.nio.ByteBuffer;
 
 import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.List;
 
 
 /**
@@ -71,7 +71,7 @@
     private Asn1Object protocolOp;
 
     /** The controls */
-    private ArrayList<Control> controls;
+    private List<Control> controls;
 
     /** The current control */
     private transient Control currentControl;
@@ -118,7 +118,7 @@
      * 
      * @return The Control Objects
      */
-    public ArrayList getControls()
+    public List<Control> getControls()
     {
         return controls;
     }
@@ -562,12 +562,10 @@
             // + Length(L3) + L3
             controlsSequenceLength = 0;
 
-            Iterator controlIterator = controls.iterator();
-
             // We may have more than one control. ControlsLength is L4.
-            while ( controlIterator.hasNext() )
+            for ( Control control:controls )
             {
-                controlsSequenceLength += ( ( Control ) controlIterator.next() ).computeLength();
+                controlsSequenceLength += control.computeLength();
             }
 
             // Computes the controls length
@@ -640,11 +638,9 @@
             bb.put( TLV.getBytes( controlsLength ) );
 
             // Encode each control
-            Iterator controlIterator = controls.iterator();
-
-            while ( controlIterator.hasNext() )
+            for ( Control control:controls )
             {
-                ( ( Control ) controlIterator.next() ).encode( bb );
+                control.encode( bb );
             }
         }
 
@@ -663,13 +659,13 @@
 
         sb.append( "LdapMessage\n" );
         sb.append( "    message Id : " ).append( messageId ).append( '\n' );
-        sb.append( protocolOp.toString() );
+        sb.append( protocolOp );
 
         if ( controls != null )
         {
-            for ( int i = 0; i < controls.size(); i++ )
+            for ( Control control:controls )
             {
-                sb.append( ( ( Control ) controls.get( i ) ).toString() );
+                sb.append( control );
             }
         }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResponse.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResponse.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResponse.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResponse.java Mon Nov 27 08:53:30 2006
@@ -127,6 +127,6 @@
      */
     public String toString()
     {
-        return ldapResult.toString();
+        return ( ldapResult != null ? ldapResult.toString() : "" );
     }
 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java Mon Nov 27 08:53:30 2006
@@ -615,14 +615,16 @@
         if ( ( referrals != null ) && ( referrals.size() != 0 ) )
         {
             sb.append( "            Referrals :\n" );
+            int i = 0;
 
-            for ( int i = 0; i < referrals.size(); i++ )
+            for ( LdapURL referral:referrals )
             {
 
-                LdapURL referral = ( LdapURL ) referrals.get( i );
-
-                sb.append( "                Referral[" ).append( i ).append( "] :" ).append( referral == null ? "" : referral.toString() )
-                    .append( '\n' );
+                sb.append( "                Referral[" ).
+                    append( i++ ).
+                    append( "] :" ).
+                    append( referral ).
+                    append( '\n' );
             }
         }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java Mon Nov 27 08:53:30 2006
@@ -29,7 +29,6 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.ModificationItem;
-import javax.naming.ldap.Control;
 
 import org.apache.directory.shared.asn1.Asn1Object;
 import org.apache.directory.shared.asn1.codec.DecoderException;
@@ -751,7 +750,7 @@
         }
 
         // Transform the controls, too
-        ArrayList twixControls = twixMessage.getControls();
+        List twixControls = twixMessage.getControls();
 
         if ( twixControls != null )
         {
@@ -1237,9 +1236,10 @@
     private void transformControls( LdapMessage twixMessage, Message msg )
     {
         Iterator list = msg.getControls().values().iterator();
+        
         while ( list.hasNext() )
         {
-            Control control = ( Control ) list.next();
+            javax.naming.ldap.Control control = ( javax.naming.ldap.Control ) list.next();
             org.apache.directory.shared.ldap.codec.Control twixControl = new org.apache.directory.shared.ldap.codec.Control();
             twixMessage.addControl( twixControl );
             twixControl.setCriticality( control.isCritical() );

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java Mon Nov 27 08:53:30 2006
@@ -441,7 +441,7 @@
         StringBuffer sb = new StringBuffer();
 
         sb.append( "    Add Request\n" );
-        sb.append( "        Entry : '" ).append( entry.toString() ).append( "'\n" );
+        sb.append( "        Entry : '" ).append( entry ).append( "'\n" );
         sb.append( "        Attributes\n" );
 
         if ( ( attributes == null ) || ( attributes.size() == 0 ) )

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequest.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequest.java Mon Nov 27 08:53:30 2006
@@ -262,22 +262,21 @@
         sb.append( "    BindRequest\n" );
         sb.append( "        Version : '" ).append( version ).append( "'\n" );
 
-        if ( StringTools.isEmpty( name.toString() ) )
+        if ( ( null == name ) || StringTools.isEmpty( name.toString() ) )
         {
             sb.append( "        Name : anonymous\n" );
         }
         else
         {
-            sb.append( "        Name : '" ).append( name.toString() ).append( "'\n" );
+            sb.append( "        Name : '" ).append( name ).append( "'\n" );
 
             if ( authentication instanceof SimpleAuthentication )
             {
-                sb.append( "        Simple authentication : '" ).append(
-                    ( ( SimpleAuthentication ) authentication ).toString() ).append( "'\n" );
+                sb.append( "        Simple authentication : '" ).append( authentication ).append( "'\n" );
             }
             else
             {
-                sb.append( ( ( SaslCredentials ) authentication ).toString() );
+                sb.append( authentication );
             }
         }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java Mon Nov 27 08:53:30 2006
@@ -27,6 +27,7 @@
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapResponse;
+import org.apache.directory.shared.ldap.util.StringTools;
 
 
 /**
@@ -186,7 +187,9 @@
 
         if ( serverSaslCreds != null )
         {
-            sb.append( "        Server sasl credentials : '" ).append( serverSaslCreds.toString() ).append( "'\n" );
+            sb.append( "        Server sasl credentials : '" ).
+                append( StringTools.dumpBytes( serverSaslCreds ) ).
+                append( "'\n" );
         }
 
         return sb.toString();

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java Mon Nov 27 08:53:30 2006
@@ -208,11 +208,13 @@
         StringBuffer sb = new StringBuffer();
 
         sb.append( "        Sasl credentials\n" );
-        sb.append( "            Mechanism :'" ).append( mechanism.toString() ).append( "'\n" );
+        sb.append( "            Mechanism :'" ).append( mechanism ).append( "'\n" );
 
         if ( credentials != null )
         {
-            sb.append( "            Credentials :'" ).append( credentials.toString() ).append( "'\n" );
+            sb.append( "            Credentials :'" ).
+                append( StringTools.dumpBytes(  credentials ) ).
+                append( "'\n" );
         }
 
         return sb.toString();

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequest.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequest.java Mon Nov 27 08:53:30 2006
@@ -274,9 +274,9 @@
         StringBuffer sb = new StringBuffer();
 
         sb.append( "    Compare request\n" );
-        sb.append( "        Entry : '" ).append( entry.toString() ).append( "'\n" );
-        sb.append( "        Attribute description : '" ).append( attributeDesc.toString() ).append( "'\n" );
-        sb.append( "        Attribute value : '" ).append( assertionValue.toString() ).append( "'\n" );
+        sb.append( "        Entry : '" ).append( entry ).append( "'\n" );
+        sb.append( "        Attribute description : '" ).append( attributeDesc ).append( "'\n" );
+        sb.append( "        Attribute value : '" ).append( StringTools.dumpObject( assertionValue )  ).append( "'\n" );
 
         return sb.toString();
     }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequest.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequest.java Mon Nov 27 08:53:30 2006
@@ -157,7 +157,7 @@
         StringBuffer sb = new StringBuffer();
 
         sb.append( "    Del request\n" );
-        sb.append( "        Entry : '" ).append( entry.toString() ).append( "'\n" );
+        sb.append( "        Entry : '" ).append( entry ).append( "'\n" );
 
         return sb.toString();
     }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequest.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequest.java Mon Nov 27 08:53:30 2006
@@ -227,11 +227,13 @@
         StringBuffer sb = new StringBuffer();
 
         sb.append( "    Extended request\n" );
-        sb.append( "        Request name : '" ).append( requestName.toString() ).append( "'\n" );
+        sb.append( "        Request name : '" ).append( requestName ).append( "'\n" );
 
         if ( requestValue != null )
         {
-            sb.append( "        Request value : '" ).append( requestValue.toString() ).append( "'\n" );
+            sb.append( "        Request value : '" ).
+                append( StringTools.dumpBytes( requestValue ) ).
+                append( "'\n" );
         }
 
         return sb.toString();

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponse.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponse.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponse.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponse.java Mon Nov 27 08:53:30 2006
@@ -264,12 +264,12 @@
 
         if ( responseName != null )
         {
-            sb.append( "        Response name :'" ).append( responseName.toString() ).append( "'\n" );
+            sb.append( "        Response name :'" ).append( responseName ).append( "'\n" );
         }
 
         if ( response != null )
         {
-            sb.append( "        Response :'" ).append( response.toString() ).append( "'\n" );
+            sb.append( "        Response :'" ).append( response ).append( "'\n" );
         }
 
         return sb.toString();

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnect.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnect.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnect.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnect.java Mon Nov 27 08:53:30 2006
@@ -211,16 +211,14 @@
         sb.append( "    TimeOffline : " ).append( timeOffline ).append( '\n' );
         sb.append( "    Delay : " ).append( delay ).append( '\n' );
 
-        if ( replicatedContexts.size() != 0 )
+        if ( ( replicatedContexts != null) && ( replicatedContexts.size() != 0 ) )
         {
-            Iterator replicatedContextIterator = replicatedContexts.iterator();
             sb.append( "    Replicated contexts :" );
 
             // We may have more than one reference.
-            while ( replicatedContextIterator.hasNext() )
+            for ( LdapURL url:replicatedContexts )
             {
-                LdapURL url = ( LdapURL ) replicatedContextIterator.next();
-                sb.append( "\n        " ).append( url.toString() );
+                sb.append( "\n        " ).append( url );
             }
         }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdown.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdown.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdown.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdown.java Mon Nov 27 08:53:30 2006
@@ -113,7 +113,7 @@
     {
         StringBuffer sb = new StringBuffer();
 
-        sb.append( "Graceful Shiutdown extended operation" );
+        sb.append( "Graceful Shutdown extended operation" );
         sb.append( "    TimeOffline : " ).append( timeOffline ).append( '\n' );
         sb.append( "    Delay : " ).append( delay ).append( '\n' );
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java Mon Nov 27 08:53:30 2006
@@ -539,7 +539,6 @@
      */
     public String toString()
     {
-
         StringBuffer sb = new StringBuffer();
 
         sb.append( "    Modify Request\n" );
@@ -547,60 +546,76 @@
 
         if ( modifications != null )
         {
-
-            for ( int i = 0; i < modifications.size(); i++ )
+            int i = 0;
+            
+            for ( ModificationItem modification:modifications )
             {
-
-                ModificationItem modification = ( ModificationItem ) modifications.get( i );
-
                 sb.append( "            Modification[" ).append( i ).append( "]\n" );
                 sb.append( "                Operation : " );
 
-                switch ( modification.getModificationOp() )
+                if ( modification != null )
                 {
-
-                    case DirContext.ADD_ATTRIBUTE:
-                        sb.append( " add\n" );
-                        break;
-
-                    case DirContext.REPLACE_ATTRIBUTE:
-                        sb.append( " replace\n" );
-                        break;
-
-                    case DirContext.REMOVE_ATTRIBUTE:
-                        sb.append( " delete\n" );
-                        break;
-                }
-
-                sb.append( "                Modification\n" );
-
-                Attribute attribute = modification.getAttribute();
-
-                try
-                {
-                    sb.append( "                    Type : '" ).append( attribute.getID() ).append( "'\n" );
-                    sb.append( "                    Vals\n" );
-
-                    for ( int j = 0; j < attribute.size(); j++ )
+                    switch ( modification.getModificationOp() )
                     {
+    
+                        case DirContext.ADD_ATTRIBUTE:
+                            sb.append( " add\n" );
+                            break;
+    
+                        case DirContext.REPLACE_ATTRIBUTE:
+                            sb.append( " replace\n" );
+                            break;
+    
+                        case DirContext.REMOVE_ATTRIBUTE:
+                            sb.append( " delete\n" );
+                            break;
+                    }
 
-                        Object attributeValue = attribute.get( j );
-                        sb.append( "                        Val[" ).append( j ).append( "] : '" );
-
-                        if ( attributeValue instanceof String )
+                    sb.append( "                Modification\n" );
+    
+                    Attribute attribute = modification.getAttribute();
+    
+                    if ( attribute != null )
+                    {
+                        try
                         {
-                            sb.append( attributeValue ).append( "' \n" );
+                            sb.append( "                    Type : '" ).append( attribute.getID() ).append( "'\n" );
+                            sb.append( "                    Vals\n" );
+        
+                            for ( int j = 0; j < attribute.size(); j++ )
+                            {
+        
+                                Object attributeValue = attribute.get( j );
+                                sb.append( "                        Val[" ).append( j ).append( "] : '" );
+        
+                                if ( attributeValue != null )
+                                {
+                                    if ( attributeValue instanceof String )
+                                    {
+                                        sb.append( attributeValue ).append( "' \n" );
+                                    }
+                                    else
+                                    {
+                                        sb.append( StringTools.utf8ToString( ( byte[] ) attributeValue ) ).append( "' \n" );
+                                    }
+                                }
+                                else
+                                {
+                                    sb.append( "<null>'\n" );
+                                }
+                            }
                         }
-                        else
+                        catch ( NamingException ne )
                         {
-                            sb.append( StringTools.utf8ToString( ( byte[] ) attributeValue ) ).append( "' \n" );
+                            log.error( "Naming exception while printing the '{}'", attribute.getID() );
                         }
                     }
                 }
-                catch ( NamingException ne )
+                else
                 {
-                    log.error( "Naming exception while printing the '{}'", attribute.getID() );
+                    sb.append( " unknown modification operation\n" );
                 }
+
             }
         }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequest.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequest.java Mon Nov 27 08:53:30 2006
@@ -289,12 +289,12 @@
 
         sb.append( "    ModifyDN Response\n" );
         sb.append( "        Entry : '" ).append( entry ).append( "'\n" );
-        sb.append( "        New RDN : '" ).append( newRDN.toString() ).append( "'\n" );
+        sb.append( "        New RDN : '" ).append( newRDN ).append( "'\n" );
         sb.append( "        Delete old RDN : " ).append( deleteOldRDN ).append( "\n" );
 
         if ( newSuperior != null )
         {
-            sb.append( "        New superior : '" ).append( newSuperior.toString() ).append( "'\n" );
+            sb.append( "        New superior : '" ).append( newSuperior ).append( "'\n" );
         }
 
         return sb.toString();

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java Mon Nov 27 08:53:30 2006
@@ -235,6 +235,6 @@
      */
     public String toString()
     {
-        return assertion.toStringRFC2254( filterType );
+        return assertion != null ? assertion.toStringRFC2254( filterType ) : "";
     }
 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java Mon Nov 27 08:53:30 2006
@@ -154,20 +154,13 @@
      */
     public String toString()
     {
-
         StringBuffer sb = new StringBuffer();
 
         if ( ( filterSet != null ) && ( filterSet.size() != 0 ) )
         {
-
-            Iterator filterIterator = filterSet.iterator();
-
-            while ( filterIterator.hasNext() )
+            for ( Filter filter:filterSet )
             {
-
-                Filter filter = ( Filter ) filterIterator.next();
-
-                sb.append( '(' ).append( filter.toString() ).append( ')' );
+                sb.append( '(' ).append( filter ).append( ')' );
             }
         }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java Mon Nov 27 08:53:30 2006
@@ -344,7 +344,7 @@
 
         if ( type != null )
         {
-            sb.append( type.toString() );
+            sb.append( type );
         }
 
         if ( dnAttributes )
@@ -362,10 +362,10 @@
         }
         else
         {
-            sb.append( ':' ).append( matchingRule.toString() );
+            sb.append( ':' ).append( matchingRule );
         }
 
-        sb.append( ":=" ).append( matchValue.toString() );
+        sb.append( ":=" ).append( matchValue );
 
         return sb.toString();
     }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java Mon Nov 27 08:53:30 2006
@@ -610,11 +610,7 @@
 
         StringBuffer sb = new StringBuffer();
 
-        sb.append( "(" );
-
-        sb.append( filter.toString() );
-
-        sb.append( ")" );
+        sb.append( "(" ).append( filter ).append( ")" );
 
         return sb.toString();
     }
@@ -627,23 +623,29 @@
     {
         StringBuffer sb = new StringBuffer();
 
-        NamingEnumeration attrs = attributes.getAll();
-        boolean isFirst = true;
-
-        while ( attrs.hasMoreElements() )
+        if ( attributes != null )
         {
-            Attribute attr = ( BasicAttribute ) attrs.nextElement();
-
-            if ( isFirst )
+            NamingEnumeration attrs = attributes.getAll();
+            boolean isFirst = true;
+    
+            if ( attrs != null )
             {
-                isFirst = false;
+                while ( attrs.hasMoreElements() )
+                {
+                    Attribute attr = ( BasicAttribute ) attrs.nextElement();
+        
+                    if ( isFirst )
+                    {
+                        isFirst = false;
+                    }
+                    else
+                    {
+                        sb.append( ", " );
+                    }
+        
+                    sb.append( attr != null ? attr.getID() : "<no ID>" );
+                }
             }
-            else
-            {
-                sb.append( ", " );
-            }
-
-            sb.append( attr.getID() );
         }
 
         return sb.toString();

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java Mon Nov 27 08:53:30 2006
@@ -448,7 +448,7 @@
         StringBuffer sb = new StringBuffer();
 
         sb.append( "    Search Result Entry\n" );
-        sb.append( "        Object Name : '" ).append( objectName.toString() ).append( "'\n" );
+        sb.append( "        Object Name : '" ).append( objectName ).append( "'\n" );
         sb.append( "        Attributes\n" );
 
         if ( ( partialAttributeList == null ) || ( partialAttributeList.size() == 0 ) )

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultReference.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultReference.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultReference.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultReference.java Mon Nov 27 08:53:30 2006
@@ -31,6 +31,7 @@
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
 
 /**
@@ -46,7 +47,7 @@
     // ----------------------------------------------------------------------------
 
     /** The set of LdapURLs */
-    private ArrayList searchResultReferences;
+    private List<LdapURL> searchResultReferences;
 
     /** The search result reference length */
     private transient int searchResultReferenceLength;
@@ -61,7 +62,7 @@
     public SearchResultReference()
     {
         super();
-        searchResultReferences = new ArrayList();
+        searchResultReferences = new ArrayList<LdapURL>();
     }
 
 
@@ -95,7 +96,7 @@
      * 
      * @return An ArrayList of SearchResultReferences
      */
-    public ArrayList getSearchResultReferences()
+    public List<LdapURL> getSearchResultReferences()
     {
         return searchResultReferences;
     }
@@ -202,11 +203,9 @@
         {
             sb.append( "        References\n" );
 
-            Iterator referencesIterator = searchResultReferences.iterator();
-
-            while ( referencesIterator.hasNext() )
+            for ( LdapURL url:searchResultReferences )
             {
-                sb.append( "            '" ).append( ( ( LdapURL ) referencesIterator.next() ).toString() ).append(
+                sb.append( "            '" ).append( url ).append(
                     "'\n" );
             }
         }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java Mon Nov 27 08:53:30 2006
@@ -24,6 +24,7 @@
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
@@ -70,7 +71,7 @@
     private String initialSubstrings;
 
     /** The any filter. It's a list of LdapString */
-    private ArrayList anySubstrings;
+    private List<String> anySubstrings;
 
     /** The final filter */
     private String finalSubstrings;
@@ -91,7 +92,7 @@
      */
     public SubstringFilter()
     {
-        anySubstrings = new ArrayList( 1 );
+        anySubstrings = new ArrayList<String>( 1 );
     }
 
 
@@ -100,7 +101,7 @@
      * 
      * @return Returns the anySubstrings.
      */
-    public ArrayList getAnySubstrings()
+    public List<String> getAnySubstrings()
     {
         return anySubstrings;
     }
@@ -360,24 +361,22 @@
 
         if ( initialSubstrings != null )
         {
-            sb.append( initialSubstrings.toString() );
+            sb.append( initialSubstrings );
         }
 
         sb.append( '*' );
 
         if ( anySubstrings != null )
         {
-            Iterator anyIterator = anySubstrings.iterator();
-
-            while ( anyIterator.hasNext() )
+            for ( String any:anySubstrings )
             {
-                sb.append( ( String ) anyIterator.next() ).append( '*' );
+                sb.append( any ).append( '*' );
             }
         }
 
         if ( finalSubstrings != null )
         {
-            sb.append( finalSubstrings.toString() );
+            sb.append( finalSubstrings );
         }
 
         return sb.toString();

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControl.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControl.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControl.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControl.java Mon Nov 27 08:53:30 2006
@@ -169,6 +169,7 @@
         sb.append( "    Entry Change Control\n" );
         sb.append( "        changeType   : '" ).append( changeType ).append( "'\n" );
         sb.append( "        previousDN   : '" ).append( previousDn ).append( "'\n" );
+        
         if ( changeNumber == UNDEFINED_CHANGE_NUMBER )
         {
             sb.append( "        changeNumber : '" ).append( "UNDEFINED" ).append( "'\n" );
@@ -177,6 +178,7 @@
         {
             sb.append( "        changeNumber : '" ).append( changeNumber ).append( "'\n" );
         }
+        
         return sb.toString();
     }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java Mon Nov 27 08:53:30 2006
@@ -347,48 +347,57 @@
 
         sb.append( tabs ).append( "Attributes\n" );
 
-        NamingEnumeration attributesIterator = attributes.getAll();
-
-        while ( attributesIterator.hasMoreElements() )
+        if ( attributes != null )
         {
-            Attribute attribute = ( Attribute ) attributesIterator.nextElement();
-
-            sb.append( tabs ).append( "    Type : '" ).append( attribute.getID() ).append( "'\n" );
-
-            for ( int j = 0; j < attribute.size(); j++ )
+            NamingEnumeration attributesIterator = attributes.getAll();
+    
+            while ( attributesIterator.hasMoreElements() )
             {
-
-                try
+                Attribute attribute = ( Attribute ) attributesIterator.nextElement();
+    
+                if ( attribute != null )
                 {
-                    Object attr = attribute.get( j );
-
-                    if ( attr instanceof String )
+                    sb.append( tabs ).append( "    Type : '" ).append( attribute.getID() ).append( "'\n" );
+        
+                    for ( int j = 0; j < attribute.size(); j++ )
                     {
-                        sb.append( tabs ).append( "        Val[" ).append( j ).append( "] : " ).append( attr ).append(
-                            " \n" );
+        
+                        try
+                        {
+                            Object attr = attribute.get( j );
+        
+                            if ( attr != null )
+                            {
+                                if ( attr instanceof String )
+                                {
+                                    sb.append( tabs ).append( "        Val[" ).append( j ).append( "] : " ).append( attr ).append(
+                                        " \n" );
+                                }
+                                else if ( attr instanceof byte[] )
+                                {
+                                    String string = StringTools.utf8ToString( ( byte[] ) attr );
+            
+                                    sb.append( tabs ).append( "        Val[" ).append( j ).append( "] : " );
+                                    sb.append( string ).append( '/' );
+                                    sb.append( StringTools.dumpBytes( ( byte[] ) attr ) );
+                                    sb.append( " \n" );
+                                }
+                                else
+                                {
+                                    sb.append( tabs ).append( "        Val[" ).append( j ).append( "] : " ).append( attr ).append(
+                                        " \n" );
+                                }
+                            }
+                        }
+                        catch ( NamingException ne )
+                        {
+                            sb.append( "Bad attribute : " ).append( ne.getMessage() );
+                        }
                     }
-                    else if ( attr instanceof byte[] )
-                    {
-                        String string = StringTools.utf8ToString( ( byte[] ) attr );
-
-                        sb.append( tabs ).append( "        Val[" ).append( j ).append( "] : " );
-                        sb.append( string ).append( '/' );
-                        sb.append( StringTools.dumpBytes( ( byte[] ) attr ) );
-                        sb.append( " \n" );
-                    }
-                    else
-                    {
-                        sb.append( tabs ).append( "        Val[" ).append( j ).append( "] : " ).append( attr ).append(
-                            " \n" );
-                    }
-                }
-                catch ( NamingException ne )
-                {
-                    sb.append( "Bad attribute : " ).append( ne.getMessage() );
                 }
             }
         }
-
+        
         return sb.toString();
     }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java Mon Nov 27 08:53:30 2006
@@ -834,6 +834,35 @@
     }
 
     /**
+     * 
+     * Helper method to render an object which can be a String or a byte[]
+     *
+     * @return A string representing the object
+     */
+    public static String dumpObject( Object object )
+    {
+        if ( object != null )
+        {
+            if ( object instanceof String )
+            {
+                return (String)object;
+            }
+            else if ( object instanceof byte[] )
+            {
+                return dumpBytes( (byte[])object );
+            }
+            else
+            {
+                return "<unknown type>";
+            }
+        }
+        else
+        {
+            return "";
+        }
+    }
+
+    /**
      * Helper function that dump an array of bytes in hex pair form, 
      * without '0x' and space chars
      * 

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java?view=diff&rev=479688&r1=479687&r2=479688
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java Mon Nov 27 08:53:30 2006
@@ -4223,4 +4223,69 @@
             fail( ee.getMessage() );
         }
     }
+    
+    /**
+     * Test the decoding of a SearchRequest
+     * for rootDSE
+     */
+    public void testDecodeSearchRequestRootDSE()
+    {
+        Asn1Decoder ldapDecoder = new LdapDecoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x33 );
+        stream.put( new byte[]
+            { 
+                0x30, (byte)0x84, 0x00, 0x00, 0x00, 0x2D, 
+                  0x02, 0x01, 0x01, 
+                  0x63, (byte)0x84, 0x00, 0x00, 0x00, 0x24, 
+                    0x04, 0x00, 
+                    0x0A, 0x01, 0x00, 
+                    0x0A, 0x01, 0x00, 
+                    0x02, 0x01, 0x00, 
+                    0x02, 0x01, 0x00, 
+                    0x01, 0x01, 0x00, 
+                    (byte)0x87, 0x0B, 
+                      0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x43, 0x6C, 0x61, 0x73, 0x73, 
+                    0x30, (byte)0x84, 0x00, 0x00, 0x00, 0x00
+            } );
+
+        String decodedPdu = StringTools.dumpBytes( stream.array() );
+        stream.flip();
+
+        // Allocate a BindRequest Container
+        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+        try
+        {
+            ldapDecoder.decode( stream, ldapMessageContainer );
+        }
+        catch ( DecoderException de )
+        {
+            de.printStackTrace();
+            fail( de.getMessage() );
+        }
+        catch ( NamingException ne )
+        {
+            ne.printStackTrace();
+            fail( ne.getMessage() );
+        }
+
+        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+        SearchRequest sr = message.getSearchRequest();
+
+        assertEquals( 1, message.getMessageId() );
+        assertEquals( "", sr.getBaseObject().toString() );
+        assertEquals( ScopeEnum.BASE_OBJECT, sr.getScope() );
+        assertEquals( LdapConstants.SCOPE_BASE_OBJECT, sr.getDerefAliases() );
+        assertEquals( 0, sr.getSizeLimit() );
+        assertEquals( 0, sr.getTimeLimit() );
+        assertEquals( false, sr.isTypesOnly() );
+        
+        PresentFilter presentFilter = ( PresentFilter ) sr.getFilter();
+        assertNotNull( presentFilter );
+        assertEquals( "objectClass", presentFilter.getAttributeDescription().toString() );
+        
+        Attributes attributes = sr.getAttributes();
+        assertEquals( 0, attributes.size() );
+    }
 }



Mime
View raw message