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 2008/12/01 00:20:03 UTC
svn commit: r721930 -
/directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java
Author: elecharny
Date: Sun Nov 30 15:20:01 2008
New Revision: 721930
URL: http://svn.apache.org/viewvc?rev=721930&view=rev
Log:
Added tests to check that we correctly update the referralManager when moving, renaming or moveAndRenaming an entry
Modified:
directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java
Modified: directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java?rev=721930&r1=721929&r2=721930&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java (original)
+++ directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java Sun Nov 30 15:20:01 2008
@@ -30,6 +30,9 @@
import javax.naming.directory.DirContext;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
+import javax.naming.ldap.Control;
+import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.ManageReferralControl;
import org.apache.directory.server.core.entry.DefaultServerEntry;
import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
@@ -345,6 +348,159 @@
/**
+ * Test of an search operation with a referral after the entry
+ * has been renamed.
+ *
+ * search for "cn=alex karasulu" on "c=usa, ou=system"
+ * we should get a referral URL thrown, which point to
+ * "c=usa, ou=system", and ask for a subtree search
+ */
+ @Test
+ public void testSearchBaseWithReferralThrowAfterRename() throws Exception
+ {
+ DirContext ctx = getWiredContextThrowOnRefferal( ldapService );
+
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+ try
+ {
+ ctx.search( "c=america,ou=Countries,ou=system", "(cn=alex karasulu)", controls );
+ fail( "Should fail here throwing a ReferralException" );
+ }
+ catch ( ReferralException re )
+ {
+ String referral = (String)re.getReferralInfo();
+ assertEquals( "ldap://localhost:" + ldapService.getIpPort() + "/c=usa,ou=system??base", referral );
+ }
+
+ Control manageDsaItControl = new ManageReferralControl();
+ ((LdapContext)ctx).setRequestControls( new Control[]{manageDsaItControl} );
+
+ // Now let's move the entry
+ ctx.rename( "c=america,ou=Countries,ou=system", "c=USA,ou=Countries,ou=system" );
+
+ controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+ ((LdapContext)ctx).setRequestControls( new Control[]{} );
+
+ try
+ {
+ ctx.search( "c=usa,ou=Countries,ou=system", "(cn=alex karasulu)", controls );
+ fail( "Should fail here throwing a ReferralException" );
+ }
+ catch ( ReferralException re )
+ {
+ String referral = (String)re.getReferralInfo();
+ assertEquals( "ldap://localhost:" + ldapService.getIpPort() + "/c=usa,ou=system??base", referral );
+ }
+
+ }
+
+
+ /**
+ * Test of an search operation with a referral after the entry
+ * has been moved.
+ *
+ * search for "cn=alex karasulu" on "c=america, ou=system"
+ * we should get a referral URL thrown, which point to
+ * "c=usa, ou=system", and ask for a subtree search
+ */
+ @Test
+ public void testSearchBaseWithReferralThrowAfterMove() throws Exception
+ {
+ DirContext ctx = getWiredContextThrowOnRefferal( ldapService );
+
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+ try
+ {
+ ctx.search( "c=america,ou=Countries,ou=system", "(cn=alex karasulu)", controls );
+ fail( "Should fail here throwing a ReferralException" );
+ }
+ catch ( ReferralException re )
+ {
+ String referral = (String)re.getReferralInfo();
+ assertEquals( "ldap://localhost:" + ldapService.getIpPort() + "/c=usa,ou=system??base", referral );
+ }
+
+ Control manageDsaItControl = new ManageReferralControl();
+ ((LdapContext)ctx).setRequestControls( new Control[]{manageDsaItControl} );
+
+ // Now let's move the entry
+ ctx.rename( "c=america,ou=Countries,ou=system", "c=america,ou=system" );
+
+ controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+ ((LdapContext)ctx).setRequestControls( new Control[]{} );
+
+ try
+ {
+ ctx.search( "c=america,ou=system", "(cn=alex karasulu)", controls );
+ fail( "Should fail here throwing a ReferralException" );
+ }
+ catch ( ReferralException re )
+ {
+ String referral = (String)re.getReferralInfo();
+ assertEquals( "ldap://localhost:" + ldapService.getIpPort() + "/c=usa,ou=system??base", referral );
+ }
+
+ }
+
+
+ /**
+ * Test of an search operation with a referral after the entry
+ * has been moved.
+ *
+ * search for "cn=alex karasulu" on "c=usa, ou=system"
+ * we should get a referral URL thrown, which point to
+ * "c=usa, ou=system", and ask for a subtree search
+ */
+ @Test
+ public void testSearchBaseWithReferralThrowAfterMoveAndRename() throws Exception
+ {
+ DirContext ctx = getWiredContextThrowOnRefferal( ldapService );
+
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+ try
+ {
+ ctx.search( "c=america,ou=Countries,ou=system", "(cn=alex karasulu)", controls );
+ fail( "Should fail here throwing a ReferralException" );
+ }
+ catch ( ReferralException re )
+ {
+ String referral = (String)re.getReferralInfo();
+ assertEquals( "ldap://localhost:" + ldapService.getIpPort() + "/c=usa,ou=system??base", referral );
+ }
+
+ Control manageDsaItControl = new ManageReferralControl();
+ ((LdapContext)ctx).setRequestControls( new Control[]{manageDsaItControl} );
+
+ // Now let's move the entry
+ ctx.rename( "c=america,ou=Countries,ou=system", "c=us,ou=system" );
+
+ controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+ ((LdapContext)ctx).setRequestControls( new Control[]{} );
+
+ try
+ {
+ ctx.search( "c=us,ou=system", "(cn=alex karasulu)", controls );
+ fail( "Should fail here throwing a ReferralException" );
+ }
+ catch ( ReferralException re )
+ {
+ String referral = (String)re.getReferralInfo();
+ assertEquals( "ldap://localhost:" + ldapService.getIpPort() + "/c=usa,ou=system??base", referral );
+ }
+
+ }
+
+
+ /**
* Test of an search operation with a referral
*
* search for "cn=alex karasulu" on "c=america, ou=system"