directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r504393 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
Date Wed, 07 Feb 2007 00:54:34 GMT
Author: elecharny
Date: Tue Feb  6 16:54:33 2007
New Revision: 504393

URL: http://svn.apache.org/viewvc?view=rev&rev=504393
Log:
Fixed DIRSERVER-839. Added a unit test

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

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java?view=diff&rev=504393&r1=504392&r2=504393
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
Tue Feb  6 16:54:33 2007
@@ -1377,6 +1377,12 @@
 
             // We have found the version, just discard the line from the list
             lines.remove( 0 );
+            
+            // and read the next lines if the current buffer is empty
+            if ( lines.size() == 0 )
+            {
+                readLines();
+            }
         }
         else
         {

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java?view=diff&rev=504393&r1=504392&r2=504393
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
Tue Feb  6 16:54:33 2007
@@ -147,6 +147,37 @@
         assertEquals( 1, reader.getVersion() );
     }
 
+    public void testLdifVersionStart() throws NamingException
+    {
+        String ldif = 
+            "version:\n" + 
+            " 1\n" + 
+            "\n" +
+            "dn: cn=app1,ou=applications,ou=conf,dc=apache,dc=org\n" + 
+            "cn: app1\n" + 
+            "objectClass: top\n" + 
+            "objectClass: apApplication\n" + 
+            "displayName:   app1   \n" + 
+            "dependencies:\n" + 
+            "envVars:";
+
+
+        LdifReader reader = new LdifReader();
+        List entries = reader.parseLdif( ldif );
+
+        assertEquals( 1, reader.getVersion() );
+        assertNotNull( entries );
+
+        Entry entry = (Entry) entries.get( 0 );
+
+        assertTrue( entry.isChangeAdd() );
+
+        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn() );
+
+        Attribute attr = entry.get( "displayname" );
+        assertTrue( attr.contains( "app1" ) );
+    }
+
     /**
      * Test the ldif parser with a file without a version. It should default to 1
      * @throws NamingException



Mime
View raw message