directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r618085 - in /directory/shared/branches/bigbang/ldap/src: main/java/org/apache/directory/shared/ldap/aci/ test/java/org/apache/directory/shared/ldap/aci/
Date Sun, 03 Feb 2008 20:55:31 GMT
Author: seelmann
Date: Sun Feb  3 12:55:28 2008
New Revision: 618085

URL: http://svn.apache.org/viewvc?rev=618085&view=rev
Log:
Fixed ACI toString() methods, removed printToBuffer() method, added tests for toString() methods

Modified:
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/GrantAndDenial.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemPermission.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java
    directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/GrantAndDenial.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/GrantAndDenial.java?rev=618085&r1=618084&r2=618085&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/GrantAndDenial.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/GrantAndDenial.java
Sun Feb  3 12:55:28 2008
@@ -170,18 +170,6 @@
 
     public String toString()
     {
-        return "[" + code + "] " + name;
-    }
-    
-    
-    /**
-     * Converts this item into its string representation as stored
-     * in directory.
-     *
-     * @param buffer the string buffer
-     */
-    public void printToBuffer( StringBuilder buffer )
-    {
-        buffer.append( getName() );
+        return name;
     }
 }

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemPermission.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemPermission.java?rev=618085&r1=618084&r2=618085&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemPermission.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemPermission.java
Sun Feb  3 12:55:28 2008
@@ -69,18 +69,8 @@
 
     public String toString()
     {
-        return "itemPermission: precedence=" + getPrecedence() + ", " + "userClasses=" +
userClasses + ", "
-            + "grantsAndDenials=" + getGrantsAndDenials();
-    }
-    
-    /**
-     * Converts this item into its string representation as stored
-     * in directory.
-     *
-     * @param buffer the string buffer
-     */
-    public void printToBuffer( StringBuilder buffer )
-    {
+        StringBuilder buffer = new StringBuilder();
+        
         buffer.append( "{ " );
 
         if ( getPrecedence() >= 0 && getPrecedence() <= 255 )
@@ -105,7 +95,7 @@
                 buffer.append( ", " );
             }
 
-            userClass.printToBuffer( buffer );
+            buffer.append( userClass.toString() );
         }
         
         buffer.append( " }, grantsAndDenials { " );
@@ -123,9 +113,11 @@
                 buffer.append( ", " );
             }
 
-            grantAndDenial.printToBuffer( buffer );
+            buffer.append( grantAndDenial.toString() );
         }
         
         buffer.append( " } }" );
+        
+        return buffer.toString();
     }
 }

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java?rev=618085&r1=618084&r2=618085&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java
Sun Feb  3 12:55:28 2008
@@ -249,29 +249,6 @@
         }
         
         
-        public void printToBuffer( StringBuilder buffer )
-        {
-            buffer.append( "{ " );
-            boolean isFirst = true;
-            
-            for ( String attributeType:attributeTypes )
-            {
-                if ( isFirst ) 
-                {
-                    isFirst = false;
-                }
-                else
-                {
-                    buffer.append( ", " );
-                }
-
-                buffer.append( attributeType );
-            }
-            
-            buffer.append( " }" );
-        }
-
-        
         /**
          * @see Object#toString()
          */
@@ -325,7 +302,7 @@
 
         public String toString()
         {
-            return "attributeType: " + attributeTypes;
+            return "attributeType " + super.toString();
         }
     }
 
@@ -351,7 +328,7 @@
 
         public String toString()
         {
-            return "allAttributeValues: " + attributeTypes;
+            return "allAttributeValues " + super.toString();
         }
     }
 
@@ -381,7 +358,7 @@
 
         public String toString()
         {
-            return "selfValue: " + attributeTypes;
+            return "selfValue " + super.toString();
         }
     }
 
@@ -461,7 +438,7 @@
             
             buf.append( " }" );
 
-            return "attributeValue: " + attributes;
+            return buf.toString();
         }
     }
 
@@ -604,7 +581,8 @@
         public String toString()
         {
         	StringBuilder buf = new StringBuilder();
-            buf.append( "rangeOfValues: " );
+            
+            buf.append( "rangeOfValues " );
             buf.append( filter.toString() );
             
             return buf.toString();
@@ -668,7 +646,7 @@
 
         public String toString()
         {
-            return "maxImmSub: " + value;
+            return "maxImmSub " + value;
         }
     }
 
@@ -801,7 +779,7 @@
 
         public String toString()
         {
-            return "attributeType=" + attributeType + ", maxCount=" + maxCount;
+            return "{ type " + attributeType + ", maxCount " + maxCount + " }";
         }
     }
 
