directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r889925 - in /directory/shared/branches/shared-schema: ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
Date Sat, 12 Dec 2009 11:08:27 GMT
Author: elecharny
Date: Sat Dec 12 11:08:26 2009
New Revision: 889925

URL: http://svn.apache.org/viewvc?rev=889925&view=rev
Log:
o When we have the same AT in MAY and MUST, we now generate an error. Fixed the test accordingly

Modified:
    directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java?rev=889925&r1=889924&r2=889925&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java
(original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java
Sat Dec 12 11:08:26 2009
@@ -28,9 +28,7 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import javax.naming.NamingException;
 import javax.naming.directory.NoSuchAttributeException;
@@ -1400,36 +1398,16 @@
         objectClass.addMustAttributeTypeOids( "cn", "ref" );
         objectClass.addMayAttributeTypeOids( "2.5.4.3" );
 
-        assertTrue( schemaManager.add( objectClass ) );
-
-        assertEquals( 0, schemaManager.getErrors().size() );
-
-        assertTrue( isOCPresent( schemaManager, "1.1.1" ) );
-
-        ObjectClass added = schemaManager.lookupObjectClassRegistry( "1.1.1" );
-
-        assertNotNull( added );
-
-        assertNotNull( added.getMustAttributeTypes() );
-        assertEquals( 2, added.getMustAttributeTypes().size() );
-        Set<String> expectedAT = new HashSet<String>();
-
-        expectedAT.add( "cn" );
-        expectedAT.add( "ref" );
-
-        for ( AttributeType attributeType : added.getMustAttributeTypes() )
-        {
-            assertTrue( expectedAT.contains( attributeType.getName() ) );
+        // Same AT i MAY and MUST : should fail
+        assertFalse( schemaManager.add( objectClass ) );
 
-            expectedAT.remove( attributeType.getName() );
-        }
+        assertEquals( 1, schemaManager.getErrors().size() );
+        assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapSchemaViolationException
);
 
-        assertNotNull( added.getMayAttributeTypes() );
-        assertEquals( 1, added.getMayAttributeTypes().size() );
-        assertEquals( "2.5.4.3", added.getMayAttributeTypes().get( 0 ).getOid() );
+        assertFalse( isOCPresent( schemaManager, "1.1.1" ) );
 
-        assertEquals( ocrSize + 1, schemaManager.getObjectClassRegistry().size() );
-        assertEquals( goidSize + 1, schemaManager.getOidRegistry().size() );
+        assertEquals( ocrSize, schemaManager.getObjectClassRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
     }
 
 

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java?rev=889925&r1=889924&r2=889925&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
Sat Dec 12 11:08:26 2009
@@ -191,6 +191,19 @@
                         break;
                     }
 
+                    // Check that the MUST AT is not also present in the MAY AT
+                    if ( mayAttributeTypes.contains( attributeType ) )
+                    {
+                        // Already registered : this is an error
+                        String msg = "Cannot register the SchemaOject " + oid
+                            + ", there are some duplicate AT in MAY and MUST : " + mustAttributeTypeName;
+
+                        Throwable error = new LdapSchemaViolationException( msg,
+                            ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+                        errors.add( error );
+                        break;
+                    }
+
                     mustAttributeTypes.add( attributeType );
                 }
             }



Mime
View raw message