directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1486732 - /directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
Date Tue, 28 May 2013 03:27:04 GMT
Author: elecharny
Date: Tue May 28 03:27:04 2013
New Revision: 1486732

URL: http://svn.apache.org/r1486732
Log:
I have ignored the test_DIRAPI140 as it takes 180 seconds.

Modified:
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java?rev=1486732&r1=1486731&r2=1486732&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
(original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
Tue May 28 03:27:04 2013
@@ -51,6 +51,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.shared.client.api.LdapApiIntegrationUtils;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -90,297 +91,297 @@ import org.junit.runner.RunWith;
 })
 public class ClientSearchRequestTest extends AbstractLdapTestUnit
 {
-private LdapNetworkConnection connection;
-
-
-@Before
-public void setup() throws Exception
-{
-    connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection(
getLdapServer() );
-}
-
-
-@After
-public void shutdown() throws Exception
-{
-    LdapApiIntegrationUtils.releasePooledAdminConnection( connection, getLdapServer() );
-}
-
-
-@Test
-public void testSimpleSearch() throws Exception
-{
-    EntryCursor cursor = connection.search( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL
);
-    int count = 0;
-
-    while ( cursor.next() )
+    private LdapNetworkConnection connection;
+    
+    
+    @Before
+    public void setup() throws Exception
     {
-        Entry entry = cursor.get();
-        assertNotNull( entry );
-        count++;
+        connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection(
getLdapServer() );
     }
-
-    SearchResultDone done = cursor.getSearchResultDone();
-
-    assertNotNull( done );
-    assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
-    assertEquals( 5, count );
-    cursor.close();
-}
-
-
-@Test
-public void testSimpleSearchWithControl() throws Exception
-{
-    SearchRequest searchRequest = new SearchRequestImpl().setBase( new Dn( "ou=system" )
)
-        .setFilter( "(objectclass=*)" )
-        .setScope( SearchScope.ONELEVEL ).addControl( new ManageDsaITImpl() );
-    SearchCursor cursor = connection.search( searchRequest );
-    int count = 0;
-
-    while ( cursor.next() )
+    
+    
+    @After
+    public void shutdown() throws Exception
     {
-        Response response = cursor.get();
-        assertNotNull( response );
-
-        if ( response instanceof SearchResultEntry )
+        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, getLdapServer()
);
+    }
+    
+    
+    @Test
+    public void testSimpleSearch() throws Exception
+    {
+        EntryCursor cursor = connection.search( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL
);
+        int count = 0;
+    
+        while ( cursor.next() )
         {
-            Entry entry = ( ( SearchResultEntry ) response ).getEntry();
+            Entry entry = cursor.get();
             assertNotNull( entry );
+            count++;
         }
-
-        count++;
+    
+        SearchResultDone done = cursor.getSearchResultDone();
+    
+        assertNotNull( done );
+        assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
+        assertEquals( 5, count );
+        cursor.close();
     }
-
-    SearchResultDone done = cursor.getSearchResultDone();
-
-    assertNotNull( done );
-    assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
-    assertEquals( 5, count );
-    cursor.close();
-}
-
-
-@Test
-public void testSearch() throws Exception
-{
-    EntryCursor cursor = connection.search( "ou=system", "(objectclass=*)",
-        SearchScope.ONELEVEL,
-        "*", "+" );
-    int count = 0;
-
-    while ( cursor.next() )
+    
+    
+    @Test
+    public void testSimpleSearchWithControl() throws Exception
     {
-        assertNotNull( cursor.get() );
-        count++;
+        SearchRequest searchRequest = new SearchRequestImpl().setBase( new Dn( "ou=system"
) )
+            .setFilter( "(objectclass=*)" )
+            .setScope( SearchScope.ONELEVEL ).addControl( new ManageDsaITImpl() );
+        SearchCursor cursor = connection.search( searchRequest );
+        int count = 0;
+    
+        while ( cursor.next() )
+        {
+            Response response = cursor.get();
+            assertNotNull( response );
+    
+            if ( response instanceof SearchResultEntry )
+            {
+                Entry entry = ( ( SearchResultEntry ) response ).getEntry();
+                assertNotNull( entry );
+            }
+    
+            count++;
+        }
+    
+        SearchResultDone done = cursor.getSearchResultDone();
+    
+        assertNotNull( done );
+        assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
+        assertEquals( 5, count );
+        cursor.close();
     }
-
-    SearchResultDone done = cursor.getSearchResultDone();
-
-    assertNotNull( done );
-    assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
-    assertEquals( 5, count );
-    cursor.close();
-}
-
-
-@Test
-public void testSearchEquality() throws Exception
-{
-    EntryCursor cursor = connection.search( "ou=system", "(objectclass=organizationalUnit)",
-        SearchScope.ONELEVEL, "*", "+" );
-    int count = 0;
-
-    while ( cursor.next() )
+    
+    
+    @Test
+    public void testSearch() throws Exception
     {
-        Entry entry = cursor.get();
-        assertNotNull( entry );
-        count++;
+        EntryCursor cursor = connection.search( "ou=system", "(objectclass=*)",
+            SearchScope.ONELEVEL,
+            "*", "+" );
+        int count = 0;
+    
+        while ( cursor.next() )
+        {
+            assertNotNull( cursor.get() );
+            count++;
+        }
+    
+        SearchResultDone done = cursor.getSearchResultDone();
+    
+        assertNotNull( done );
+        assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
+        assertEquals( 5, count );
+        cursor.close();
     }
-
-    assertEquals( 4, count );
-    cursor.close();
-}
-
-
-@Test
-public void testAsyncSearch() throws Exception
-{
-    SearchFuture searchFuture = connection.searchAsync( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL,
"*",
-        "+" );
-    int count = 0;
-    Response searchResponse = null;
-
-    do
+    
+    
+    @Test
+    public void testSearchEquality() throws Exception
     {
-        searchResponse = searchFuture.get( 1000, TimeUnit.MILLISECONDS );
-        assertNotNull( searchResponse );
-        if ( !( searchResponse instanceof SearchResultDone ) )
+        EntryCursor cursor = connection.search( "ou=system", "(objectclass=organizationalUnit)",
+            SearchScope.ONELEVEL, "*", "+" );
+        int count = 0;
+    
+        while ( cursor.next() )
         {
+            Entry entry = cursor.get();
+            assertNotNull( entry );
             count++;
         }
+    
+        assertEquals( 4, count );
+        cursor.close();
     }
-    while ( !( searchResponse instanceof SearchResultDone ) );
-
-    assertEquals( 5, count );
-}
-
-
-/**
- * Test a search with a Substring filter
- * @throws Exception
- */
-@Test
-public void testSearchPersonSubstring() throws Exception
-{
-    SearchFuture searchFuture = connection.searchAsync( "ou=system", "(objectclass=*ers*)",
SearchScope.SUBTREE,
-        "*", "+" );
-    int count = 0;
-    Response searchResponse = null;
-
-    do
+    
+    
+    @Test
+    public void testAsyncSearch() throws Exception
     {
-        searchResponse = searchFuture.get( 100000, TimeUnit.MILLISECONDS );
-        assertNotNull( searchResponse );
-
-        if ( !( searchResponse instanceof SearchResultDone ) )
+        SearchFuture searchFuture = connection.searchAsync( "ou=system", "(objectclass=*)",
SearchScope.ONELEVEL, "*",
+            "+" );
+        int count = 0;
+        Response searchResponse = null;
+    
+        do
+        {
+            searchResponse = searchFuture.get( 1000, TimeUnit.MILLISECONDS );
+            assertNotNull( searchResponse );
+            if ( !( searchResponse instanceof SearchResultDone ) )
+            {
+                count++;
+            }
+        }
+        while ( !( searchResponse instanceof SearchResultDone ) );
+    
+        assertEquals( 5, count );
+    }
+    
+    
+    /**
+     * Test a search with a Substring filter
+     * @throws Exception
+     */
+    @Test
+    public void testSearchPersonSubstring() throws Exception
+    {
+        SearchFuture searchFuture = connection.searchAsync( "ou=system", "(objectclass=*ers*)",
SearchScope.SUBTREE,
+            "*", "+" );
+        int count = 0;
+        Response searchResponse = null;
+    
+        do
+        {
+            searchResponse = searchFuture.get( 100000, TimeUnit.MILLISECONDS );
+            assertNotNull( searchResponse );
+    
+            if ( !( searchResponse instanceof SearchResultDone ) )
+            {
+                count++;
+            }
+        }
+        while ( !( searchResponse instanceof SearchResultDone ) );
+    
+        assertEquals( 3, count );
+    }
+    
+    
+    @Test
+    public void testSearchWithDerefAlias() throws Exception
+    {
+        SearchRequest searchRequest = new SearchRequestImpl();
+        searchRequest.setBase( new Dn( "ou=users,ou=system" ) );
+        searchRequest.setFilter( "(objectClass=*)" );
+        searchRequest.setScope( SearchScope.ONELEVEL );
+        searchRequest.addAttributes( "*" );
+    
+        int count = 0;
+        Cursor<Response> cursor = connection.search( searchRequest );
+    
+        while ( cursor.next() )
+        {
+            count++;
+        }
+        cursor.close();
+    
+        // due to dereferencing of aliases we get only one entry
+        assertEquals( 2, count );
+    
+        count = 0;
+        searchRequest.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES );
+        cursor = connection.search( searchRequest );
+    
+        while ( cursor.next() )
         {
             count++;
         }
+        cursor.close();
+    
+        assertEquals( 3, count );
     }
