directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r499787 - /directory/apacheds/branches/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Date Thu, 25 Jan 2007 13:37:11 GMT
Author: elecharny
Date: Thu Jan 25 05:37:10 2007
New Revision: 499787

URL: http://svn.apache.org/viewvc?view=rev&rev=499787
Log:
Added a test for DIRSERVER-826. Test is ok, without any code modification
in the server...

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

Modified: directory/apacheds/branches/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java?view=diff&rev=499787&r1=499786&r2=499787
==============================================================================
--- directory/apacheds/branches/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
(original)
+++ directory/apacheds/branches/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Thu Jan 25 05:37:10 2007
@@ -57,6 +57,8 @@
     public static final String RDN = "cn=Tori Amos";
     public static final String RDN2 = "cn=Rolling-Stones";
     public static final String PERSON_DESCRIPTION = "an American singer-songwriter";
+    private static final String HEATHER_RDN = "cn=Heather Graham";
+    private static final String filter = "(objectclass=*)";
 
     private static final byte[] jpeg = new byte[]
         {
@@ -151,6 +153,16 @@
         attributes.put( "description", "an English singer-songwriter" );
         ctx.createSubcontext( RDN2, attributes );
         
+        // Create entry
+        Attributes heather = new LockableAttributesImpl();
+        Attribute ocls = new LockableAttributeImpl( "objectClass" );
+        ocls.add( "top" );
+        ocls.add( "person" );
+        heather.put( ocls );
+        heather.put( "cn", "Heather Nova" );
+        heather.put( "sn", "Nova" );
+
+        ctx.createSubcontext( HEATHER_RDN, heather );
     }
 
 
@@ -187,7 +199,16 @@
         return results;
     }
 
-    
+    protected void checkForAttributes( Attributes attrs, String[] attrNames )
+    {
+        for ( int i = 0; i < attrNames.length; i++ )
+        {
+            String attrName = attrNames[i];
+
+            assertNotNull( "Check if attr " + attrName + " is present", attrs.get( attrNames[i]
) );
+        }
+    }
+
     public void testDirserver635() throws NamingException
     {
         // create additional entry
@@ -915,5 +936,64 @@
         assertNotNull( attrs.get( "description" ) );
         assertNotNull( attrs.get( "createtimestamp" ) );
         assertNotNull( attrs.get( "creatorsname" ) );
+    }
+    
+    /**
+     * Check if user and operational attributes are present, if both "*" and "+" are requested.
+     */
+    public void testSearchOperationalAndUserAttributes() throws NamingException
+    {
+        SearchControls ctls = new SearchControls();
+ 
+        ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        ctls.setReturningAttributes( new String[]
+            { "+", "*" } );
+
+        String[] userAttrNames =
+            { "objectClass", "sn", "cn" };
+
+        String[] opAttrNames =
+            { "creatorsName", "createTimestamp" };
+
+        NamingEnumeration result = ctx.search( HEATHER_RDN, filter, ctls );
+
+        if ( result.hasMore() )
+        {
+            SearchResult entry = ( SearchResult ) result.next();
+            Attributes attrs = entry.getAttributes();
+
+            assertNotNull( attrs );
+
+            checkForAttributes( attrs, userAttrNames );
+            checkForAttributes( attrs, opAttrNames );
+        }
+        else
+        {
+            fail( "entry " + HEATHER_RDN + " not found" );
+        }
+
+        result.close();
+
+        ctls.setReturningAttributes( new String[]
+            { "*", "+" } );
+
+        result = ctx.search( HEATHER_RDN, filter, ctls );
+
+        if ( result.hasMore() )
+        {
+            SearchResult entry = ( SearchResult ) result.next();
+            Attributes attrs = entry.getAttributes();
+
+            assertNotNull( attrs );
+            
+            checkForAttributes( attrs, userAttrNames );
+            checkForAttributes( attrs, opAttrNames );
+        }
+        else
+        {
+            fail( "entry " + HEATHER_RDN + " not found" );
+        }
+
+        result.close();
     }
 }



Mime
View raw message