directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1785417 - /directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterParserTest.java
Date Fri, 03 Mar 2017 22:35:37 GMT
Author: elecharny
Date: Fri Mar  3 22:35:36 2017
New Revision: 1785417

URL: http://svn.apache.org/viewvc?rev=1785417&view=rev
Log:
Added a test to check that special filter chars like '(' or ')' get escaped properly

Modified:
    directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterParserTest.java

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterParserTest.java?rev=1785417&r1=1785416&r2=1785417&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterParserTest.java
(original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterParserTest.java
Fri Mar  3 22:35:36 2017
@@ -29,6 +29,7 @@ import static org.junit.Assert.fail;
 import java.nio.charset.StandardCharsets;
 import java.text.ParseException;
 import java.util.List;
+import java.util.Locale;
 
 import com.mycila.junit.concurrent.Concurrency;
 import com.mycila.junit.concurrent.ConcurrentJunitRunner;
@@ -1167,4 +1168,17 @@ public class FilterParserTest
         assertTrue( child instanceof PresenceNode );
         assertEquals( "cn", ((PresenceNode)child).attribute );
     }
+    
+    
+    @Test
+    public void testFilterWithSpecialChars() throws ParseException
+    {
+        String filterStr = String.format( Locale.ROOT, "(%s=%s)", "cn", FilterEncoder.encodeFilterValue(
"ACME(tm)" ) );
+        
+        assertEquals( "(cn=ACME\\28tm\\29)", filterStr );
+        
+        String filterStr2 = new EqualityNode<>( "cn", new StringValue( "ACME(tm)" )
).toString();
+        
+        assertEquals( "(cn=ACME\\28tm\\29)", filterStr2 );
+    }
 }



Mime
View raw message