You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2007/01/25 11:52:49 UTC
svn commit: r499730 -
/directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java
Author: elecharny
Date: Thu Jan 25 02:52:49 2007
New Revision: 499730
URL: http://svn.apache.org/viewvc?view=rev&rev=499730
Log:
Added new tests for DIRSERVER-836
Modified:
directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java
Modified: directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java?view=diff&rev=499730&r1=499729&r2=499730
==============================================================================
--- directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java (original)
+++ directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java Thu Jan 25 02:52:49 2007
@@ -44,6 +44,10 @@
*/
public class SearchITest extends AbstractAdminTestCase
{
+ private static final String rdn = "cn=Heather Nova";
+ private static final String filter = "(objectclass=*)";
+
+
protected void setUp() throws Exception
{
if ( this.getName().equals( "testOpAttrDenormalizationOn" ) )
@@ -149,6 +153,20 @@
assertNotNull( attribute );
assertTrue( attribute.contains( "top" ) );
assertTrue( attribute.contains( "organizationalUnit" ) );
+
+ // Create entry cn=Heather Nova, ou=system
+ 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 = ( DirContext ) sysRoot.createSubcontext( rdn, heather );
+ assertNotNull( ctx );
+
+ ctx = ( DirContext ) sysRoot.lookup( rdn );
+ assertNotNull( ctx );
}
@@ -230,5 +248,97 @@
assertNotNull( attrs.get( "creatorsName" ) );
assertNotNull( attrs.get( "objectClass" ) );
assertNotNull( attrs.get( "ou" ) );
+ }
+
+
+ /**
+ * Search an entry and fetch an unknown attribute
+ */
+ public void testSearchFetchNonExistingAttribute() throws NamingException
+ {
+ SearchControls ctls = new SearchControls();
+
+ ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
+ ctls.setReturningAttributes( new String[]
+ { "cn", "unknownAttribute" } );
+
+ NamingEnumeration result = sysRoot.search( rdn, filter, ctls );
+
+ if ( result.hasMore() )
+ {
+ SearchResult entry = ( SearchResult ) result.next();
+ Attributes attrs = entry.getAttributes();
+ Attribute cn = attrs.get( "cn" );
+
+ assertNotNull( cn );
+ assertEquals( "Heather Nova", cn.get().toString() );
+ }
+ else
+ {
+ fail( "entry " + rdn + " not found" );
+ }
+
+ result.close();
+ }
+
+ /**
+ * Search an entry and fetch an attribute with unknown option
+ */
+ public void testSearchFetchNonExistingAttributeOption() throws NamingException
+ {
+ SearchControls ctls = new SearchControls();
+ ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
+ ctls.setReturningAttributes( new String[]
+ { "cn", "sn;unknownOption" } );
+
+ NamingEnumeration result = sysRoot.search( rdn, filter, ctls );
+
+ if ( result.hasMore() )
+ {
+ SearchResult entry = ( SearchResult ) result.next();
+ Attributes attrs = entry.getAttributes();
+ Attribute cn = attrs.get( "cn" );
+
+ assertNotNull( cn );
+ assertEquals( "Heather Nova", cn.get().toString() );
+
+ Attribute sn = attrs.get( "sn" );
+ assertNull( sn );
+ }
+ else
+ {
+ fail( "entry " + rdn + " not found" );
+ }
+
+ result.close();
+ }
+
+ /**
+ * Search an entry and fetch an attribute with twice the same attributeType
+ */
+ public void testSearchFetchTwiceSameAttribute() throws NamingException
+ {
+ SearchControls ctls = new SearchControls();
+ ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
+ ctls.setReturningAttributes( new String[]
+ { "cn", "cn" } );
+
+ NamingEnumeration result = sysRoot.search( rdn, filter, ctls );
+
+ if ( result.hasMore() )
+ {
+ SearchResult entry = ( SearchResult ) result.next();
+ Attributes attrs = entry.getAttributes();
+ Attribute cn = attrs.get( "cn" );
+
+ assertNotNull( cn );
+ assertEquals( "Heather Nova", cn.get().toString() );
+ }
+ else
+ {
+ fail( "entry " + rdn + " not found" );
+ }
+
+ result.close();
}
}