directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r615071 [4/5] - in /directory: apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/bra...
Date Thu, 24 Jan 2008 22:39:50 GMT
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?rev=615071&r1=615070&r2=615071&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Thu Jan 24 14:39:32 2008
@@ -21,12 +21,14 @@
 
 import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.constants.ServerDNConstants;
+import org.apache.directory.server.core.entry.DefaultServerAttribute;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerAttribute;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.DITContentRule;
@@ -40,12 +42,8 @@
 import org.apache.directory.shared.ldap.schema.syntax.ComparatorDescription;
 import org.apache.directory.shared.ldap.schema.syntax.NormalizerDescription;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxCheckerDescription;
-import org.apache.directory.shared.ldap.util.AttributeUtils;
-import org.apache.directory.shared.ldap.util.ImmutableAttributesWrapper;
 
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
@@ -64,7 +62,7 @@
 
 
     /** cached version of the schema subentry with all attributes in it */
-    private Attributes schemaSubentry;
+    private ServerEntry schemaSubentry;
     private final Object lock = new Object();
 
     /** a handle on the registries */
@@ -113,10 +111,13 @@
     }
 
 
-    private Attribute generateComparators()
+    private ServerAttribute generateComparators() throws NamingException
     {
-        Attribute attr = new AttributeImpl( SchemaConstants.COMPARATORS_AT );
+        ServerAttribute attr = new DefaultServerAttribute( 
+            registries.getAttributeTypeRegistry().lookup( SchemaConstants.COMPARATORS_AT ) );
+
         Iterator<ComparatorDescription> list = registries.getComparatorRegistry().comparatorDescriptionIterator();
+        
         while ( list.hasNext() )
         {
             ComparatorDescription description = list.next();
@@ -127,24 +128,28 @@
     }
 
 
-    private Attribute generateNormalizers()
+    private ServerAttribute generateNormalizers() throws NamingException
     {
-        Attribute attr;
-        attr = new AttributeImpl( SchemaConstants.NORMALIZERS_AT );
+        ServerAttribute attr = new DefaultServerAttribute( 
+            registries.getAttributeTypeRegistry().lookup( SchemaConstants.NORMALIZERS_AT ) );
+
         Iterator<NormalizerDescription> list = registries.getNormalizerRegistry().normalizerDescriptionIterator();
+
         while ( list.hasNext() )
         {
             NormalizerDescription normalizer = list.next();
             attr.add( SchemaUtils.render( normalizer ).toString() );
         }
+        
         return attr;
     }
 
 
-    private Attribute generateSyntaxCheckers()
+    private ServerAttribute generateSyntaxCheckers() throws NamingException
     {
-        Attribute attr;
-        attr = new AttributeImpl( SchemaConstants.SYNTAX_CHECKERS_AT );
+        ServerAttribute attr = new DefaultServerAttribute( 
+            registries.getAttributeTypeRegistry().lookup( SchemaConstants.SYNTAX_CHECKERS_AT ) );
+
         Iterator<SyntaxCheckerDescription> list =
             registries.getSyntaxCheckerRegistry().syntaxCheckerDescriptionIterator();
 
@@ -153,14 +158,16 @@
             SyntaxCheckerDescription syntaxCheckerDescription = list.next();
             attr.add( SchemaUtils.render( syntaxCheckerDescription ).toString() );
         }
+        
         return attr;
     }
 
 
-    private Attribute generateObjectClasses() throws NamingException
+    private ServerAttribute generateObjectClasses() throws NamingException
     {
-        Attribute attr;
-        attr = new AttributeImpl( SchemaConstants.OBJECT_CLASSES_AT );
+        ServerAttribute attr = new DefaultServerAttribute( 
+            registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASSES_AT ) );
+
         Iterator<ObjectClass> list = registries.getObjectClassRegistry().iterator();
 
         while ( list.hasNext() )
@@ -168,14 +175,16 @@
             ObjectClass oc = list.next();
             attr.add( SchemaUtils.render( oc ).toString() );
         }
+        
         return attr;
     }
 
 
-    private Attribute generateAttributeTypes() throws NamingException
+    private ServerAttribute generateAttributeTypes() throws NamingException
     {
-        Attribute attr;
-        attr = new AttributeImpl( SchemaConstants.ATTRIBUTE_TYPES_AT );
+        ServerAttribute attr = new DefaultServerAttribute( 
+            registries.getAttributeTypeRegistry().lookup( SchemaConstants.ATTRIBUTE_TYPES_AT ) );
+
         Iterator<AttributeType> list = registries.getAttributeTypeRegistry().iterator();
 
         while ( list.hasNext() )
@@ -183,14 +192,16 @@
             AttributeType at = list.next();
             attr.add( SchemaUtils.render( at ).toString() );
         }
+
         return attr;
     }
 
 
-    private Attribute generateMatchingRules() throws NamingException
+    private ServerAttribute generateMatchingRules() throws NamingException
     {
-        Attribute attr;
-        attr = new AttributeImpl( SchemaConstants.MATCHING_RULES_AT );
+        ServerAttribute attr = new DefaultServerAttribute( 
+            registries.getAttributeTypeRegistry().lookup( SchemaConstants.MATCHING_RULES_AT ) );
+
         Iterator<MatchingRule> list = registries.getMatchingRuleRegistry().iterator();
 
         while ( list.hasNext() )
@@ -198,14 +209,16 @@
             MatchingRule mr = list.next();
             attr.add( SchemaUtils.render( mr ).toString() );
         }
+
         return attr;
     }
 
 
-    private Attribute generateMatchingRuleUses()
+    private ServerAttribute generateMatchingRuleUses() throws NamingException
     {
-        Attribute attr;
-        attr = new AttributeImpl( SchemaConstants.MATCHING_RULE_USE_AT );
+        ServerAttribute attr = new DefaultServerAttribute( 
+            registries.getAttributeTypeRegistry().lookup( SchemaConstants.MATCHING_RULE_USE_AT ) );
+
         Iterator<MatchingRuleUse> list = registries.getMatchingRuleUseRegistry().iterator();
 
         while ( list.hasNext() )
@@ -213,14 +226,16 @@
             MatchingRuleUse mru = list.next();
             attr.add( SchemaUtils.render( mru ).toString() );
         }
+
         return attr;
     }
 
 
-    private Attribute generateSyntaxes()
+    private ServerAttribute generateSyntaxes() throws NamingException
     {
-        Attribute attr;
-        attr = new AttributeImpl( SchemaConstants.LDAP_SYNTAXES_AT );
+        ServerAttribute attr = new DefaultServerAttribute( 
+            registries.getAttributeTypeRegistry().lookup( SchemaConstants.LDAP_SYNTAXES_AT ) );
+
         Iterator<Syntax> list = registries.getSyntaxRegistry().iterator();
 
         while ( list.hasNext() )
@@ -228,14 +243,16 @@
             Syntax syntax = list.next();
             attr.add( SchemaUtils.render( syntax ).toString() );
         }
+
         return attr;
     }
 
 
-    private Attribute generateDitContextRules()
+    private ServerAttribute generateDitContextRules() throws NamingException
     {
-        Attribute attr;
-        attr = new AttributeImpl( SchemaConstants.DIT_CONTENT_RULES_AT );
+        ServerAttribute attr = new DefaultServerAttribute( 
+            registries.getAttributeTypeRegistry().lookup( SchemaConstants.DIT_CONTENT_RULES_AT ) );
+
         Iterator<DITContentRule> list = registries.getDitContentRuleRegistry().iterator();
 
         while ( list.hasNext() )
@@ -243,29 +260,33 @@
             DITContentRule dcr = list.next();
             attr.add( SchemaUtils.render( dcr ).toString() );
         }
+        
         return attr;
     }
 
 
