You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by dj...@apache.org on 2007/08/23 02:32:09 UTC
svn commit: r568785 - 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
Author: djencks
Date: Wed Aug 22 17:32:08 2007
New Revision: 568785
URL: http://svn.apache.org/viewvc?rev=568785&view=rev
Log:
DIRSERVER-1029 fix attrId comparison in changedype: modify/ add: attrId operations
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?rev=568785&r1=568784&r2=568785&view=diff
==============================================================================
--- 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 Wed Aug 22 17:32:08 2007
@@ -1037,16 +1037,16 @@
// A standard AttributeType/AttributeValue pair
int colonIndex = line.indexOf( ':' );
- String attributeType = lowerLine.substring( 0, colonIndex );
+ String attributeType = line.substring( 0, colonIndex );
- if ( attributeType.equals( modified ) == false )
+ if ( attributeType.equalsIgnoreCase( modified ) == false )
{
log.error( "The modified attribute and the attribute value spec must be equal" );
throw new NamingException( "Bad modify attribute" );
}
// We should *not* have a DN twice
- if ( attributeType.equals( "dn" ) )
+ if ( attributeType.equalsIgnoreCase( "dn" ) )
{
log.error( "An entry must not have two DNs" );
throw new NamingException( "A ldif entry should not have two DN" );
@@ -1055,7 +1055,7 @@
Object attributeValue = parseValue( line, colonIndex );
// Update the entry
- entry.addModificationItem( modification, attributeType, attributeValue );
+ entry.addModificationItem( modification, modified, attributeValue );
isEmptyValue = false;
state = ATTRVAL_SPEC_OR_SEP;
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?rev=568785&r1=568784&r2=568785&view=diff
==============================================================================
--- 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 Wed Aug 22 17:32:08 2007
@@ -205,7 +205,6 @@
* Spaces at the end of values should not be included into values.
*
* @throws NamingException
- * @throws ParsingException
*/
public void testLdifParserEndSpaces() throws NamingException
{
@@ -235,11 +234,54 @@
}
+ public void testLdifParserAddAttrCaseInsensitiveAttrId() throws NamingException
+ {
+ // test that mixed case attr ids work at all
+ String ldif =
+ "version: 1\n" +
+ "dn: dc=example,dc=com\n" +
+ "changetype: modify\n" +
+ "add: administrativeRole\n" +
+ "administrativeRole: accessControlSpecificArea";
+
+ testReaderAttrIdCaseInsensitive( ldif );
+ // test that attr id comparisons are case insensitive and that the version in the add: line is used.
+ // See DIRSERVER-1029 for some discussion.
+ ldif =
+ "version: 1\n" +
+ "dn: dc=example,dc=com\n" +
+ "changetype: modify\n" +
+ "add: administrativeRole\n" +
+ "administrativerole: accessControlSpecificArea";
+
+ testReaderAttrIdCaseInsensitive( ldif );
+ }
+
+ private void testReaderAttrIdCaseInsensitive( String ldif )
+ throws NamingException
+ {
+ LdifReader reader = new LdifReader();
+
+ List entries = reader.parseLdif( ldif );
+ assertNotNull( entries );
+
+ Entry entry = ( Entry ) entries.get( 0 );
+
+ assertTrue( entry.isChangeModify() );
+
+ assertEquals( "dc=example,dc=com", entry.getDn() );
+
+ List<ModificationItemImpl> mods = entry.getModificationItems( );
+ assertTrue( mods.size() == 1 );
+ Attribute attr = mods.get(0).getAttribute();
+ assertTrue( attr.getID().equals( "administrativeRole"));
+ assertEquals( attr.get(), "accessControlSpecificArea" );
+ }
+
/**
* Changes and entries should not be mixed
*
* @throws NamingException
- * @throws ParsingException
*/
public void testLdifParserCombinedEntriesChanges() throws NamingException
{
@@ -278,7 +320,6 @@
* Changes and entries should not be mixed
*
* @throws NamingException
- * @throws ParsingException
*/
public void testLdifParserCombinedEntriesChanges2() throws NamingException
{
@@ -316,7 +357,6 @@
* Changes and entries should not be mixed
*
* @throws NamingException
- * @throws ParsingException
*/
public void testLdifParserCombinedChangesEntries() throws NamingException
{
@@ -355,7 +395,6 @@
* Changes and entries should not be mixed
*
* @throws NamingException
- * @throws ParsingException
*/
public void testLdifParserCombinedChangesEntries2() throws NamingException
{