-    while ( !( searchResponse instanceof SearchResultDone ) );
-
-    assertEquals( 3, count );
-}
-
-
-@Test
-public void testSearchWithDerefAlias() throws Exception
-{
-    SearchRequest searchRequest = new SearchRequestImpl();
-    searchRequest.setBase( new Dn( "ou=users,ou=system" ) );
-    searchRequest.setFilter( "(objectClass=*)" );
-    searchRequest.setScope( SearchScope.ONELEVEL );
-    searchRequest.addAttributes( "*" );
-
-    int count = 0;
-    Cursor<Response> cursor = connection.search( searchRequest );
-
-    while ( cursor.next() )
+    
+    
+    @Test
+    public void testSearchUTF8() throws Exception
     {
-        count++;
+        EntryCursor cursor = connection.search( "ou=users,ou=system", "(sn=Emmanuel L\u00E9charny)",
SearchScope.ONELEVEL,
+            "*", "+" );
+    
+        assertTrue( cursor.next() );
+    
+        Entry entry = cursor.get();
+        assertNotNull( entry );
+        assertTrue( entry.contains( "cn", "elecharny" ) );
+        assertTrue( entry.contains( "sn", "Emmanuel L\u00E9charny" ) );
+    
+        cursor.close();
     }
-    cursor.close();
-
-    // due to dereferencing of aliases we get only one entry
-    assertEquals( 2, count );
-
-    count = 0;
-    searchRequest.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES );
-    cursor = connection.search( searchRequest );
-
-    while ( cursor.next() )
+    
+    
+    @Test
+    public void testSearchBinary() throws Exception
     {
-        count++;
+        connection.loadSchema();
+        EntryCursor cursor = connection
+            .search(
+                "ou=system",
+                "(publicKey=\\30\\5C\\30\\0D\\06\\09\\2A\\86\\48\\86\\F7\\0D\\01\\01\\01\\05\\00\\03\\4B\\00\\30\\48\\02\\41\\00\\A6\\C7\\9C\\B1\\6C\\E4\\DD\\8F\\1E\\4D\\20\\93\\22\\3F\\83\\75\\DE\\21\\D8\\F1\\9D\\63\\80\\5B\\94\\55\\6A\\9E\\33\\59\\9B\\8D\\63\\88\\0D\\18\\7D\\4C\\85\\F1\\CF\\54\\77\\32\\E9\\61\\0C\\A2\\8F\\B3\\6B\\15\\34\\5E\\1F\\88\\BF\\A0\\73\\AC\\86\\BB\\D0\\85\\02\\03\\01\\00\\01)",
+                SearchScope.SUBTREE, "publicKey" );
+    
+        assertTrue( cursor.next() );
+    
+        Entry entry = cursor.get();
+        assertNotNull( entry.get( "publicKey" ) );
+    
+        cursor.close();
     }
