You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2005/09/01 03:46:37 UTC
svn commit: r265617 - in /directory/apacheds/trunk/core: ./
src/main/java/org/apache/ldap/server/schema/
src/main/java/org/apache/ldap/server/subtree/
src/test/org/apache/ldap/server/subtree/
Author: akarasulu
Date: Wed Aug 31 18:46:29 2005
New Revision: 265617
URL: http://svn.apache.org/viewcvs?rev=265617&view=rev
Log:
changes ...
o adding subtree specification evaluation algorithm to determine of an entry
is included within the collection of a spec
o fixed a big in the GlobablOidRegistry where it was not checking the bootstrap
registry if a lookup was not found
o added test cases for almost full coverage (99%)
Completes task DIREVE-234 here:
http://issues.apache.org/jira/browse/DIREVE-234
Added:
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/RefinementEvaluator.java (with props)
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/RefinementLeafEvaluator.java (with props)
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubtreeEvaluator.java (with props)
directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/
directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/RefinementEvaluatorTest.java (with props)
directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/RefinementLeafEvaluatorTest.java (with props)
directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubtreeEvaluatorTest.java (with props)
Modified:
directory/apacheds/trunk/core/project.xml
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/GlobalOidRegistry.java (contents, props changed)
Modified: directory/apacheds/trunk/core/project.xml
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/project.xml?rev=265617&r1=265616&r2=265617&view=diff
==============================================================================
--- directory/apacheds/trunk/core/project.xml (original)
+++ directory/apacheds/trunk/core/project.xml Wed Aug 31 18:46:29 2005
@@ -67,7 +67,7 @@
<dependency>
<groupId>directory-shared</groupId>
<artifactId>ldap-common</artifactId>
- <version>0.9.2</version>
+ <version>0.9.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>${pom.groupId}</groupId>
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/GlobalOidRegistry.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/GlobalOidRegistry.java?rev=265617&r1=265616&r2=265617&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/GlobalOidRegistry.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/GlobalOidRegistry.java Wed Aug 31 18:46:29 2005
@@ -241,8 +241,13 @@
*/
public List getNameSet( String oid ) throws NamingException
{
- Object value = byOid.get( oid );
+ Object value = this.byOid.get( oid );
+ if ( null == value )
+ {
+ value = this.bootstrap.getNameSet( oid );
+ }
+
if ( null == value )
{
String msg = "OID '" + oid + "' was not found within the OID registry";
Propchange: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/GlobalOidRegistry.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/RefinementEvaluator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/RefinementEvaluator.java?rev=265617&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/RefinementEvaluator.java (added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/RefinementEvaluator.java Wed Aug 31 18:46:29 2005
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ldap.server.subtree;
+
+
+import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.filter.BranchNode;
+import org.apache.ldap.common.filter.SimpleNode;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import java.util.Iterator;
+
+
+/**
+ * The top level evaluation node for a refinement.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class RefinementEvaluator
+{
+ /** Leaf Evaluator flyweight use for leaf filter assertions */
+ private RefinementLeafEvaluator leafEvaluator;
+
+
+ // ------------------------------------------------------------------------
+ // C O N S T R U C T O R S
+ // ------------------------------------------------------------------------
+
+
+ public RefinementEvaluator( RefinementLeafEvaluator leafEvaluator )
+ {
+ this.leafEvaluator = leafEvaluator;
+ }
+
+
+ public boolean evaluate( ExprNode node, Attribute 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( "objectClass" ) )
+ {
+ throw new IllegalArgumentException( "Attribute objectClasses should be of id 'objectClass'" );
+ }
+ if ( node.isLeaf() )
+ {
+ return leafEvaluator.evaluate( ( SimpleNode ) node, objectClasses );
+ }
+
+ BranchNode bnode = ( BranchNode ) node;
+
+ switch( bnode.getOperator() )
+ {
+ case( BranchNode.OR ):
+ Iterator children = bnode.getChildren().iterator();
+
+ while ( children.hasNext() )
+ {
+ ExprNode child = ( ExprNode ) children.next();
+
+ if ( evaluate( child, objectClasses ) )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ case( BranchNode.AND ):
+ children = bnode.getChildren().iterator();
+ while ( children.hasNext() )
+ {
+ ExprNode child = ( ExprNode ) children.next();
+
+ if ( ! evaluate( child, objectClasses ) )
+ {
+ return false;
+ }
+ }
+
+ return true;
+ case( BranchNode.NOT ):
+ if ( null != bnode.getChild() )
+ {
+ return ! evaluate( bnode.getChild(), objectClasses );
+ }
+
+ throw new IllegalArgumentException( "Negation has no child: " + node );
+ default:
+ throw new IllegalArgumentException( "Unrecognized branch node operator: "
+ + bnode.getOperator() );
+ }
+ }
+}
Propchange: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/RefinementEvaluator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/RefinementLeafEvaluator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/RefinementLeafEvaluator.java?rev=265617&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/RefinementLeafEvaluator.java (added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/RefinementLeafEvaluator.java Wed Aug 31 18:46:29 2005
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ldap.server.subtree;
+
+
+import org.apache.ldap.common.filter.*;
+import org.apache.ldap.server.schema.OidRegistry;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import java.util.Iterator;
+
+
+/**
+ * A refinement leaf node evaluator. This evaluator checks to see if the
+ * objectClass attribute of a candidate entry is matched by a leaf node in
+ * a refinement filter expression tree.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class RefinementLeafEvaluator
+{
+ /** an OID to name and vice versa registry */
+ private final OidRegistry registry;
+
+
+ /**
+ * Creates a refinement filter's leaf node evaluator.
+ *
+ * @param registry the OID registry used to lookup names for objectClass OIDs
+ */
+ public RefinementLeafEvaluator( OidRegistry registry )
+ {
+ this.registry = registry;
+ }
+
+
+ /**
+ * Evaluates whether or not a simple leaf node of a refinement filter selects an
+ * entry based on the entry's objectClass attribute values.
+ *
+ * @param node the leaf node of the refinement filter
+ * @param objectClasses the objectClass attribute's values
+ * @return true if the leaf node selects the entry based on objectClass values, false
+ * if it rejects the entry
+ * @throws NamingException
+ */
+ public boolean evaluate( SimpleNode node, Attribute objectClasses ) throws NamingException
+ {
+ if ( node == null )
+ {
+ throw new IllegalArgumentException( "node cannot be null" );
+ }
+ if ( node.getAssertionType() != LeafNode.EQUALITY )
+ {
+ throw new NamingException( "Unrecognized assertion type for refinement node: "
+ + node.getAssertionType() );
+ }
+ if ( ! node.getAttribute().equalsIgnoreCase( "objectclass" ) )
+ {
+ throw new NamingException( "Refinement leaf node attribute was " + node.getAttribute() );
+ }
+
+ if ( null == objectClasses )
+ {
+ throw new IllegalArgumentException( "objectClasses argument cannot be null" );
+ }
+ if ( ! objectClasses.getID().equalsIgnoreCase( "objectclass" ) )
+ {
+ throw new IllegalArgumentException( "objectClasses attribute must be for ID 'objectClass'" );
+ }
+
+ // check if AVA value exists in attribute
+ if ( objectClasses.contains( node.getValue() ) )
+ {
+ return true;
+ }
+
+ // If the filter value for the objectClass is an OID we need to resolve a name
+ if ( Character.isDigit( node.getValue().charAt( 0 ) ) )
+ {
+ Iterator list = registry.getNameSet( node.getValue() ).iterator();
+ while ( list.hasNext() )
+ {
+ String objectClass = ( String ) list.next();
+ if ( objectClasses.contains( objectClass ) )
+ {
+ return true;
+ }
+ }
+ }
+
+ // no match so return false
+ return false;
+ }
+}
Propchange: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/RefinementLeafEvaluator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubtreeEvaluator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubtreeEvaluator.java?rev=265617&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubtreeEvaluator.java (added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubtreeEvaluator.java Wed Aug 31 18:46:29 2005
@@ -0,0 +1,192 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ldap.server.subtree;
+
+
+import org.apache.ldap.common.util.NamespaceTools;
+import org.apache.ldap.common.name.LdapName;
+import org.apache.ldap.common.subtree.SubtreeSpecification;
+import org.apache.ldap.server.schema.OidRegistry;
+
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import java.util.Iterator;
+
+
+/**
+ * An evaluator used to determine if an entry is included in the collection
+ * represented by a subtree specification.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class SubtreeEvaluator
+{
+ /** A refinement filter evaluator */
+ private final RefinementEvaluator evaluator;
+
+
+ /**
+ * Creates a subtreeSpecification evaluatior which can be used to determine
+ * if an entry is included within the collection of a subtree.
+ *
+ * @param registry a registry used to lookup objectClass names for OIDs
+ */
+ public SubtreeEvaluator( OidRegistry registry )
+ {
+ RefinementLeafEvaluator leafEvaluator = new RefinementLeafEvaluator( registry );
+ evaluator = new RefinementEvaluator( leafEvaluator );
+ }
+
+
+ /**
+ * Determines if an entry is selected by a subtree specification.
+ *
+ * @param subtree the subtree specification
+ * @param apDn the distinguished name of the administrative point containing the subentry
+ * @param entryDn the distinguished name of the candidate entry
+ * @param objectClasses the objectClasses of the candidate entry
+ * @return true if the entry is selected by the specification, false if it is not
+ * @throws javax.naming.NamingException if errors are encountered while evaluating selection
+ */
+ public boolean evaluate( SubtreeSpecification subtree, Name apDn, Name entryDn, Attribute objectClasses )
+ throws NamingException
+ {
+ /* =====================================================================
+ * NOTE: Regarding the overall approach, we try to narrow down the
+ * possibilities by slowly pruning relative names off of the entryDn.
+ * For example we check first if the entry is a descendant of the AP.
+ * If so we use the relative name thereafter to calculate if it is
+ * a descendant of the base. This means shorter names to compare and
+ * less work to do while we continue to deduce inclusion by the subtree
+ * specification.
+ * =====================================================================
+ */
+
+ /*
+ * First we simply check if the candidate entry is a descendant of the
+ * administrative point. In the process we calculate the relative
+ * distinguished name relative to the administrative point.
+ */
+ Name apRelativeRdn;
+ if ( ! NamespaceTools.isDescendant( apDn, entryDn ) )
+ {
+ return false;
+ }
+ else if ( apDn.equals( entryDn ) )
+ {
+ apRelativeRdn = new LdapName();
+ }
+ else
+ {
+ apRelativeRdn = NamespaceTools.getRelativeName( apDn, entryDn );
+ }
+
+ /*
+ * We do the same thing with the base as we did with the administrative
+ * point: check if the entry is a descendant of the base and find the
+ * relative name of the entry with respect to the base rdn. With the
+ * baseRelativeRdn we can later make comparisons with specific exclusions.
+ */
+ Name baseRelativeRdn;
+ if ( subtree.getBase() != null && subtree.getBase().size() == 0 )
+ {
+ baseRelativeRdn = apRelativeRdn;
+ }
+ else if ( apRelativeRdn.equals( subtree.getBase() ) )
+ {
+ baseRelativeRdn = new LdapName();
+ }
+ else if ( ! NamespaceTools.isDescendant( subtree.getBase(), apRelativeRdn ) )
+ {
+ return false;
+ }
+ else
+ {
+ baseRelativeRdn = NamespaceTools.getRelativeName( subtree.getBase(), apRelativeRdn );
+ }
+
+ /*
+ * Evaluate based on minimum and maximum chop values. Here we simply
+ * need to compare the distances respectively with the size of the
+ * baseRelativeRdn. For the max distance entries with a baseRelativeRdn
+ * size greater than the max distance are rejected. For the min distance
+ * entries with a baseRelativeRdn size less than the minimum distance
+ * are rejected.
+ */
+ if ( subtree.getMaxBaseDistance() != SubtreeSpecification.UNBOUNDED_MAX )
+ {
+ if ( subtree.getMaxBaseDistance() < baseRelativeRdn.size() )
+ {
+ return false;
+ }
+ }
+
+ if ( subtree.getMinBaseDistance() > 0 )
+ {
+ if ( baseRelativeRdn.size() < subtree.getMinBaseDistance() )
+ {
+ return false;
+ }
+ }
+
+ /*
+ * For specific exclusions we must iterate through the set and check
+ * if the baseRelativeRdn is a descendant of the exclusion. The
+ * isDescendant() function will return true if the compared names
+ * are equal so for chopAfter exclusions we must check for equality
+ * as well and reject if the relative names are equal.
+ */
+ Iterator list = subtree.getChopBeforeExclusions().iterator();
+ while ( list.hasNext() )
+ {
+ Name chopBefore = ( Name ) list.next();
+ if ( NamespaceTools.isDescendant( chopBefore, baseRelativeRdn ) )
+ {
+ return false;
+ }
+ }
+
+ list = subtree.getChopAfterExclusions().iterator();
+ while ( list.hasNext() )
+ {
+ Name chopAfter = ( Name ) list.next();
+ if ( NamespaceTools.isDescendant( chopAfter, baseRelativeRdn ) && ! chopAfter.equals( baseRelativeRdn ) )
+ {
+ return false;
+ }
+ }
+
+ /*
+ * The last remaining step is to check and see if the refinement filter
+ * selects the entry candidate based on objectClass attribute values.
+ * To do this we invoke the refinement evaluator members evaluate() method.
+ */
+ if ( subtree.getRefinement() != null )
+ {
+ return evaluator.evaluate( subtree.getRefinement(), objectClasses );
+ }
+
+ /*
+ * If nothing has rejected the candidate entry and there is no refinement
+ * filter then the entry is included in the collection represented by the
+ * subtree specification so we return true.
+ */
+ return true;
+ }
+}
Propchange: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubtreeEvaluator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/RefinementEvaluatorTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/RefinementEvaluatorTest.java?rev=265617&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/RefinementEvaluatorTest.java (added)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/RefinementEvaluatorTest.java Wed Aug 31 18:46:29 2005
@@ -0,0 +1,248 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ldap.server.subtree;
+
+
+import junit.framework.TestCase;
+
+import javax.naming.NamingException;
+import javax.naming.directory.BasicAttribute;
+
+import org.apache.ldap.server.schema.bootstrap.*;
+import org.apache.ldap.server.schema.GlobalRegistries;
+import org.apache.ldap.server.schema.OidRegistry;
+import org.apache.ldap.common.filter.*;
+
+import java.util.Set;
+import java.util.HashSet;
+
+
+/**
+ * Unit test cases for testing the evaluator for refinements.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class RefinementEvaluatorTest extends TestCase
+{
+ /** the global registries */
+ private GlobalRegistries registries;
+ /** the refinement evaluator to test */
+ private RefinementEvaluator evaluator;
+
+
+ /**
+ * Initializes the global registries.
+ * @throws javax.naming.NamingException if there is a failure loading the schema
+ */
+ private void init() throws NamingException
+ {
+ BootstrapRegistries bsRegistries = new BootstrapRegistries();
+ BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
+ Set schemas = new HashSet();
+ schemas.add( new SystemSchema() );
+ schemas.add( new ApacheSchema() );
+ schemas.add( new CoreSchema() );
+ schemas.add( new CosineSchema() );
+ schemas.add( new InetorgpersonSchema() );
+ schemas.add( new JavaSchema() );
+ loader.load( schemas, bsRegistries );
+ registries = new GlobalRegistries( bsRegistries );
+ }
+
+
+ /**
+ * Initializes registries and creates the leaf evalutator
+ * @throws Exception if there are schema initialization problems
+ */
+ protected void setUp() throws Exception
+ {
+ init();
+ OidRegistry registry = registries.getOidRegistry();
+ RefinementLeafEvaluator leafEvaluator = new RefinementLeafEvaluator( registry );
+ evaluator = new RefinementEvaluator( leafEvaluator );
+ }
+
+
+ /**
+ * Sets evaluator and registries to null.
+ */
+ protected void tearDown()
+ {
+ evaluator = null;
+ registries = null;
+ }
+
+
+ /**
+ * Test cases for various bad combinations of arguments
+ * @throws Exception if something goes wrongg
+ */
+ public void testForBadArguments() throws Exception
+ {
+ try
+ {
+ assertFalse( evaluator.evaluate( null, new BasicAttribute( "objectClass" ) ) );
+ fail( "should never get here due to an IAE" );
+ }
+ catch ( IllegalArgumentException iae )
+ {
+ }
+
+ try
+ {
+ assertFalse( evaluator.evaluate( new SimpleNode( "", "", LeafNode.EQUALITY ), null ) );
+ fail( "should never get here due to an IAE" );
+ }
+ catch ( IllegalArgumentException iae )
+ {
+ }
+
+ try
+ {
+ assertFalse( evaluator.evaluate( new SimpleNode( "", "", LeafNode.EQUALITY ),
+ new BasicAttribute( "blah") ) );
+ fail( "should never get here due to an IAE" );
+ }
+ catch ( IllegalArgumentException iae )
+ {
+ }
+ }
+
+
+ public void testMatchByName() throws Exception
+ {
+ BasicAttribute objectClasses = null;
+
+ // positive test
+ objectClasses = new BasicAttribute( "objectClass", "person" );
+ assertTrue( evaluator.evaluate( new SimpleNode( "objectClass", "person", LeafNode.EQUALITY ),
+ objectClasses ) );
+
+ objectClasses = new BasicAttribute( "objectClass" );
+ objectClasses.add( "person" );
+ objectClasses.add( "blah" );
+ assertTrue( evaluator.evaluate( new SimpleNode( "objectClass", "person", LeafNode.EQUALITY ),
+ objectClasses ) );
+
+ // negative tests
+ objectClasses = new BasicAttribute( "objectClass", "person" );
+ assertFalse( evaluator.evaluate( new SimpleNode( "objectClass", "blah", LeafNode.EQUALITY ),
+ objectClasses ) );
+
+ objectClasses = new BasicAttribute( "objectClass", "blah" );
+ assertFalse( evaluator.evaluate( new SimpleNode( "objectClass", "person", LeafNode.EQUALITY ),
+ objectClasses ) );
+ }
+
+
+ public void testMatchByOID() throws Exception
+ {
+ BasicAttribute objectClasses = null;
+
+ // positive test
+ objectClasses = new BasicAttribute( "objectClass", "person" );
+ assertTrue( evaluator.evaluate( new SimpleNode( "objectClass", "2.5.6.6", LeafNode.EQUALITY ),
+ objectClasses ) );
+
+ objectClasses = new BasicAttribute( "objectClass" );
+ objectClasses.add( "person" );
+ objectClasses.add( "blah" );
+ assertTrue( evaluator.evaluate( new SimpleNode( "objectClass", "2.5.6.6", LeafNode.EQUALITY ),
+ objectClasses ) );
+
+ // negative tests
+ objectClasses = new BasicAttribute( "objectClass", "person" );
+ assertFalse( evaluator.evaluate( new SimpleNode( "objectClass", "2.5.6.5", LeafNode.EQUALITY ),
+ objectClasses ) );
+
+ objectClasses = new BasicAttribute( "objectClass", "blah" );
+ assertFalse( evaluator.evaluate( new SimpleNode( "objectClass", "2.5.6.5", LeafNode.EQUALITY ),
+ objectClasses ) );
+ }
+
+
+ public void testComplexOrRefinement() throws Exception
+ {
+ ExprNode refinement = null;
+ BasicAttribute objectClasses = new BasicAttribute( "objectClass", "person" );
+ FilterParser parser = new FilterParserImpl();
+ String refStr = "(| (objectClass=person) (objectClass=organizationalUnit) )";
+ refinement = parser.parse( refStr );
+
+ assertTrue( evaluator.evaluate( refinement, objectClasses ) );
+ objectClasses = new BasicAttribute( "objectClass", "organizationalUnit" );
+ assertTrue( evaluator.evaluate( refinement, objectClasses ) );
+ objectClasses = new BasicAttribute( "objectClass", "domain" );
+ assertFalse( evaluator.evaluate( refinement, objectClasses ) );
+ }
+
+
+ public void testComplexAndRefinement() throws Exception
+ {
+ ExprNode refinement = null;
+ BasicAttribute objectClasses = new BasicAttribute( "objectClass", "person" );
+ objectClasses.add( "organizationalUnit" );
+ FilterParser parser = new FilterParserImpl();
+ String refStr = "(& (objectClass=person) (objectClass=organizationalUnit) )";
+ refinement = parser.parse( refStr );
+
+ assertTrue( evaluator.evaluate( refinement, objectClasses ) );
+ objectClasses = new BasicAttribute( "objectClass", "organizationalUnit" );
+ assertFalse( evaluator.evaluate( refinement, objectClasses ) );
+ objectClasses = new BasicAttribute( "objectClass", "person" );
+ assertFalse( evaluator.evaluate( refinement, objectClasses ) );
+ objectClasses = new BasicAttribute( "objectClass", "domain" );
+ assertFalse( evaluator.evaluate( refinement, objectClasses ) );
+ }
+
+
+ public void testComplexNotRefinement() throws Exception
+ {
+ ExprNode refinement = null;
+ BasicAttribute objectClasses = new BasicAttribute( "objectClass", "person" );
+ FilterParser parser = new FilterParserImpl();
+ String refStr = "(! (objectClass=person) )";
+ refinement = parser.parse( refStr );
+
+ assertFalse( evaluator.evaluate( refinement, objectClasses ) );
+ objectClasses = new BasicAttribute( "objectClass", "organizationalUnit" );
+ assertTrue( evaluator.evaluate( refinement, objectClasses ) );
+ objectClasses = new BasicAttribute( "objectClass", "domain" );
+ assertTrue( evaluator.evaluate( refinement, objectClasses ) );
+
+ try
+ {
+ assertFalse( evaluator.evaluate( new BranchNode( 1000 ),
+ new BasicAttribute( "objectClass" ) ) );
+ fail( "should never get here due to an IAE" );
+ }
+ catch ( IllegalArgumentException iae )
+ {
+ }
+
+ try
+ {
+ assertFalse( evaluator.evaluate( new BranchNode( BranchNode.NOT ),
+ new BasicAttribute( "objectClass" ) ) );
+ fail( "should never get here due to an IAE" );
+ }
+ catch ( IllegalArgumentException iae )
+ {
+ }
+ }
+}
Propchange: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/RefinementEvaluatorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/RefinementLeafEvaluatorTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/RefinementLeafEvaluatorTest.java?rev=265617&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/RefinementLeafEvaluatorTest.java (added)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/RefinementLeafEvaluatorTest.java Wed Aug 31 18:46:29 2005
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ldap.server.subtree;
+
+
+import junit.framework.TestCase;
+
+import javax.naming.NamingException;
+import javax.naming.directory.BasicAttribute;
+
+import org.apache.ldap.server.schema.bootstrap.*;
+import org.apache.ldap.server.schema.GlobalRegistries;
+import org.apache.ldap.server.schema.OidRegistry;
+import org.apache.ldap.common.filter.SimpleNode;
+import org.apache.ldap.common.filter.LeafNode;
+
+import java.util.Set;
+import java.util.HashSet;
+
+
+/**
+ * Unit test cases for testing the evaluator for refinement leaf nodes.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class RefinementLeafEvaluatorTest extends TestCase
+{
+ /** the global registries */
+ private GlobalRegistries registries;
+ /** the refinement leaf evaluator to test */
+ private RefinementLeafEvaluator evaluator;
+
+
+ /**
+ * Initializes the global registries.
+ * @throws NamingException if there is a failure loading the schema
+ */
+ private void init() throws NamingException
+ {
+ BootstrapRegistries bsRegistries = new BootstrapRegistries();
+ BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
+ Set schemas = new HashSet();
+ schemas.add( new SystemSchema() );
+ schemas.add( new ApacheSchema() );
+ schemas.add( new CoreSchema() );
+ schemas.add( new CosineSchema() );
+ schemas.add( new InetorgpersonSchema() );
+ schemas.add( new JavaSchema() );
+ loader.load( schemas, bsRegistries );
+ registries = new GlobalRegistries( bsRegistries );
+ }
+
+
+ /**
+ * Initializes registries and creates the leaf evalutator
+ * @throws Exception if there are schema initialization problems
+ */
+ protected void setUp() throws Exception
+ {
+ init();
+ OidRegistry registry = registries.getOidRegistry();
+ evaluator = new RefinementLeafEvaluator( registry );
+ }
+
+
+ /**
+ * Sets evaluator and registries to null.
+ */
+ protected void tearDown()
+ {
+ evaluator = null;
+ registries = null;
+ }
+
+
+ /**
+ * Test cases for various bad combinations of arguments
+ * @throws Exception if something goes wrongg
+ */
+ public void testForBadArguments() throws Exception
+ {
+ BasicAttribute objectClasses = null;
+
+ try
+ {
+ assertFalse( evaluator.evaluate( null, null ) );
+ fail( "should never get here due to an IAE" );
+ }
+ catch ( IllegalArgumentException iae )
+ {
+ }
+
+ try
+ {
+ assertFalse( evaluator.evaluate( new SimpleNode( "", "", LeafNode.GREATEREQ ), objectClasses ) );
+ fail( "should never get here due to an NE" );
+ }
+ catch ( NamingException ne )
+ {
+ }
+
+ try
+ {
+ assertFalse( evaluator.evaluate( new SimpleNode( "", "", LeafNode.EQUALITY ), objectClasses ) );
+ fail( "should never get here due to an NE" );
+ }
+ catch ( NamingException ne )
+ {
+ }
+
+ try
+ {
+ assertFalse( evaluator.evaluate( new SimpleNode( "objectClass", "", LeafNode.EQUALITY ), objectClasses ) );
+ fail( "should never get here due to an IAE" );
+ }
+ catch ( IllegalArgumentException iae )
+ {
+ }
+
+ try
+ {
+ objectClasses = new BasicAttribute( "incorrectAttrId" );
+ assertFalse( evaluator.evaluate( new SimpleNode( "objectClass", "", LeafNode.EQUALITY ), objectClasses ) );
+ fail( "should never get here due to an IAE" );
+ }
+ catch ( IllegalArgumentException iae )
+ {
+ }
+ }
+
+
+ public void testMatchByName() throws Exception
+ {
+ BasicAttribute objectClasses = null;
+
+ // positive test
+ objectClasses = new BasicAttribute( "objectClass", "person" );
+ assertTrue( evaluator.evaluate( new SimpleNode( "objectClass", "person", LeafNode.EQUALITY ),
+ objectClasses ) );
+
+ objectClasses = new BasicAttribute( "objectClass" );
+ objectClasses.add( "person" );
+ objectClasses.add( "blah" );
+ assertTrue( evaluator.evaluate( new SimpleNode( "objectClass", "person", LeafNode.EQUALITY ),
+ objectClasses ) );
+
+ // negative tests
+ objectClasses = new BasicAttribute( "objectClass", "person" );
+ assertFalse( evaluator.evaluate( new SimpleNode( "objectClass", "blah", LeafNode.EQUALITY ),
+ objectClasses ) );
+
+ objectClasses = new BasicAttribute( "objectClass", "blah" );
+ assertFalse( evaluator.evaluate( new SimpleNode( "objectClass", "person", LeafNode.EQUALITY ),
+ objectClasses ) );
+ }
+
+
+ public void testMatchByOID() throws Exception
+ {
+ BasicAttribute objectClasses = null;
+
+ // positive test
+ objectClasses = new BasicAttribute( "objectClass", "person" );
+ assertTrue( evaluator.evaluate( new SimpleNode( "objectClass", "2.5.6.6", LeafNode.EQUALITY ),
+ objectClasses ) );
+
+ objectClasses = new BasicAttribute( "objectClass" );
+ objectClasses.add( "person" );
+ objectClasses.add( "blah" );
+ assertTrue( evaluator.evaluate( new SimpleNode( "objectClass", "2.5.6.6", LeafNode.EQUALITY ),
+ objectClasses ) );
+
+ // negative tests
+ objectClasses = new BasicAttribute( "objectClass", "person" );
+ assertFalse( evaluator.evaluate( new SimpleNode( "objectClass", "2.5.6.5", LeafNode.EQUALITY ),
+ objectClasses ) );
+
+ objectClasses = new BasicAttribute( "objectClass", "blah" );
+ assertFalse( evaluator.evaluate( new SimpleNode( "objectClass", "2.5.6.5", LeafNode.EQUALITY ),
+ objectClasses ) );
+ }
+}
Propchange: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/RefinementLeafEvaluatorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubtreeEvaluatorTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubtreeEvaluatorTest.java?rev=265617&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubtreeEvaluatorTest.java (added)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubtreeEvaluatorTest.java Wed Aug 31 18:46:29 2005
@@ -0,0 +1,270 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ldap.server.subtree;
+
+
+import junit.framework.TestCase;
+import org.apache.ldap.server.schema.GlobalRegistries;
+import org.apache.ldap.server.schema.OidRegistry;
+import org.apache.ldap.server.schema.bootstrap.*;
+import org.apache.ldap.common.subtree.SubtreeSpecificationModifier;
+import org.apache.ldap.common.subtree.SubtreeSpecification;
+import org.apache.ldap.common.name.LdapName;
+import org.apache.ldap.common.filter.FilterParserImpl;
+import org.apache.ldap.common.filter.FilterParser;
+import org.apache.ldap.common.filter.ExprNode;
+
+import javax.naming.NamingException;
+import javax.naming.Name;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.BasicAttribute;
+import java.util.Set;
+import java.util.HashSet;
+
+
+/**
+ * Unit test cases for the SubtreeEvaluator.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class SubtreeEvaluatorTest extends TestCase
+{
+ private GlobalRegistries registries;
+ private SubtreeEvaluator evaluator;
+
+
+ private void init() throws NamingException
+ {
+ BootstrapRegistries bsRegistries = new BootstrapRegistries();
+ registries = new GlobalRegistries( bsRegistries );
+ BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
+ Set schemas = new HashSet();
+ schemas.add( new SystemSchema() );
+ schemas.add( new ApacheSchema() );
+ schemas.add( new CoreSchema() );
+ schemas.add( new CosineSchema() );
+ schemas.add( new InetorgpersonSchema() );
+ schemas.add( new JavaSchema() );
+ loader.load( schemas, bsRegistries );
+ }
+
+
+ protected void setUp() throws Exception
+ {
+ init();
+ OidRegistry registry = registries.getOidRegistry();
+ evaluator = new SubtreeEvaluator( registry );
+ }
+
+
+ protected void tearDown() throws Exception
+ {
+ evaluator = null;
+ registries = null;
+ }
+
+
+ public void testDefaults() throws Exception
+ {
+ SubtreeSpecificationModifier modifier = new SubtreeSpecificationModifier();
+ SubtreeSpecification ss = modifier.getSubtreeSpecification();
+ Name apDn = new LdapName( "ou=system" );
+ Name entryDn = new LdapName( "ou=users,ou=system" );
+ Attribute objectClasses = new BasicAttribute( "objectClass" );
+
+ assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=system" );
+ assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=abc" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+ }
+
+
+ public void testWithBase() throws Exception
+ {
+ SubtreeSpecificationModifier modifier = new SubtreeSpecificationModifier();
+ modifier.setBase( new LdapName( "ou=users" ) );
+ SubtreeSpecification ss = modifier.getSubtreeSpecification();
+ Name apDn = new LdapName( "ou=system" );
+ Name entryDn = new LdapName( "ou=users,ou=system" );
+ Attribute objectClasses = new BasicAttribute( "objectClass" );
+
+ assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "uid=akarasulu,ou=users,ou=system" );
+ assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+ }
+
+
+ public void testWithMinMax() throws Exception
+ {
+ SubtreeSpecificationModifier modifier = new SubtreeSpecificationModifier();
+ modifier.setMinBaseDistance( 1 );
+ modifier.setMaxBaseDistance( 3 );
+ modifier.setBase( new LdapName( "ou=users" ) );
+ SubtreeSpecification ss = modifier.getSubtreeSpecification();
+ Name apDn = new LdapName( "ou=system" );
+ Name entryDn = new LdapName( "ou=users,ou=system" );
+ Attribute objectClasses = new BasicAttribute( "objectClass" );
+
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "uid=akarasulu,ou=users,ou=system" );
+ assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=twolevels,uid=akarasulu,ou=users,ou=system" );
+ assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
+ assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=fourlevels,ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+ }
+
+
+ public void testWithMinMaxAndChopAfter() throws Exception
+ {
+ SubtreeSpecificationModifier modifier = new SubtreeSpecificationModifier();
+ Set chopAfter = new HashSet();
+ chopAfter.add( new LdapName( "uid=Tori Amos" ) );
+ chopAfter.add( new LdapName( "ou=twolevels,uid=akarasulu" ) );
+ modifier.setChopAfterExclusions( chopAfter );
+ modifier.setMinBaseDistance( 1 );
+ modifier.setMaxBaseDistance( 3 );
+ modifier.setBase( new LdapName( "ou=users" ) );
+ SubtreeSpecification ss = modifier.getSubtreeSpecification();
+ Name apDn = new LdapName( "ou=system" );
+ Name entryDn = new LdapName( "ou=users,ou=system" );
+ Attribute objectClasses = new BasicAttribute( "objectClass" );
+
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "uid=akarasulu,ou=users,ou=system" );
+ assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=twolevels,uid=akarasulu,ou=users,ou=system" );
+ assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=fourlevels,ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+ }
+
+
+ public void testWithMinMaxAndChopBefore() throws Exception
+ {
+ SubtreeSpecificationModifier modifier = new SubtreeSpecificationModifier();
+ Set chopBefore = new HashSet();
+ chopBefore.add( new LdapName( "uid=Tori Amos" ) );
+ chopBefore.add( new LdapName( "ou=threelevels,ou=twolevels,uid=akarasulu" ) );
+ modifier.setChopBeforeExclusions( chopBefore );
+ modifier.setMinBaseDistance( 1 );
+ modifier.setMaxBaseDistance( 3 );
+ modifier.setBase( new LdapName( "ou=users" ) );
+ SubtreeSpecification ss = modifier.getSubtreeSpecification();
+ Name apDn = new LdapName( "ou=system" );
+ Name entryDn = new LdapName( "ou=users,ou=system" );
+ Attribute objectClasses = new BasicAttribute( "objectClass" );
+
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "uid=akarasulu,ou=users,ou=system" );
+ assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=twolevels,uid=akarasulu,ou=users,ou=system" );
+ assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=fourlevels,ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+ }
+
+
+ public void testWithMinMaxAndSimpleRefinement() throws Exception
+ {
+ FilterParser parser = new FilterParserImpl();
+ ExprNode refinement = parser.parse( "( objectClass = person )" );
+
+ SubtreeSpecificationModifier modifier = new SubtreeSpecificationModifier();
+ modifier.setRefinement( refinement );
+ modifier.setMinBaseDistance( 1 );
+ modifier.setMaxBaseDistance( 3 );
+ modifier.setBase( new LdapName( "ou=users" ) );
+ SubtreeSpecification ss = modifier.getSubtreeSpecification();
+ Name apDn = new LdapName( "ou=system" );
+ Name entryDn = new LdapName( "ou=users,ou=system" );
+ Attribute objectClasses = new BasicAttribute( "objectClass", "person" );
+
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "uid=akarasulu,ou=users,ou=system" );
+ assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=twolevels,uid=akarasulu,ou=users,ou=system" );
+ assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
+ assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=fourlevels,ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ // now change the refinement so the entry is rejected
+ objectClasses = new BasicAttribute( "objectClass", "organizationalUnit" );
+
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "uid=akarasulu,ou=users,ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=twolevels,uid=akarasulu,ou=users,ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ entryDn = new LdapName( "ou=fourlevels,ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
+ assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
+
+ }
+}
Propchange: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubtreeEvaluatorTest.java
------------------------------------------------------------------------------
svn:eol-style = native