directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r649721 - in /directory/sandbox/akarasulu/bigbang: apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/ shared/ldap-constants/src/m...
Date Fri, 18 Apr 2008 23:00:47 GMT
Author: akarasulu
Date: Fri Apr 18 16:00:35 2008
New Revision: 649721

URL: http://svn.apache.org/viewvc?rev=649721&view=rev
Log:
full coverage for PresenceCursor and PrecenseEvaluator using PresenceTest

Added:
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
      - copied, changed from r649703, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceCursorTest.java
Removed:
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceCursorTest.java
Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java
    directory/sandbox/akarasulu/bigbang/shared/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java?rev=649721&r1=649720&r2=649721&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java
Fri Apr 18 16:00:35 2008
@@ -116,7 +116,7 @@
             Iterator<AttributeType> descendants =
                 registries.getAttributeTypeRegistry().descendants( node.getAttribute() );
 
-            while ( descendants.hasNext() )
+            do
             {
                 AttributeType descendant = descendants.next();
 
@@ -127,6 +127,7 @@
                     return true;
                 }
             }
+            while ( descendants.hasNext() );
         }
 
         // we fell through so a match was not found - assertion was false.

Copied: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
(from r649703, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceCursorTest.java)
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java?p2=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java&p1=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceCursorTest.java&r1=649703&r2=649721&rev=649721&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceCursorTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
Fri Apr 18 16:00:35 2008
@@ -28,7 +28,6 @@
 import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
 import org.apache.directory.server.xdbm.tools.StoreUtils;
-import org.apache.directory.server.xdbm.tools.IndexUtils;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
@@ -47,14 +46,14 @@
 
 
 /**
- * TODO doc me!
+ * Tests PresenceCursor and PresenceEvaluator functionality.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $$Rev$$
  */
-public class PresenceCursorTest
+public class PresenceTest
 {
-    private static final Logger LOG = LoggerFactory.getLogger( PresenceCursorTest.class.getSimpleName()
);
+    private static final Logger LOG = LoggerFactory.getLogger( PresenceTest.class.getSimpleName()
);
 
     File wkdir;
     Store<Attributes> store;
@@ -62,7 +61,7 @@
     AttributeTypeRegistry attributeRegistry;
 
 
-    public PresenceCursorTest() throws Exception
+    public PresenceTest() throws Exception
     {
         // setup the standard registries
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
@@ -76,6 +75,7 @@
         bootstrapSchemas.add( new ApacheSchema() );
         bootstrapSchemas.add( new CoreSchema() );
         bootstrapSchemas.add( new SystemSchema() );
+        bootstrapSchemas.add( new CollectiveSchema() );
         loader.loadWithDependencies( bootstrapSchemas, registries );
         attributeRegistry = registries.getAttributeTypeRegistry();
     }
@@ -279,7 +279,6 @@
         assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getValue() );
 
         // test afterLast()
-        IndexUtils.printContents( store.getNdnIndex() );
         cursor.afterLast();
         assertFalse( cursor.available() );
         assertTrue( cursor.previous() );
@@ -322,6 +321,62 @@
     }
 
 