@@ -854,7 +832,7 @@
 
         public String toString()
         {
-            return "{attributeType=" + attributeType + ", valuesIn=" + valuesIn + "}";
+            return "{ type " + attributeType + ", valuesIn " + valuesIn + " }";
         }
     }
 }

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java?rev=618085&r1=618084&r2=618085&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java
Sun Feb  3 12:55:28 2008
@@ -60,15 +60,6 @@
     {
     }
     
-    
-    /**
-     * Converts this item into its string representation as stored
-     * in directory.
-     *
-     * @param buffer the string buffer
-     */
-    public abstract void printToBuffer( StringBuilder buffer );
-    
 
     /**
      * Every directory user (with possible requirements for
@@ -88,12 +79,6 @@
         {
             return "allUsers";
         }
-        
-        
-        public void printToBuffer( StringBuilder buffer )
-        {
-            buffer.append( "allUsers" );
-        }
     }
 
     /**
@@ -115,12 +100,6 @@
         {
             return "thisEntry";
         }
-        
-        
-        public void printToBuffer( StringBuilder buffer )
-        {
-            buffer.append( "thisEntry" );
-        }
     }
 
     /**
@@ -175,12 +154,8 @@
 
         public String toString()
         {
-            return names.toString();
-        }
-        
-        
-        public void printToBuffer( StringBuilder buffer )
-        {
+            StringBuilder buffer = new StringBuilder();
+            
             boolean isFirst = true;
             buffer.append( "{ " );
             
@@ -201,6 +176,8 @@
             }
             
             buffer.append( " }" );
+            
+            return buffer.toString();
         }
     }
 
@@ -226,14 +203,7 @@
 
         public String toString()
         {
-            return "name: " + super.toString();
-        }
-        
-        
-        public void printToBuffer( StringBuilder buffer )
-        {
-            buffer.append( "name " );
-            super.printToBuffer( buffer );
+            return "name " + super.toString();
         }
     }
 
@@ -262,14 +232,7 @@
 
         public String toString()
         {
-            return "userGroup: " + super.toString();
-        }
-        
-        
-        public void printToBuffer( StringBuilder buffer )
-        {
-            buffer.append( "userGroup " );
-            super.printToBuffer( buffer );
+            return "userGroup " + super.toString();
         }
     }
 
@@ -324,12 +287,8 @@
 
         public String toString()
         {
-            return "subtree: " + subtreeSpecifications;
-        }
-        
-        
-        public void printToBuffer( StringBuilder buffer )
-        {
+            StringBuilder buffer = new StringBuilder();
+            
             boolean isFirst = true;
             buffer.append( "subtree { " );
             
@@ -348,6 +307,8 @@
             }
             
             buffer.append( " }" );
+            
+            return buffer.toString();
         }
     }
 }

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java?rev=618085&r1=618084&r2=618085&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
Sun Feb  3 12:55:28 2008
@@ -23,8 +23,6 @@
 
 import java.text.ParseException;
 
-import org.apache.directory.shared.ldap.aci.ACIItemParser;
-
 import junit.framework.TestCase;
 
 
@@ -64,6 +62,13 @@
     }
 
 
+    private void checkItemToString( String spec, ACIItem item ) throws Exception
+    {
+        // try to parse the result of item.toString() again
+        parser.parse( item.toString() );
+    }
+
+
     /**
      * Tests the parser with a rangeOfValues with a nested filter.
      */
@@ -73,7 +78,8 @@
             + "itemOrUserFirst itemFirst  :{ protectedItems  "
             + "{ rangeOfValues (&(&(|(|(cn=ccc)(!(cn=ddd))(&(cn=aaa)(cn=bbb))))))
" + "}  , itemPermissions {  } } }";
 
-        parser.parse( spec );
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
         
         
         spec = " { identificationTag \"id8\", precedence 0, authenticationLevel simple "
@@ -82,7 +88,8 @@
             + "{ protectedItems { rangeOfValues (|(!(cn=aaa))(sn=bbb)) }, grantsAndDenials
{ grantAdd } } "
             + " } } }";
         
-        parser.parse( spec );
+        item = parser.parse( spec );
+        checkItemToString( spec, item );
     }
 
 
@@ -100,7 +107,8 @@
             + "{ precedence 10, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\"
} "
             + " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare
 , grantModify } } } }}";
 
-        parser.parse( spec );
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
     }
 
 
@@ -116,7 +124,8 @@
             + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  ,
attributeValue {x=y,m=n,k=l} , "
             + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } }  }
  ";
 
-        parser.parse( spec );
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
     }
 
 
@@ -126,7 +135,8 @@
             + "itemOrUserFirst userFirst: { " + "userClasses { allUsers }, "
             + "userPermissions { { protectedItems {entry}, " + "grantsAndDenials { grantAdd
} } } } }";
 
