directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r430861 - in /directory/branches/apacheds/1.0: core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Date Fri, 11 Aug 2006 19:06:37 GMT
Author: akarasulu
Date: Fri Aug 11 12:06:37 2006
New Revision: 430861

URL: http://svn.apache.org/viewvc?rev=430861&view=rev
Log:
Fixes and test cases for DIRSERVER-705: object class top missing in search result

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

Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?rev=430861&r1=430860&r2=430861&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
(original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
Fri Aug 11 12:06:37 2006
@@ -187,15 +187,15 @@
         SearchControls searchCtls ) throws NamingException
     {
         // check to make sure the DN searched for is a subentry
+        Invocation invocation = InvocationStack.getInstance().peek();
         if ( !subschemaSubentryDn.toNormName().equals( base.toNormName() ) )
         {
             NamingEnumeration e = nextInterceptor.search( base, env, filter, searchCtls );
             if ( searchCtls.getReturningAttributes() != null )
             {
-                return e;
+                return new SearchResultFilteringEnumeration( e, new SearchControls(), invocation,
topFilter );
             }
 
-            Invocation invocation = InvocationStack.getInstance().peek();
             return new SearchResultFilteringEnumeration( e, searchCtls, invocation, filters
);
         }
 
@@ -230,10 +230,9 @@
         NamingEnumeration e = nextInterceptor.search( base, env, filter, searchCtls );
         if ( searchCtls.getReturningAttributes() != null )
         {
-            return e;
+            return new SearchResultFilteringEnumeration( e, searchCtls, invocation, topFilter
);
         }
 
-        Invocation invocation = InvocationStack.getInstance().peek();
         return new SearchResultFilteringEnumeration( e, searchCtls, invocation, filters );
     }
 

Modified: directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java?rev=430861&r1=430860&r2=430861&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
(original)
+++ directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Fri Aug 11 12:06:37 2006
@@ -429,6 +429,91 @@
         subentry.put( "prescriptiveACI", aciItem );
         adminCtx.createSubcontext( "cn=" + cn, subentry );
     }
+    
+
+    /**
+     * Test case to demonstrate DIRSERVER-705 ("object class top missing in search
+     * result, if scope is base and attribute objectClass is requested explicitly").
+     */
+    public void testAddWithObjectclasses() throws NamingException
+    {
+
+        // Create entry
+        Attributes heather = new BasicAttributes();
+        Attribute ocls = new BasicAttribute( "objectClass" );
+        ocls.add( "top" );
+        ocls.add( "person" );
+        heather.put( ocls );
+        heather.put( "cn", "Heather Nova" );
+        heather.put( "sn", "Nova" );
+        String rdn = "cn=Heather Nova";
+        ctx.createSubcontext( rdn, heather );
+
+        SearchControls ctls = new SearchControls();
+        ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        ctls.setReturningAttributes( new String[]
+            { "objectclass" } );
+        String filter = "(objectclass=*)";
+
+        NamingEnumeration result = ctx.search( rdn, filter, ctls );
+        if ( result.hasMore() )
+        {
+            SearchResult entry = ( SearchResult ) result.next();
+            Attributes heatherReloaded = entry.getAttributes();
+            Attribute loadedOcls = heatherReloaded.get( "objectClass" );
+            assertNotNull( loadedOcls );
+            assertTrue( loadedOcls.contains( "person" ) );
+            assertTrue( loadedOcls.contains( "top" ) );
+        }
+        else
+        {
+            fail( "entry " + rdn + " not found" );
+        }
+
+        ctx.destroySubcontext( rdn );
+    }
+
+
+    /**
+     * Test case to demonstrate DIRSERVER-705 ("object class top missing in search
+     * result, if scope is base and attribute objectClass is requested explicitly").
+     */
+    public void testAddWithMissingObjectclasses() throws NamingException
+    {
+
+        // Create entry
+        Attributes kate = new BasicAttributes();
+        kate.put( "objectClass", "organizationalperson" );
+        kate.put( "cn", "Kate Bush" );
+        kate.put( "sn", "Bush" );
+        String rdn = "cn=Kate Bush";
+        ctx.createSubcontext( rdn, kate );
+
+        SearchControls ctls = new SearchControls();
+        ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        ctls.setReturningAttributes( new String[]
+            { "objectclass" } );
+        String filter = "(objectclass=*)";
+
+        NamingEnumeration result = ctx.search( rdn, filter, ctls );
+        if ( result.hasMore() )
+        {
+            SearchResult entry = ( SearchResult ) result.next();
+            Attributes kateReloaded = entry.getAttributes();
+            Attribute loadedOcls = kateReloaded.get( "objectClass" );
+            assertNotNull( loadedOcls );
+            assertTrue( loadedOcls.contains( "top" ) );
+            assertTrue( loadedOcls.contains( "person" ) );
+            assertTrue( loadedOcls.contains( "organizationalperson" ) );
+
+        }
+        else
+        {
+            fail( "entry " + rdn + " not found" );
+        }
+
+        ctx.destroySubcontext( rdn );
+    }
 
 
     public void testSubentryControl() throws Exception



Mime
View raw message