Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 17261 invoked from network); 11 Jul 2005 06:17:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Jul 2005 06:17:49 -0000 Received: (qmail 4533 invoked by uid 500); 11 Jul 2005 06:17:49 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 4482 invoked by uid 500); 11 Jul 2005 06:17:48 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 4469 invoked by uid 99); 11 Jul 2005 06:17:48 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Jul 2005 23:17:48 -0700 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 10 Jul 2005 23:17:46 -0700 Received: (qmail 17235 invoked by uid 65534); 11 Jul 2005 06:17:46 -0000 Message-ID: <20050711061746.17234.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r210073 - in /directory/shared/ldap/trunk/common/src: java/org/apache/ldap/common/ldif/LdifParserImpl.java test/org/apache/ldap/common/ldif/ test/org/apache/ldap/common/ldif/LdifParserImplTest.java Date: Mon, 11 Jul 2005 06:17:45 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.0.2 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: akarasulu Date: Sun Jul 10 23:17:44 2005 New Revision: 210073 URL: http://svn.apache.org/viewcvs?rev=210073&view=rev Log: changes ... o minor bug fix: parser died when LDIF had no value for an attribute o added test case to catch and test for the bug which now succeeds Added: directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/ldif/ directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/ldif/LdifParserImplTest.java Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/ldif/LdifParserImpl.java Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/ldif/LdifParserImpl.java URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/ldif/LdifParserImpl.java?rev=210073&r1=210072&r2=210073&view=diff ============================================================================== --- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/ldif/LdifParserImpl.java (original) +++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/ldif/LdifParserImpl.java Sun Jul 10 23:17:44 2005 @@ -95,16 +95,21 @@ // Capture data while at first colon. attrName = line.substring( 0, index ).trim(); + if ( line.length() <= index + 1 ) + { + continue; + } + // Consume next char and check if it's a colon for binary attr. if ( line.charAt( ++index ) == ':' ) { isBase64Encoded = true; } - + // Advance index past whitespace to the first char of the value. try { - while ( line.charAt( ++index ) == ' ' ) + while ( ( line.length() <= index + 1 ) && line.charAt( ++index ) == ' ' ) {; // Does nothing! } Added: directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/ldif/LdifParserImplTest.java URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/ldif/LdifParserImplTest.java?rev=210073&view=auto ============================================================================== --- directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/ldif/LdifParserImplTest.java (added) +++ directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/ldif/LdifParserImplTest.java Sun Jul 10 23:17:44 2005 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2005 Your Corporation. All Rights Reserved. + */ +package org.apache.ldap.common.ldif; + + +import junit.framework.TestCase; +import org.apache.ldap.common.message.LockableAttributesImpl; + +import javax.naming.directory.Attributes; +import javax.naming.NamingException; + + +/** + * @author Alex Karasulu + * @version $Rev$ + */ +public class LdifParserImplTest extends TestCase +{ + public void testLdifParser() throws NamingException + { + String ldif = "dn: cn=app1,ou=applications,ou=conf,dc=apache,dc=org\n" + + "cn: app1\n" + + "objectClass: top\n" + + "objectClass: apApplication\n" + + "displayName: app1\n" + + "serviceType: http\n" + + "dependencies:\n" + + "httpHeaders:\n" + + "startupOptions:\n" + + "envVars:"; + LdifParser parser = new LdifParserImpl(); + Attributes attrs = new LockableAttributesImpl(); + parser.parse( attrs, ldif ); + + assertNotNull( attrs ); + } +}