-    private Attribute generateDitStructureRules()
+    private ServerAttribute generateDitStructureRules() throws NamingException
     {
-        Attribute attr;
-        attr = new AttributeImpl( SchemaConstants.DIT_STRUCTURE_RULES_AT );
+        ServerAttribute attr = new DefaultServerAttribute( 
+            registries.getAttributeTypeRegistry().lookup( SchemaConstants.DIT_STRUCTURE_RULES_AT ) );
+
         Iterator<DITStructureRule> list = registries.getDitStructureRuleRegistry().iterator();
 
         while ( list.hasNext() )
         {
-            DITStructureRule dsr =list.next();
+            DITStructureRule dsr = list.next();
             attr.add( SchemaUtils.render( dsr ).toString() );
         }
+        
         return attr;
     }
 
 
-    private Attribute generateNameForms()
+    private ServerAttribute generateNameForms() throws NamingException
     {
-        Attribute attr;
-        attr = new AttributeImpl( SchemaConstants.NAME_FORMS_AT );
+        ServerAttribute attr = new DefaultServerAttribute( 
+            registries.getAttributeTypeRegistry().lookup( SchemaConstants.NAME_FORMS_AT ) );
+
         Iterator<NameForm> list = registries.getNameFormRegistry().iterator();
 
         while ( list.hasNext() )
@@ -273,21 +294,22 @@
             NameForm nf = list.next();
             attr.add( SchemaUtils.render( nf ).toString() );
         }
+        
         return attr;
     }
 
 
-    private void generateSchemaSubentry( Attributes mods ) throws NamingException
+    private void generateSchemaSubentry( ServerEntry mods ) throws NamingException
     {
-        Attributes attrs = new AttributesImpl( true );
+        ServerEntry attrs = new DefaultServerEntry( registries, mods.getDn() );
 
         // add the objectClass attribute
-        Attribute oc = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
-        oc.add( SchemaConstants.TOP_OC );
-        oc.add( "subschema" );
-        oc.add( SchemaConstants.SUBENTRY_OC );
-        oc.add( ApacheSchemaConstants.APACHE_SUBSCHEMA_OC );
-        attrs.put( oc );
+        attrs.put( SchemaConstants.OBJECT_CLASS_AT, 
+            SchemaConstants.TOP_OC,
+            SchemaConstants.SUBSCHEMA_OC,
+            SchemaConstants.SUBENTRY_OC,
+            ApacheSchemaConstants.APACHE_SUBSCHEMA_OC
+            );
 
         // add the cn attribute as required for the RDN
         attrs.put( SchemaConstants.CN_AT, "schema" );
@@ -304,43 +326,32 @@
         attrs.put( generateDitContextRules() );
         attrs.put( generateDitStructureRules() );
         attrs.put( generateNameForms() );
-        attrs.put( new AttributeImpl( SchemaConstants.SUBTREE_SPECIFICATION_AT, "{}" ) );
-
+        attrs.put( SchemaConstants.SUBTREE_SPECIFICATION_AT, "{}" );
 
         // -------------------------------------------------------------------
         // set standard operational attributes for the subentry
         // -------------------------------------------------------------------
 
         // Add the createTimestamp
-        Attribute attr = new AttributeImpl( SchemaConstants.CREATE_TIMESTAMP_AT );
         AttributeType createTimestampAT = registries.
             getAttributeTypeRegistry().lookup( SchemaConstants.CREATE_TIMESTAMP_AT );
-        Attribute createTimestamp = AttributeUtils.getAttribute( mods, createTimestampAT );
-        attr.add( createTimestamp.get() );
-        attrs.put( attr );
+        ServerAttribute createTimestamp = mods.get( createTimestampAT );
+        attrs.put( SchemaConstants.CREATE_TIMESTAMP_AT, createTimestamp.get() );
 
         // Add the creatorsName
-        attr = new AttributeImpl( SchemaConstants.CREATORS_NAME_AT );
-        attr.add( ServerDNConstants.ADMIN_SYSTEM_DN );
-        attrs.put( attr );
+        attrs.put( SchemaConstants.CREATORS_NAME_AT, ServerDNConstants.ADMIN_SYSTEM_DN );
 
         // Add the modifyTimestamp
-        attr = new AttributeImpl( SchemaConstants.MODIFY_TIMESTAMP_AT );
         AttributeType schemaModifyTimestampAT = registries.
             getAttributeTypeRegistry().lookup( ApacheSchemaConstants.SCHEMA_MODIFY_TIMESTAMP_AT );
-        Attribute schemaModifyTimestamp =
-            AttributeUtils.getAttribute( mods, schemaModifyTimestampAT );
-        attr.add( schemaModifyTimestamp.get() );
-        attrs.put( attr );
+        ServerAttribute schemaModifyTimestamp = mods.get( schemaModifyTimestampAT );
+        attrs.put( SchemaConstants.MODIFY_TIMESTAMP_AT, schemaModifyTimestamp.get() );
 
         // Add the modifiersName
-        attr = new AttributeImpl( SchemaConstants.MODIFIERS_NAME_AT );
         AttributeType schemaModifiersNameAT = registries.
             getAttributeTypeRegistry().lookup( ApacheSchemaConstants.SCHEMA_MODIFIERS_NAME_AT );
-        Attribute schemaModifiersName =
-            AttributeUtils.getAttribute( mods, schemaModifiersNameAT );
-        attr.add( schemaModifiersName.get() );
-        attrs.put( attr );
+        ServerAttribute schemaModifiersName = mods.get( schemaModifiersNameAT );
+        attrs.put( SchemaConstants.MODIFIERS_NAME_AT, schemaModifiersName.get() );
 
         // don't swap out if a request for the subentry is in progress or we
         // can give back an inconsistent schema back to the client so we block
@@ -351,9 +362,9 @@
     }
 
 
-    private void addAttribute( Attributes attrs, String id ) throws NamingException
+    private void addAttribute( ServerEntry attrs, String id ) throws NamingException
     {
-        Attribute attr = schemaSubentry.get( id );
+        ServerAttribute attr = schemaSubentry.get( id );
 
         if ( attr != null )
         {
@@ -368,7 +379,7 @@
      * @return the schemaSubentry
      * @throws NamingException if there is a failure to access schema timestamps
      */
-    public Attributes getSubschemaEntryImmutable() throws NamingException
+    public ServerEntry getSubschemaEntryImmutable() throws NamingException
     {
         if ( schemaSubentry == null )
         {
@@ -376,7 +387,7 @@
                     new LookupOperationContext( registries, schemaModificationAttributesDN ) ) );
         }
 
-        return new ImmutableAttributesWrapper( schemaSubentry );
+        return (ServerEntry)schemaSubentry.clone();
     }
 
 
@@ -386,7 +397,7 @@
      * @return the schemaSubentry
      * @throws NamingException if there is a failure to access schema timestamps
      */
-    public Attributes getSubschemaEntryCloned() throws NamingException
+    public ServerEntry getSubschemaEntryCloned() throws NamingException
     {
         if ( schemaSubentry == null )
         {
@@ -394,7 +405,7 @@
                     new LookupOperationContext( registries, schemaModificationAttributesDN ) ) );
         }
 
-        return ( Attributes ) schemaSubentry.clone();
+        return ( ServerEntry ) schemaSubentry.clone();
     }
 
 
@@ -406,7 +417,7 @@
      * @return the subschema entry with the ids provided
      * @throws NamingException if there are failures during schema info access
      */
