directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1133060 - in /directory/shared/trunk: integ/src/test/java/org/apache/directory/shared/ldap/model/name/ ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/osgi/ ldap/model/src/main/antlr/
Date Tue, 07 Jun 2011 16:02:00 GMT
Author: elecharny
Date: Tue Jun  7 16:01:59 2011
New Revision: 1133060

URL: http://svn.apache.org/viewvc?rev=1133060&view=rev
Log:
Fix for DIRSERVER-1440
o Modified the complex parser to keep the spaces before an AT value
o Fixed the DN parser tests

Modified:
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java
    directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/osgi/AbstractCodecServiceTest.java
    directory/shared/trunk/ldap/model/src/main/antlr/distinguishedName.g

Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java?rev=1133060&r1=1133059&r2=1133060&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java
(original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java
Tue Jun  7 16:01:59 2011
@@ -357,6 +357,28 @@ public class DnTest
 
 
     /**
+     * Test for DIRSTUDIO-589, DIRSTUDIO-591, DIRSHARED-38
+     *
+     * Check escaped sharp followed by a hex sequence
+     * (without the ESC it would be a valid hexstring).
+     */
+    @Test
+    public void testDnEscValue() throws LdapException, LdapException
+    {
+        Dn dn = new Dn( "cn = Exa\\+mple  one " );
+
+        assertTrue( Dn.isValid( "cn = Exa\\+mple  one " ) );
+        assertEquals( "cn=Exa\\+mple  one", dn.getNormName() );
+        assertEquals( "cn = Exa\\+mple  one ", dn.getName() );
+
+        Dn dn2 = new Dn( schemaManager, "cn = Exa\\+mple  one " );
+
+        assertEquals( "2.5.4.3=exa\\+mple one", dn2.getNormName() );
+        assertEquals( "cn = Exa\\+mple  one ", dn2.getName() );
+    }
+
+
+    /**
       * test a simple Dn with a # on first position
       */
     @Test
@@ -2471,7 +2493,7 @@ public class DnTest
         assertEquals( " cn = Amos\\,Tori ", dn1.getRdn().getName() );
         Ava atav1 = dn1.getRdn().getAva();
         assertEquals( "cn", atav1.getUpType() );
-        assertEquals( "Amos,Tori", atav1.getUpValue().getString() );
+        assertEquals( " Amos\\,Tori ", atav1.getUpValue().getString() );
 
         // antlr parser: hexstring with trailing spaces
         Dn dn3 = new Dn( " cn = #414243 , ou=system " );
@@ -2486,7 +2508,7 @@ public class DnTest
         assertEquals( " cn = \\41\\42\\43 ", dn4.getRdn().getName() );
         Ava atav4 = dn4.getRdn().getAva();
         assertEquals( "cn", atav4.getUpType() );
-        assertEquals( "ABC", atav4.getUpValue().getString() );
+        assertEquals( " \\41\\42\\43 ", atav4.getUpValue().getString() );
         assertEquals( "ABC", atav4.getNormValue().getString() );
 
         // antlr parser: quotestring with trailing spaces
@@ -2494,7 +2516,7 @@ public class DnTest
         assertEquals( " cn = \"ABC\" ", dn5.getRdn().getName() );
         Ava atav5 = dn5.getRdn().getAva();
         assertEquals( "cn", atav5.getUpType() );
-        assertEquals( "ABC", atav5.getUpValue().getString() );
+        assertEquals( " \"ABC\" ", atav5.getUpValue().getString() );
         assertEquals( "ABC", atav5.getNormValue().getString() );
 
         // fast parser: string value with trailing spaces
@@ -2625,7 +2647,7 @@ public class DnTest
         assertEquals( "example", rdn.getNormValue().getString() );
         assertEquals( "2.5.4.11=example+2.5.4.11=test", rdn.getNormName() );
         assertEquals( "ou", rdn.getUpType() );
-        assertEquals( "Example", rdn.getUpValue().getString() );
+        assertEquals( "  Example ", rdn.getUpValue().getString() );
         assertEquals( "  ou  =  Example + ou = TEST ", rdn.getName() );
 
         // The first ATAV
@@ -2636,7 +2658,7 @@ public class DnTest
         assertEquals( "example", atav.getNormValue().getValue() );
 
         assertEquals( "ou", atav.getUpType() );
-        assertEquals( "Example", atav.getUpValue().getValue() );
+        assertEquals( "  Example ", atav.getUpValue().getValue() );
 
         assertEquals( "  ou  =  Example ", atav.getUpName() );
 
@@ -2656,7 +2678,7 @@ public class DnTest
             assertEquals( "test", ava.getNormValue().getValue() );
 
             assertEquals( "ou", ava.getUpType() );
-            assertEquals( "TEST", ava.getUpValue().getValue() );
+            assertEquals( " TEST ", ava.getUpValue().getValue() );
             assertEquals( " ou = TEST ", ava.getUpName() );
         }
     }
