directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r679083 - in /directory: apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ shared/branches/bigbang/ldap/src/test/java/org/ap...
Date Wed, 23 Jul 2008 13:14:13 GMT
Author: elecharny
Date: Wed Jul 23 06:14:13 2008
New Revision: 679083

URL: http://svn.apache.org/viewvc?rev=679083&view=rev
Log:
o Fixed the failing test MatchingRuleCompareTest
o Changed the CompareMessage to store a Value<?> instead of a byte[]

Modified:
    directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/MatchingRuleCompareTest.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequest.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequestImpl.java
    directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/message/CompareRequestImplTest.java

Modified: directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/MatchingRuleCompareTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/MatchingRuleCompareTest.java?rev=679083&r1=679082&r2=679083&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/MatchingRuleCompareTest.java
(original)
+++ directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/MatchingRuleCompareTest.java
Wed Jul 23 06:14:13 2008
@@ -28,6 +28,7 @@
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
 import javax.naming.ldap.InitialLdapContext;
 import javax.naming.ldap.LdapContext;
 
@@ -152,7 +153,7 @@
         {
             String value = values[i];
 
-            NamingEnumeration enumeration = ctx.search( PERSON_RDN, "sn={0}", new String[]
+            NamingEnumeration<SearchResult> enumeration = ctx.search( PERSON_RDN, "sn={0}",
new String[]
                 { value }, ctls );
             boolean result = enumeration.hasMore();
 
@@ -260,7 +261,7 @@
         {
             String value = values[i];
 
-            NamingEnumeration enumeration = ctx.search( GROUP_RDN, "member={0}", new Object[]
+            NamingEnumeration<SearchResult> enumeration = ctx.search( GROUP_RDN, "member={0}",
new Object[]
                 { value }, ctls );
             boolean result = enumeration.hasMore();
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequest.java?rev=679083&r1=679082&r2=679083&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequest.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequest.java
Wed Jul 23 06:14:13 2008
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.ldap.message;
 
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
 
@@ -61,7 +62,7 @@
      * 
      * @return the attribute value to used in comparison.
      */
-    byte[] getAssertionValue();
+    Value<?> getAssertionValue();
 
 
     /**

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequestImpl.java?rev=679083&r1=679082&r2=679083&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequestImpl.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequestImpl.java
Wed Jul 23 06:14:13 2008
@@ -20,14 +20,15 @@
 package org.apache.directory.shared.ldap.message;
 
 
-import java.util.Arrays;
-
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 
 /**
- * Lockable comparison request implementation.
+ * Comparison request implementation.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
@@ -43,7 +44,7 @@
     private String attrId;
 
     /** The value of the attribute used in the comparison */
-    private byte[] attrVal;
+    private Value<?> attrVal;
 
     private CompareResponse response;
 
@@ -59,7 +60,7 @@
      * @param id
      *            the sequence identifier of the CompareRequest message.
      */
-    public CompareRequestImpl(final int id)
+    public CompareRequestImpl( final int id )
     {
         super( id, TYPE );
     }
@@ -99,7 +100,7 @@
      * 
      * @return the attribute value to used in comparison.
      */
-    public byte[] getAssertionValue()
+    public Value<?> getAssertionValue()
     {
         return attrVal;
     }
@@ -113,7 +114,7 @@
      */
     public void setAssertionValue( String attrVal )
     {
-        this.attrVal = StringTools.getBytesUtf8( attrVal );
+        this.attrVal = new ClientStringValue( attrVal );
     }
 
 
@@ -127,9 +128,10 @@
     {
         if ( attrVal != null )
         {
-            this.attrVal = new byte[ attrVal.length ];
-            System.arraycopy( attrVal, 0, this.attrVal, 0, attrVal.length );
-        } else {
+            this.attrVal = new ClientBinaryValue( attrVal );
+        }
+        else
+        {
             this.attrVal = null;
         }
     }
@@ -193,8 +195,7 @@
     /**
      * Checks to see if an object is equivalent to this CompareRequest.
      * 
-     * @param obj
-     *            the obj to compare with this CompareRequest
+     * @param obj the obj to compare with this CompareRequest
      * @return true if the obj is equal to this request, false otherwise
      */
     public boolean equals( Object obj )
@@ -210,18 +211,19 @@
         }
 
         CompareRequest req = ( CompareRequest ) obj;
+        LdapDN reqName = req.getName();
 
-        if ( name != null && req.getName() == null )
+        if ( ( name != null ) && ( reqName == null ) )
         {
             return false;
         }
 
-        if ( name == null && req.getName() != null )
+        if ( ( name == null ) && ( reqName != null ) )
         {
             return false;
         }
 
-        if ( name != null && req.getName() != null )
+        if ( ( name != null ) && ( reqName != null ) )
         {
             if ( !name.equals( req.getName() ) )
             {
@@ -229,43 +231,43 @@
             }
         }
 
-        if ( attrId != null && req.getAttributeId() == null )
+        String reqId = req.getAttributeId();
+
+        if ( ( attrId != null ) && ( reqId == null ) )
         {
             return false;
         }
 
-        if ( attrId == null && req.getAttributeId() != null )
+        if ( ( attrId == null ) && ( reqId != null ) )
         {
             return false;
         }
 
-        if ( attrId != null && req.getAttributeId() != null )
+        if ( ( attrId != null ) && ( reqId != null ) )
         {
-            if ( !attrId.equals( req.getAttributeId() ) )
+            if ( !attrId.equals( reqId ) )
             {
                 return false;
             }
         }
 
-        if ( attrVal != null && req.getAssertionValue() == null )
-        {
-            return false;
-        }
-
-        if ( attrVal == null && req.getAssertionValue() != null )
-        {
-            return false;
-        }
+        Value<?> reqVal = req.getAssertionValue();
 
-        if ( attrVal != null && req.getAssertionValue() != null )
+        if ( attrVal != null )
         {
-            if ( !Arrays.equals( attrVal, req.getAssertionValue() ) )
+            if ( reqVal != null )
+            {
+                return attrVal.equals( reqVal );
+            }
+            else
             {
                 return false;
             }
         }
-
-        return true;
+        else
+        {
+            return reqVal == null;
+        }
     }
 
 
@@ -276,13 +278,23 @@
      */
     public String toString()
     {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
 
         sb.append( "    Compare request\n" );
         sb.append( "        Entry : '" ).append( name.toString() ).append( "'\n" );
         sb.append( "        Attribute description : '" ).append( attrId ).append( "'\n" );
-        sb.append( "        Attribute value : '" ).append( StringTools.utf8ToString( attrVal
) ).append( '/' ).append(
-            StringTools.dumpBytes( attrVal ) ).append( "'\n" );
+        sb.append( "        Attribute value : '" );
+        
+        if ( attrVal instanceof ClientStringValue )
+        {
+            sb.append( attrVal.get() );
+        }
+        else
+        {
+            byte[] binVal = (byte[])attrVal.get();
+            sb.append( StringTools.utf8ToString( binVal ) ).append( '/' ).append(
+                StringTools.dumpBytes( binVal ) ).append( "'\n" );
+        }
 
         return sb.toString();
     }

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/message/CompareRequestImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/message/CompareRequestImplTest.java?rev=679083&r1=679082&r2=679083&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/message/CompareRequestImplTest.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/message/CompareRequestImplTest.java
Wed Jul 23 06:14:13 2008
@@ -28,6 +28,7 @@
 import javax.naming.InvalidNameException;
 import javax.naming.ldap.Control;
 
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.message.AbandonListener;
 import org.apache.directory.shared.ldap.message.CompareRequest;
 import org.apache.directory.shared.ldap.message.CompareRequestImpl;
@@ -141,7 +142,7 @@
     {
         CompareRequest req0 = new CompareRequest()
         {
-            public byte[] getAssertionValue()
+            public Value<?> getAssertionValue()
             {
                 return null;
             }



Mime
View raw message