-    public Attributes getSubschemaEntry( String[] ids ) throws NamingException
+    public ServerEntry getSubschemaEntry( String[] ids ) throws NamingException
     {
         if ( ids == null )
         {
@@ -414,7 +425,7 @@
         }
 
         Set<String> setOids = new HashSet<String>();
-        AttributesImpl attrs = new AttributesImpl();
+        ServerEntry attrs = new DefaultServerEntry( registries, LdapDN.EMPTY_LDAPDN );
         boolean returnAllOperationalAttributes = false;
 
         synchronized( lock )
@@ -423,7 +434,7 @@
             // Check if we need an update by looking at timestamps on disk
             // ---------------------------------------------------------------
 
-            Attributes mods = schemaPartition.lookup( new LookupOperationContext( registries, schemaModificationAttributesDN ) );
+            ServerEntry mods = schemaPartition.lookup( new LookupOperationContext( registries, schemaModificationAttributesDN ) );
 // @todo enable this optimization at some point but for now it
 // is causing some problems so I will just turn it off
 //          Attribute modifyTimeDisk = mods.get( SchemaConstants.MODIFY_TIMESTAMP_AT );

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/RefinementEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/RefinementEvaluator.java?rev=615071&r1=615070&r2=615071&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/RefinementEvaluator.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/RefinementEvaluator.java Thu Jan 24 14:39:32 2008
@@ -20,6 +20,7 @@
 package org.apache.directory.server.core.subtree;
 
 
+import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.filter.AndNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
@@ -54,20 +55,23 @@
     }
 
 
-    public boolean evaluate( ExprNode node, Attribute objectClasses ) throws NamingException
+    public boolean evaluate( ExprNode node, ServerAttribute objectClasses ) throws NamingException
     {
         if ( node == null )
         {
             throw new IllegalArgumentException( "node cannot be null" );
         }
+        
         if ( objectClasses == null )
         {
             throw new IllegalArgumentException( "objectClasses cannot be null" );
         }
-        if ( !objectClasses.getID().equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT ) )
+        
+        if ( !objectClasses.isA( SchemaConstants.OBJECT_CLASS_AT ) )
         {
             throw new IllegalArgumentException( "Attribute objectClasses should be of id 'objectClass'" );
         }
