directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r583404 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/ldif/LdifUtils.java test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java
Date Wed, 10 Oct 2007 09:26:05 GMT
Author: elecharny
Date: Wed Oct 10 02:26:04 2007
New Revision: 583404

URL: http://svn.apache.org/viewvc?rev=583404&view=rev
Log:
Fixed a bug in LdifUtil : attributes with null value weren't correctly generated.
The convertToLdif(Attribute) metod is now public

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifUtils.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifUtils.java?rev=583404&r1=583403&r2=583404&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifUtils.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifUtils.java
Wed Oct 10 02:26:04 2007
@@ -250,8 +250,12 @@
 			
 			Object value = attr.get( i );
             
-            // Checking if the value is binary
-            if ( value instanceof byte[] )
+            // First, deal with null value (which is valid)
+            if ( value == null )
+            {
+                lineBuffer.append( ':' );
+            }
+            else if ( value instanceof byte[] )
             {
             	// It is binary, so we have to encode it using Base64 before adding it
             	char[] encoded = Base64.encode( ( byte[] ) value );

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java?rev=583404&r1=583403&r2=583404&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java
Wed Oct 10 02:26:04 2007
@@ -234,7 +234,7 @@
     
     
     /**
-     * Tests that unsave characters are encoded using UTF-8 charset. 
+     * Tests that unsafe characters are encoded using UTF-8 charset. 
      * 
      * @throws NamingException
      */
@@ -244,6 +244,19 @@
         String ldif = LdifUtils.convertToLdif( attributes );
         assertEquals( "cn:: U2FhcmJyw7xja2Vu\n", ldif );
     }
+    
+    /**
+     * Tests that null values are correctly encoded 
+     * 
+     * @throws NamingException
+     */
+    public void testConvertToLdifAttrWithNullValues() throws NamingException
+    {
+        Attributes attributes = new BasicAttributes( "cn", null );
+        String ldif = LdifUtils.convertToLdif( attributes );
+        assertEquals( "cn:\n", ldif );
+    }
+    
     
     public void testConvertEntryToLdif() throws NamingException
     {



Mime
View raw message