You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2006/09/18 11:50:21 UTC

svn commit: r447345 - in /directory/trunks/shared/ldap/src: main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java

Author: elecharny
Date: Mon Sep 18 02:50:20 2006
New Revision: 447345

URL: http://svn.apache.org/viewvc?view=rev&rev=447345
Log:
Applied patch for DIRSERVER-743 in trunks

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

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java?view=diff&rev=447345&r1=447344&r2=447345
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java Mon Sep 18 02:50:20 2006
@@ -1413,8 +1413,6 @@
                     }
                 }
 
-                isFirstLine = false;
-
                 // We will read the first line which is not a comment
                 switch ( line.charAt( 0 ) )
                 {
@@ -1423,6 +1421,8 @@
                         break;
 
                     case ' ':
+                        isFirstLine = false;
+
                         if ( insideComment )
                         {
                             continue;
@@ -1441,6 +1441,8 @@
                         break;
 
                     default:
+                        isFirstLine = false;
+
                         // We have found a new entry
                         // First, stores the previous one if any.
                         if ( sb.length() != 0 )

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java?view=diff&rev=447345&r1=447344&r2=447345
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java Mon Sep 18 02:50:20 2006
@@ -1423,4 +1423,53 @@
             assertTrue( true );
         }
     }
+
+    public void testLdifReaderDirServer() throws NamingException, Exception
+    {
+        String ldif = 
+            "# -------------------------------------------------------------------\n" +
+            "#\n" +
+            "#  Licensed to the Apache Software Foundation (ASF) under one\n" +
+            "#  or more contributor license agreements.  See the NOTICE file\n" +
+            "#  distributed with this work for additional information\n" +
+            "#  regarding copyright ownership.  The ASF licenses this file\n" +
+            "#  to you under the Apache License, Version 2.0 (the\n" +
+            "#  \"License\"); you may not use this file except in compliance\n" +
+            "#  with the License.  You may obtain a copy of the License at\n" +
+            "#  \n" +
+            "#    http://www.apache.org/licenses/LICENSE-2.0\n" +
+            "#  \n" +
+            "#  Unless required by applicable law or agreed to in writing,\n" +
+            "#  software distributed under the License is distributed on an\n" +
+            "#  \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n" +
+            "#  KIND, either express or implied.  See the License for the\n" +
+            "#  specific language governing permissions and limitations\n" +
+            "#  under the License. \n" +
+            "#  \n" +
+            "#\n" +
+            "# EXAMPLE.COM is freely and reserved for testing according to this RFC:\n" +
+            "#\n" +
+            "# http://www.rfc-editor.org/rfc/rfc2606.txt\n" +
+            "#\n" +
+            "# -------------------------------------------------------------------\n" +
+            "\n" +
+            "dn: ou=Users, dc=example, dc=com\n" +
+            "objectclass: top\n" +
+            "objectclass: organizationalunit\n" +
+            "ou: Users";
+            
+        LdifReader reader = new LdifReader();
+
+        List entries = reader.parseLdif( ldif );
+        Entry entry = (Entry) entries.get( 0 );
+
+        assertEquals( "ou=Users, dc=example, dc=com", entry.getDn() );
+
+        Attribute attr = entry.get( "objectclass" );
+        assertTrue( attr.contains( "top" ) );
+        assertTrue( attr.contains( "organizationalunit" ) );
+
+        attr = entry.get( "ou" );
+        assertTrue( attr.contains( "Users" ) );
+    }
 }