+        
         if ( node.isLeaf() )
         {
             return leafEvaluator.evaluate( ( SimpleNode ) node, objectClasses );

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluator.java?rev=615071&r1=615070&r2=615071&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluator.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluator.java Thu Jan 24 14:39:32 2008
@@ -20,6 +20,7 @@
 package org.apache.directory.server.core.subtree;
 
 
+import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.filter.EqualityNode;
@@ -66,16 +67,18 @@
      * if it rejects the entry
      * @throws NamingException
      */
-    public boolean evaluate( SimpleNode node, Attribute objectClasses ) throws NamingException
+    public boolean evaluate( SimpleNode node, ServerAttribute objectClasses ) throws NamingException
     {
         if ( node == null )
         {
             throw new IllegalArgumentException( "node cannot be null" );
         }
+        
         if ( !( node instanceof EqualityNode ) )
         {
             throw new NamingException( "Unrecognized assertion type for refinement node: " + node );
         }
+        
         if ( !node.getAttribute().equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT ) )
         {
             throw new NamingException( "Refinement leaf node attribute was " + node.getAttribute() );
@@ -85,13 +88,21 @@
         {
             throw new IllegalArgumentException( "objectClasses argument cannot be null" );
         }
-        if ( !objectClasses.getID().equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT ) )
+        
+        if ( !objectClasses.isA( SchemaConstants.OBJECT_CLASS_AT ) )
         {
             throw new IllegalArgumentException( "objectClasses attribute must be for ID 'objectClass'" );
         }
 
         // check if AVA value exists in attribute
-        if ( objectClasses.contains( node.getValue() ) )
+        if ( node.getValue() instanceof String )
+        {
+            if ( objectClasses.contains( (String)node.getValue() ) )
+            {
+                return true;
+            }
+        }
+        else if ( objectClasses.contains( (byte[])node.getValue() ) )
         {
             return true;
         }

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=615071&r1=615070&r2=615071&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java Thu Jan 24 14:39:32 2008
@@ -422,8 +422,8 @@
             // get the name of the administrative point and its administrativeRole attributes
             LdapDN apName = ( LdapDN ) name.clone();
             apName.remove( name.size() - 1 );
-            Attributes ap = nexus.lookup( new LookupOperationContext( registries, apName ) );
-            Attribute administrativeRole = ap.get( "administrativeRole" );
+            ServerEntry ap = nexus.lookup( new LookupOperationContext( registries, apName ) );
+            ServerAttribute administrativeRole = ap.get( "administrativeRole" );
 
             // check that administrativeRole has something valid in it for us
             if ( administrativeRole == null || administrativeRole.size() <= 0 )
@@ -595,10 +595,10 @@
     public void delete( NextInterceptor next, DeleteOperationContext opContext ) throws NamingException
     {
     	LdapDN name = opContext.getDn();
-        Attributes entry = nexus.lookup( new LookupOperationContext( registries, name ) );
-        Attribute objectClasses = AttributeUtils.getAttribute( entry, objectClassType );
+    	ServerEntry entry = nexus.lookup( new LookupOperationContext( registries, name ) );
+        ServerAttribute objectClasses = entry.get( objectClassType );
 
-        if ( AttributeUtils.containsValueCaseIgnore( objectClasses, SchemaConstants.SUBENTRY_OC ) )
+        if ( objectClasses.contains( SchemaConstants.SUBENTRY_OC ) )
         {
             SubtreeSpecification ss = subentryCache.removeSubentry( name.toNormName() ).getSubtreeSpecification();
             next.delete( opContext );
@@ -753,10 +753,7 @@
     {
         LdapDN name = opContext.getDn();
 
-        ServerEntry entry = ServerEntryUtils.toServerEntry( 
-            nexus.lookup( new LookupOperationContext( registries, name ) ),
-            name,
-            registries );
+        ServerEntry entry = nexus.lookup( new LookupOperationContext( registries, name ) );
         
         ServerAttribute objectClasses = entry.get( objectClassType );
 
@@ -831,10 +828,7 @@
         LdapDN oriChildName = opContext.getDn();
         LdapDN parent = opContext.getParent();
 
-        ServerEntry entry = ServerEntryUtils.toServerEntry( 
-            nexus.lookup( new LookupOperationContext( registries, oriChildName ) ),
-            oriChildName,
-            registries );
+        ServerEntry entry = nexus.lookup( new LookupOperationContext( registries, oriChildName ) );
         
         ServerAttribute objectClasses = entry.get( objectClassType );
 
@@ -909,10 +903,7 @@
         LdapDN oriChildName = opContext.getDn();
         LdapDN newParentName = opContext.getParent();
         
-        ServerEntry entry = ServerEntryUtils.toServerEntry( 
-            nexus.lookup( new LookupOperationContext( registries, oriChildName ) ),
-            oriChildName,
-            registries );
+        ServerEntry entry = nexus.lookup( new LookupOperationContext( registries, oriChildName ) );
 
         ServerAttribute objectClasses = entry.get( SchemaConstants.OBJECT_CLASS_AT );
 
@@ -1029,10 +1020,7 @@
         LdapDN name = opContext.getDn();
         List<ModificationItemImpl> mods = opContext.getModItems();
         
-        ServerEntry entry = ServerEntryUtils.toServerEntry( 
-            nexus.lookup( new LookupOperationContext( registries, name ) ),
-            name,
-            registries );
+        ServerEntry entry = nexus.lookup( new LookupOperationContext( registries, name ) );
         
         ServerEntry oldEntry = (ServerEntry) entry.clone();
         ServerAttribute objectClasses = entry.get( objectClassType );
@@ -1119,10 +1107,7 @@
             
             if ( !objectClasses.contains( SchemaConstants.SUBENTRY_OC ) )
             {
-                ServerEntry newEntry = ServerEntryUtils.toServerEntry( 
-                    nexus.lookup( new LookupOperationContext( registries, name ) ),
-                    name,
-                    registries );
+                ServerEntry newEntry = nexus.lookup( new LookupOperationContext( registries, name ) );
 
 	            List<ModificationItemImpl> subentriesOpAttrMods = getModsOnEntryModification( name, oldEntry, newEntry );
                 

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java?rev=615071&r1=615070&r2=615071&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java Thu Jan 24 14:39:32 2008
@@ -26,7 +26,6 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.event.Evaluator;
 import org.apache.directory.server.core.event.ExpressionEvaluator;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
@@ -196,7 +195,7 @@
          */
         if ( subtree.getRefinement() != null )
         {
-            return evaluator.evaluate( subtree.getRefinement(), entryLdapDn.toNormName(), ServerEntryUtils.toAttributesImpl( entry ) );
+            return evaluator.evaluate( subtree.getRefinement(), entryLdapDn.toNormName(), entry );
         }
 
         /*

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/DeleteStoredProcedureParameterInjector.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/DeleteStoredProcedureParameterInjector.java?rev=615071&r1=615070&r2=615071&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/DeleteStoredProcedureParameterInjector.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/DeleteStoredProcedureParameterInjector.java Thu Jan 24 14:39:32 2008
@@ -26,7 +26,6 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
 import org.apache.directory.server.core.invocation.Invocation;
 import org.apache.directory.server.core.partition.PartitionNexusProxy;
@@ -74,10 +73,7 @@
          * Using LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS here to exclude operational attributes
          * especially subentry related ones like "triggerExecutionSubentries".
          */
-        ServerEntry deletedEntry = ServerEntryUtils.toServerEntry( 
-            proxy.lookup( new LookupOperationContext( registries, deletedEntryName ), PartitionNexusProxy.LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS ),
-            deletedEntryName,
-            registries );
+        ServerEntry deletedEntry = proxy.lookup( new LookupOperationContext( registries, deletedEntryName ), PartitionNexusProxy.LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS );
         
         return deletedEntry;
     }

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/ModifyStoredProcedureParameterInjector.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/ModifyStoredProcedureParameterInjector.java?rev=615071&r1=615070&r2=615071&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/ModifyStoredProcedureParameterInjector.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/ModifyStoredProcedureParameterInjector.java Thu Jan 24 14:39:32 2008
@@ -28,7 +28,6 @@
 import javax.naming.directory.ModificationItem;
 
 import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
 import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
 import org.apache.directory.server.core.invocation.Invocation;
@@ -112,10 +111,7 @@
          * Using LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS here to exclude operational attributes
          * especially subentry related ones like "triggerExecutionSubentries".
          */
-        return ServerEntryUtils.toServerEntry( 
-            proxy.lookup( new LookupOperationContext( registries, modifiedEntryName ), PartitionNexusProxy.LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS ),
-            modifiedEntryName,
-            registries );
+        return proxy.lookup( new LookupOperationContext( registries, modifiedEntryName ), PartitionNexusProxy.LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS );
     }
 
 }

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java?rev=615071&r1=615070&r2=615071&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java Thu Jan 24 14:39:32 2008
@@ -24,7 +24,6 @@
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.entry.ServerValue;
 import org.apache.directory.server.core.interceptor.BaseInterceptor;
 import org.apache.directory.server.core.interceptor.InterceptorChain;
@@ -138,10 +137,7 @@
         {
             LdapDN parentDn = ( LdapDN ) dn.clone();
             parentDn.remove( dn.size() - 1 );
-            entry = ServerEntryUtils.toServerEntry( 
-                proxy.lookup( new LookupOperationContext( registries, parentDn ), PartitionNexusProxy.LOOKUP_BYPASS ),
-                parentDn,
-                registries );
+            entry = proxy.lookup( new LookupOperationContext( registries, parentDn ), PartitionNexusProxy.LOOKUP_BYPASS );
         }
 
         ServerAttribute subentries = entry.get( SchemaConstants.TRIGGER_EXECUTION_SUBENTRIES_AT );
@@ -313,10 +309,7 @@
         // Gather supplementary data.
         Invocation invocation = InvocationStack.getInstance().peek();
         PartitionNexusProxy proxy = invocation.getProxy();
-        ServerEntry deletedEntry = ServerEntryUtils.toServerEntry( 
-            proxy.lookup( new LookupOperationContext( registries, name ), PartitionNexusProxy.LOOKUP_BYPASS ),
-            name,
-            registries );
+        ServerEntry deletedEntry = proxy.lookup( new LookupOperationContext( registries, name ), PartitionNexusProxy.LOOKUP_BYPASS );
         
         ServerLdapContext callerRootCtx = ( ServerLdapContext ) ( ( ServerLdapContext ) invocation.getCaller() ).getRootContext();
         StoredProcedureParameterInjector injector = new DeleteStoredProcedureParameterInjector( registries, invocation, name );
@@ -350,10 +343,7 @@
         // Gather supplementary data.
         Invocation invocation = InvocationStack.getInstance().peek();
         PartitionNexusProxy proxy = invocation.getProxy();
-        ServerEntry modifiedEntry = ServerEntryUtils.toServerEntry( 
-            proxy.lookup( new LookupOperationContext( registries, normName ), PartitionNexusProxy.LOOKUP_BYPASS ),
-            normName,
-            registries );
+        ServerEntry modifiedEntry = proxy.lookup( new LookupOperationContext( registries, normName ), PartitionNexusProxy.LOOKUP_BYPASS );
         
         ServerLdapContext callerRootCtx = ( ServerLdapContext ) ( ( ServerLdapContext ) invocation.getCaller() ).getRootContext();
         StoredProcedureParameterInjector injector = new ModifyStoredProcedureParameterInjector( invocation, opContext );
@@ -390,10 +380,7 @@
         // Gather supplementary data.        
         Invocation invocation = InvocationStack.getInstance().peek();
         PartitionNexusProxy proxy = invocation.getProxy();
-        ServerEntry renamedEntry = ServerEntryUtils.toServerEntry( 
-            proxy.lookup( new LookupOperationContext( registries, name ), PartitionNexusProxy.LOOKUP_BYPASS ),
-            name,
-            registries );
+        ServerEntry renamedEntry = proxy.lookup( new LookupOperationContext( registries, name ), PartitionNexusProxy.LOOKUP_BYPASS );
         
         ServerLdapContext callerRootCtx = ( ServerLdapContext ) ( ( ServerLdapContext ) invocation.getCaller() ).getRootContext();
         
@@ -440,10 +427,7 @@
         // Gather supplementary data.        
         Invocation invocation = InvocationStack.getInstance().peek();
         PartitionNexusProxy proxy = invocation.getProxy();
-        ServerEntry movedEntry = ServerEntryUtils.toServerEntry( 
-            proxy.lookup( new LookupOperationContext( registries, oriChildName ), PartitionNexusProxy.LOOKUP_BYPASS ),
-            oriChildName,
-            registries );
+        ServerEntry movedEntry = proxy.lookup( new LookupOperationContext( registries, oriChildName ), PartitionNexusProxy.LOOKUP_BYPASS );
         
         ServerLdapContext callerRootCtx = ( ServerLdapContext ) ( ( ServerLdapContext ) invocation.getCaller() ).getRootContext();
         
@@ -468,10 +452,7 @@
         // will not be valid at the new location.
         // This will certainly be fixed by the SubentryInterceptor,
         // but after this service.
-        ServerEntry importedEntry = ServerEntryUtils.toServerEntry( 
-            proxy.lookup( new LookupOperationContext( registries, oriChildName ), PartitionNexusProxy.LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS ),
-            oriChildName,
-            registries );
+        ServerEntry importedEntry = proxy.lookup( new LookupOperationContext( registries, oriChildName ), PartitionNexusProxy.LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS );
         
         // As the target entry does not exist yet and so
         // its subentry operational attributes are not there,
@@ -521,10 +502,7 @@
         // Gather supplementary data.        
         Invocation invocation = InvocationStack.getInstance().peek();
         PartitionNexusProxy proxy = invocation.getProxy();
-        ServerEntry movedEntry = ServerEntryUtils.toServerEntry( 
-            proxy.lookup( new LookupOperationContext( registries, oriChildName ), PartitionNexusProxy.LOOKUP_BYPASS ),
-            oriChildName,
-            registries );
+        ServerEntry movedEntry = proxy.lookup( new LookupOperationContext( registries, oriChildName ), PartitionNexusProxy.LOOKUP_BYPASS );
         
         ServerLdapContext callerRootCtx = ( ServerLdapContext ) ( ( ServerLdapContext ) invocation.getCaller() ).getRootContext();
         
@@ -550,10 +528,7 @@
         // will not be valid at the new location.
         // This will certainly be fixed by the SubentryInterceptor,
         // but after this service.
-        ServerEntry importedEntry = ServerEntryUtils.toServerEntry( 
-            proxy.lookup( new LookupOperationContext( registries, oriChildName ), PartitionNexusProxy.LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS ),
-            oriChildName,
-            registries );
+        ServerEntry importedEntry = proxy.lookup( new LookupOperationContext( registries, oriChildName ), PartitionNexusProxy.LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS );
 
         // As the target entry does not exist yet and so
         // its subentry operational attributes are not there,
@@ -643,7 +618,6 @@
         }
         catch ( NamingException e )
         {
-            e.printStackTrace();
             LdapNamingException lne = new LdapNamingException( ResultCodeEnum.OTHER );
             lne.setRootCause( e );
             throw lne;

Modified: directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java?rev=615071&r1=615070&r2=615071&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java (original)
+++ directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java Thu Jan 24 14:39:32 2008
@@ -20,11 +20,11 @@
 package org.apache.directory.server.core.authz.support;
 
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.authn.LdapPrincipal;
 import org.apache.directory.server.core.changelog.ChangeLog;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.interceptor.Interceptor;
 import org.apache.directory.server.core.interceptor.InterceptorChain;
@@ -42,12 +42,10 @@
 import org.apache.directory.shared.ldap.aci.UserClass;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.ldif.Entry;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
 import javax.naming.directory.SearchResult;
 import javax.naming.ldap.LdapContext;
 import java.io.File;
@@ -60,6 +58,10 @@
 import java.util.NoSuchElementException;
 import java.util.Set;
 
+import org.junit.Test;
+import org.junit.BeforeClass;
+import static org.junit.Assert.assertEquals;
+
 
 /**
  * Tests {@link MaxImmSubFilter}.
@@ -67,7 +69,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class MaxImmSubFilterTest extends TestCase
+public class MaxImmSubFilterTest
 {
     private static final Collection<ACITuple> EMPTY_ACI_TUPLE_COLLECTION = Collections.unmodifiableCollection( new ArrayList<ACITuple>() );
     private static final Collection<UserClass> EMPTY_USER_CLASS_COLLECTION = Collections.unmodifiableCollection( new ArrayList<UserClass>() );
@@ -76,26 +78,25 @@
     private static final Set<MicroOperation> EMPTY_MICRO_OPERATION_SET = Collections.unmodifiableSet( new HashSet<MicroOperation>() );
 
     private static final LdapDN ROOTDSE_NAME = new LdapDN();
-    private static final LdapDN ENTRY_NAME;
-    private static final Collection<ProtectedItem> PROTECTED_ITEMS = new ArrayList<ProtectedItem>();
-    private static final Attributes ENTRY = new AttributesImpl();
-
-    static
-    {
-        try
-        {
-            ENTRY_NAME = new LdapDN( "ou=test, ou=system" );
-        }
-        catch ( NamingException e )
-        {
-            throw new Error();
-        }
+    private static LdapDN ENTRY_NAME;
+    private static Collection<ProtectedItem> PROTECTED_ITEMS = new ArrayList<ProtectedItem>();
+    private static ServerEntry ENTRY;
+    
+    /** A reference to the directory service */
+    private static DirectoryService service;
+
+    
+    @BeforeClass public static void setup() throws NamingException
+    {
+        service = new DefaultDirectoryService();
 
+        ENTRY_NAME = new LdapDN( "ou=test, ou=system" );
         PROTECTED_ITEMS.add( new ProtectedItem.MaxImmSub( 2 ) );
+        ENTRY = new DefaultServerEntry( service.getRegistries(), ENTRY_NAME );
     }
 
 
-    public void testWrongScope() throws Exception
+    @Test public void testWrongScope() throws Exception
     {
         MaxImmSubFilter filter = new MaxImmSubFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
@@ -104,15 +105,15 @@
 
         tuples = Collections.unmodifiableCollection( tuples );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, null, null,
             null, ENTRY_NAME, null, null, ENTRY, null, null ) );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
             null, null, ENTRY_NAME, null, null, ENTRY, null, null ) );
     }
 
 