-        parser.parse( spec );
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
     }
 
 
@@ -136,7 +146,8 @@
             + "itemOrUserFirst userFirst: { " + "userClasses { allUsers, name { \"ou=blah\"
} }, "
             + "userPermissions { { protectedItems {entry}, " + "grantsAndDenials { grantAdd
} } } } }";
 
-        parser.parse( spec );
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
     }
 
 
@@ -151,7 +162,8 @@
             + "{ precedence 10, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\"
} "
             + " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare
 , grantModify } } } }}";
 
-        parser.parse( spec );
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
     }
 
 
@@ -164,7 +176,8 @@
             + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  ,
attributeValue {x=y,m=n,k=l} , "
             + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } }  }
  ";
 
-        parser.parse( spec );
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
     }
 
 
@@ -223,7 +236,8 @@
             + "{ precedence 10, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\"
} "
             + " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare
 , grantModify } } } }}";
 
-        parser.parse( spec );
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
     }
 
 
@@ -260,7 +274,8 @@
             + "userPermissions { { grantsAndDenials { grantBrowse }, protectedItems{ entry
 , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
             + "rangeOfValues (cn=ErsinEr) }  } } }  }   ";
 
-        parser.parse( spec );
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
     }
 
 
@@ -294,7 +309,8 @@
             + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } }, "
             + " identificationTag \"id2\"   , authenticationLevel none, precedence 14 } 
 ";
 
-        parser.parse( spec );
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
     }
 
 
@@ -348,7 +364,8 @@
             + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
             + "minimum  1, maximum   2 } } } }  }   ";
 
-        parser.parse( spec );
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
     }
 
 
@@ -362,7 +379,8 @@
             + " attributeValue { ou=people  , cn=Ersin  }  , rangeOfValues (cn=ErsinEr) ,
"
             + "classes and : { item: xyz , or:{item:X,item:Y}   }}  " + " }}";
 
-        parser.parse( spec );
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
     }
 
 
@@ -384,7 +402,7 @@
     }
 
 
-    public void testRestrictedValueComponentsOrderDoesNotMatter() throws Exception
+    public void testMaxValueCountComponentsOrderDoesNotMatter() throws Exception
     {
         String spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel
none  , "
             + "itemOrUserFirst userFirst:  { userClasses {  allUsers  , name { \"ou=people,cn=ersin\"
}, "
@@ -393,11 +411,12 @@
             + "maxValueCount { { type 10.11.12, maxCount 10 }, { maxCount 20, type 11.12.13
 } } "
             + " }  , grantsAndDenials { grantBrowse } } } }  }   ";
 
-        parser.parse( spec );
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
     }
 
 
-    public void testMaxValueCountComponentsOrderDoesNotMatter() throws Exception
+    public void testRestrictedValueComponentsOrderDoesNotMatter() throws Exception
     {
         String spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel
none  , "
             + "itemOrUserFirst userFirst:  { userClasses {  allUsers  , name { \"ou=people,cn=ersin\"
}, "
@@ -406,10 +425,24 @@
             + "restrictedBy { { type 10.11.12, valuesIn ou }, { valuesIn cn, type 11.12.13
 } } "
             + " }  , grantsAndDenials { grantBrowse } } } }  }   ";
 
-        parser.parse( spec );
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
     }
 
 
+    public void testMaxImmSubComponentsOrderDoesNotMatter() throws Exception
+    {
+        String spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel
none  , "
+            + "itemOrUserFirst userFirst:  { userClasses {  allUsers  , name { \"ou=people,cn=ersin\"
}, "
+            + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\"," + "minimum
 1, maximum   2 } } }  , "
+            + "userPermissions { { protectedItems{ entry  , maxImmSub 5 "
+            + " }  , grantsAndDenials { grantBrowse } } } }  }   ";
+        
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+    }
+    
+    
     public void testSubtreeSpecificationComponentsOrderDoesNotMatter() throws Exception
     {
         String spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel
none  , "
@@ -418,7 +451,8 @@
             + "subtree {{ minimum 7, maximum 9, base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
             + " maximum   2, minimum  1 } } }  }  }   ";
 
-        parser.parse( spec );
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
     }
     
     
@@ -454,7 +488,7 @@
         try
         {
             parser.parse( spec );
-            fail("Expected ParseException, invalid protected item 'attributeValue { must_be_a_name_value_pair
}'");
+            fail("Expected ParseException, invalid protected item 'attributeValue { x=y,m=n,k=l,x
}'");
         }
         catch ( ParseException e )
         {



Mime
View raw message