@@ -2665,18 +2687,18 @@ public class DnTest
     @Test
     public void testNormalizeAsciiWithEscaped() throws Exception
     {
-        Dn dn = new Dn( "  ou  =  Ex\\+mple ,  ou  =  COM " );
+        Dn dn = new Dn( "  ou  =  Ex\\+mple " );
 
         dn.apply( schemaManager );
-        assertEquals( "2.5.4.11=ex\\+mple,2.5.4.11=com", dn.getNormName() );
-        assertEquals( "  ou  =  Ex\\+mple ,  ou  =  COM ", dn.getName() );
+        assertEquals( "2.5.4.11=ex\\+mple", dn.getNormName() );
+        assertEquals( "  ou  =  Ex\\+mple ", dn.getName() );
 
         Rdn rdn = dn.getRdn();
         assertEquals( "2.5.4.11", rdn.getNormType() );
         assertEquals( "ex+mple", rdn.getNormValue().getString() );
         assertEquals( "2.5.4.11=ex\\+mple", rdn.getNormName() );
         assertEquals( "ou", rdn.getUpType() );
-        assertEquals( "Ex+mple", rdn.getUpValue().getString() );
+        assertEquals( "  Ex\\+mple ", rdn.getUpValue().getString() );
         assertEquals( "  ou  =  Ex\\+mple ", rdn.getName() );
 
         Ava atav = rdn.getAva();
@@ -2686,7 +2708,7 @@ public class DnTest
         assertEquals( "ex+mple", atav.getNormValue().getValue() );
 
         assertEquals( "ou", atav.getUpType() );
-        assertEquals( "Ex+mple", atav.getUpValue().getValue() );
+        assertEquals( "  Ex\\+mple ", atav.getUpValue().getValue() );
 
         assertEquals( "  ou  =  Ex\\+mple ", atav.getUpName() );
     }
@@ -2710,7 +2732,7 @@ public class DnTest
         assertEquals( "OU", rdn.getUpType() );
         assertEquals( "ou", rdn.getNormType() );
 
-        assertEquals( "Ex+mple", rdn.getUpValue().getString() );
+        assertEquals( "  Ex\\+mple ", rdn.getUpValue().getString() );
         assertEquals( "Ex+mple", rdn.getNormValue().getString() );
 
         // The first ATAV
@@ -2722,7 +2744,7 @@ public class DnTest
         assertEquals( "ou", atav.getNormType() );
         assertEquals( "OU", atav.getUpType() );
 
-        assertEquals( "Ex+mple", atav.getUpValue().getValue() );
+        assertEquals( "  Ex\\+mple ", atav.getUpValue().getValue() );
         assertEquals( "Ex+mple", atav.getNormValue().getValue() );
 
         assertEquals( 2, rdn.size() );
@@ -2742,7 +2764,7 @@ public class DnTest
             assertEquals( "ou", ava.getUpType() );
             assertEquals( "ou", ava.getNormType() );
 
