directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r501384 - /directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java
Date Tue, 30 Jan 2007 12:03:16 GMT
Author: elecharny
Date: Tue Jan 30 04:03:15 2007
New Revision: 501384

URL: http://svn.apache.org/viewvc?view=rev&rev=501384
Log:
Added many tests for search operation, testing the subSchemaSubEntry searches with different
cases

Modified:
    directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java

Modified: directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java?view=diff&rev=501384&r1=501383&r2=501384
==============================================================================
--- directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java
(original)
+++ directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java
Tue Jan 30 04:03:15 2007
@@ -180,7 +180,39 @@
         assertTrue( ocs.contains( "inetOrgPerson" ) );
     }
 
-    public void testSearchForSubSchemaSubEntry() throws NamingException
+    public void testSearchForSubSchemaSubEntryUserAttrsOnly() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        
+        Map subSchemaEntry = new HashMap();
+        NamingEnumeration results = sysRoot.search( "cn=schema", "(objectClass=*)", controls
);
+
+        while ( results.hasMore() )
+        {
+            SearchResult result = ( SearchResult ) results.next();
+            subSchemaEntry.put( result.getName(), result.getAttributes() );
+        }
+
+        // We should have only one entry in the result
+        assertEquals( 1, subSchemaEntry.size() );
+        
+        // It should be the normalized form of cn=schema,ou=system
+        Attributes attrs = (Attributes)subSchemaEntry.get( "2.5.4.3=schema,2.5.4.11=system"
);
+        
+        assertNotNull( attrs );
+        
+        // We should have 2 attributes in the result :
+        // - attributeTypes
+        // - cn
+        // - objectClass
+        assertEquals( 2, attrs.size() );
+        
+        assertNotNull( attrs.get( "cn" ) );
+        assertNotNull( attrs.get( "objectClass" ) );
+    }
+
+    public void testSearchForSubSchemaSubEntryAllAttrs() throws NamingException
     {
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.OBJECT_SCOPE );
@@ -195,6 +227,230 @@
             subSchemaEntry.put( result.getName(), result.getAttributes() );
         }
 
+        // We should have only one entry in the result
+        assertEquals( 1, subSchemaEntry.size() );
+        
+        // It should be the normalized form of cn=schema,ou=system
+        Attributes attrs = (Attributes)subSchemaEntry.get( "2.5.4.3=schema,2.5.4.11=system"
);
+        
+        assertNotNull( attrs );
+        
+        // We should have 14 attributes in the result :
+        // - attributeTypes
+        // - cn
+        // - creatorsName
+        // - createTimestamp
+        // - dITContentRules
+        // - dITStructureRules
+        // - ldapSyntaxes
+        // - matchingRules
+        // - matchingRuleUse
+        // - modifiersName
+        // - modifyTimestamp
+        // - nameForms
+        // - objectClass
+        // - objectClasses
+        assertEquals( 14, attrs.size() );
+        
+        assertNotNull( attrs.get( "attributeTypes" ) );
+        assertNotNull( attrs.get( "cn" ) );
+        assertNotNull( attrs.get( "creatorsName" ) );
+        assertNotNull( attrs.get( "createTimestamp" ) );
+        assertNotNull( attrs.get( "dITContentRules" ) );
+        assertNotNull( attrs.get( "dITStructureRules" ) );
+        assertNotNull( attrs.get( "ldapSyntaxes" ) );
+        assertNotNull( attrs.get( "matchingRules" ) );
+        assertNotNull( attrs.get( "matchingRuleUse" ) );
+        assertNotNull( attrs.get( "modifiersName" ) );
+        assertNotNull( attrs.get( "modifyTimestamp" ) );
+        assertNotNull( attrs.get( "nameForms" ) );
+        assertNotNull( attrs.get( "objectClass" ) );
+        assertNotNull( attrs.get( "objectClasses" ) );
+    }
+
+    public void testSearchForSubSchemaSubEntrySingleAttributeSelected() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        controls.setReturningAttributes( new String[]{ "nameForms" } );
+        
+        Map subSchemaEntry = new HashMap();
+        NamingEnumeration results = sysRoot.search( "cn=schema", "(objectClass=*)", controls
);
+
+        while ( results.hasMore() )
+        {
+            SearchResult result = ( SearchResult ) results.next();
+            subSchemaEntry.put( result.getName(), result.getAttributes() );
+        }
+
+        // We should have only one entry in the result
+        assertEquals( 1, subSchemaEntry.size() );
+        
+        // It should be the normalized form of cn=schema,ou=system
+        Attributes attrs = (Attributes)subSchemaEntry.get( "2.5.4.3=schema,2.5.4.11=system"
);
+        
+        assertNotNull( attrs );
+        
+        // We should have 1 attribute in the result :
+        // - nameForms
+        assertEquals( 1, attrs.size() );
+        
+        assertNull( attrs.get( "attributeTypes" ) );
+        assertNull( attrs.get( "cn" ) );
+        assertNull( attrs.get( "creatorsName" ) );
+        assertNull( attrs.get( "createTimestamp" ) );
+        assertNull( attrs.get( "dITContentRules" ) );
+        assertNull( attrs.get( "dITStructureRules" ) );
+        assertNull( attrs.get( "ldapSyntaxes" ) );
+        assertNull( attrs.get( "matchingRules" ) );
+        assertNull( attrs.get( "matchingRuleUse" ) );
+        assertNull( attrs.get( "modifiersName" ) );
+        assertNull( attrs.get( "modifyTimestamp" ) );
+        assertNotNull( attrs.get( "nameForms" ) );
+        assertNull( attrs.get( "objectClass" ) );
+        assertNull( attrs.get( "objectClasses" ) );
+    }
+
+    public void testSearchForSubSchemaSubEntryBadFilter() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        controls.setReturningAttributes( new String[]{ "+" } );
+        
+        Map subSchemaEntry = new HashMap();
+        NamingEnumeration results = sysRoot.search( "cn=schema", "(objectClass=nothing)",
controls );
+
+        while ( results.hasMore() )
+        {
+            SearchResult result = ( SearchResult ) results.next();
+            subSchemaEntry.put( result.getName(), result.getAttributes() );
+        }
+
+        // We should have no entry in the result
+        assertEquals( 0, subSchemaEntry.size() );
+    }
+
+    public void testSearchForSubSchemaSubEntryFilterEqualTop() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        controls.setReturningAttributes( new String[]{ "+" } );
+        
+        Map subSchemaEntry = new HashMap();
+        NamingEnumeration results = sysRoot.search( "cn=schema", "(objectClass=top)", controls
);
+
+        while ( results.hasMore() )
+        {
+            SearchResult result = ( SearchResult ) results.next();
+            subSchemaEntry.put( result.getName(), result.getAttributes() );
+        }
+
+        // We should have only one entry in the result
+        assertEquals( 1, subSchemaEntry.size() );
+        
+        // It should be the normalized form of cn=schema,ou=system
+        Attributes attrs = (Attributes)subSchemaEntry.get( "2.5.4.3=schema,2.5.4.11=system"
);
+        
+        assertNotNull( attrs );
+        
+        // We should have 14 attribute in the result :
+        // - nameForms
+        assertEquals( 14, attrs.size() );
+        
+        assertNotNull( attrs.get( "attributeTypes" ) );
+        assertNotNull( attrs.get( "cn" ) );
+        assertNotNull( attrs.get( "creatorsName" ) );
+        assertNotNull( attrs.get( "createTimestamp" ) );
+        assertNotNull( attrs.get( "dITContentRules" ) );
+        assertNotNull( attrs.get( "dITStructureRules" ) );
+        assertNotNull( attrs.get( "ldapSyntaxes" ) );
+        assertNotNull( attrs.get( "matchingRules" ) );
+        assertNotNull( attrs.get( "matchingRuleUse" ) );
+        assertNotNull( attrs.get( "modifiersName" ) );
+        assertNotNull( attrs.get( "modifyTimestamp" ) );
+        assertNotNull( attrs.get( "nameForms" ) );
+        assertNotNull( attrs.get( "objectClass" ) );
+        assertNotNull( attrs.get( "objectClasses" ) );
+    }
+
+    public void testSearchForSubSchemaSubEntryFilterEqualSubSchema() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        controls.setReturningAttributes( new String[]{ "+" } );
+        
+        Map subSchemaEntry = new HashMap();
+        NamingEnumeration results = sysRoot.search( "cn=schema", "(objectClass=subSchema)",
controls );
+
+        while ( results.hasMore() )
+        {
+            SearchResult result = ( SearchResult ) results.next();
+            subSchemaEntry.put( result.getName(), result.getAttributes() );
+        }
+
+        // We should have only one entry in the result
         assertEquals( 1, subSchemaEntry.size() );
