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 2010/12/11 17:38:35 UTC
svn commit: r1044677 - in /directory:
apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/
shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/
shared/trunk/ldap/src/test/java/org/apache/directory/shared/...
Author: elecharny
Date: Sat Dec 11 16:38:35 2010
New Revision: 1044677
URL: http://svn.apache.org/viewvc?rev=1044677&view=rev
Log:
Fixed DIRSERVER-1564
Modified:
directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryIT.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/PrepareString.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/DNTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/normalizers/DeepTrimNormalizerTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryIT.java?rev=1044677&r1=1044676&r2=1044677&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryIT.java Sat Dec 11 16:38:35 2010
@@ -1503,6 +1503,70 @@ public class SubschemaSubentryIT extends
}
+ /**
+ * Tests the addition of a new attributeType where the DESC contains only spaces
+ */
+ @Test
+ public void testAddAttributeTypeWithSpaceDesc() throws Exception
+ {
+ enableSchema( "nis" );
+ DN dn = new DN( getSubschemaSubentryDN() );
+ String substrate = "( 1.3.6.1.4.1.18060.0.4.0.2.10000 NAME ( 'bogus' 'bogusName' ) "
+ + "DESC ' ' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SUP name SINGLE-VALUE X-SCHEMA 'nis' )";
+ ModificationItem[] mods = new ModificationItem[1];
+ mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE, new BasicAttribute( "attributeTypes", substrate ) );
+
+ // Apply the addition
+ getRootContext( service ).modifyAttributes( JndiUtils.toName( dn ), mods );
+
+ // Get back the list of attributes, and find the one we just added
+ Attributes attrs = getSubschemaSubentryAttributes();
+ Attribute attrTypes = attrs.get( "attributeTypes" );
+ AttributeType attributeType = null;
+
+ for ( int ii = 0; ii < attrTypes.size(); ii++ )
+ {
+ String desc = ( String ) attrTypes.get( ii );
+
+ if ( desc.indexOf( "1.3.6.1.4.1.18060.0.4.0.2.10000" ) != -1 )
+ {
+ attributeType = ATTRIBUTE_TYPE_DESCRIPTION_SCHEMA_PARSER.parseAttributeTypeDescription( desc );
+ break;
+ }
+ }
+
+ assertNotNull( attributeType );
+ assertEquals( true, attributeType.isSingleValued() );
+ assertEquals( false, attributeType.isCollective() );
+ assertEquals( false, attributeType.isObsolete() );
+ assertEquals( true, attributeType.isUserModifiable() );
+ assertEquals( " ", attributeType.getDescription() );
+ assertEquals( "bogus", attributeType.getNames().get( 0 ) );
+ assertEquals( "bogusName", attributeType.getNames().get( 1 ) );
+ assertEquals( "name", attributeType.getSuperiorOid() );
+
+ // Now check that the entry has been added
+ attrs = getSchemaContext( service ).getAttributes(
+ "m-oid=1.3.6.1.4.1.18060.0.4.0.2.10000,ou=attributeTypes,cn=nis" );
+ assertNotNull( attrs );
+ SchemaEntityFactory factory = new SchemaEntityFactory();
+
+ Entry serverEntry = ServerEntryUtils.toServerEntry( attrs, DN.EMPTY_DN, service.getSchemaManager() );
+
+ AttributeType at = factory.getAttributeType( service.getSchemaManager(), serverEntry, service
+ .getSchemaManager().getRegistries(), "nis" );
+ assertEquals( "1.3.6.1.4.1.18060.0.4.0.2.10000", at.getOid() );
+ assertEquals( "name", at.getSuperiorOid() );
+ assertEquals( " ", at.getDescription() );
+ assertEquals( "bogus", at.getNames().get( 0 ) );
+ assertEquals( "bogusName", at.getNames().get( 1 ) );
+ assertEquals( true, at.isUserModifiable() );
+ assertEquals( false, at.isCollective() );
+ assertEquals( false, at.isObsolete() );
+ assertEquals( true, at.isSingleValued() );
+ }
+
+
// -----------------------------------------------------------------------
// ObjectClass Tests
// -----------------------------------------------------------------------
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/PrepareString.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/PrepareString.java?rev=1044677&r1=1044676&r2=1044677&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/PrepareString.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/PrepareString.java Sat Dec 11 16:38:35 2010
@@ -4758,8 +4758,8 @@ public final class PrepareString
if ( start == limit )
{
- // we only have spaces
- return "";
+ // we only have spaces, we keep only one
+ return " ";
}
else if ( isCombiningMark( c ) )
{
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/DNTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/DNTest.java?rev=1044677&r1=1044676&r2=1044677&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/DNTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/DNTest.java Sat Dec 11 16:38:35 2010
@@ -3373,16 +3373,16 @@ public class DNTest
DN dn3 = new DN( "ou=\\ ,ou=system" );
dn3.normalize( oids );
assertEquals( "ou=\\ ,ou=system", dn3.getName() );
- assertEquals( "ou=,ou=system", dn3.getNormName() );
+ assertEquals( "ou=\\ ,ou=system", dn3.getNormName() );
assertEquals( "ou=\\ ", dn3.getRdn().getName() );
- assertEquals( "ou=", dn3.getRdn().getNormName() );
+ assertEquals( "ou=\\ ", dn3.getRdn().getNormName() );
DN dn4 = new DN( "ou=\\20,ou=system" );
dn4.normalize( oids );
assertEquals( "ou=\\20,ou=system", dn4.getName() );
- assertEquals( "ou=,ou=system", dn4.getNormName() );
+ assertEquals( "ou=\\ ,ou=system", dn4.getNormName() );
assertEquals( "ou=\\20", dn4.getRdn().getName() );
- assertEquals( "ou=", dn4.getRdn().getNormName() );
+ assertEquals( "ou=\\ ", dn4.getRdn().getNormName() );
}
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/normalizers/DeepTrimNormalizerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/normalizers/DeepTrimNormalizerTest.java?rev=1044677&r1=1044676&r2=1044677&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/normalizers/DeepTrimNormalizerTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/normalizers/DeepTrimNormalizerTest.java Sat Dec 11 16:38:35 2010
@@ -20,16 +20,15 @@
package org.apache.directory.shared.ldap.schema.normalizers;
+import static org.junit.Assert.assertEquals;
+
import org.apache.directory.junit.tools.Concurrent;
import org.apache.directory.junit.tools.ConcurrentJunitRunner;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.schema.Normalizer;
-import org.apache.directory.shared.ldap.schema.normalizers.DeepTrimNormalizer;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.assertEquals;
-
/**
* Test the normalizer class
@@ -60,7 +59,7 @@ public class DeepTrimNormalizerTest
public void testDeepTrimNormalizerOneSpace() throws LdapException
{
Normalizer normalizer = new DeepTrimNormalizer( "1.1.1" );
- assertEquals( "", normalizer.normalize( " " ) );
+ assertEquals( " ", normalizer.normalize( " " ) );
}
@@ -68,7 +67,7 @@ public class DeepTrimNormalizerTest
public void testDeepTrimNormalizerTwoSpaces() throws LdapException
{
Normalizer normalizer = new DeepTrimNormalizer( "1.1.1" );
- assertEquals( "", normalizer.normalize( " " ) );
+ assertEquals( " ", normalizer.normalize( " " ) );
}
@@ -76,7 +75,7 @@ public class DeepTrimNormalizerTest
public void testDeepTrimNormalizerNSpaces() throws LdapException
{
Normalizer normalizer = new DeepTrimNormalizer( "1.1.1" );
- assertEquals( "", normalizer.normalize( " " ) );
+ assertEquals( " ", normalizer.normalize( " " ) );
}
@@ -171,7 +170,7 @@ public class DeepTrimNormalizerTest
char[] chars = new char[]
{ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0085, 0x00A0, 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005,
0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x2028, 0x2029, 0x202F, 0x205F };
- assertEquals( "", normalizer.normalize( new String( chars ) ) );
+ assertEquals( " ", normalizer.normalize( new String( chars ) ) );
}
@@ -205,7 +204,7 @@ public class DeepTrimNormalizerTest
chars[pos++] = 0x00AD;
- assertEquals( "", normalizer.normalize( new String( chars ) ) );
+ assertEquals( " ", normalizer.normalize( new String( chars ) ) );
}
/*
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java?rev=1044677&r1=1044676&r2=1044677&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java Sat Dec 11 16:38:35 2010
@@ -146,6 +146,32 @@ public class OpenLdapSchemaParserTest
}
+ /**
+ * Test that we can handle a DESC which contains only spaces
+ */
+ @Test
+ public void testAttributeTypeParseWithSpaceDesc() throws Exception
+ {
+ String attributeTypeData = "# adding a comment \n"
+ + "attributetype ( 2.5.4.2 NAME 'knowledgeInformation'\n"
+ + " DESC ' '\n"
+ + " EQUALITY caseIgnoreMatch\n"
+ + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )";
+
+ parser.parse( attributeTypeData );
+ List<AttributeType> attributeTypeList = parser.getAttributeTypes();
+ Map<String, AttributeType> attributeTypes = mapAttributeTypes( attributeTypeList );
+ AttributeType type = attributeTypes.get( "2.5.4.2" );
+
+ assertNotNull( type );
+ assertEquals( "2.5.4.2", type.getOid() );
+ assertEquals( "knowledgeInformation", type.getName() );
+ assertEquals( " ", type.getDescription() );
+ assertEquals( "1.3.6.1.4.1.1466.115.121.1.15", type.getSyntaxOid() );
+ assertEquals( 32768, type.getSyntaxLength() );
+ }
+
+
@Test
public void testComplexAttributeTypeParse() throws Exception
{