directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r570748 - /directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java
Date Wed, 29 Aug 2007 10:40:53 GMT
Author: elecharny
Date: Wed Aug 29 03:40:52 2007
New Revision: 570748

URL: http://svn.apache.org/viewvc?rev=570748&view=rev
Log:
o Added constants for "*", "+" and "1.1" special attributes
o Modified the code to use those constants
o Added a workaround for clients who are sending empty parameters
o Correctly handling the "1.1" special attribute mixed with other attributes (=> ignoring
it) 

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

Modified: directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java?rev=570748&r1=570747&r2=570748&view=diff
==============================================================================
--- directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java
(original)
+++ directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java
Wed Aug 29 03:40:52 2007
@@ -222,6 +222,83 @@
         assertNull( attrs.get( "creatorsName" ) );
     }
 
+    public void testSearchUserAttrAndOpAttr() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        controls.setDerefLinkFlag( false );
+        controls.setReturningAttributes( new String[] { "*", "creatorsName" } );
+        sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, DerefAliasesEnum.NEVER_DEREF_ALIASES
);
+        HashMap<String, Attributes> map = new HashMap<String, Attributes>();
+
+        NamingEnumeration list = sysRoot.search( "", "(ou=testing01)", controls );
+        while ( list.hasMore() )
+        {
+            SearchResult result = ( SearchResult ) list.next();
+            map.put( result.getName(), result.getAttributes() );
+        }
+
+        assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
+        
+        Attributes attrs = map.get( "ou=testing01,ou=system" );
+        
+        assertNotNull( attrs.get( "objectClass" ) );
+        assertNotNull( attrs.get( "ou" ) );
+        assertNotNull( attrs.get( "creatorsName" ) );
+        assertNull( attrs.get( "createTimestamp" ) );
+    }
+
+    public void testSearchUserAttrAndNoAttr() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        controls.setDerefLinkFlag( false );
+        controls.setReturningAttributes( new String[] { "1.1", "ou" } );
+        sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, DerefAliasesEnum.NEVER_DEREF_ALIASES
);
+        HashMap<String, Attributes> map = new HashMap<String, Attributes>();
+
+        NamingEnumeration list = sysRoot.search( "", "(ou=testing01)", controls );
+        while ( list.hasMore() )
+        {
+            SearchResult result = ( SearchResult ) list.next();
+            map.put( result.getName(), result.getAttributes() );
+        }
+
+        assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
+        
+        Attributes attrs = map.get( "ou=testing01,ou=system" );
+        
+        assertNull( attrs.get( "objectClass" ) );
+        assertNotNull( attrs.get( "ou" ) );
+        assertNull( attrs.get( "creatorsName" ) );
+        assertNull( attrs.get( "createTimestamp" ) );
+    }
+
+    public void testSearchNoAttr() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        controls.setDerefLinkFlag( false );
+        controls.setReturningAttributes( new String[] { "1.1" } );
+        sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, DerefAliasesEnum.NEVER_DEREF_ALIASES
);
+        HashMap<String, Attributes> map = new HashMap<String, Attributes>();
+
+        NamingEnumeration list = sysRoot.search( "", "(ou=testing01)", controls );
+        while ( list.hasMore() )
+        {
+            SearchResult result = ( SearchResult ) list.next();
+            map.put( result.getName(), result.getAttributes() );
+        }
+
+        assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
+        
+        Attributes attrs = map.get( "ou=testing01,ou=system" );
+        
+        assertNull( attrs.get( "objectClass" ) );
+        assertNull( attrs.get( "ou" ) );
+        assertNull( attrs.get( "creatorsName" ) );
+        assertNull( attrs.get( "createTimestamp" ) );
+    }
 
     public void testSearchAllAttr() throws NamingException
     {



Mime
View raw message