directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r690196 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/codec/ main/java/org/apache/directory/shared/ldap/codec/search/ main/java/org/apache/directory/shared/ldap/filter/ main/java/org/apache/directory/shar...
Date Fri, 29 Aug 2008 11:53:34 GMT
Author: elecharny
Date: Fri Aug 29 04:53:33 2008
New Revision: 690196

URL: http://svn.apache.org/viewvc?rev=690196&view=rev
Log:
o Removed JNDI elements from the SearchRequest message
o Removed JNDI elements from the Assertion class 

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/Assertion.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java?rev=690196&r1=690195&r2=690196&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
Fri Aug 29 04:53:33 2008
@@ -25,8 +25,6 @@
 import java.util.List;
 
 import javax.naming.InvalidNameException;
-import javax.naming.NamingEnumeration;
-import javax.naming.directory.Attribute;
 
 import org.apache.directory.shared.asn1.Asn1Object;
 import org.apache.directory.shared.asn1.codec.DecoderException;
@@ -64,6 +62,7 @@
 import org.apache.directory.shared.ldap.codec.search.controls.PSearchControlCodec;
 import org.apache.directory.shared.ldap.codec.search.controls.SubEntryControlCodec;
 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.filter.AndNode;
 import org.apache.directory.shared.ldap.filter.ApproximateNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
@@ -82,7 +81,6 @@
 import org.apache.directory.shared.ldap.message.AddRequestImpl;
 import org.apache.directory.shared.ldap.message.AddResponseImpl;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.message.BindRequestImpl;
 import org.apache.directory.shared.ldap.message.BindResponseImpl;
 import org.apache.directory.shared.ldap.message.CascadeControl;