-    public void testRootDSE() throws Exception
+    @Test public void testRootDSE() throws Exception
     {
         MaxImmSubFilter filter = new MaxImmSubFilter();
 
@@ -122,21 +123,21 @@
 
         tuples = Collections.unmodifiableCollection( tuples );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null,
             ROOTDSE_NAME, null, null, ENTRY, null, null ) );
     }
 
 
-    public void testZeroTuple() throws Exception
+    @Test public void testZeroTuple() throws Exception
     {
         MaxImmSubFilter filter = new MaxImmSubFilter();
 
-        Assert.assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ENTRY, null, null, null, null, null,
+        assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ENTRY, null, null, null, null, null,
             ENTRY_NAME, null, null, ENTRY, null, null ).size() );
     }
 
 
-    public void testDenialTuple() throws Exception
+    @Test public void testDenialTuple() throws Exception
     {
         MaxImmSubFilter filter = new MaxImmSubFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
@@ -145,22 +146,22 @@
 
         tuples = Collections.unmodifiableCollection( tuples );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null,
             ENTRY_NAME, null, null, ENTRY, null, null ) );
     }
 
 
-    public void testGrantTuple() throws Exception
+    @Test public void testGrantTuple() throws Exception
     {
         MaxImmSubFilter filter = new MaxImmSubFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
         tuples.add( new ACITuple( EMPTY_USER_CLASS_COLLECTION, AuthenticationLevel.NONE, 
             PROTECTED_ITEMS, EMPTY_MICRO_OPERATION_SET, true, 0 ) );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, new MockProxy( 1 ), null, null, null,
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, new MockProxy( 1 ), null, null, null,
             null, ENTRY_NAME, null, null, ENTRY, null, null ).size() );
 
-        Assert.assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, new MockProxy( 3 ), null, null, null,
+        assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, new MockProxy( 3 ), null, null, null,
             null, ENTRY_NAME, null, null, ENTRY, null, null ).size() );
     }
 

Modified: directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/MaxValueCountFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/MaxValueCountFilterTest.java?rev=615071&r1=615070&r2=615071&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/MaxValueCountFilterTest.java (original)
+++ directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/MaxValueCountFilterTest.java Thu Jan 24 14:39:32 2008
@@ -26,22 +26,27 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
+import javax.naming.NamingException;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
 
