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/05/22 01:55:29 UTC
svn commit: r540366 -
/directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java
Author: elecharny
Date: Mon May 21 16:55:28 2007
New Revision: 540366
URL: http://svn.apache.org/viewvc?view=rev&rev=540366
Log:
Added tests for DIRSERVER-936
Modified:
directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java
Modified: directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java?view=diff&rev=540366&r1=540365&r2=540366
==============================================================================
--- directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java (original)
+++ directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaServiceITest.java Mon May 21 16:55:28 2007
@@ -507,4 +507,137 @@
assertTrue( seeAlso.contains( "cn=Bad E\u00e9k\u00e0,ou=people,o=sevenSeas" ) );
}
+ /**
+ * Doing a search with filtering attributes should work even if the attribute
+ * is not valid
+ *
+ */
+ public void testSearchForUnknownAttributes() throws NamingException
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+ Map<String, Attributes> persons = new HashMap<String, Attributes>();
+ controls.setReturningAttributes( new String[] { "9.9.9" } );
+
+ NamingEnumeration results = sysRoot.search( "", "(objectClass=person)", controls );
+
+ while ( results.hasMore() )
+ {
+ SearchResult result = ( SearchResult ) results.next();
+ persons.put( result.getName(), result.getAttributes() );
+ }
+
+ // admin is extra
+ assertEquals( 4, persons.size() );
+
+ Attributes person = null;
+ Attribute ocs = null;
+
+ person = persons.get( "cn=person0,ou=system" );
+ assertNotNull( person );
+ ocs = person.get( "objectClass" );
+ assertNull( ocs );
+
+ ocs = person.get( "9.9.9" );
+ assertNull( ocs );
+
+ person = persons.get( "cn=person1,ou=system" );
+ assertNotNull( person );
+ ocs = person.get( "objectClass" );
+ assertNull( ocs );
+
+ person = persons.get( "cn=person2,ou=system" );
+ assertNotNull( person );
+ ocs = person.get( "objectClass" );
+ assertNull( ocs );
+ }
+
+ /**
+ * Check that if we request a Attribute which is not an AttributeType,
+ * we still get a result
+ */
+ public void testSearchAttributesOIDObjectClass() throws NamingException
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+ Map<String, Attributes> persons = new HashMap<String, Attributes>();
+ controls.setReturningAttributes( new String[] { "2.5.6.6" } );
+
+ NamingEnumeration results = sysRoot.search( "", "(objectClass=person)", controls );
+
+ while ( results.hasMore() )
+ {
+ SearchResult result = ( SearchResult ) results.next();
+ persons.put( result.getName(), result.getAttributes() );
+ }
+
+ // admin is extra
+ assertEquals( 4, persons.size() );
+
+ Attributes person = null;
+ Attribute ocs = null;
+
+ person = persons.get( "cn=person0,ou=system" );
+ assertNotNull( person );
+ ocs = person.get( "objectClass" );
+ assertNull( ocs );
+
+ // We should not get this attribute (it's an ObjectClass)
+ ocs = person.get( "2.5.6.6" );
+ assertNull( ocs );
+
+ person = persons.get( "cn=person1,ou=system" );
+ assertNotNull( person );
+ ocs = person.get( "objectClass" );
+ assertNull( ocs );
+
+ person = persons.get( "cn=person2,ou=system" );
+ assertNotNull( person );
+ ocs = person.get( "objectClass" );
+ assertNull( ocs );
+ }
+
+ /**
+ * Check that if we request a Attribute which is an ObjectClass.
+ */
+ public void testSearchAttributesOIDObjectClassName() throws NamingException
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+ Map<String, Attributes> persons = new HashMap<String, Attributes>();
+ controls.setReturningAttributes( new String[] { "person" } );
+
+ NamingEnumeration results = sysRoot.search( "", "(objectClass=person)", controls );
+
+ while ( results.hasMore() )
+ {
+ SearchResult result = ( SearchResult ) results.next();
+ persons.put( result.getName(), result.getAttributes() );
+ }
+
+ // admin is extra
+ assertEquals( 4, persons.size() );
+
+ Attributes person = null;
+ Attribute ocs = null;
+
+ person = persons.get( "cn=person0,ou=system" );
+ assertNotNull( person );
+ ocs = person.get( "objectClass" );
+ assertNull( ocs );
+
+ // We should not get this attrinute (it's an ObjectClass)
+ ocs = person.get( "2.5.4.46" );
+ assertNull( ocs );
+
+ person = persons.get( "cn=person1,ou=system" );
+ assertNotNull( person );
+ ocs = person.get( "objectClass" );
+ assertNull( ocs );
+
+ person = persons.get( "cn=person2,ou=system" );
+ assertNotNull( person );
+ ocs = person.get( "objectClass" );
+ assertNull( ocs );
+ }
}