@@ -663,17 +661,15 @@
         // Twix : ArrayList attributes -> Snickers : ArrayList attributes
         if ( searchRequest.getAttributes() != null )
         {
-            NamingEnumeration<?> attributes = searchRequest.getAttributes().getAll();
+            List<EntryAttribute> attributes = searchRequest.getAttributes();
 
-            if ( attributes != null )
+            if ( ( attributes != null ) && ( attributes.size() != 0 ) )
             {
-                while ( attributes.hasMoreElements() )
+                for ( EntryAttribute attribute:attributes )
                 {
-                    Attribute attribute = ( AttributeImpl ) attributes.nextElement();
-
                     if ( attribute != null )
                     {
-                        snickersMessage.addAttribute( attribute.getID() );
+                        snickersMessage.addAttribute( attribute.getId() );
                     }
                 }
             }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java?rev=690196&r1=690195&r2=690196&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java
Fri Aug 29 04:53:33 2008
@@ -23,10 +23,8 @@
 import java.io.UnsupportedEncodingException;
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.directory.shared.asn1.Asn1Object;
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
@@ -38,9 +36,9 @@
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapMessage;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
 import org.apache.directory.shared.ldap.filter.SearchScope;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
 
@@ -89,7 +87,7 @@
     private Filter filter;
     
     /** The list of attributes to get */
-    private Attributes attributes = new AttributesImpl( true );
+    private List<EntryAttribute> attributes = new ArrayList<EntryAttribute>();
 
     /** The current filter. This is used while decoding a PDU */
     private Filter currentFilter;
@@ -135,7 +133,7 @@
      * 
      * @return Returns the attributes.
      */
-    public Attributes getAttributes()
+    public List<EntryAttribute> getAttributes()
     {
         return attributes;
     }
@@ -148,7 +146,7 @@
      */
     public void addAttribute( String attribute )
     {
-        attributes.put( new AttributeImpl( attribute ) );
+        attributes.add( new DefaultClientAttribute( attribute ) );
     }
 
 
@@ -493,17 +491,13 @@
 
         if ( ( attributes != null ) && ( attributes.size() != 0 ) )
         {
-            NamingEnumeration<? extends Attribute> attributeIterator = attributes.getAll();
-
             // Compute the attributes length
-            while ( attributeIterator.hasMoreElements() )
+            for ( EntryAttribute attribute:attributes )
             {
-                Attribute attribute = attributeIterator.nextElement();
-
                 // add the attribute length to the attributes length
                 try
                 {
-                    int idLength = attribute.getID().getBytes( "UTF-8" ).length;
+                    int idLength = attribute.getId().getBytes( "UTF-8" ).length;
                     attributeDescriptionListLength += 1 + TLV.getNbBytes( idLength ) + idLength;
                 }
                 catch ( UnsupportedEncodingException uee )
@@ -587,14 +581,10 @@
 
             if ( ( attributes != null ) && ( attributes.size() != 0 ) )
             {
-                NamingEnumeration<? extends Attribute> attributeIterator = attributes.getAll();
-
                 // encode each attribute
-                while ( attributeIterator.hasMoreElements() )
+                for ( EntryAttribute attribute:attributes )
                 {
-                    Attribute attribute = ( AttributeImpl ) attributeIterator.nextElement();
-
-                    Value.encode( buffer, attribute.getID() );
+                    Value.encode( buffer, attribute.getId() );
                 }
             }
         }
@@ -634,15 +624,13 @@
 
         if ( attributes != null )
         {
-            NamingEnumeration<? extends Attribute> attrs = attributes.getAll();
             boolean isFirst = true;
     
-            if ( attrs != null )
+            if ( ( attributes != null ) && ( attributes.size() != 0 ) )
             {
-                while ( attrs.hasMoreElements() )
+                // encode each attribute
+                for ( EntryAttribute attribute:attributes )
                 {
-                    Attribute attr = attrs.nextElement();
-        
                     if ( isFirst )
                     {
                         isFirst = false;
@@ -652,7 +640,7 @@
                         sb.append( ", " );
                     }
         
-                    sb.append( attr != null ? attr.getID() : "<no ID>" );
+                    sb.append( attribute != null ? attribute.getId() : "<no ID>" );
                 }
             }
         }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/Assertion.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/Assertion.java?rev=690196&r1=690195&r2=690196&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/Assertion.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/Assertion.java
Fri Aug 29 04:53:33 2008
@@ -21,7 +21,8 @@
 
 
 import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
+
+import org.apache.directory.shared.ldap.entry.Entry;
 
 
 /**
@@ -35,18 +36,14 @@
 {
     /**
      * Checks to see if a candidate is valid by asserting an arbitrary predicate
-     * against the candidate. Where available entry attributes will be provided
+     * against the candidate. Where available entry will be provided
      * however there is no guarantee. The entry's attributes are only provided
      * if they were previously accessed. All assertions should handle cases
      * where the entry argument is null.
      * 
-     * @param a_dn
-     *            the normalized dn of the candidate entry to be tested
-     * @param a_entry
-     *            the entry's attributes if available
+     * @param entry the entry if available
      * @return true if the candidate satisfies the predicate, false otherwise
-     * @throws NamingException
-     *             if an error occurs while asserting the predicate
+     * @throws NamingException if an error occurs while asserting the predicate
      */
-    boolean assertCandidate( String a_dn, Attributes a_entry ) throws NamingException;
+    boolean assertCandidate( Entry entry ) throws NamingException;
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java?rev=690196&r1=690195&r2=690196&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
Fri Aug 29 04:53:33 2008
@@ -25,17 +25,12 @@
 import java.util.Map;
 import java.util.Set;
 
-import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
 
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.Value;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.schema.syntax.AbstractAdsSchemaDescription;
 import org.apache.directory.shared.ldap.schema.syntax.AbstractSchemaDescription;
 import org.apache.directory.shared.ldap.schema.syntax.AttributeTypeDescription;
@@ -126,83 +121,6 @@
     }
 
 
-    /**
-     * Gets the target entry as it would look after a modification operation 
-     * were performed on it.
-     * 
-     * @param modOp the modification operation performed: add, remove, replace
-     * @param mods the modified attributes
-     * @param entry the source entry that is modified
-     * @return the resultant entry after the modifications have taken place
-     * @throws NamingException if there are problems accessing attributes
-     */
-    public static Attributes getTargetEntry( int modOp, Attributes mods, Attributes entry
) throws NamingException
-    {
-        Attributes targetEntry = ( Attributes ) entry.clone();
-        NamingEnumeration<String> list = mods.getIDs();
-        switch ( modOp )
-        {
-            case ( DirContext.REPLACE_ATTRIBUTE  ):
-                while ( list.hasMore() )
-                {
-                    targetEntry.put( mods.get( list.next() ) );
-                }
-                break;
-            case ( DirContext.REMOVE_ATTRIBUTE  ):
-                while ( list.hasMore() )
-                {
-                    String id = list.next();
-                    Attribute toBeRemoved = mods.get( id );
-
-                    if ( toBeRemoved.size() == 0 )
-                    {
-                        targetEntry.remove( id );
-                    }
-                    else
-                    {
-                        Attribute existing = targetEntry.get( id );
-
-                        if ( existing != null )
-                        {
-                            for ( int ii = 0; ii < toBeRemoved.size(); ii++ )
-                            {
-                                existing.remove( toBeRemoved.get( ii ) );
-                            }
-                        }
-                    }
-                }
-                break;
-            case ( DirContext.ADD_ATTRIBUTE  ):
-                while ( list.hasMore() )
-                {
-                    String id = list.next();
-                    Attribute combined = new AttributeImpl( id );
-                    Attribute toBeAdded = mods.get( id );
-                    Attribute existing = entry.get( id );
-
-                    if ( existing != null )
-                    {
-                        for ( int ii = 0; ii < existing.size(); ii++ )
-                        {
-                            combined.add( existing.get( ii ) );
-                        }
-                    }
-
-                    for ( int ii = 0; ii < toBeAdded.size(); ii++ )
-                    {
-                        combined.add( toBeAdded.get( ii ) );
-                    }
-                    targetEntry.put( combined );
-                }
-                break;
-            default:
-                throw new IllegalStateException( "undefined modification type: " + modOp
);
-        }
-
-        return targetEntry;
-    }
-
-
     // ------------------------------------------------------------------------
     // qdescrs rendering operations
     // ------------------------------------------------------------------------

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java?rev=690196&r1=690195&r2=690196&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java
Fri Aug 29 04:53:33 2008
@@ -22,10 +22,9 @@
 
 import java.nio.ByteBuffer;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
-import javax.naming.directory.Attributes;
-
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
 import org.apache.directory.shared.asn1.codec.DecoderException;
@@ -36,6 +35,7 @@
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
 import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.schema.OidNormalizer;
@@ -141,11 +141,11 @@
         assertEquals( true, sr.isTypesOnly() );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes  )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the length