-    cursor.close();
-
-    assertEquals( 3, count );
-}
-
-
-@Test
-public void testSearchUTF8() throws Exception
-{
-    EntryCursor cursor = connection.search( "ou=users,ou=system", "(sn=Emmanuel L\u00E9charny)",
SearchScope.ONELEVEL,
-        "*", "+" );
-
-    assertTrue( cursor.next() );
-
-    Entry entry = cursor.get();
-    assertNotNull( entry );
-    assertTrue( entry.contains( "cn", "elecharny" ) );
-    assertTrue( entry.contains( "sn", "Emmanuel L\u00E9charny" ) );
-
-    cursor.close();
-}
-
-
-@Test
-public void testSearchBinary() throws Exception
-{
-    connection.loadSchema();
-    EntryCursor cursor = connection
-        .search(
-            "ou=system",
-            "(publicKey=\\30\\5C\\30\\0D\\06\\09\\2A\\86\\48\\86\\F7\\0D\\01\\01\\01\\05\\00\\03\\4B\\00\\30\\48\\02\\41\\00\\A6\\C7\\9C\\B1\\6C\\E4\\DD\\8F\\1E\\4D\\20\\93\\22\\3F\\83\\75\\DE\\21\\D8\\F1\\9D\\63\\80\\5B\\94\\55\\6A\\9E\\33\\59\\9B\\8D\\63\\88\\0D\\18\\7D\\4C\\85\\F1\\CF\\54\\77\\32\\E9\\61\\0C\\A2\\8F\\B3\\6B\\15\\34\\5E\\1F\\88\\BF\\A0\\73\\AC\\86\\BB\\D0\\85\\02\\03\\01\\00\\01)",
-            SearchScope.SUBTREE, "publicKey" );
-
-    assertTrue( cursor.next() );
-
-    Entry entry = cursor.get();
-    assertNotNull( entry.get( "publicKey" ) );
-
-    cursor.close();
-}
-
-
-@Test
-public void testSubDn() throws Exception
-{
-    connection.loadSchema();
-    EntryCursor cursor = connection.search( "ou=system", "(cn=user1)", SearchScope.SUBTREE,
"publicKey" );
-
-    assertTrue( cursor.next() );
-
-    Entry entry = cursor.get();
-    assertEquals( "cn=user1,ou=users,ou=system", entry.getDn().getName() );
-
-    cursor.close();
-
-    SearchRequest req = new SearchRequestImpl();
-    req.setScope( SearchScope.SUBTREE );
-    req.addAttributes( "*" );
-    req.setTimeLimit( 0 );
-    req.setBase( new Dn( "ou=system" ) );
-    req.setFilter( "(cn=user1)" );
-
-    SearchCursor searchCursor = connection.search( req );
-
-    assertTrue( searchCursor.next() );
-
-    Response response = searchCursor.get();
-
-    Entry resultEntry = ( ( SearchResultEntry ) response ).getEntry();
-    assertEquals( "cn=user1,ou=users,ou=system", resultEntry.getDn().getName() );
-
-    searchCursor.close();
-}
-
-
-/**
- * Test to demonstrate https://issues.apache.org/jira/browse/DIRAPI-140
- * Fixed to demonstrate that it works, if we loop until we don't have anymore results
- */
-@Test
-public void test_DIRAPI140() throws Exception
-{
-    for ( int i = 0; i < 10000; i++ )
+    
+    
+    @Test
+    public void testSubDn() throws Exception
     {
+        connection.loadSchema();
+        EntryCursor cursor = connection.search( "ou=system", "(cn=user1)", SearchScope.SUBTREE,
"publicKey" );
+    
+        assertTrue( cursor.next() );
+    
+        Entry entry = cursor.get();
+        assertEquals( "cn=user1,ou=users,ou=system", entry.getDn().getName() );
+    
+        cursor.close();
+    
         SearchRequest req = new SearchRequestImpl();
         req.setScope( SearchScope.SUBTREE );
         req.addAttributes( "*" );
         req.setTimeLimit( 0 );
         req.setBase( new Dn( "ou=system" ) );
         req.setFilter( "(cn=user1)" );
-
+    
         SearchCursor searchCursor = connection.search( req );
-
-        // We should have only one entry
+    
         assertTrue( searchCursor.next() );
-
+    
+        Response response = searchCursor.get();
+    
+        Entry resultEntry = ( ( SearchResultEntry ) response ).getEntry();
+        assertEquals( "cn=user1,ou=users,ou=system", resultEntry.getDn().getName() );
+    
         searchCursor.close();
     }
-}
-
+    
+    
+    /**
+     * Test to demonstrate https://issues.apache.org/jira/browse/DIRAPI-140
+     * Fixed to demonstrate that it works, if we loop until we don't have anymore results
+     */
+    @Test
+    @Ignore("The test has been fixed, it's now ignored as it takes 180seconds")
+    public void test_DIRAPI140() throws Exception
+    {
+        for ( int i = 0; i < 10000; i++ )
+        {
+            SearchRequest req = new SearchRequestImpl();
+            req.setScope( SearchScope.SUBTREE );
+            req.addAttributes( "*" );
+            req.setTimeLimit( 0 );
+            req.setBase( new Dn( "ou=system" ) );
+            req.setFilter( "(cn=user1)" );
+    
+            SearchCursor searchCursor = connection.search( req );
+    
+            // We should have only one entry
+            assertTrue( searchCursor.next() );
+    
+            searchCursor.close();
+        }
+    }
 }



Mime
View raw message