+import org.apache.directory.server.core.DefaultDirectoryService;
+import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.authz.support.MaxValueCountFilter;
 import org.apache.directory.server.core.authz.support.OperationScope;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.shared.ldap.aci.ACITuple;
 import org.apache.directory.shared.ldap.aci.MicroOperation;
 import org.apache.directory.shared.ldap.aci.ProtectedItem;
 import org.apache.directory.shared.ldap.aci.UserClass;
 import org.apache.directory.shared.ldap.aci.ProtectedItem.MaxValueCountItem;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
 
 
 /**
@@ -50,7 +55,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class MaxValueCountFilterTest extends TestCase
+public class MaxValueCountFilterTest
 {
     private static final Collection<ACITuple> EMPTY_ACI_TUPLE_COLLECTION = Collections.unmodifiableCollection( new ArrayList<ACITuple>() );
     private static final Collection<UserClass> EMPTY_USER_CLASS_COLLECTION = Collections.unmodifiableCollection( new ArrayList<UserClass>() );
@@ -59,26 +64,38 @@
     private static final Set<MicroOperation> EMPTY_MICRO_OPERATION_SET = Collections.unmodifiableSet( new HashSet<MicroOperation>() );
 
     private static final Collection<ProtectedItem> PROTECTED_ITEMS = new ArrayList<ProtectedItem>();
-    private static final Attributes ENTRY = new AttributesImpl();
-    private static final Attributes FULL_ENTRY = new AttributesImpl();
+    private static ServerEntry ENTRY;
+    private static ServerEntry FULL_ENTRY;
 
     static
     {
         Collection<MaxValueCountItem> mvcItems = new ArrayList<MaxValueCountItem>();
-        mvcItems.add( new MaxValueCountItem( "testAttr", 2 ) );
+        mvcItems.add( new MaxValueCountItem( "cn", 2 ) );
         PROTECTED_ITEMS.add( new ProtectedItem.MaxValueCount( mvcItems ) );
+    }
 
-        ENTRY.put( "testAttr", "1" );
 
-        Attribute attr = new AttributeImpl( "testAttr" );
-        attr.add( "1" );
-        attr.add( "2" );
-        attr.add( "3" );
-        FULL_ENTRY.put( attr );
+    /** A reference to the directory service */
+    private static DirectoryService service;
+
+    
+    @BeforeClass public static void init() throws NamingException
+    {
+        service = new DefaultDirectoryService();
+    }
+    
+    @Before public void setup() throws NamingException
+    {
+        LdapDN entryName = new LdapDN( "ou=test, ou=system" );
+        ENTRY = new DefaultServerEntry( service.getRegistries(), entryName );
+        FULL_ENTRY = new DefaultServerEntry( service.getRegistries(), entryName );
+        
+        ENTRY.put( "cn", "1" );
+        FULL_ENTRY.put( "cn", "1", "2", "3" );
     }
 
 
-    public void testWrongScope() throws Exception
+    @Test public void testWrongScope() throws Exception
     {
         MaxValueCountFilter filter = new MaxValueCountFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
@@ -87,24 +104,24 @@
 
         tuples = Collections.unmodifiableCollection( tuples );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, null, null,
             null, null, null, null, null, null, null ) );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null,
             null, null, null, null, null ) );
     }
 
 
-    public void testZeroTuple() throws Exception
+    @Test public void testZeroTuple() throws Exception
     {
         MaxValueCountFilter filter = new MaxValueCountFilter();
 
-        Assert.assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, 
+        assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, 
             null, null, null, null, null, null, null, null, null, null, null ).size() );
     }
 
 
-    public void testDenialTuple() throws Exception
+    @Test public void testDenialTuple() throws Exception
     {
         MaxValueCountFilter filter = new MaxValueCountFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
@@ -113,24 +130,32 @@
 
         tuples = Collections.unmodifiableCollection( tuples );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
-            null, null, null, "testAttr", null, ENTRY, null, null ) );
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
-            null, null, null, "testAttr", null, FULL_ENTRY, null, null ) );
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
+            null, null, null, "cn", null, ENTRY, null, null ) );
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
+            null, null, null, "cn", null, FULL_ENTRY, null, null ) );
     }
 
 
-    public void testGrantTuple() throws Exception
+    @Test public void testGrantTuple() throws Exception
     {
         MaxValueCountFilter filter = new MaxValueCountFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
-        tuples.add( new ACITuple( EMPTY_USER_CLASS_COLLECTION, AuthenticationLevel.NONE, PROTECTED_ITEMS, 
-            EMPTY_MICRO_OPERATION_SET, true, 0 ) );
+        
+        // Test with this ACI :
+        // 
+        tuples.add( new ACITuple( 
+            EMPTY_USER_CLASS_COLLECTION, 
+            AuthenticationLevel.NONE, 
+            PROTECTED_ITEMS, 
+            EMPTY_MICRO_OPERATION_SET, 
+            true, 
+            0 ) );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
-            null, null, "testAttr", null, ENTRY, null, ENTRY ).size() );
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+            null, null, "cn", null, ENTRY, null, ENTRY ).size() );
 
-        Assert.assertEquals( 0, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
-            null, null, "testAttr", null, FULL_ENTRY, null, FULL_ENTRY ).size() );
+        assertEquals( 0, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+            null, null, "cn", null, FULL_ENTRY, null, FULL_ENTRY ).size() );
     }
 }

Modified: directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java?rev=615071&r1=615070&r2=615071&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java (original)
+++ directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java Thu Jan 24 14:39:32 2008
@@ -28,14 +28,17 @@
 
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
 
+import org.apache.directory.server.core.DefaultDirectoryService;
+import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.authz.support.OperationScope;
 import org.apache.directory.server.core.authz.support.RelatedProtectedItemFilter;
 import org.apache.directory.server.core.authz.support.RelatedUserClassFilter;
+import org.apache.directory.server.core.entry.DefaultServerAttribute;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerAttribute;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.event.ExpressionEvaluator;
 import org.apache.directory.server.core.subtree.RefinementEvaluator;
 import org.apache.directory.server.core.subtree.RefinementLeafEvaluator;
@@ -48,10 +51,14 @@
 import org.apache.directory.shared.ldap.aci.ProtectedItem.MaxValueCountItem;
 import org.apache.directory.shared.ldap.aci.ProtectedItem.RestrictedByItem;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+
 
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
 
 /**
  * Tests {@link RelatedUserClassFilter}.
@@ -59,158 +66,178 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class RelatedProtectedItemFilterTest extends TestCase
+public class RelatedProtectedItemFilterTest
 {
     private static final Collection<UserClass> EMPTY_USER_CLASS_COLLECTION = Collections.unmodifiableCollection( new ArrayList<UserClass>() );
     private static final Collection<ACITuple> EMPTY_ACI_TUPLE_COLLECTION = Collections.unmodifiableCollection( new ArrayList<ACITuple>() );
     private static final Set<MicroOperation> EMPTY_MICRO_OPERATION_SET = Collections.unmodifiableSet( new HashSet<MicroOperation>() );
 
-    private static final LdapDN GROUP_NAME;
-    private static final LdapDN USER_NAME;
-    private static final Set<LdapDN> USER_NAMES = new HashSet<LdapDN>();
-    private static final Set<LdapDN> GROUP_NAMES = new HashSet<LdapDN>();
+    private static LdapDN GROUP_NAME;
+    private static LdapDN USER_NAME;
+    private static Set<LdapDN> USER_NAMES = new HashSet<LdapDN>();
+    private static Set<LdapDN> GROUP_NAMES = new HashSet<LdapDN>();
 
     private static final AttributeTypeRegistry ATTR_TYPE_REGISTRY_A = new DummyAttributeTypeRegistry( false );
     private static final AttributeTypeRegistry ATTR_TYPE_REGISTRY_B = new DummyAttributeTypeRegistry( true );
-    private static final OidRegistry OID_REGISTRY = new DummyOidRegistry();
+    private static OidRegistry OID_REGISTRY;
+
+    private static RelatedProtectedItemFilter filterA;
+    private static RelatedProtectedItemFilter filterB;
 
-    private static final RelatedProtectedItemFilter filterA;
-    private static final RelatedProtectedItemFilter filterB;
+    /** A reference to the directory service */
+    private static DirectoryService service;
+    
+    /** The CN attribute Type */
+    private static AttributeType CN_AT;
 
