directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r501432 - /directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java
Date Tue, 30 Jan 2007 16:05:45 GMT
Author: elecharny
Date: Tue Jan 30 08:05:44 2007
New Revision: 501432

URL: http://svn.apache.org/viewvc?view=rev&rev=501432
Log:
Fixed a problem when searchingfor infos in subschemaSubentry

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

Modified: directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java?view=diff&rev=501432&r1=501431&r2=501432
==============================================================================
--- directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java
(original)
+++ directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java
Tue Jan 30 08:05:44 2007
@@ -77,6 +77,7 @@
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         Map<String, Attributes> persons = new HashMap<String, Attributes>();
         NamingEnumeration results = sysRoot.search( "", "(objectClass=person)", controls
);
+        
         while ( results.hasMore() )
         {
             SearchResult result = ( SearchResult ) results.next();
@@ -121,6 +122,7 @@
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         Map<String, Attributes> orgPersons = new HashMap<String, Attributes>();
         NamingEnumeration results = sysRoot.search( "", "(objectClass=organizationalPerson)",
controls );
+        
         while ( results.hasMore() )
         {
             SearchResult result = ( SearchResult ) results.next();
@@ -158,6 +160,7 @@
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         Map<String, Attributes> inetOrgPersons = new HashMap<String, Attributes>();
         NamingEnumeration results = sysRoot.search( "", "(objectClass=inetOrgPerson)", controls
);
+        
         while ( results.hasMore() )
         {
             SearchResult result = ( SearchResult ) results.next();
@@ -178,5 +181,279 @@
         assertTrue( ocs.contains( "person" ) );
         assertTrue( ocs.contains( "organizationalPerson" ) );
         assertTrue( ocs.contains( "inetOrgPerson" ) );
+    }
+    
+    public void testSearchForSubSchemaSubEntryUserAttrsOnly() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        
+        Map<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
+        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 = 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 );
+        controls.setReturningAttributes( new String[]{ "+" } );
+        
+        Map<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
+        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 = 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<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
+        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 = 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<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
+        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<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
+        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 = 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<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
+        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 = 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<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
+        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<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
+        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