-            assertEquals( "T+ST ", ava.getUpValue().getValue() );
+            assertEquals( " T\\+ST\\  ", ava.getUpValue().getValue() );
             assertEquals( "T+ST ", ava.getNormValue().getValue() );
         }
 
@@ -2761,7 +2783,7 @@ public class DnTest
         assertEquals( "OU", rdn.getUpType() );
         assertEquals( "2.5.4.11", rdn.getNormType() );
 
-        assertEquals( "Ex+mple", rdn.getUpValue().getString() );
+        assertEquals( "  Ex\\+mple ", rdn.getUpValue().getString() );
         assertEquals( "ex+mple", rdn.getNormValue().getString() );
 
         // The first ATAV
@@ -2773,7 +2795,7 @@ public class DnTest
         assertEquals( "2.5.4.11", atav.getNormType() );
         assertEquals( "OU", atav.getUpType() );
 
-        assertEquals( "Ex+mple", atav.getUpValue().getValue() );
+        assertEquals( "  Ex\\+mple ", atav.getUpValue().getValue() );
         assertEquals( "ex+mple", atav.getNormValue().getValue() );
 
         assertEquals( 2, rdn.size() );
@@ -2793,7 +2815,7 @@ public class DnTest
             assertEquals( "ou", ava.getUpType() );
             assertEquals( "2.5.4.11", ava.getNormType() );
 
-            assertEquals( "T+ST ", ava.getUpValue().getValue() );
+            assertEquals( " T\\+ST\\  ", ava.getUpValue().getValue() );
             assertEquals( "t+st", ava.getNormValue().getValue() );
         }
     }

Modified: directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/osgi/AbstractCodecServiceTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/osgi/AbstractCodecServiceTest.java?rev=1133060&r1=1133059&r2=1133060&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/osgi/AbstractCodecServiceTest.java
(original)
+++ directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/osgi/AbstractCodecServiceTest.java
Tue Jun  7 16:01:59 2011
@@ -22,7 +22,6 @@ package org.apache.directory.shared.ldap
 
 import org.apache.directory.shared.ldap.codec.api.LdapApiServiceFactory;
 import org.apache.directory.shared.ldap.codec.api.LdapEncoder;
-import org.apache.directory.shared.ldap.codec.osgi.DefaultLdapCodecService;
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
 import org.apache.mina.filter.codec.ProtocolDecoder;

Modified: directory/shared/trunk/ldap/model/src/main/antlr/distinguishedName.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/antlr/distinguishedName.g?rev=1133060&r1=1133059&r2=1133060&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/antlr/distinguishedName.g (original)
+++ directory/shared/trunk/ldap/model/src/main/antlr/distinguishedName.g Tue Jun  7 16:01:59
2011
@@ -313,6 +313,7 @@ attributeTypeAndValue [Rdn rdn] returns 
         matchedProduction( "attributeTypeAndValue()" );
         String type = null;
         UpAndNormValue value = new UpAndNormValue();
+        String upValue = null;
     }
     :
     (
@@ -320,7 +321,19 @@ attributeTypeAndValue [Rdn rdn] returns 
         type = attributeType { upName += type; }
         ( SPACE { upName += " "; } )*
         EQUALS { upName += "="; }
-        ( SPACE { upName += " "; } )*
+        ( SPACE 
+        { 
+            upName += " "; 
+            
+            if ( upValue == null )
+            {
+                upValue = " ";
+            }
+            else
+            {
+                upValue += " "; 
+            } 
+        } )*
         attributeValue[value] 
         {
             try
@@ -330,11 +343,16 @@ attributeTypeAndValue [Rdn rdn] returns 
             
                 if ( value.value instanceof String )
                 {
+                    if ( upValue != null )
+                    {
+                        value.rawValue = upValue + value.rawValue;
+                    }
+
                     ava = new Ava(
                         type,
                         type,
+                        new StringValue( (String)value.rawValue ),
                         new StringValue( (String)value.value ), 
-                        new StringValue( (String)value.value ),
                         upName
                     );
                 }



Mime
View raw message