You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2005/07/11 08:17:45 UTC
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
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 <a href="mailto:akarasulu@safehaus.org">Alex Karasulu</a>
+ * @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 );
+ }
+}