+    @Test
+    public void testEvaluatorIndexed() throws Exception
+    {
+        PresenceNode node = new PresenceNode( SchemaConstants.CN_AT_OID );
+        PresenceEvaluator evaluator = new PresenceEvaluator( node, store, registries );
+        ForwardIndexEntry<String,Attributes> entry = new ForwardIndexEntry<String,Attributes>();
+        entry.setValue( SchemaConstants.CN_AT_OID );
+        entry.setId( ( long ) 3 );
+        assertFalse( evaluator.evaluate( entry ) );
+        entry = new ForwardIndexEntry<String,Attributes>();
+        entry.setValue( SchemaConstants.CN_AT_OID );
+        entry.setId( ( long ) 5 );
+        assertTrue( evaluator.evaluate( entry ) );
+    }
+
+
+    @Test
+    public void testEvaluatorNotIndexed() throws Exception
+    {
+        PresenceNode node = new PresenceNode( SchemaConstants.NAME_AT_OID );
+        PresenceEvaluator evaluator = new PresenceEvaluator( node, store, registries );
+        ForwardIndexEntry<String,Attributes> entry = new ForwardIndexEntry<String,Attributes>();
+        entry.setValue( SchemaConstants.NAME_AT_OID );
+        entry.setId( ( long ) 3 );
+        assertTrue( evaluator.evaluate( entry ) );
+        entry = new ForwardIndexEntry<String,Attributes>();
+        entry.setValue( SchemaConstants.NAME_AT_OID );
+        entry.setId( ( long ) 5 );
+        assertTrue( evaluator.evaluate( entry ) );
+
+        node = new PresenceNode( SchemaConstants.SEARCHGUIDE_AT_OID );
+        evaluator = new PresenceEvaluator( node, store, registries );
+        entry = new ForwardIndexEntry<String,Attributes>();
+        entry.setValue( SchemaConstants.SEARCHGUIDE_AT_OID );
+        entry.setId( ( long ) 3 );
+        assertFalse( evaluator.evaluate( entry ) );
+        entry = new ForwardIndexEntry<String,Attributes>();
+        entry.setValue( SchemaConstants.SEARCHGUIDE_AT_OID );
+        entry.setId( ( long ) 5 );
+        entry.setObject( store.lookup( ( long ) 5 ));
+        assertFalse( evaluator.evaluate( entry ) );
+
+        node = new PresenceNode( SchemaConstants.ST_AT_OID );
+        evaluator = new PresenceEvaluator( node, store, registries );
+        entry = new ForwardIndexEntry<String,Attributes>();
+        entry.setValue( SchemaConstants.ST_AT_OID );
+        entry.setId( ( long ) 3 );
+        assertFalse( evaluator.evaluate( entry ) );
+        entry = new ForwardIndexEntry<String,Attributes>();
+        entry.setValue( SchemaConstants.ST_AT_OID );
+        entry.setId( ( long ) 5 );
+        entry.setObject( store.lookup( ( long ) 5 ));
+        assertFalse( evaluator.evaluate( entry ) );
+    }
+
+
     @Test ( expected = InvalidCursorPositionException.class )
     public void testInvalidCursorPositionException() throws Exception
     {
@@ -330,8 +385,6 @@
         PresenceCursor cursor = new PresenceCursor( store, evaluator );
         cursor.get();
     }
-
-
 
 
     @Test ( expected = InvalidCursorPositionException.class )

Modified: directory/sandbox/akarasulu/bigbang/shared/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java?rev=649721&r1=649720&r2=649721&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java
(original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java
Fri Apr 18 16:00:35 2008
@@ -128,7 +128,11 @@
     // AliasedObjectName
     String ALIASED_OBJECT_NAME_AT = "aliasedObjectName";
     String ALIASED_OBJECT_NAME_AT_OID = "2.5.4.1";
-    
+
+    // Name
+    String NAME_AT = "name";
+    String NAME_AT_OID = "2.5.4.41";
+
     // Cn
     String CN_AT = "cn";
     String COMMON_NAME_AT = "commonName";
@@ -138,7 +142,21 @@
     String SN_AT = "sn";
     String SURNAME_AT = "surname";
     String SN_AT_OID = "2.5.4.4";
-    
+
+    // St
+    String ST_AT = "st";
+    String STATEORPROVINCE_NAME_AT = "stateOrProvinceName";
+    String ST_AT_OID = "2.5.4.8";
+
+    // Street
+    String STREET_AT = "street";
+    String STREET_ADDRESS_AT = "streetAddress";
+    String STREET_AT_OID = "2.5.4.9";
+
+    // SearchGuide
+    String SEARCHGUIDE_AT = "searchguide";
+    String SEARCHGUIDE_AT_OID = "2.5.4.14";
+
     // Ou
     String O_AT = "o";
     String ORGANIZATION_NAME_AT = "organizationName";



Mime
View raw message