Added a test to check DIRSERVER-1414
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 @@
"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 @@
}
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 @@
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 @@
}
cursor.close();
- assertEquals( 3, count );
+ assertEquals( 5, count );
}
@@ -359,6 +402,39 @@
}
+ @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