@@ -381,7 +381,7 @@
         assertEquals( "", extensibleMatchFilter.getMatchValue().toString() );
         assertFalse( extensibleMatchFilter.isDnAttributes() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
         assertEquals( 0, attributes.size() );
     }
@@ -663,7 +663,7 @@
         assertEquals( "test", extensibleMatchFilter.getMatchValue() );
         assertFalse( extensibleMatchFilter.isDnAttributes() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
         assertEquals( 0, attributes.size() );
     }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java?rev=690196&r1=690195&r2=690196&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java
Fri Aug 29 04:53:33 2008
@@ -25,8 +25,6 @@
 import java.util.List;
 import java.util.Map;
 
-import javax.naming.directory.Attributes;
-
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
 import org.apache.directory.shared.asn1.codec.DecoderException;
@@ -38,6 +36,7 @@
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.search.SearchRequest;
 import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.schema.OidNormalizer;
@@ -157,11 +156,11 @@
         assertEquals( "t", substringFilter.getInitialSubstrings() );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the length
@@ -273,11 +272,11 @@
         assertEquals( "t", substringFilter.getInitialSubstrings() );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the Control
@@ -398,11 +397,11 @@
         assertEquals( null, substringFilter.getFinalSubstrings() );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the length
@@ -515,11 +514,11 @@
         assertEquals( "t", substringFilter.getFinalSubstrings() );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the length
@@ -633,11 +632,11 @@
         assertEquals( "t", substringFilter.getFinalSubstrings() );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the length
@@ -749,11 +748,11 @@
         assertEquals( "t", substringFilter.getAnySubstrings().get( 0 ) );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the length
@@ -862,11 +861,11 @@
         assertEquals( "t", substringFilter.getFinalSubstrings() );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the length
@@ -978,11 +977,11 @@
         assertEquals( "*", substringFilter.getAnySubstrings().get( 0 ) );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the length
@@ -1098,11 +1097,11 @@
         assertEquals( null, substringFilter.getFinalSubstrings() );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the length
@@ -1215,11 +1214,11 @@
         assertEquals( "Amos", substringFilter.getFinalSubstrings() );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the length

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java?rev=690196&r1=690195&r2=690196&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
Fri Aug 29 04:53:33 2008
@@ -22,10 +22,10 @@
 
 import java.nio.ByteBuffer;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-
-import javax.naming.directory.Attributes;
+import java.util.Set;
 
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
@@ -48,6 +48,7 @@
 import org.apache.directory.shared.ldap.codec.search.controls.SubEntryControlCodec;
 import org.apache.directory.shared.ldap.message.Message;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.message.SearchResponseDoneImpl;
 import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
@@ -219,11 +220,11 @@
         assertEquals( "objectclass", assertion.getAttributeDesc() );
         assertEquals( "ttt", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the encoding
@@ -384,11 +385,11 @@
         assertEquals( "ttt", assertion.getAssertionValue().get() );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the length
@@ -551,11 +552,11 @@
         assertEquals( "ttt", assertion.getAssertionValue().get() );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the length
@@ -656,7 +657,7 @@
         assertEquals( "objectClass", presentFilter.getAttributeDescription() );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
         assertEquals( 0, attributes.size() );
 
@@ -756,7 +757,7 @@
         assertEquals( "objectClass", presentFilter.getAttributeDescription() );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
         assertEquals( 1, attributes.size() );
     }