-    static
+    /** The SN attribute Type */
+    private static AttributeType SN_AT;
+
+    
+    @BeforeClass public static void setup() throws NamingException
     {
-        try
-        {
-            GROUP_NAME = new LdapDN( "ou=test,ou=groups,ou=system" );
-            USER_NAME = new LdapDN( "ou=test, ou=users, ou=system" );
+        service = new DefaultDirectoryService();
+        OID_REGISTRY = service.getRegistries().getOidRegistry();
 
-            filterA = new RelatedProtectedItemFilter( new RefinementEvaluator( new RefinementLeafEvaluator(
-                OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_A ), OID_REGISTRY, ATTR_TYPE_REGISTRY_A );
+        GROUP_NAME = new LdapDN( "ou=test,ou=groups,ou=system" );
+        USER_NAME = new LdapDN( "ou=test, ou=users, ou=system" );
 
-            filterB = new RelatedProtectedItemFilter( new RefinementEvaluator( new RefinementLeafEvaluator(
-                OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_B ), OID_REGISTRY, ATTR_TYPE_REGISTRY_B );
-        }
-        catch ( NamingException e )
-        {
-            throw new Error();
-        }
+        filterA = new RelatedProtectedItemFilter( new RefinementEvaluator( new RefinementLeafEvaluator(
+            OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_A ), OID_REGISTRY, ATTR_TYPE_REGISTRY_A );
+
+        filterB = new RelatedProtectedItemFilter( new RefinementEvaluator( new RefinementLeafEvaluator(
+            OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_B ), OID_REGISTRY, ATTR_TYPE_REGISTRY_B );
 
         USER_NAMES.add( USER_NAME );
         GROUP_NAMES.add( GROUP_NAME );
+        CN_AT = service.getRegistries().getAttributeTypeRegistry().lookup( "cn" );
+        SN_AT = service.getRegistries().getAttributeTypeRegistry().lookup( "sn" );
     }
 
+    
+    private Collection<Attribute> convert( Collection<ServerAttribute> attributes )
+    {
+        Set<Attribute> jndiAttributes = new HashSet<Attribute>();
+        
+        for ( ServerAttribute attribute:attributes )
+        {
+            jndiAttributes.add( ServerEntryUtils.toAttributeImpl( attribute ) );
+        }
+        
+        return jndiAttributes;
+    }
 
-    public void testZeroTuple() throws Exception
+    @Test public void testZeroTuple() throws Exception
     {
-        Assert.assertEquals( 0, filterA.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
+        assertEquals( 0, filterA.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
             null, null, null, null, null, null, null, null, null ).size() );
     }
 
 
-    public void testEntry() throws Exception
+    @Test public void testEntry() throws Exception
     {
         Collection<ACITuple> tuples = getTuples( ProtectedItem.ENTRY );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
             AuthenticationLevel.NONE, null, "ou", null, null, null, null ).size() );
     }
 
 
-    public void testAllUserAttributeTypes() throws Exception
+    @Test public void testAllUserAttributeTypes() throws Exception
     {
         Collection<ACITuple> tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "userAttr", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
 
         tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
-            null, null, "userAttr", null, null, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+            null, null, "cn", null, null, null, null ).size() );
     }
 
 
-    public void testAllUserAttributeTypesAndValues() throws Exception
+    @Test public void testAllUserAttributeTypesAndValues() throws Exception
     {
         Collection<ACITuple> tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES_AND_VALUES );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "userAttr", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
 
         tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES_AND_VALUES );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
-            null, null, "userAttr", null, null, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+            null, null, "cn", null, null, null, null ).size() );
     }
 
 
-    public void testAllAttributeValues() throws Exception
+    @Test public void testAllAttributeValues() throws Exception
     {
         Collection<String> attrTypes = new ArrayList<String>();
-        attrTypes.add( "attrA" );
+        attrTypes.add( "cn" );
         Collection<ACITuple> tuples = getTuples( new ProtectedItem.AllAttributeValues( attrTypes ) );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "attrA", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
 
         tuples = getTuples( new ProtectedItem.AllAttributeValues( attrTypes ) );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME, null,
-            null, null, "attrA", null, null, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME, null,
+            null, null, "cn", null, null, null, null ).size() );
 
-        Assert.assertEquals( 0, filterB.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME, null,
-            null, null, "attrB", null, null, null, null ).size() );
+        assertEquals( 0, filterB.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME, null,
+            null, null, "sn", null, null, null, null ).size() );
     }
 
 
-    public void testAttributeType() throws Exception
+    @Test public void testAttributeType() throws Exception
     {
         Collection<String> attrTypes = new ArrayList<String>();
-        attrTypes.add( "attrA" );
+        attrTypes.add( "cn" );
         Collection<ACITuple> tuples = getTuples( new ProtectedItem.AttributeType( attrTypes ) );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "attrA", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
 
         tuples = getTuples( new ProtectedItem.AttributeType( attrTypes ) );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
-            null, null, "attrA", null, null, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+            null, null, "cn", null, null, null, null ).size() );
 
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
-            null, null, "attrB", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+            null, null, "sn", null, null, null, null ).size() );
     }
 
 
-    public void testAttributeValue() throws Exception
+    @Test public void testAttributeValue() throws Exception
     {
-        Collection<Attribute> attributes = new ArrayList<Attribute>();
-        attributes.add( new AttributeImpl( "attrA", "valueA" ) );
-        Collection<ACITuple> tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
+        Collection<ServerAttribute> attributes = new ArrayList<ServerAttribute>();
+        attributes.add( new DefaultServerAttribute( "cn", CN_AT, "valueA" ) );
+        Collection<ACITuple> tuples = getTuples( new ProtectedItem.AttributeValue( convert( attributes ) ) );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "attrA", null, null, null, null ).size() );
-        tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
-            null, null, "attrA", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
+        tuples = getTuples( new ProtectedItem.AttributeValue( convert( attributes )  ) );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+            null, null, "cn", null, null, null, null ).size() );
 
-        tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
+        tuples = getTuples( new ProtectedItem.AttributeValue( convert( attributes )  ) );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrA", "valueA", null, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "cn", "valueA", null, null, null ).size() );
 
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrA", "valueB", null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "cn", "valueB", null, null, null ).size() );
 
-        tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
+        tuples = getTuples( new ProtectedItem.AttributeValue( convert( attributes )  ) );
 
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrB", "valueA", null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "sn", "valueA", null, null, null ).size() );
     }
 
 
@@ -220,106 +247,107 @@
     }
 
 
-    public void testMaxImmSub() throws Exception
+    @Test public void testMaxImmSub() throws Exception
     {
         Collection<ACITuple> tuples = getTuples( new ProtectedItem.MaxImmSub( 2 ) );
 
-        // Should always retain ruples.
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "attrA", null, null, null, null ).size() );
+        // Should always retain tuples.
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
     }
 
 
-    public void testMaxValueCount() throws Exception
+    @Test public void testMaxValueCount() throws Exception
     {
         Collection<MaxValueCountItem> mvcItems = new ArrayList<MaxValueCountItem>();
-        mvcItems.add( new MaxValueCountItem( "attrA", 3 ) );
+        mvcItems.add( new MaxValueCountItem( "cn", 3 ) );
         Collection<ACITuple> tuples = getTuples( new ProtectedItem.MaxValueCount( mvcItems ) );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "attrA", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
         tuples = getTuples( new ProtectedItem.MaxValueCount( mvcItems ) );
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
-            null, null, "attrA", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+            null, null, "cn", null, null, null, null ).size() );
 
         tuples = getTuples( new ProtectedItem.MaxValueCount( mvcItems ) );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrA", null, null, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "cn", null, null, null, null ).size() );
 
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrB", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "sn", null, null, null, null ).size() );
     }
 
 
     /* this test requires a real registry with real values or the dummy registry
      * needs to be altered to contain some usable mock data.  This is a result of
      * using the registry now in this operation.    
+     *
     public void testRangeOfValues() throws Exception
     {
-        Attributes entry = new AttributesImpl( true );
-        entry.put( "attrA", "valueA" );
-        Collection tuples = getTuples( new ProtectedItem.RangeOfValues( new PresenceNode( "attrA" ) ) );
+        ServerEntry entry = new DefaultServerEntry( service.getRegistries(), USER_NAME );
+        entry.put( "cn", "valueA" );
+        Collection<ACITuple> tuples = getTuples( new ProtectedItem.RangeOfValues( new PresenceNode( "cn" ) ) );
 
         Assert.assertEquals( 1, filterA.filter( tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null,
             new LdapDN( "ou=testEntry" ), null, null, entry, null ).size() );
 
-        entry.remove( "attrA" );
-        Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+        entry.remove( "cn" );
+        Assert.assertEquals( 0, filterA.filter( service.getRegistries(), tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
             null, null, new LdapDN( "ou=testEntry" ), null, null, entry, null ).size() );
     }
     */
 
 