+        
+        // It should be the normalized form of cn=schema,ou=system
+        Attributes attrs = (Attributes)subSchemaEntry.get( "2.5.4.3=schema,2.5.4.11=system"
);
+        
+        assertNotNull( attrs );
+        
+        // We should have 14 attribute in the result :
+        // - nameForms
+        assertEquals( 14, attrs.size() );
+        
+        assertNotNull( attrs.get( "attributeTypes" ) );
+        assertNotNull( attrs.get( "cn" ) );
+        assertNotNull( attrs.get( "creatorsName" ) );
+        assertNotNull( attrs.get( "createTimestamp" ) );
+        assertNotNull( attrs.get( "dITContentRules" ) );
+        assertNotNull( attrs.get( "dITStructureRules" ) );
+        assertNotNull( attrs.get( "ldapSyntaxes" ) );
+        assertNotNull( attrs.get( "matchingRules" ) );
+        assertNotNull( attrs.get( "matchingRuleUse" ) );
+        assertNotNull( attrs.get( "modifiersName" ) );
+        assertNotNull( attrs.get( "modifyTimestamp" ) );
+        assertNotNull( attrs.get( "nameForms" ) );
+        assertNotNull( attrs.get( "objectClass" ) );
+        assertNotNull( attrs.get( "objectClasses" ) );
+    }
+
+    public void testSearchForSubSchemaSubEntryNotObjectScope() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        controls.setReturningAttributes( new String[]{ "+" } );
+        
+        Map subSchemaEntry = new HashMap();
+        NamingEnumeration results = sysRoot.search( "cn=schema", "(objectClass=nothing)",
controls );
+
+        while ( results.hasMore() )
+        {
+            SearchResult result = ( SearchResult ) results.next();
+            subSchemaEntry.put( result.getName(), result.getAttributes() );
+        }
+
+        // We should have no entry in the result
+        assertEquals( 0, subSchemaEntry.size() );
+    }
+
+    public void testSearchForSubSchemaSubEntryComposedFilters() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        controls.setReturningAttributes( new String[]{ "+" } );
+        
+        Map subSchemaEntry = new HashMap();
+        NamingEnumeration results = sysRoot.search( "cn=schema", "(&(objectClass=*)(objectClass=top))",
controls );
+
+        while ( results.hasMore() )
+        {
+            SearchResult result = ( SearchResult ) results.next();
+            subSchemaEntry.put( result.getName(), result.getAttributes() );
+        }
+
+        // We should have no entry in the result
+        assertEquals( 0, subSchemaEntry.size() );
     }
 }



Mime
View raw message