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/04 21:38:59 UTC
svn commit: r492728 -
/directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Author: elecharny
Date: Thu Jan 4 12:38:58 2007
New Revision: 492728
URL: http://svn.apache.org/viewvc?view=rev&rev=492728
Log:
Fixed issue DIRSERVER-789, and added the associated tests.
(was : searching for an attribute either with it's short form, alias, OID, or inherited attributetype, like
cn, commonname, 2.5.4.3, name)
Modified:
directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Modified: directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java?view=diff&rev=492728&r1=492727&r2=492728
==============================================================================
--- directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java (original)
+++ directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java Thu Jan 4 12:38:58 2007
@@ -699,4 +699,166 @@
}
}
}
+
+ public void testSearchOID() throws NamingException
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+ NamingEnumeration res = ctx.search( "", "(2.5.4.3=Tori*)", controls );
+
+ // collect all results
+ while ( res.hasMore() )
+ {
+ SearchResult result = ( SearchResult ) res.next();
+
+ Attributes attrs = result.getAttributes();
+
+ NamingEnumeration all = attrs.getAll();
+
+ while ( all.hasMoreElements() )
+ {
+ Attribute attr = (Attribute)all.next();
+
+ if ( "jpegPhoto".equalsIgnoreCase( attr.getID() ) )
+ {
+ byte[] jpegVal = (byte[])attr.get();
+
+ assertTrue( Arrays.equals( jpegVal, jpeg ) );
+ }
+ }
+ }
+ }
+
+ public void testSearchAttrCN() throws NamingException
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+ controls.setReturningAttributes( new String[]{"cn"} );
+
+ NamingEnumeration res = ctx.search( "", "(commonName=Tori*)", controls );
+
+ assertTrue( res.hasMore() );
+
+ // collect all results
+ while ( res.hasMore() )
+ {
+ SearchResult result = ( SearchResult ) res.next();
+
+ Attributes attrs = result.getAttributes();
+
+ NamingEnumeration all = attrs.getAll();
+
+ assertTrue( all.hasMoreElements() );
+
+ while ( all.hasMoreElements() )
+ {
+ Attribute attr = (Attribute)all.next();
+
+ if ( "commonName".equalsIgnoreCase( attr.getID() ) )
+ {
+ assertEquals( "Tori Amos", (String)attr.get() );
+ }
+ }
+ }
+ }
+
+ public void testSearchAttrName() throws NamingException
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+ controls.setReturningAttributes( new String[]{"name"} );
+
+ NamingEnumeration res = ctx.search( "", "(commonName=Tori*)", controls );
+
+ assertTrue( res.hasMore() );
+
+ // collect all results
+ while ( res.hasMore() )
+ {
+ SearchResult result = ( SearchResult ) res.next();
+
+ Attributes attrs = result.getAttributes();
+
+ NamingEnumeration all = attrs.getAll();
+
+ assertTrue( all.hasMoreElements() );
+
+ while ( all.hasMoreElements() )
+ {
+ Attribute attr = (Attribute)all.next();
+
+ if ( "commonName".equalsIgnoreCase( attr.getID() ) )
+ {
+ assertEquals( "Tori Amos", (String)attr.get() );
+ }
+ }
+ }
+ }
+
+ public void testSearchAttrCommonName() throws NamingException
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+ controls.setReturningAttributes( new String[]{"commonName"} );
+
+ NamingEnumeration res = ctx.search( "", "(commonName=Tori*)", controls );
+
+ assertTrue( res.hasMore() );
+
+ // collect all results
+ while ( res.hasMore() )
+ {
+ SearchResult result = ( SearchResult ) res.next();
+
+ Attributes attrs = result.getAttributes();
+
+ NamingEnumeration all = attrs.getAll();
+
+ assertTrue( all.hasMoreElements() );
+
+ while ( all.hasMoreElements() )
+ {
+ Attribute attr = (Attribute)all.next();
+
+ if ( "commonName".equalsIgnoreCase( attr.getID() ) )
+ {
+ assertEquals( "Tori Amos", (String)attr.get() );
+ }
+ }
+ }
+ }
+
+ public void testSearchAttrOID() throws NamingException
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+ controls.setReturningAttributes( new String[]{"2.5.4.3"} );
+
+ NamingEnumeration res = ctx.search( "", "(commonName=Tori*)", controls );
+
+ assertTrue( res.hasMore() );
+
+ // collect all results
+ while ( res.hasMore() )
+ {
+ SearchResult result = ( SearchResult ) res.next();
+
+ Attributes attrs = result.getAttributes();
+
+ NamingEnumeration all = attrs.getAll();
+
+ assertTrue( all.hasMoreElements() );
+
+ while ( all.hasMoreElements() )
+ {
+ Attribute attr = (Attribute)all.next();
+
+ if ( "2.5.4.3".equalsIgnoreCase( attr.getID() ) )
+ {
+ assertEquals( "Tori Amos", (String)attr.get() );
+ }
+ }
+ }
+ }
+
}