-    public void testRestrictedBy() throws Exception
+    @Test public void testRestrictedBy() throws Exception
     {
         Collection<RestrictedByItem> rbItems = new ArrayList<RestrictedByItem>();
-        rbItems.add( new RestrictedByItem( "attrA", "attrB" ) );
+        rbItems.add( new RestrictedByItem( "cn", "sn" ) );
         Collection<ACITuple> tuples = getTuples( new ProtectedItem.RestrictedBy( rbItems ) );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "attrA", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
         tuples = getTuples( new ProtectedItem.RestrictedBy( rbItems ) );
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
-            null, null, "attrA", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+            null, null, "cn", null, null, null, null ).size() );
 
         tuples = getTuples( new ProtectedItem.RestrictedBy( rbItems ) );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrA", null, null, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "cn", null, null, null, null ).size() );
 
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrB", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "sn", null, null, null, null ).size() );
     }
 
 
-    public void testSelfValue() throws Exception
+    @Test public void testSelfValue() throws Exception
     {
         Collection<String> attrTypes = new ArrayList<String>();
-        attrTypes.add( "attrA" );
+        attrTypes.add( "cn" );
         Collection<ACITuple> tuples = getTuples( new ProtectedItem.SelfValue( attrTypes ) );
 
-        Attributes entry = new AttributesImpl();
-        entry.put( "attrA", USER_NAME.toNormName() );
+        ServerEntry entry = new DefaultServerEntry( service.getRegistries(), USER_NAME );
+        entry.put( "cn", USER_NAME.toNormName() );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "attrA", null, entry, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, entry, null, null ).size() );
 
         tuples = getTuples( new ProtectedItem.SelfValue( attrTypes ) );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrA", null, entry, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "cn", null, entry, null, null ).size() );
 
-        entry.remove( "attrA" );
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrA", null, entry, null, null ).size() );
+        entry.remove( "cn" );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "cn", null, entry, null, null ).size() );
 
         tuples = getTuples( new ProtectedItem.SelfValue( attrTypes ) );
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrB", null, entry, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "sn", null, entry, null, null ).size() );
     }
 
 

Modified: directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java?rev=615071&r1=615070&r2=615071&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java (original)
+++ directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java Thu Jan 24 14:39:32 2008
@@ -26,22 +26,26 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import javax.naming.NamingException;
 
+import org.apache.directory.server.core.DefaultDirectoryService;
+import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.authz.support.OperationScope;
 import org.apache.directory.server.core.authz.support.RestrictedByFilter;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.shared.ldap.aci.ACITuple;
 import org.apache.directory.shared.ldap.aci.MicroOperation;
 import org.apache.directory.shared.ldap.aci.ProtectedItem;
 import org.apache.directory.shared.ldap.aci.UserClass;
 import org.apache.directory.shared.ldap.aci.ProtectedItem.RestrictedByItem;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
 
 
 /**
@@ -50,7 +54,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class RestrictedByFilterTest extends TestCase
+public class RestrictedByFilterTest
 {
     private static final Collection<UserClass> UC_EMPTY_COLLECTION = Collections.unmodifiableCollection( new ArrayList<UserClass>() );
     private static final Collection<ACITuple> AT_EMPTY_COLLECTION = Collections.unmodifiableCollection( new ArrayList<ACITuple>() );
@@ -58,23 +62,33 @@
     private static final Set<MicroOperation> MO_EMPTY_SET = Collections.unmodifiableSet( new HashSet<MicroOperation>() );
 
     private static final Collection<ProtectedItem> PROTECTED_ITEMS = new ArrayList<ProtectedItem>();
-    private static final Attributes ENTRY = new AttributesImpl();
+    private static ServerEntry ENTRY;
 
     static
     {
         Collection<RestrictedByItem> mvcItems = new ArrayList<RestrictedByItem>();
-        mvcItems.add( new RestrictedByItem( "choice", "option" ) );
+        mvcItems.add( new RestrictedByItem( "sn", "cn" ) );
         PROTECTED_ITEMS.add( new ProtectedItem.RestrictedBy( mvcItems ) );
+    }
+
+
+    /** A reference to the directory service */
+    private static DirectoryService service;
+
+    
+    @BeforeClass public static void setup() throws NamingException
+    {
+        service = new DefaultDirectoryService();
 
-        Attribute attr = new AttributeImpl( "option" );
-        attr.add( "1" );
-        attr.add( "2" );
+        LdapDN entryName = new LdapDN( "ou=test, ou=system" );
+        PROTECTED_ITEMS.add( new ProtectedItem.MaxImmSub( 2 ) );
+        ENTRY = new DefaultServerEntry( service.getRegistries(), entryName );
 
-        ENTRY.put( attr );
+        ENTRY.put( "cn", "1", "2" );
     }
 
 
-    public void testWrongScope() throws Exception
+    @Test public void testWrongScope() throws Exception
     {
         RestrictedByFilter filter = new RestrictedByFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
@@ -82,24 +96,24 @@
 
         tuples = Collections.unmodifiableCollection( tuples );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, null, null,
             null, null, null, null, null, null, null ) );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null,
             null, null, null, null, null ) );
     }
 
 
-    public void testZeroTuple() throws Exception
+    @Test public void testZeroTuple() throws Exception
     {
         RestrictedByFilter filter = new RestrictedByFilter();
 
-        Assert.assertEquals( 0, filter.filter( null, AT_EMPTY_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
+        assertEquals( 0, filter.filter( null, AT_EMPTY_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
             null, null, null, null, null, null, null, null, null ).size() );
     }
 
 
-    public void testDenialTuple() throws Exception
+    @Test public void testDenialTuple() throws Exception
     {
         RestrictedByFilter filter = new RestrictedByFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
@@ -107,24 +121,24 @@
 
         tuples = Collections.unmodifiableCollection( tuples );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
             null, null, null, "testAttr", null, ENTRY, null, null ) );
     }
 
 
-    public void testGrantTuple() throws Exception
+    @Test public void testGrantTuple() throws Exception
     {
         RestrictedByFilter filter = new RestrictedByFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
         tuples.add( new ACITuple( UC_EMPTY_COLLECTION, AuthenticationLevel.NONE, PROTECTED_ITEMS, MO_EMPTY_SET, true, 0 ) );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
-            null, null, "choice", "1", ENTRY, null, null ).size() );
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+            null, null, "sn", "1", ENTRY, null, null ).size() );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
-            null, null, "choice", "2", ENTRY, null, null ).size() );
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+            null, null, "sn", "2", ENTRY, null, null ).size() );
 
-        Assert.assertEquals( 0, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
-            null, null, "choice", "3", ENTRY, null, null ).size() );
+        assertEquals( 0, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+            null, null, "sn", "3", ENTRY, null, null ).size() );
     }
 }

Modified: directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/interceptor/MockInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/interceptor/MockInterceptor.java?rev=615071&r1=615070&r2=615071&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/interceptor/MockInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/interceptor/MockInterceptor.java Thu Jan 24 14:39:32 2008
@@ -45,7 +45,6 @@
 
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
 import javax.naming.directory.SearchResult;
 import java.util.Iterator;
 
@@ -171,7 +170,7 @@
     }
 
 
-    public Attributes lookup( NextInterceptor next, LookupOperationContext opContext ) throws NamingException
+    public ServerEntry lookup( NextInterceptor next, LookupOperationContext opContext ) throws NamingException
     {
         test.interceptors.add( this );
         return next.lookup( opContext );



Mime
View raw message