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 2019/06/25 14:49:59 UTC
[directory-server] branch master updated: Added a test to check
DIRSERVER-1414
This is an automated email from the ASF dual-hosted git repository.
elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-server.git
The following commit(s) were added to refs/heads/master by this push:
new db6b686 Added a test to check DIRSERVER-1414
db6b686 is described below
commit db6b6866677a1face9d6bce767f0ff104ae1cc59
Author: emmanuel lecharny <el...@apache.org>
AuthorDate: Tue Jun 25 16:49:55 2019 +0200
Added a test to check DIRSERVER-1414
---
.../operations/search/ClientSearchRequestTest.java | 84 ++++++++++++++++++++--
1 file changed, 80 insertions(+), 4 deletions(-)
diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
index 4555929..4d461fc 100644
--- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
+++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
@@ -87,7 +87,22 @@ import org.junit.runner.RunWith;
"objectClass: extensibleObject",
"sn:: RW1tYW51ZWwgTMOpY2hhcm55",
"cn: elecharny",
- "publicKey:: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKbHnLFs5N2PHk0gkyI/g3XeIdjxnWOAW5RVap4zWZuNY4gNGH1MhfHPVHcy6WEMoo+zaxU0Xh+Iv6BzrIa70IUCAwEAAQ=="
+ "publicKey:: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKbHnLFs5N2PHk0gkyI/g3XeIdjxnWOAW5RVap4zWZuNY4gNGH1MhfHPVHcy6WEMoo+zaxU0Xh+Iv6BzrIa70IUCAwEAAQ==",
+
+ // Another test
+ "dn: cn= test THIS , ou=users,ou=system",
+ "objectClass: person",
+ "objectClass: top",
+ "sn: test sn",
+ "cn: test THIS ",
+
+ // Another test
+ "dn: cn=test, ou=users,ou=system",
+ "objectClass: person",
+ "objectClass: top",
+ "sn: test sn",
+ "cn: test"
+
})
public class ClientSearchRequestTest extends AbstractLdapTestUnit
{
@@ -251,7 +266,35 @@ public class ClientSearchRequestTest extends AbstractLdapTestUnit
}
while ( !( searchResponse instanceof SearchResultDone ) );
- assertEquals( 3, count );
+ assertEquals( 5, count );
+ }
+
+
+ /**
+ * Test a search with a more evoluted Substring filter
+ * @throws Exception
+ */
+ @Test
+ public void testSearchSubstring2() throws Exception
+ {
+ SearchFuture searchFuture = connection.searchAsync( "ou=system", "(cn=Test *)", 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( 2, count );
}
@@ -274,7 +317,7 @@ public class ClientSearchRequestTest extends AbstractLdapTestUnit
cursor.close();
// due to dereferencing of aliases we get only one entry
- assertEquals( 2, count );
+ assertEquals( 4, count );
count = 0;
searchRequest.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES );
@@ -286,7 +329,7 @@ public class ClientSearchRequestTest extends AbstractLdapTestUnit
}
cursor.close();
- assertEquals( 3, count );
+ assertEquals( 5, count );
}
@@ -359,6 +402,39 @@ public class ClientSearchRequestTest extends AbstractLdapTestUnit
}
+ @Test
+ public void testSubstring() 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