|
|
Author: elecharny
Date: Thu Jan 4 12:26:33 2007
New Revision: 492721
URL: http://svn.apache.org/viewvc?view=rev&rev=492721
Log:
Added tests for DIRSERVER-789 : searching for attributes cn, commonName,
2.5.4.3 and name
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=492721&r1=492720&r2=492721
==============================================================================
---
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
Thu Jan 4 12:26:33 2007
@@ -699,4 +699,165 @@
}
}
}
+
+ 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() );
+ }
+ }
+ }
+ }
}
|
|