directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1570807 - in /directory/shared/trunk/ldap/model/src: main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java test/java/org/apache/directory/api/ldap/model/ldif/LdifReaderTest.java
Date Sat, 22 Feb 2014 07:34:39 GMT
Author: elecharny
Date: Sat Feb 22 07:34:38 2014
New Revision: 1570807

URL: http://svn.apache.org/r1570807
Log:
Fix for DIRAPI-175 : we now accept LDIF with entry not having any attribute (typiclly what
we get when we do a search with 1.1)

Modified:
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
    directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/ldif/LdifReaderTest.java

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java?rev=1570807&r1=1570806&r2=1570807&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
Sat Feb 22 07:34:38 2014
@@ -1328,7 +1328,7 @@ public class LdifReader implements Itera
         Iterator<String> iter = lines.iterator();
 
         // This flag is used to distinguish between an entry and a change
-        int type = UNKNOWN;
+        int type = LDIF_ENTRY;
 
         // The following boolean is used to check that a control is *not*
         // found elswhere than just after the dn

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/ldif/LdifReaderTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/ldif/LdifReaderTest.java?rev=1570807&r1=1570806&r2=1570807&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/ldif/LdifReaderTest.java
(original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/ldif/LdifReaderTest.java
Sat Feb 22 07:34:38 2014
@@ -2314,4 +2314,44 @@ public class LdifReaderTest
         attr = entry.get( "envvars" );
         assertNull( attr.get().getValue() );
     }
+
+
+    /**
+     * Test a LDIF generated by a request with 1.1
+     */
+    @Test
+    public void testLdifParserNoAttribute() throws Exception
+    {
+        String ldif =
+            "version:   1\n" +
+            "dn: cn=test1\n" +
+            "\n" +
+            "dn: cn=test2\n" +
+            "\n" +
+            "dn: cn=test3";
+
+        LdifReader reader = new LdifReader();
+        List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
+
+        assertNotNull( entries );
+
+        // Check test 1
+        LdifEntry entry = entries.get( 0 );
+        assertTrue( entry.isLdifContent() );
+        assertEquals( "cn=test1", entry.getDn().getName() );
+        assertEquals( 0, entry.size() );
+
+        // Check test 2
+        entry = entries.get( 1 );
+        assertTrue( entry.isLdifContent() );
+        assertEquals( "cn=test2", entry.getDn().getName() );
+        assertEquals( 0, entry.size() );
+
+        // Check test 3
+        entry = entries.get( 2 );
+        assertTrue( entry.isLdifContent() );
+        assertEquals( "cn=test3", entry.getDn().getName() );
+        assertEquals( 0, entry.size() );
+    }
 }



Mime
View raw message