directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r496353 - /directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Date Mon, 15 Jan 2007 14:55:45 GMT
Author: elecharny
Date: Mon Jan 15 06:55:44 2007
New Revision: 496353

URL: http://svn.apache.org/viewvc?view=rev&rev=496353
Log:
Added two test case for DIRSERVER-826

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

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?view=diff&rev=496353&r1=496352&r2=496353
==============================================================================
--- 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
Mon Jan 15 06:55:44 2007
@@ -831,4 +831,89 @@
         assertEquals( 1, attrs.get("cn").size() );
         assertEquals( "Tori Amos", (String)attrs.get("cn").get() );
     }
+
+    public void testSearchUsersAttrs() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        controls.setReturningAttributes( new String[]{"*"} );
+        
+        NamingEnumeration res = ctx.search( "", "(commonName=Tori Amos)", controls );
+        
+        assertTrue( res.hasMore() );
+        
+        SearchResult result = ( SearchResult ) res.next();
+        
+        // ensure that result is not null
+        assertNotNull( result );
+        
+        Attributes attrs = result.getAttributes();
+        
+        // ensure that all user attributes are returned
+        assertEquals( 5, attrs.size() );
+        assertNotNull( attrs.get( "cn" ) );
+        assertNotNull( attrs.get( "sn" ) );
+        assertNotNull( attrs.get( "objectClass" ) );
+        assertNotNull( attrs.get( "jpegPhoto" ) );
+        assertNotNull( attrs.get( "description" ) );
+        assertNull( attrs.get( "createtimestamp" ) );
+        assertNull( attrs.get( "creatorsname" ) );
+    }
+
+    public void testSearchOperationalAttrs() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        controls.setReturningAttributes( new String[]{"+"} );
+        
+        NamingEnumeration res = ctx.search( "", "(commonName=Tori Amos)", controls );
+        
+        assertTrue( res.hasMore() );
+        
+        SearchResult result = ( SearchResult ) res.next();
+        
+        // ensure that result is not null
+        assertNotNull( result );
+        
+        Attributes attrs = result.getAttributes();
+        
+        // ensure that all operational attributes are returned
+        // and no user attributes
+        assertEquals( 2, attrs.size() );
+        assertNull( attrs.get( "cn" ) );
+        assertNull( attrs.get( "sn" ) );
+        assertNull( attrs.get( "objectClass" ) );
+        assertNull( attrs.get( "jpegPhoto" ) );
+        assertNull( attrs.get( "description" ) );
+        assertNotNull( attrs.get( "createtimestamp" ) );
+        assertNotNull( attrs.get( "creatorsname" ) );
+    }
+    
+    public void testSearchAllAttrs() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        controls.setReturningAttributes( new String[]{"+", "*"} );
+        
+        NamingEnumeration res = ctx.search( "", "(commonName=Tori Amos)", controls );
+        
+        assertTrue( res.hasMore() );
+        
+        SearchResult result = ( SearchResult ) res.next();
+        
+        // ensure that result is not null
+        assertNotNull( result );
+        
+        Attributes attrs = result.getAttributes();
+        
+        // ensure that all user attributes are returned
+        assertEquals( 7, attrs.size() );
+        assertNotNull( attrs.get( "cn" ) );
+        assertNotNull( attrs.get( "sn" ) );
+        assertNotNull( attrs.get( "objectClass" ) );
+        assertNotNull( attrs.get( "jpegPhoto" ) );
+        assertNotNull( attrs.get( "description" ) );
+        assertNotNull( attrs.get( "createtimestamp" ) );
+        assertNotNull( attrs.get( "creatorsname" ) );
+    }
 }



Mime
View raw message