directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1226442 - /directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/jndi/referral/SearchReferralIT.java
Date Mon, 02 Jan 2012 15:25:48 GMT
Author: elecharny
Date: Mon Jan  2 15:25:47 2012
New Revision: 1226442

URL: http://svn.apache.org/viewvc?rev=1226442&view=rev
Log:
Closing some cursors

Modified:
    directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/jndi/referral/SearchReferralIT.java

Modified: directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/jndi/referral/SearchReferralIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/jndi/referral/SearchReferralIT.java?rev=1226442&r1=1226441&r2=1226442&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/jndi/referral/SearchReferralIT.java
(original)
+++ directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/jndi/referral/SearchReferralIT.java
Mon Jan  2 15:25:47 2012
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.core.jndi.referral;
 
+
 import static org.apache.directory.server.core.integ.IntegrationUtils.getContext;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -65,380 +66,389 @@ import org.junit.runner.RunWith;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-@RunWith ( FrameworkRunner.class )
+@RunWith(FrameworkRunner.class)
 @CreateDS(name = "SearchReferralIT")
-@ApplyLdifs( {
-    // Root
-    "dn: c=WW,ou=system",
-    "objectClass: country",
-    "objectClass: top",
-    "c: WW",
-    
-    // Sub-root
-    "dn: o=MNN,c=WW,ou=system",
-    "objectClass: organization",
-    "objectClass: top",
-    "o: MNN",
-    
-    // Another Sub-root
-    "dn: o=PNN,c=WW,ou=system",
-    "objectClass: organization",
-    "objectClass: top",
-    "o: MNN",
-    
-    // Referral #1
-    "dn: ou=Roles,o=MNN,c=WW,ou=system",
-    "objectClass: extensibleObject",
-    "objectClass: referral",
-    "objectClass: top",
-    "ou: Roles",
-    "ref: ldap://hostd/ou=Roles,dc=apache,dc=org",
-    
-    // Referral #2
-    "dn: ou=People,o=MNN,c=WW,ou=system",
-    "objectClass: extensibleObject",
-    "objectClass: referral",
-    "objectClass: top",
-    "ou: People",
-    "ref: ldap://hostb/OU=People,DC=example,DC=com",
-    "ref: ldap://hostc/OU=People,O=MNN,C=WW",
-    
-    // Entry # 1
-    "dn: cn=Alex Karasulu,o=MNN,c=WW,ou=system",
-    "objectClass: person",
-    "objectClass: top",
-    "cn: Alex Karasulu",
-    "sn: akarasulu",
-    
-    // Entry # 2
-    "dn: cn=Alex,o=MNN,c=WW,ou=system",
-    "objectClass: person",
-    "objectClass: top",
-    "cn: Alex",
-    "sn: akarasulu"
-    }
-)
+@ApplyLdifs(
+    {
+        // Root
+        "dn: c=WW,ou=system",
+        "objectClass: country",
+        "objectClass: top",
+        "c: WW",
+
+        // Sub-root
+        "dn: o=MNN,c=WW,ou=system",
+        "objectClass: organization",
+        "objectClass: top",
+        "o: MNN",
+
+        // Another Sub-root
+        "dn: o=PNN,c=WW,ou=system",
+        "objectClass: organization",
+        "objectClass: top",
+        "o: MNN",
+
+        // Referral #1
+        "dn: ou=Roles,o=MNN,c=WW,ou=system",
+        "objectClass: extensibleObject",
+        "objectClass: referral",
+        "objectClass: top",
+        "ou: Roles",
+        "ref: ldap://hostd/ou=Roles,dc=apache,dc=org",
+
+        // Referral #2
+        "dn: ou=People,o=MNN,c=WW,ou=system",
+        "objectClass: extensibleObject",
+        "objectClass: referral",
+        "objectClass: top",
+        "ou: People",
+        "ref: ldap://hostb/OU=People,DC=example,DC=com",
+        "ref: ldap://hostc/OU=People,O=MNN,C=WW",
+
+        // Entry # 1
+        "dn: cn=Alex Karasulu,o=MNN,c=WW,ou=system",
+        "objectClass: person",
+        "objectClass: top",
+        "cn: Alex Karasulu",
+        "sn: akarasulu",
+
+        // Entry # 2
+        "dn: cn=Alex,o=MNN,c=WW,ou=system",
+        "objectClass: person",
+        "objectClass: top",
+        "cn: Alex",
+        "sn: akarasulu"
+})
 public class SearchReferralIT extends AbstractLdapTestUnit
 {
 
-    /** The Context we are using to inject entries with JNDI */
-    LdapContext MNNCtx;
-    
-    /** The entries we are using to do the tests */
-    Attributes userEntry;
-    Entry serverEntry;
-    
-    @Before
-    public void setUp() throws Exception
-    {
-        MNNCtx = getContext( ServerDNConstants.ADMIN_SYSTEM_DN, getService(), "o=MNN,c=WW,ou=system"
);
-
-        // JNDI entry
-        userEntry = new BasicAttributes( "objectClass", "top", true );
-        userEntry.get( "objectClass" ).add( "person" );
-        userEntry.put( "sn", "elecharny" );
-        userEntry.put( "cn", "Emmanuel Lecharny" );
-        
-        // Core API entry
-        Dn dn = new Dn( "cn=Emmanuel Lecharny, ou=apache, ou=people, o=MNN, c=WW, ou=system"
);
-        serverEntry = new DefaultEntry( getService().getSchemaManager(), dn );
-
-        serverEntry.put( "ObjectClass", "top", "person" );
-        serverEntry.put( "sn", "elecharny" );
-        serverEntry.put( "cn", "Emmanuel Lecharny" );
-    }
-
-    
-    /**
-     * Test a search of a non existing entry (not a referral), with no referral 
-     * in its ancestor.
-     */
-    @Test
-    public void testSearchNotExistingSuperiorNoReferralAncestor() throws Exception
-    {
-        Attributes attrs = new BasicAttributes( "ObjectClass", "top", true );
-        
-        try
-        {
-            MNNCtx.search( "cn=nobody", attrs );
-            fail();
-        }
-        catch ( NameNotFoundException nnfe )
-        {
-            assertTrue( true );
-        }
+/** The Context we are using to inject entries with JNDI */
+LdapContext MNNCtx;
+
+/** The entries we are using to do the tests */
+Attributes userEntry;
+Entry serverEntry;
+
+
+@Before
+public void setUp() throws Exception
+{
+    MNNCtx = getContext( ServerDNConstants.ADMIN_SYSTEM_DN, getService(), "o=MNN,c=WW,ou=system"
);
+
+    // JNDI entry
+    userEntry = new BasicAttributes( "objectClass", "top", true );
+    userEntry.get( "objectClass" ).add( "person" );
+    userEntry.put( "sn", "elecharny" );
+    userEntry.put( "cn", "Emmanuel Lecharny" );
+
+    // Core API entry
+    Dn dn = new Dn( "cn=Emmanuel Lecharny, ou=apache, ou=people, o=MNN, c=WW, ou=system"
);
+    serverEntry = new DefaultEntry( getService().getSchemaManager(), dn );
+
+    serverEntry.put( "ObjectClass", "top", "person" );
+    serverEntry.put( "sn", "elecharny" );
+    serverEntry.put( "cn", "Emmanuel Lecharny" );
+}
+
+
+/**
+ * Test a search of a non existing entry (not a referral), with no referral 
+ * in its ancestor.
+ */
+@Test
+public void testSearchNotExistingSuperiorNoReferralAncestor() throws Exception
+{
+    Attributes attrs = new BasicAttributes( "ObjectClass", "top", true );
+
+    try
+    {
+        MNNCtx.search( "cn=nobody", attrs );
+        fail();
+    }
+    catch ( NameNotFoundException nnfe )
+    {
+        assertTrue( true );
     }
+}
 
-    
-    /**
-     * Test a search of a non existing entry (not a referral), with a referral 
-     * in its ancestor, using JNDI throw.
-     */
-    @Test
-    public void testSearchWithReferralAncestorJNDIThrow() throws Exception
-    {
-        Attributes attrs = new BasicAttributes( "ObjectClass", "top", true );
-        
-        try
-        {
-            MNNCtx.addToEnvironment( DirContext.REFERRAL, "throw" );
-            MNNCtx.search( "ou=nobody,ou=apache,ou=roles", attrs );
-            fail();
-        }
-        catch ( ReferralException re )
-        {
-            int nbRefs = 0;
-            Set<String> expectedRefs = new HashSet<String>();
-            expectedRefs.add( "ldap://hostd/ou=nobody,ou=apache,ou=Roles,dc=apache,dc=org??one"
);
-            
-            do 
-            {
-                String ref = (String)re.getReferralInfo();
-                
-                assertTrue( expectedRefs.contains( ref ) );
-                nbRefs ++;
-            }
-            while ( re.skipReferral() );
-            
-            assertEquals( 1, nbRefs );
-        }
+
+/**
+ * Test a search of a non existing entry (not a referral), with a referral 
+ * in its ancestor, using JNDI throw.
+ */
+@Test
+public void testSearchWithReferralAncestorJNDIThrow() throws Exception
+{
+    Attributes attrs = new BasicAttributes( "ObjectClass", "top", true );
+
+    try
+    {
+        MNNCtx.addToEnvironment( DirContext.REFERRAL, "throw" );
+        MNNCtx.search( "ou=nobody,ou=apache,ou=roles", attrs );
+        fail();
     }
+    catch ( ReferralException re )
+    {
+        int nbRefs = 0;
+        Set<String> expectedRefs = new HashSet<String>();
+        expectedRefs.add( "ldap://hostd/ou=nobody,ou=apache,ou=Roles,dc=apache,dc=org??one"
);
 
-    
-    /**
-     * Test a search of a non existing entry (not a referral), with a referral 
-     * in its ancestor, using JNDI ignore.
-     */
-    @Test
-    public void testSearchWithReferralAncestorJNDIIgnore() throws Exception
-    {
-        Attributes attrs = new BasicAttributes( "ObjectClass", "top", true );
-        
-        try
-        {
-            MNNCtx.addToEnvironment( DirContext.REFERRAL, "ignore" );
-            MNNCtx.search( "ou=nobody,ou=apache,ou=roles", attrs );
-            fail();
-        }
-        catch ( PartialResultException pre )
+        do
         {
-            assertTrue( true );
+            String ref = ( String ) re.getReferralInfo();
+
+            assertTrue( expectedRefs.contains( ref ) );
+            nbRefs++;
         }
+        while ( re.skipReferral() );
+
+        assertEquals( 1, nbRefs );
     }
+}
 
-    
-    /**
-     * Test a search of a non existing entry (not a referral), with a referral 
-     * in its ancestor, using the Core API without the ManageDsaIt flag.
-     */
-    @Test
-    public void testSearchWithReferralAncestorCoreAPIWithoutManageDSAIt() throws Exception
-    {
-        CoreSession coreSession = getService().getAdminSession();
-        Dn dn = new Dn( "ou=nobody,ou=apache,ou=roles,o=Mnn,c=WW,ou=system" );
-        
-        try
-        {
-            coreSession.search( dn, "(ObjectClass=*)", false );
-            fail();
-        }
-        catch ( LdapReferralException re )
-        {
-            int nbRefs = 0;
-            Set<String> expectedRefs = new HashSet<String>();
-            expectedRefs.add( "ldap://hostd/ou=nobody,ou=apache,ou=Roles,dc=apache,dc=org??base"
);
-            
-            do 
-            {
-                String ref = (String)re.getReferralInfo();
-                
-                assertTrue( expectedRefs.contains( ref ) );
-                nbRefs ++;
-            }
-            while ( re.skipReferral() );
-            
-            assertEquals( 1, nbRefs );
-        }
+
+/**
+ * Test a search of a non existing entry (not a referral), with a referral 
+ * in its ancestor, using JNDI ignore.
+ */
+@Test
+public void testSearchWithReferralAncestorJNDIIgnore() throws Exception
+{
+    Attributes attrs = new BasicAttributes( "ObjectClass", "top", true );
+
+    try
+    {
+        MNNCtx.addToEnvironment( DirContext.REFERRAL, "ignore" );
+        MNNCtx.search( "ou=nobody,ou=apache,ou=roles", attrs );
+        fail();
+    }
+    catch ( PartialResultException pre )
+    {
+        assertTrue( true );
     }
+}
 
-    
-    /**
-     * Test a search of a non existing entry (not a referral), with a referral 
-     * in its ancestor, using the Core API with the ManageDsaIt flag.
-     */
-    @Test
-    public void testSearchWithReferralAncestorCoreAPIWithManageDSAIt() throws Exception
-    {
-        CoreSession coreSession = getService().getAdminSession();
-        Dn dn = new Dn( "ou=nobody,ou=apache,ou=roles,o=Mnn,c=WW,ou=system" );
-        
-        try
-        {
-            coreSession.search( dn, "(ObjectClass=*)", true );
-            fail();
-        }
-        catch ( LdapPartialResultException lpre )
-        {
-            assertTrue( true );
-        }
+
+/**
+ * Test a search of a non existing entry (not a referral), with a referral 
+ * in its ancestor, using the Core API without the ManageDsaIt flag.
+ */
+@Test
+public void testSearchWithReferralAncestorCoreAPIWithoutManageDSAIt() throws Exception
+{
+    CoreSession coreSession = getService().getAdminSession();
+    Dn dn = new Dn( "ou=nobody,ou=apache,ou=roles,o=Mnn,c=WW,ou=system" );
+
+    try
+    {
+        coreSession.search( dn, "(ObjectClass=*)", false );
+        fail();
     }
+    catch ( LdapReferralException re )
+    {
+        int nbRefs = 0;
+        Set<String> expectedRefs = new HashSet<String>();
+        expectedRefs.add( "ldap://hostd/ou=nobody,ou=apache,ou=Roles,dc=apache,dc=org??base"
);
 
-    
-    /**
-     * Test a search of an existing entry (not a referral).
-     */
-    @Test
-    public void testSearchExistingNoReferral() throws Exception
-    {
-        SearchControls sCtrls = new SearchControls();
-        sCtrls.setReturningAttributes( new String[]{ "*" } );
-        sCtrls.setSearchScope( SearchControls.OBJECT_SCOPE );
-        
-        NamingEnumeration<SearchResult> result = MNNCtx.search( "cn=Alex Karasulu",
"(ObjectClass=top)", sCtrls );
-        
-        assertNotNull( result );
-        int nbRes = 0;
-        
-        while ( result.hasMoreElements() )
+        do
         {
-            SearchResult entry = result.nextElement();
-            assertNotNull( entry );
-            assertNotNull( entry.getAttributes() );
-            assertNotNull( entry.getAttributes().get( "cn" ) );
-            assertEquals( "Alex Karasulu", entry.getAttributes().get( "cn" ).get() );
-            nbRes++;
+            String ref = ( String ) re.getReferralInfo();
+
+            assertTrue( expectedRefs.contains( ref ) );
+            nbRefs++;
         }
-        
-        assertEquals( 1, nbRes );
+        while ( re.skipReferral() );
+
+        assertEquals( 1, nbRefs );
     }
+}
 
-    
-    /**
-     * Test a search of an existing referral, using JNDI throw.
-     */
-    @Test
-    public void testSearchExistingReferralJNDIThrow() throws Exception
-    {
-        SearchControls sCtrls = new SearchControls();
-        sCtrls.setReturningAttributes( new String[]{ "*" } );
-        sCtrls.setSearchScope( SearchControls.OBJECT_SCOPE );
-        
-        MNNCtx.addToEnvironment( DirContext.REFERRAL, "throw" );
-        
-        try
-        {
-            MNNCtx.search( "ou=Roles", "(ObjectClass=top)", sCtrls );
-            fail();
-        }
-        catch ( ReferralException re )
-        {
-            int nbRefs = 0;
-            Set<String> expectedRefs = new HashSet<String>();
-            expectedRefs.add( "ldap://hostd/ou=Roles,dc=apache,dc=org??base" );
-            
-            do 
-            {
-                String ref = (String)re.getReferralInfo();
-                
-                assertTrue( expectedRefs.contains( ref ) );
-                nbRefs ++;
-            }
-            while ( re.skipReferral() );
-            
-            assertEquals( 1, nbRefs );
-        }
+
+/**
+ * Test a search of a non existing entry (not a referral), with a referral 
+ * in its ancestor, using the Core API with the ManageDsaIt flag.
+ */
+@Test
+public void testSearchWithReferralAncestorCoreAPIWithManageDSAIt() throws Exception
+{
+    CoreSession coreSession = getService().getAdminSession();
+    Dn dn = new Dn( "ou=nobody,ou=apache,ou=roles,o=Mnn,c=WW,ou=system" );
+
+    try
+    {
+        coreSession.search( dn, "(ObjectClass=*)", true );
+        fail();
+    }
+    catch ( LdapPartialResultException lpre )
+    {
+        assertTrue( true );
     }
+}
 
-    
-    /**
-     * Test a search of an existing referral, using JNDI ignore.
-     */
-    @Test
-    public void testSearchExistingReferralJNDIIgnore() throws Exception
-    {
-        SearchControls sCtrls = new SearchControls();
-        sCtrls.setReturningAttributes( new String[]{ "*" } );
-        sCtrls.setSearchScope( SearchControls.OBJECT_SCOPE );
-        
-        MNNCtx.addToEnvironment( DirContext.REFERRAL, "ignore" );
-        
-        NamingEnumeration<SearchResult> result = MNNCtx.search( "ou=Roles", "(ObjectClass=top)",
sCtrls );
-        
-        assertNotNull( result );
-        int nbRes = 0;
-        
-        while ( result.hasMoreElements() )
-        {
-            SearchResult entry = result.nextElement();
-            assertNotNull( entry );
-            assertNotNull( entry.getAttributes() );
-            assertNotNull( entry.getAttributes().get( "ou" ) );
-            assertEquals( "Roles", entry.getAttributes().get( "ou" ).get() );
-            nbRes++;
-        }
-        
-        assertEquals( 1, nbRes );
+
+/**
+ * Test a search of an existing entry (not a referral).
+ */
+@Test
+public void testSearchExistingNoReferral() throws Exception
+{
+    SearchControls sCtrls = new SearchControls();
+    sCtrls.setReturningAttributes( new String[]
+        { "*" } );
+    sCtrls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+    NamingEnumeration<SearchResult> result = MNNCtx.search( "cn=Alex Karasulu", "(ObjectClass=top)",
sCtrls );
+
+    assertNotNull( result );
+    int nbRes = 0;
+
+    while ( result.hasMoreElements() )
+    {
+        SearchResult entry = result.nextElement();
+        assertNotNull( entry );
+        assertNotNull( entry.getAttributes() );
+        assertNotNull( entry.getAttributes().get( "cn" ) );
+        assertEquals( "Alex Karasulu", entry.getAttributes().get( "cn" ).get() );
+        nbRes++;
     }
-    
-    /**
-     * Test a search of an existing referral, using the Core API without the ManageDsaIt
flag.
-     */
-    @Test
-    public void testSearchExistingReferralCoreAPIWithoutManageDsaIT() throws Exception
-    {
-        CoreSession coreSession = getService().getAdminSession();
-        Dn dn = new Dn( "ou=roles,o=Mnn,c=WW,ou=system" );
-        
-        try
-        {
-            coreSession.search( dn, "(ObjectClass=*)", false );
-            fail();
-        }
-        catch ( LdapReferralException re )
+
+    assertEquals( 1, nbRes );
+}
+
+
+/**
+ * Test a search of an existing referral, using JNDI throw.
+ */
+@Test
+public void testSearchExistingReferralJNDIThrow() throws Exception
+{
+    SearchControls sCtrls = new SearchControls();
+    sCtrls.setReturningAttributes( new String[]
+        { "*" } );
+    sCtrls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+    MNNCtx.addToEnvironment( DirContext.REFERRAL, "throw" );
+
+    try
+    {
+        MNNCtx.search( "ou=Roles", "(ObjectClass=top)", sCtrls );
+        fail();
+    }
+    catch ( ReferralException re )
+    {
+        int nbRefs = 0;
+        Set<String> expectedRefs = new HashSet<String>();
+        expectedRefs.add( "ldap://hostd/ou=Roles,dc=apache,dc=org??base" );
+
+        do
         {
-            int nbRefs = 0;
-            Set<String> expectedRefs = new HashSet<String>();
-            expectedRefs.add( "ldap://hostd/ou=Roles,dc=apache,dc=org??base" );
-            
-            do 
-            {
-                String ref = (String)re.getReferralInfo();
-                
-                assertTrue( expectedRefs.contains( ref ) );
-                nbRefs ++;
-            }
-            while ( re.skipReferral() );
-            
-            assertEquals( 1, nbRefs );
+            String ref = ( String ) re.getReferralInfo();
+
+            assertTrue( expectedRefs.contains( ref ) );
+            nbRefs++;
         }
+        while ( re.skipReferral() );
+
+        assertEquals( 1, nbRefs );
     }
+}
+
 
-    
-    /**
-     * Test a search of an existing referral, using the Core API with the ManageDsaIt flag.
-     */
-    @Test
-    public void testSearchExistingReferralCoreAPIWithManageDsaIT() throws Exception
-    {
-        CoreSession coreSession = getService().getAdminSession();
-        Dn dn = new Dn( "ou=roles,o=Mnn,c=WW,ou=system" );
-        
-        EntryFilteringCursor cursor = coreSession.search( dn, "(ObjectClass=*)", true );
-        
-        assertNotNull( cursor );
-        
-        cursor.beforeFirst();
-        int nbRes = 0;
-        
-        while ( cursor.next() )
+/**
+ * Test a search of an existing referral, using JNDI ignore.
+ */
+@Test
+public void testSearchExistingReferralJNDIIgnore() throws Exception
+{
+    SearchControls sCtrls = new SearchControls();
+    sCtrls.setReturningAttributes( new String[]
+        { "*" } );
+    sCtrls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+    MNNCtx.addToEnvironment( DirContext.REFERRAL, "ignore" );
+
+    NamingEnumeration<SearchResult> result = MNNCtx.search( "ou=Roles", "(ObjectClass=top)",
sCtrls );
+
+    assertNotNull( result );
+    int nbRes = 0;
+
+    while ( result.hasMoreElements() )
+    {
+        SearchResult entry = result.nextElement();
+        assertNotNull( entry );
+        assertNotNull( entry.getAttributes() );
+        assertNotNull( entry.getAttributes().get( "ou" ) );
+        assertEquals( "Roles", entry.getAttributes().get( "ou" ).get() );
+        nbRes++;
+    }
+
+    result.close();
+
+    assertEquals( 1, nbRes );
+}
+
+
+/**
+ * Test a search of an existing referral, using the Core API without the ManageDsaIt flag.
+ */
+@Test
+public void testSearchExistingReferralCoreAPIWithoutManageDsaIT() throws Exception
+{
+    CoreSession coreSession = getService().getAdminSession();
+    Dn dn = new Dn( "ou=roles,o=Mnn,c=WW,ou=system" );
+
+    try
+    {
+        coreSession.search( dn, "(ObjectClass=*)", false );
+        fail();
+    }
+    catch ( LdapReferralException re )
+    {
+        int nbRefs = 0;
+        Set<String> expectedRefs = new HashSet<String>();
+        expectedRefs.add( "ldap://hostd/ou=Roles,dc=apache,dc=org??base" );
+
+        do
         {
-            Entry entry = cursor.get();
-            assertNotNull( entry );
-            assertNotNull( entry.get( "ou" ) );
-            assertEquals( "Roles", entry.get( "ou" ).getString() );
-            nbRes++;
+            String ref = ( String ) re.getReferralInfo();
+
+            assertTrue( expectedRefs.contains( ref ) );
+            nbRefs++;
         }
-        
-        assertEquals( 1, nbRes );
+        while ( re.skipReferral() );
+
+        assertEquals( 1, nbRefs );
+    }
+}
+
+
+/**
+ * Test a search of an existing referral, using the Core API with the ManageDsaIt flag.
+ */
+@Test
+public void testSearchExistingReferralCoreAPIWithManageDsaIT() throws Exception
+{
+    CoreSession coreSession = getService().getAdminSession();
+    Dn dn = new Dn( "ou=roles,o=Mnn,c=WW,ou=system" );
+
+    EntryFilteringCursor cursor = coreSession.search( dn, "(ObjectClass=*)", true );
+
+    assertNotNull( cursor );
+
+    cursor.beforeFirst();
+    int nbRes = 0;
+
+    while ( cursor.next() )
+    {
+        Entry entry = cursor.get();
+        assertNotNull( entry );
+        assertNotNull( entry.get( "ou" ) );
+        assertEquals( "Roles", entry.get( "ou" ).getString() );
+        nbRes++;
     }
+
+    cursor.close();
+
+    assertEquals( 1, nbRes );
+}
 }



Mime
View raw message