directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r566925 - in /directory/apacheds/trunk/server-unit/src: main/java/org/apache/directory/server/unit/ test/java/org/apache/directory/server/ test/resources/ test/resources/org/apache/directory/server/
Date Fri, 17 Aug 2007 05:40:47 GMT
Author: akarasulu
Date: Thu Aug 16 22:40:46 2007
New Revision: 566925

URL: http://svn.apache.org/viewvc?view=rev&rev=566925
Log:
added tests to try to reproduce DIRSERVER-951 but could not

Modified:
    directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
    directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/NegationOperatorITest.java
    directory/apacheds/trunk/server-unit/src/test/resources/log4j.properties
    directory/apacheds/trunk/server-unit/src/test/resources/org/apache/directory/server/NegationOperatorITest.ldif

Modified: directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java?view=diff&rev=566925&r1=566924&r2=566925
==============================================================================
--- directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
(original)
+++ directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
Thu Aug 16 22:40:46 2007
@@ -39,6 +39,7 @@
 import javax.naming.ldap.InitialLdapContext;
 import javax.naming.ldap.LdapContext;
 
+import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
 import org.apache.commons.io.FileUtils;
@@ -164,7 +165,12 @@
             
             for ( int ii = 0; ii < origAttribute.size(); ii++ )
             {
-                assertTrue( readAttribute.contains( origAttribute.get( ii ) ) );
+                if ( ! readAttribute.contains( origAttribute.get( ii ) ) )
+                {
+                    log.error( "Failed to verify entry addition of {}. {} attribute in original
" +
+                    		"entry missing from read entry.", entry.getDn(), id );
+                    throw new AssertionFailedError( "Failed to verify entry addition of "
+ entry.getDn()  );
+                }
             }
         }
     }

Modified: directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/NegationOperatorITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/NegationOperatorITest.java?view=diff&rev=566925&r1=566924&r2=566925
==============================================================================
--- directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/NegationOperatorITest.java
(original)
+++ directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/NegationOperatorITest.java
Thu Aug 16 22:40:46 2007
@@ -20,9 +20,28 @@
 package org.apache.directory.server;
 
 
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
 import javax.naming.ldap.LdapContext;
 
+import org.apache.directory.server.core.partition.Oid;
+import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration;
 import org.apache.directory.server.unit.AbstractServerTest;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.ldif.Entry;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.util.DateUtils;
+import org.apache.directory.shared.ldap.util.NamespaceTools;
 
 
 /**
@@ -37,6 +56,7 @@
 public class NegationOperatorITest extends AbstractServerTest
 {
     private LdapContext ctx = null;
+    private List<Entry> loadedEntries;
 
 
     /**
@@ -44,7 +64,47 @@
      */
     public void setUp() throws Exception
     {
+        if ( this.getName().indexOf( "Indexed" ) != -1 )
+        {
+            MutableBTreePartitionConfiguration systemCfg = new MutableBTreePartitionConfiguration();
+            systemCfg.setId( "system" );
+            
+            // @TODO need to make this configurable for the system partition
+            systemCfg.setCacheSize( 500 );
+            
+            systemCfg.setSuffix( PartitionNexus.SYSTEM_PARTITION_SUFFIX );
+    
+            // Add indexed attributes for system partition
+            Set<Object> indexedAttrs = new HashSet<Object>();
+            indexedAttrs.add( Oid.ALIAS );
+            indexedAttrs.add( Oid.EXISTANCE );
+            indexedAttrs.add( Oid.HIERARCHY );
+            indexedAttrs.add( Oid.NDN );
+            indexedAttrs.add( Oid.ONEALIAS );
+            indexedAttrs.add( Oid.SUBALIAS );
+            indexedAttrs.add( Oid.UPDN );
+            indexedAttrs.add( SchemaConstants.OBJECT_CLASS_AT );
+            indexedAttrs.add( SchemaConstants.OU_AT );
+            systemCfg.setIndexedAttributes( indexedAttrs );
+    
+            // Add context entry for system partition
+            Attributes systemEntry = new AttributesImpl();
+            Attribute objectClassAttr = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT
);
+            objectClassAttr.add( SchemaConstants.TOP_OC );
+            objectClassAttr.add( SchemaConstants.ORGANIZATIONAL_UNIT_OC );
+            objectClassAttr.add( SchemaConstants.EXTENSIBLE_OBJECT_OC );
+            systemEntry.put( objectClassAttr );
+            systemEntry.put( SchemaConstants.CREATORS_NAME_AT, PartitionNexus.ADMIN_PRINCIPAL
);
+            systemEntry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime()
);
+            systemEntry.put( NamespaceTools.getRdnAttribute( PartitionNexus.SYSTEM_PARTITION_SUFFIX
),
+                NamespaceTools.getRdnValue( PartitionNexus.SYSTEM_PARTITION_SUFFIX ) );
+            systemCfg.setContextEntry( systemEntry );
+            
+            configuration.setSystemPartitionConfiguration( systemCfg );
+        }
+        
         super.setUp();