@@ -838,11 +839,20 @@
         assertEquals( "objectClass", presentFilter.getAttributeDescription() );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
         assertEquals( 2, attributes.size() );
-        assertNotNull( attributes.get( "sn" ) );
-        assertNotNull( attributes.get( "*" ) );
+        Set<String> expectedAttrs = new HashSet<String>();
+        expectedAttrs.add( "sn" );
+        expectedAttrs.add( "*" );
+        
+        for ( EntryAttribute attribute:attributes )
+        {
+            assertTrue( expectedAttrs.contains( attribute.getId() ) );
+            expectedAttrs.remove( attribute.getId() );
+        }
+        
+        assertEquals( 0, expectedAttrs.size() );
     }        
 
 
@@ -969,11 +979,11 @@
         assertEquals( "abok", assertion.getAssertionValue().get() );
 
         // The attributes
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the length
@@ -1249,11 +1259,11 @@
         assertEquals( "organizationalUnitName", assertion.getAttributeDesc() );
         assertEquals( "ttt", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // We won't check the encoding, as it has changed because of
@@ -1556,11 +1566,11 @@
         assertEquals( "objectclass", assertion.getAttributeDesc() );
         assertEquals( "ttt", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
-        for ( int i = 0; i < attributes.size(); i++ )
+        for ( EntryAttribute attribute:attributes )
         {
-            assertNotNull( attributes.get( "attr" + i ) );
+            assertNotNull( attribute );
         }
 
         // Check the encoding
@@ -2508,7 +2518,7 @@
         assertEquals( "test", assertion.getAttributeDesc() );
         assertEquals( "", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
         assertEquals( 0, attributes.size() );
 
@@ -2590,14 +2600,10 @@
         assertEquals( "test", assertion.getAttributeDesc() );
         assertEquals( "", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
         assertEquals( 1, attributes.size() );
-
-        for ( int i = 0; i < attributes.size(); i++ )
-        {
-            assertNotNull( attributes.get( "*" ) );
-        }
+        assertEquals( "*", attributes.get( 0 ).getId() );
 
         // Check the encoding
         // We won't check the whole PDU, as it may differs because
@@ -2688,7 +2694,7 @@
         assertEquals( "test", assertion.getAttributeDesc() );
         assertEquals( "", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
 
         assertEquals( 0, attributes.size() );
     }
@@ -3045,7 +3051,7 @@
         assertEquals( "a", assertion.getAttributeDesc() );
         assertEquals( "b", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
 
         // Check the encoding
@@ -3153,7 +3159,7 @@
         assertEquals( "a", assertion.getAttributeDesc() );
         assertEquals( "b", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
 
         // Check the encoding
@@ -3276,7 +3282,7 @@
         assertEquals( "c", assertion.getAttributeDesc() );
         assertEquals( "d", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
 
         // Check the encoding
@@ -3390,7 +3396,7 @@
         assertEquals( "a", assertion.getAttributeDesc() );
         assertEquals( "b", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
 
         // Check the encoding
@@ -3520,7 +3526,7 @@
         assertEquals( "c", assertion.getAttributeDesc() );
         assertEquals( "d", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
 
         // Check the encoding
@@ -3649,7 +3655,7 @@
         assertEquals( "c", assertion.getAttributeDesc() );
         assertEquals( "d", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
 
         // Check the encoding
@@ -3792,7 +3798,7 @@
         assertEquals( "e", assertion.getAttributeDesc() );
         assertEquals( "f", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
 
         // Check the encoding
@@ -3929,7 +3935,7 @@
         assertEquals( "c", assertion.getAttributeDesc() );
         assertEquals( "d", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
 
         // Check the encoding
@@ -4080,7 +4086,7 @@
         assertEquals( "e", assertion.getAttributeDesc() );
         assertEquals( "f", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
 
         // Check the encoding
@@ -4217,7 +4223,7 @@
         assertEquals( "e", assertion.getAttributeDesc() );
         assertEquals( "f", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
 
         // Check the encoding
@@ -4295,7 +4301,7 @@
         assertNotNull( presentFilter );
         assertEquals( "objectClass", presentFilter.getAttributeDescription() );
         
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
     }
     
@@ -4389,7 +4395,7 @@
         assertEquals( "sbAttribute", assertion.getAttributeDesc() );
         assertEquals( "Buy ", assertion.getAssertionValue().get() );
 
-        Attributes attributes = sr.getAttributes();
+        List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
     }
     



Mime
View raw message