+        loadedEntries = super.loadTestLdif( true );
         ctx = getWiredContext();
         assertNotNull( ctx );
     }
@@ -57,12 +117,69 @@
     {
         ctx.close();
         ctx = null;
+        loadedEntries = null;
         super.tearDown();
     }
     
+
+    /**
+     * Tests to make sure a negated search for actors without ou
+     * with value 'drama' returns those that do not have the attribute
+     * and do not have a 'drama' value for ou if the attribute still
+     * exists.  This test does not build an index on ou for the system
+     * partition.
+     */
+    public void testSearchNotDrama() throws Exception
+    {
+        // jack black has ou but not drama, and joe newbie has no ou what so ever
+        Set<SearchResult> results = getResults( "(!(ou=drama))" );
+        assertTrue( contains( "uid=jblack,ou=actors,ou=system", results ) );
+        assertTrue( contains( "uid=jnewbie,ou=actors,ou=system", results ) );
+    }
+
+    
+    /**
+     * Tests to make sure a negated search for actors without ou
+     * with value 'drama' returns those that do not have the attribute
+     * and do not have a 'drama' value for ou if the attribute still
+     * exists.  This test DOES build an index on ou for the system
+     * partition and should have failed if the bug in DIRSERVER-951
+     * was present and reproducable.
+     */
+    public void testSearchNotDramaIndexed() throws Exception
+    {
+        // jack black has ou but not drama, and joe newbie has no ou what so ever
+        Set<SearchResult> results = getResults( "(!(ou=drama))" );
+        assertTrue( contains( "uid=jblack,ou=actors,ou=system", results ) );
+        assertTrue( contains( "uid=jnewbie,ou=actors,ou=system", results ) );
+    }
+
+    
+    boolean contains( String dn, Set<SearchResult> results )
+    {
+        for ( SearchResult result : results )
+        {
+            if ( result.getNameInNamespace().equals( dn ) )
+            {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+    
     
-    public void testLoad() throws Exception
+    Set<SearchResult> getResults( String filter ) throws NamingException
     {
-        assertEquals( 2, super.loadTestLdif( true ).size() );
+        Set<SearchResult> results = new HashSet<SearchResult>();
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        NamingEnumeration<SearchResult> namingEnumeration = ctx.search( "ou=actors,ou=system",
filter, controls );
+        while( namingEnumeration.hasMore() )
+        {
+            results.add( namingEnumeration.next() );
+        }
+        
+        return results;
     }
 }

Modified: directory/apacheds/trunk/server-unit/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-unit/src/test/resources/log4j.properties?view=diff&rev=566925&r1=566924&r2=566925
==============================================================================
--- directory/apacheds/trunk/server-unit/src/test/resources/log4j.properties (original)
+++ directory/apacheds/trunk/server-unit/src/test/resources/log4j.properties Thu Aug 16 22:40:46
2007
@@ -1,4 +1,4 @@
-log4j.rootCategory=INFO, stdout
+log4j.rootCategory=OFF, stdout
 
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

Modified: directory/apacheds/trunk/server-unit/src/test/resources/org/apache/directory/server/NegationOperatorITest.ldif
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-unit/src/test/resources/org/apache/directory/server/NegationOperatorITest.ldif?view=diff&rev=566925&r1=566924&r2=566925
==============================================================================
--- directory/apacheds/trunk/server-unit/src/test/resources/org/apache/directory/server/NegationOperatorITest.ldif
(original)
+++ directory/apacheds/trunk/server-unit/src/test/resources/org/apache/directory/server/NegationOperatorITest.ldif
Thu Aug 16 22:40:46 2007
@@ -1,13 +1,46 @@
-dn: ou=people,ou=system
+dn: ou=actors,ou=system
 objectClass: top
 objectClass: organizationalUnit
-ou: people
+ou: actors
 
-dn: uid=jblack,ou=people,ou=system
+dn: uid=jblack,ou=actors,ou=system
 objectClass: top
 objectClass: person
+objectClass: organizationalPerson
 objectClass: uidObject
 uid: jblack
+ou: comedy
+ou: adventure 
 cn: Jack Black
 sn: Black 
+
+dn: uid=bpitt,ou=actors,ou=system
+objectClass: top
+objectClass: person
+objectClass: organizationalPerson
+objectClass: uidObject
+uid: bpitt
+ou: drama
+ou: adventure
+cn: Brad Pitt
+sn: Pitt
+
+dn: uid=gcloony,ou=actors,ou=system
+objectClass: top
+objectClass: person
+objectClass: organizationalPerson
+objectClass: uidObject
+uid: gcloony
+ou: drama
+cn: Goerge Cloony
+sn: Cloony
+
+dn: uid=jnewbie,ou=actors,ou=system
+objectClass: top
+objectClass: person
+objectClass: organizationalPerson
+objectClass: uidObject
+uid: jnewbie
+cn: Joe Newbie
+sn: Newbie
 



Mime
View raw message