directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r823360 [2/6] - in /directory: apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/ apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/syn...
Date Fri, 09 Oct 2009 00:03:51 GMT
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java Fri Oct  9 00:03:45 2009
@@ -20,6 +20,7 @@
 package org.apache.directory.server.core.schema.registries.synchronizers;
 
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -27,12 +28,15 @@
 
 import javax.naming.NamingException;
 
-import org.apache.directory.server.constants.ServerDNConstants;
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.OperationManager;
 import org.apache.directory.server.core.entry.DefaultServerAttribute;
 import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.entry.ServerModification;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
+import org.apache.directory.server.core.partition.ByPassConstants;
 import org.apache.directory.server.core.schema.PartitionSchemaLoader;
 import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
@@ -47,11 +51,13 @@
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.SchemaObject;
+import org.apache.directory.shared.ldap.schema.SchemaObjectType;
 import org.apache.directory.shared.ldap.schema.SchemaWrapper;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.apache.directory.shared.ldap.schema.registries.Schema;
 import org.apache.directory.shared.ldap.schema.registries.SchemaObjectRegistry;
+import org.apache.directory.shared.ldap.util.DateUtils;
 import org.apache.directory.shared.schema.loader.ldif.SchemaEntityFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -84,10 +90,15 @@
     /** The m-dependencies AttributeType */
     private final AttributeType dependenciesAT;
     
+    /** The modifiersName AttributeType */
+    private final AttributeType modifiersNameAT;
+    
+    /** The modifyTimestamp AttributeType */
+    private final AttributeType modifyTimestampAT;
+    
     /** A static DN referencing ou=schema */
     private final LdapDN ouSchemaDN;
 
-
     /**
      * Creates and initializes a new instance of Schema synchronizer
      *
@@ -104,24 +115,21 @@
         cnAT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.CN_AT );
         dependenciesAT = registries.getAttributeTypeRegistry()
             .lookup( MetaSchemaConstants.M_DEPENDENCIES_AT );
+        modifiersNameAT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.MODIFIERS_NAME_AT );
+        modifyTimestampAT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.MODIFY_TIMESTAMP_AT );
         
-        ouSchemaDN = new LdapDN( ServerDNConstants.OU_SCHEMA_DN );
+        ouSchemaDN = new LdapDN( SchemaConstants.OU_SCHEMA );
         ouSchemaDN.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
     }
 
 
     /**
-     * Reacts to modification of a metaSchema object.  At this point the 
-     * only considerable changes are to the m-disabled and the 
-     * m-dependencies attributes.
-     * 
-     * @param name the dn of the metaSchema object modified
-     * @param mods the attribute modifications as an ModificationItem arry
-     * @param entry the entry after the modifications have been applied
+     * {@inheritDoc}
      */
-    public boolean modify( LdapDN name, List<Modification> mods, ServerEntry entry,
-        ServerEntry targetEntry, boolean cascade ) throws Exception
+    public boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry, boolean cascade ) throws Exception
     {
+        ServerEntry entry = opContext.getEntry();
+        List<Modification> mods = opContext.getModItems(); 
         boolean hasModification = SCHEMA_UNCHANGED;
         
         // Check if the entry has a m-disabled attribute 
@@ -134,7 +142,7 @@
             ModificationOperation modification = disabledModification.getOperation();
             ServerAttribute attribute = (ServerAttribute)disabledModification.getAttribute();
             
-            hasModification = disable( name, modification, attribute, disabledInEntry );
+            hasModification = modifyDisable( opContext, modification, attribute, disabledInEntry );
         }
 
         // check if the new schema is enabled or disabled
@@ -384,9 +392,33 @@
     // -----------------------------------------------------------------------
 
     
-    private boolean disable( LdapDN name, ModificationOperation modOp, EntryAttribute disabledInMods, EntryAttribute disabledInEntry )
-        throws Exception
+    /**
+     * Modify the Disable flag (the flag can be set to true or false).
+     * 
+     * We can ADD, REMOVE or MODIFY this flag. The following matrix expose what will be the consequences
+     * of this operation, depending on the current state
+     * 
+     * <pre>
+     *                 +-------------------+--------------------+--------------------+
+     *     op/state    |       TRUE        |       FALSE        |       ABSENT       |
+     * +-------+-------+----------------------------------------+--------------------+
+     * | ADD   | TRUE  | do nothing        | do nothing         | disable the schema |
+     * |       +-------+-------------------+--------------------+--------------------+
+     * |       | FALSE | do nothing        | do nothing         | do nothing         |
+     * +-------+-------+-------------------+--------------------+--------------------+
+     * |REMOVE | N/A   | enable the schema | do nothing         | do nothing         |
+     * +-------+-------+-------------------+--------------------+--------------------+
+     * |MODIFY | TRUE  | do nothing        | disable the schema | disable the schema |
+     * |       +-------+-------------------+--------------------+--------------------+
+     * |       | FALSE | enable the schema | do nothing         |  do nothing        |
+     * +-------+-------+-------------------+--------------------+--------------------+
+     * </pre>
+     */
+    private boolean modifyDisable( ModifyOperationContext opContext, ModificationOperation modOp, 
+        EntryAttribute disabledInMods, EntryAttribute disabledInEntry ) throws Exception
     {
+        LdapDN name = opContext.getDn();
+        
         switch ( modOp )
         {
             /*
@@ -398,7 +430,7 @@
                 {
                     if ( "TRUE".equalsIgnoreCase( disabledInMods.getString() ) )
                     {
-                        return disableSchema( getSchemaName( name ) );
+                        return disableSchema( opContext.getSession(), getSchemaName( name ) );
                     }
                 }
                 
@@ -431,7 +463,7 @@
                 }
                 
                 boolean isNewStateDisabled = false;
-                
+               
                 if ( disabledInMods != null )
                 {
                     isNewStateDisabled = "TRUE".equalsIgnoreCase( disabledInMods.getString() );
@@ -444,7 +476,7 @@
 
                 if ( !isCurrentlyDisabled && isNewStateDisabled )
                 {
-                    return disableSchema( getSchemaName( name ) );
+                    return disableSchema( opContext.getSession(), getSchemaName( name ) );
                 }
                 
                 break;
@@ -462,8 +494,71 @@
         return ( String ) schema.getRdn().getValue();
     }
 
+    
+    /**
+     * Build the DN to access a schemaObject path for a specific schema 
+     */
+    private LdapDN buildDn( SchemaObjectType schemaObjectType, String schemaName ) throws NamingException
+    {
+        
+        LdapDN path = new LdapDN( 
+            SchemaConstants.OU_SCHEMA,
+            "cn=" + schemaName,
+            schemaObjectType.getRdn()
+            );
+        
+        return path;
+    }
+    
+    
+    /**
+     * Disable a schema and update all of its schemaObject 
+     */
+    private void disable( SchemaObject schemaObject, CoreSession session, Registries registries )
+        throws Exception
+    {
+        Schema schema = registries.getLoadedSchema( schemaObject.getSchemaName() );
+        List<Modification> modifications = new ArrayList<Modification>();
+        
+        // The m-disabled AT
+        EntryAttribute disabledAttr = new DefaultServerAttribute( disabledAT, "FALSE" );
+        Modification disabledMod = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, disabledAttr );
+        
+        modifications.add( disabledMod );
+        
+        // The modifiersName AT
+        EntryAttribute modifiersNameAttr = 
+            new DefaultServerAttribute( modifiersNameAT, session.getEffectivePrincipal().getName() );
+        Modification modifiersNameMod = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, modifiersNameAttr );
+        
+        modifications.add( modifiersNameMod );
+        
+        // The modifyTimestamp AT
+        EntryAttribute modifyTimestampAttr = 
+            new DefaultServerAttribute( modifyTimestampAT, DateUtils.getGeneralizedTime() );
+        Modification modifyTimestampMod = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, modifyTimestampAttr );
+        
+        modifications.add( modifyTimestampMod );
+        
+        // Call the modify operation
+        LdapDN dn = buildDn( schemaObject.getObjectType(), schemaObject.getName() );
+        
+        ModifyOperationContext modifyContext = new ModifyOperationContext( session, dn, modifications );
+        modifyContext.setByPassed( ByPassConstants.BYPASS_ALL_COLLECTION );
 
-    private boolean disableSchema( String schemaName ) throws Exception
+        OperationManager operationManager = 
+            session.getDirectoryService().getOperationManager();
+        
+        operationManager.modify( modifyContext );
+        
+        // Now iterate on all the schemaObject under this schema
+        for ( SchemaWrapper schemaWrapper : schema.getContent() )
+        {
+            
+        }
+    }
+
+    private boolean disableSchema( CoreSession session, String schemaName ) throws Exception
     {
         // First check that the schema is not already disabled
         Map<String, Schema> schemas = registries.getLoadedSchemas();
@@ -489,7 +584,7 @@
         
         // Use brute force right now : iterate through all the schemaObjects
         // searching for those associated with the disabled schema
-        disableAT( schemaName );
+        disableAT( session, schemaName );
         
         Set<SchemaWrapper> content = registries.getLoadedSchema( schemaName ).getContent(); 
 
@@ -504,7 +599,7 @@
     }
     
     
-    private void disableAT( String schemaName )
+    private void disableAT( CoreSession session, String schemaName )
     {
         AttributeTypeRegistry atRegistry = registries.getAttributeTypeRegistry();
         
@@ -520,21 +615,36 @@
                 EntryAttribute disable = new DefaultServerAttribute( disabledAT, "TRUE"  );
                 Modification modification = 
                     new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, disable );
+                
+                //session.modify( dn, mods, ignoreReferral, log )
             }
         }
     }
 
 
     /**
-     * TODO - for now we're just going to add the schema to the global 
-     * registries ... we may need to add it to more than that though later.
+     * Enabling a schema consist on switching all of its schema element to enable.
      */
     private boolean enableSchema( String schemaName ) throws Exception
     {
         Schema schema = loader.getSchema( schemaName );
 
-        if ( schema != null )
+        if ( schema == null )
         {
+            // This is not possible. We can't enable a schema which is not loaded.
+            String msg = "Unwilling to enable a not loaded schema: " + schemaName;
+            LOG.error( msg );
+            throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+        
+        for ( SchemaWrapper schemaWrapper : schema.getContent() )
+        {
+            SchemaObject schemaObject = schemaWrapper.get();
+            
+            if ( schemaObject.isDisabled() )
+            {
+                //schemaObject.enable();
+        }
             // TODO log warning: schemaName + " was already loaded"
             schema.enable();
             registries.schemaLoaded( schema );

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxCheckerSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxCheckerSynchronizer.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxCheckerSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxCheckerSynchronizer.java Fri Oct  9 00:03:45 2009
@@ -23,6 +23,7 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
 import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
@@ -72,11 +73,16 @@
     }
 
 
-    public boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean cascade ) throws Exception
+    /**
+     * {@inheritDoc}
+     */
+    public boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry, boolean cascade ) throws Exception
     {
+        LdapDN name = opContext.getDn();
+        ServerEntry entry = opContext.getEntry();
         String schemaName = getSchemaName( name );
         String oid = getOid( entry );
-        SyntaxChecker syntaxChecker = factory.getSyntaxChecker( targetEntry, registries );
+        SyntaxChecker syntaxChecker = factory.getSyntaxChecker( targetEntry, registries, schemaName );
         
         if ( isSchemaEnabled( schemaName ) )
         {
@@ -100,19 +106,17 @@
         LdapDN dn = entry.getDn();
         LdapDN parentDn = ( LdapDN ) dn.clone();
         parentDn.remove( parentDn.size() - 1 );
-        checkNewParent( parentDn );
-        String oid = getOid( entry );
-        
-        if ( registries.getSyntaxCheckerRegistry().contains( oid ) )
-        {
-            throw new LdapNamingException( "Oid " + oid + " for new schema syntaxChecker is not unique.", 
-                ResultCodeEnum.OTHER );
-        }
-        
-        SyntaxChecker syntaxChecker = factory.getSyntaxChecker( entry, registries );
 
+        // The parent DN must be ou=syntaxcheckers,cn=<schemaName>,ou=schema
+        checkParent( parentDn, syntaxCheckerRegistry, SchemaConstants.SYNTAX_CHECKER );
+
+        // The new schemaObject's OID must not already exist
+        checkOidIsUniqueForSyntaxChecker( entry );
+        
+        // Build the new SyntaxChecker from the given entry
         String schemaName = getSchemaName( dn );
-        syntaxChecker.setSchemaName( schemaName );
+        
+        SyntaxChecker syntaxChecker = factory.getSyntaxChecker( entry, registries, schemaName );
 
         addToSchema( syntaxChecker, schemaName );
 
@@ -129,23 +133,35 @@
      */
     public void delete( ServerEntry entry, boolean cascade ) throws Exception
     {
-        String oid = getOid( entry );
+        LdapDN dn = entry.getDn();
+        LdapDN parentDn = ( LdapDN ) dn.clone();
+        parentDn.remove( parentDn.size() - 1 );
         
-        if ( ldapSyntaxRegistry.contains( oid ) )
+        // The parent DN must be ou=syntaxcheckers,cn=<schemaName>,ou=schema
+        checkParent( parentDn, syntaxCheckerRegistry, SchemaConstants.SYNTAX_CHECKER );
+
+        // Get the SyntaxChecker's instance
+        String schemaName = getSchemaName( entry.getDn() );
+        SyntaxChecker syntaxChecker = factory.getSyntaxChecker( entry, registries, schemaName );
+        
+        String oid = syntaxChecker.getOid();
+        
+        if ( isSchemaEnabled( schemaName ) )
         {
-            String msg = "The syntaxChecker with OID " + oid 
-                + " cannot be deleted until all " 
-                + "syntaxes using this syntaxChecker have also been deleted.";
-            throw new LdapOperationNotSupportedException( msg, 
-                ResultCodeEnum.UNWILLING_TO_PERFORM );
+            if ( registries.isReferenced( syntaxChecker ) )
+            {
+                String msg = "Cannot delete " + entry.getDn().getUpName() + ", as there are some " +
+                " dependant SchemaObjects :\n" + getReferenced( syntaxChecker );
+            LOG.warn( msg );
+            throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+            }
         }
         
-        String schemaName = getSchemaName( entry.getDn() );
-
-        SyntaxChecker syntaxChecker = factory.getSyntaxChecker( entry, registries );
+        // Remove the SyntaxChecker from the schema content
         deleteFromSchema( syntaxChecker, schemaName );
 
-        if ( isSchemaEnabled( schemaName ) )
+        // Update the Registries now
+        if ( syntaxCheckerRegistry.contains( oid ) )
         {
             syntaxCheckerRegistry.unregister( oid );
             LOG.debug( "Removed {} from the enabled schema {}", syntaxChecker, schemaName );
@@ -186,7 +202,7 @@
         
         if ( isSchemaEnabled( schemaName ) )
         {
-            SyntaxChecker syntaxChecker = factory.getSyntaxChecker( targetEntry, registries );
+            SyntaxChecker syntaxChecker = factory.getSyntaxChecker( targetEntry, registries, schemaName );
             syntaxCheckerRegistry.unregister( oldOid );
             syntaxCheckerRegistry.register( syntaxChecker );
         }
@@ -212,6 +228,7 @@
         ServerEntry targetEntry = ( ServerEntry ) entry.clone();
         
         String newOid = ( String ) newRdn.getValue();
+        
         if ( registries.getSyntaxCheckerRegistry().contains( newOid ) )
         {
             throw new LdapNamingException( "Oid " + newOid + " for new schema syntaxChecker is not unique.", 
@@ -219,7 +236,7 @@
         }
 
         targetEntry.put( MetaSchemaConstants.M_OID_AT, newOid );
-        SyntaxChecker syntaxChecker = factory.getSyntaxChecker( targetEntry, registries );
+        SyntaxChecker syntaxChecker = factory.getSyntaxChecker( targetEntry, registries, newSchemaName );
 
         if ( isSchemaEnabled( oldSchemaName ) )
         {
@@ -249,7 +266,7 @@
                 ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
-        SyntaxChecker syntaxChecker = factory.getSyntaxChecker( entry, registries );
+        SyntaxChecker syntaxChecker = factory.getSyntaxChecker( entry, registries, newSchemaName );
         
         if ( isSchemaEnabled( oldSchemaName ) )
         {
@@ -263,6 +280,18 @@
     }
     
     
+    private void checkOidIsUniqueForSyntaxChecker( ServerEntry entry ) throws Exception
+    {
+        String oid = getOid( entry );
+        
+        if ( registries.getNormalizerRegistry().contains( oid ) )
+        {
+            throw new LdapNamingException( "Oid " + oid + " for new schema SyntaxChecker is not unique.", 
+                ResultCodeEnum.OTHER );
+        }
+    }
+
+    
     private void checkNewParent( LdapDN newParent ) throws NamingException
     {
         if ( newParent.size() != 3 )

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxSynchronizer.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxSynchronizer.java Fri Oct  9 00:03:45 2009
@@ -26,6 +26,7 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
 import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
@@ -41,6 +42,7 @@
 import org.apache.directory.shared.ldap.schema.registries.LdapSyntaxRegistry;
 import org.apache.directory.shared.ldap.schema.registries.MatchingRuleRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.schema.registries.Schema;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -75,8 +77,13 @@
     }
 
     
-    public boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean cascade ) throws Exception
+    /**
+     * {@inheritDoc}
+     */
+    public boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry, boolean cascade ) throws Exception
     {
+        LdapDN name = opContext.getDn();
+        ServerEntry entry = opContext.getEntry();
         String oid = getOid( entry );
         LdapSyntax syntax = factory.getSyntax( targetEntry, registries, getSchemaName( name ) );
         String schemaName = getSchemaName( entry.getDn() );
@@ -101,16 +108,34 @@
         LdapDN dn = entry.getDn();
         LdapDN parentDn = ( LdapDN ) dn.clone();
         parentDn.remove( parentDn.size() - 1 );
-        checkNewParent( parentDn );
+
+        // The parent DN must be ou=syntaxes,cn=<schemaName>,ou=schema
+        checkParent( parentDn, syntaxRegistry, SchemaConstants.SYNTAX );
+
+        // The new schemaObject's OID must not already exist
         checkOidIsUnique( entry );
         
+        // Build the new Syntax from the given entry
         String schemaName = getSchemaName( dn );
         LdapSyntax syntax = factory.getSyntax( entry, registries, schemaName );
 
+        // Applies the Registrie sto this Syntax 
+        Schema schema = registries.getLoadedSchema( schemaName );
+
+        if ( schema.isEnabled() && syntax.isEnabled() )
+        {
+            syntax.applyRegistries( registries );
+        }
+        
+        // Associates this Syntax with the schema
         addToSchema( syntax, schemaName );
 
+        // Don't inject the modified element if the schema is disabled
         if ( isSchemaEnabled( schemaName ) )
         {
+            // Update the using table, as a Syntax is associated with a SyntaxChecker
+            registries.addReference( syntax, syntax.getSyntaxChecker() );
+
             syntaxRegistry.register( syntax );
             LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName );
         }
@@ -183,29 +208,40 @@
      */
     public void delete( ServerEntry entry, boolean cascade ) throws Exception
     {
-        String oid = getOid( entry );
+        LdapDN dn = entry.getDn();
+        LdapDN parentDn = ( LdapDN ) dn.clone();
+        parentDn.remove( parentDn.size() - 1 );
+        
+        // The parent DN must be ou=syntaxes,cn=<schemaName>,ou=schema
+        checkParent( parentDn, syntaxRegistry, SchemaConstants.SYNTAX );
+        
+        // Get the Syntax from the given entry ( it has been grabbed from the server earlier)
         String schemaName = getSchemaName( entry.getDn() );
         LdapSyntax syntax = factory.getSyntax( entry, registries, schemaName );
         
-        // Check that this syntax is not used by an AttributeType
-        List<SchemaObject> dependees = checkInUse( oid );
+        String oid = syntax.getOid();
         
-        if ( dependees.size() != 0 )
+        if ( isSchemaEnabled( schemaName ) )
         {
-            String msg = "The syntax with OID " + oid 
-                + " cannot be deleted until all entities" 
-                + " using this syntax have also been deleted.  The following dependees exist: " 
-                + getNames( dependees );
-            LOG.warn(  msg  );
-            throw new LdapOperationNotSupportedException( msg, 
-              ResultCodeEnum.UNWILLING_TO_PERFORM );
+            if ( registries.isReferenced( syntax ) )
+            {
+                String msg = "Cannot delete " + entry.getDn().getUpName() + ", as there are some " +
+                    " dependant SchemaObjects :\n" + getReferenced( syntax );
+                LOG.warn( msg );
+                throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+            }
         }
         
         deleteFromSchema( syntax, schemaName );
 
-        if ( isSchemaEnabled( schemaName ) )
+        if ( syntaxRegistry.contains( oid ) )
         {
             syntaxRegistry.unregister( oid );
+            
+            // Now, update the references.
+            // The SyntaxChecker
+            registries.delReference( syntax.getSyntaxChecker(), syntax );
+            
             LOG.debug( "Removed {} from the enabled schema {}", syntax, schemaName );
         }
         else

Modified: directory/apacheds/branches/apacheds-schema/core-constants/src/main/java/org/apache/directory/server/constants/ServerDNConstants.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-constants/src/main/java/org/apache/directory/server/constants/ServerDNConstants.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-constants/src/main/java/org/apache/directory/server/constants/ServerDNConstants.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-constants/src/main/java/org/apache/directory/server/constants/ServerDNConstants.java Fri Oct  9 00:03:45 2009
@@ -54,10 +54,10 @@
     public static final String CN_SCHEMA_DN_NORMALIZED      = "2.5.4.3=schema";
    
     /** the DN for the schema in dit area */
-    public static final String OU_SCHEMA_DN                 = "ou=schema";
+    //public static final String OU_SCHEMA_DN                 = "ou=schema";
 
     /** the normalized DN for the schema in DIT area */
-    public static final String OU_SCHEMA_DN_NORMALIZED      = "2.5.4.11=schema";
+    //public static final String OU_SCHEMA_DN_NORMALIZED      = "2.5.4.11=schema";
     
     /** The DN for the schema modifications */
     public static final String SCHEMA_MODIFICATIONS_DN      = "cn=schemaModifications,ou=schema";

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java Fri Oct  9 00:03:45 2009
@@ -570,7 +570,7 @@
     {
         ServerAttribute attr = new DefaultServerAttribute( atCN );
         
-        // No value, this should be valid
+        // No value, this should not be valid
         assertFalse( attr.isValid() );
         
         attr.add( "test", "test2", "A123\\;" );

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java Fri Oct  9 00:03:45 2009
@@ -36,7 +36,7 @@
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.comparators.ByteArrayComparator;
-import org.apache.directory.shared.ldap.schema.syntaxCheckers.AcceptAllSyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntaxCheckers.OctetStringSyntaxChecker;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 import static org.junit.Assert.assertEquals;
@@ -79,7 +79,7 @@
     @Before public void initAT()
     {
         s = TestServerEntryUtils.syntaxFactory( "1.1.1.1", false );
-        s.setSyntaxChecker( new AcceptAllSyntaxChecker( "1.1.1.1" ) );
+        s.setSyntaxChecker( new OctetStringSyntaxChecker() );
         mr = TestServerEntryUtils.matchingRuleFactory( "1.1.2.1" );
         mr.setSyntax( s );
         

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java Fri Oct  9 00:03:45 2009
@@ -47,7 +47,7 @@
 import org.apache.directory.shared.ldap.schema.comparators.StringComparator;
 import org.apache.directory.shared.ldap.schema.normalizers.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.schema.normalizers.NoOpNormalizer;
-import org.apache.directory.shared.ldap.schema.syntaxCheckers.AcceptAllSyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntaxCheckers.OctetStringSyntaxChecker;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -79,7 +79,7 @@
     @Before public void initAT()
     {
         s = new TestServerEntryUtils.S( "1.1.1.1", false );
-        s.setSyntaxChecker( new AcceptAllSyntaxChecker( "1.1.1.1" ) );
+        s.setSyntaxChecker( new OctetStringSyntaxChecker() );
         mr = new TestServerEntryUtils.MR( "1.1.2.1" );
         mr.setSyntax( s );
         mr.setLdapComparator( new StringComparator() );

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java Fri Oct  9 00:03:45 2009
@@ -39,6 +39,7 @@
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.jndi.ServerLdapContext;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
 import org.apache.directory.shared.ldap.ldif.ChangeType;
@@ -184,7 +185,7 @@
 
     public static LdapContext getSchemaContext( DirectoryService service ) throws Exception
     {
-        return getContext( ServerDNConstants.ADMIN_SYSTEM_DN, service, ServerDNConstants.OU_SCHEMA_DN );
+        return getContext( ServerDNConstants.ADMIN_SYSTEM_DN, service, SchemaConstants.OU_SCHEMA );
     }
 
 

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java Fri Oct  9 00:03:45 2009
@@ -20,23 +20,14 @@
 package org.apache.directory.server.core.operational;
 
 
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.entry.DefaultServerEntry;
-import org.apache.directory.server.core.integ.CiRunner;
 import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext;
 import static org.apache.directory.server.core.integ.IntegrationUtils.getUserAddLdif;
-import org.apache.directory.shared.ldap.constants.JndiPropertyConstants;
-import org.apache.directory.shared.ldap.ldif.LdifEntry;
-import org.apache.directory.shared.ldap.message.AliasDerefMode;
-import org.apache.directory.shared.ldap.util.StringTools;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import org.junit.Test;
-import org.junit.runner.RunWith;
 
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
@@ -52,6 +43,17 @@
 import javax.naming.directory.SearchResult;
 import javax.naming.ldap.LdapContext;
 
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.integ.CiRunner;
+import org.apache.directory.shared.ldap.constants.JndiPropertyConstants;
+import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
+import org.apache.directory.shared.ldap.ldif.LdifEntry;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
 
 /**
  * Tests the methods on JNDI contexts that are analogous to entry modify
@@ -369,29 +371,19 @@
      *
      * @throws NamingException on error
      */
-    @Test
+    @Test( expected=LdapSchemaViolationException.class )
     public void testModifyOperationalAttributeAdd() throws Exception
     {
         LdapContext sysRoot = getSystemContext( service );
         createData( sysRoot );
 
-        ModificationItem modifyOp = new ModificationItem( DirContext.ADD_ATTRIBUTE, new BasicAttribute(
+        ModificationItem modifyOp = new ModificationItem( DirContext.ADD_ATTRIBUTE, 
+            new BasicAttribute(
             "modifiersName", "cn=Tori Amos,dc=example,dc=com" ) );
 
-        try
-        {
-            sysRoot.modifyAttributes( RDN_KATE_BUSH, new ModificationItem[]
-                { modifyOp } );
-            fail( "modification of entry should fail" );
-        }
-        catch ( InvalidAttributeValueException e )
-        {
-            // expected
-        }
-        catch ( NoPermissionException e )
-        {
-            // expected
-        }
+        sysRoot.modifyAttributes( RDN_KATE_BUSH, new ModificationItem[]
+            { modifyOp } );
+        fail( "modification of entry should fail" );
     }
 
 

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operations/compare/CompareDirserver1139IT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operations/compare/CompareDirserver1139IT.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operations/compare/CompareDirserver1139IT.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operations/compare/CompareDirserver1139IT.java Fri Oct  9 00:03:45 2009
@@ -20,13 +20,15 @@
 package org.apache.directory.server.core.operations.compare;
 
 import static org.apache.directory.server.core.integ.IntegrationUtils.getSchemaContext;
-
+import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import javax.naming.NamingEnumeration;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.ModificationItem;
 import javax.naming.directory.SearchControls;
@@ -37,15 +39,11 @@
 import org.apache.directory.server.core.integ.CiRunner;
 import org.apache.directory.server.core.integ.Level;
 import org.apache.directory.server.core.integ.annotations.CleanupLevel;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
-
-import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 
 
 /**
@@ -96,7 +94,7 @@
         Attributes krb5kdcAttrs = schemaRoot.getAttributes( "cn=krb5kdc" );
         boolean isKrb5kdcDisabled = false;
         
-        if ( nisAttrs.get( "m-disabled" ) != null )
+        if ( krb5kdcAttrs.get( "m-disabled" ) != null )
         {
             isKrb5kdcDisabled = ( ( String ) krb5kdcAttrs.get( "m-disabled" ).get() ).equalsIgnoreCase( "TRUE" );
         }
@@ -118,39 +116,35 @@
     private void injectEntries( LdapContext sysRoot ) throws Exception
     {
         // Add the group
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "ObjectClass" );
-        oc.add( "groupOfNames" );
-        oc.add( "top" );
-        attrs.put( oc );
-        attrs.put( "cn", "group" );
-        attrs.put( "member", "cn=user,ou=users,ou=system" );
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "ObjectClass: top",
+            "ObjectClass: groupOfNames",
+            "cn: group",
+            "member: cn=user,ou=users,ou=system" );
         
         sysRoot.createSubcontext( "cn=group,ou=groups", attrs );
         
         // Add the user
-        attrs = new BasicAttributes( "objectClass", "top", true );
-        oc = new BasicAttribute( "ObjectClass" );
-        oc.add( "top" );
-        oc.add( "organizationalPerson" );
-        oc.add( "person" );
-        oc.add( "krb5Principal" );
-        oc.add( "posixAccount" );
-        oc.add( "shadowAccount" );
-        oc.add( "krb5KDCEntry" );
-        oc.add( "inetOrgPerson" );
-        attrs.put( oc );
-        attrs.put( "cn", "user" );
-        attrs.put( "gidnumber", "100" );
-        attrs.put( "givenname", "user" );
-        attrs.put( "homedirectory", "/home/users/user" );
-        attrs.put( "krb5KeyVersionNumber", "1" );
-        attrs.put( "krb5PrincipalName", "user@APACHE.ORG" );
-        attrs.put( "loginshell", "/bin/bash" );
-        attrs.put( "mail", "user@apache.org" );
-        attrs.put( "sn", "User" );
-        attrs.put( "uid", "user" );
-        attrs.put( "uidnumber", "1001" );
+        attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: organizationalPerson",
+            "objectClass: person",
+            "objectClass: krb5Principal",
+            "objectClass: posixAccount",
+            "objectClass: shadowAccount",
+            "objectClass: krb5KDCEntry",
+            "objectClass: inetOrgPerson",
+            "cn: user",
+            "gidnumber: 100",
+            "givenname: user",
+            "homedirectory: /home/users/user",
+            "krb5KeyVersionNumber: 1",
+            "krb5PrincipalName: user@APACHE.ORG",
+            "loginshell: /bin/bash",
+            "mail: user@apache.org",
+            "sn: User",
+            "uid: user",
+            "uidnumber: 1001" );
         
         sysRoot.createSubcontext( "cn=user,ou=users", attrs );
     }

Added: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandlerIT.java?rev=823360&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandlerIT.java (added)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandlerIT.java Fri Oct  9 00:03:45 2009
@@ -0,0 +1,88 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.schema;
+
+import java.io.File;
+import java.util.Enumeration;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.BeforeClass;
+
+/**
+ * A common class for all the MetaXXXHandler test classes
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class AbstractMetaSchemaObjectHandlerIT
+{
+    protected static String workingDir;
+
+    @BeforeClass
+    public static final void init()
+    {
+        String path = AbstractMetaSchemaObjectHandlerIT.class.getResource( "" ).getPath();
+        int targetPos = path.indexOf( "target" );
+        workingDir = path.substring( 0, targetPos + 6 ) + "/server-work/schema";
+    }
+    
+    
+    /**
+     * Get the path on disk where a specific SchemaObject is stored
+     *
+     * @param dn the SchemaObject DN
+     */
+    protected String getSchemaPath( LdapDN dn )
+    {
+        StringBuilder sb = new StringBuilder();
+        
+        sb.append( workingDir ).append( '/' ).append( "ou=schema" );
+        
+        Enumeration<Rdn> rdns = dn.getAllRdn();
+        
+        while ( rdns.hasMoreElements() )
+        {
+            sb.append( '/' );
+            sb.append( StringTools.toLowerCase( rdns.nextElement().getUpName() ) );
+        }
+        
+        sb.append( ".ldif" );
+        
+        return sb.toString();
+    }
+
+    
+    /**
+     * Check that a specific SchemaObject is stored on the disk at the
+     * correct position in the Ldif partition
+     *
+     * @param dn The SchemaObject DN
+     */
+    protected boolean isOnDisk( LdapDN dn )
+    {
+        String schemaObjectFileName = StringTools.toLowerCase( getSchemaPath( dn ) );
+
+        File file = new File( schemaObjectFileName );
+        
+        return file.exists();
+    }
+}

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java Fri Oct  9 00:03:45 2009
@@ -61,7 +61,7 @@
  */
 @RunWith ( CiRunner.class )
 @CleanupLevel( Level.CLASS )
-public class MetaAttributeTypeHandlerIT
+public class MetaAttributeTypeHandlerIT extends AbstractMetaSchemaObjectHandlerIT
 {
     private static final String DESCRIPTION0 = "A test attributeType";
     private static final String DESCRIPTION1 = "An alternate description";
@@ -70,9 +70,12 @@
     private static final String NEW_OID = "1.3.6.1.4.1.18060.0.4.0.2.100001";
     private static final String DEPENDEE_OID = "1.3.6.1.4.1.18060.0.4.0.2.100002";
 
-
     public static DirectoryService service;
 
+    protected static AttributeTypeRegistry getAttributeTypeRegistry()
+    {
+        return service.getRegistries().getAttributeTypeRegistry();
+    }
     
     /**
      * Gets relative DN to ou=schema.
@@ -87,19 +90,13 @@
     }
 
 
-    private static AttributeTypeRegistry getAttributeTypeRegistry()
-    {
-        return service.getRegistries().getAttributeTypeRegistry();
-    }
-    
-    
     // ----------------------------------------------------------------------
     // Test all core methods with normal operational pathways
     // ----------------------------------------------------------------------
 
     
     @Test
-    public void testAddAttributeType() throws Exception
+    public void testAddAttributeTypeToEnabledSchema() throws Exception
     {
         Attributes attrs = AttributeUtils.createAttributes( 
             "objectClass: top",
@@ -118,37 +115,90 @@
         
         assertTrue( service.getRegistries().getAttributeTypeRegistry().contains( OID ) );
         assertEquals( getAttributeTypeRegistry().getSchemaName( OID ), "apachemeta" );
+        assertTrue( isOnDisk( dn ) );
+    }
+    
+    
+    @Test
+    public void testAddAttributeTypeToDisabledSchema() throws Exception
+    {
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaAttributeType",
+            "m-oid:" + OID,
+            "m-syntax:" + SchemaConstants.INTEGER_SYNTAX,
+            "m-description:" + DESCRIPTION0,
+            "m-equality: caseIgnoreMatch",
+            "m-singleValue: FALSE",
+            "m-usage: directoryOperation" );
+
+        LdapDN dn = getAttributeTypeContainer( "nis" );
+        dn.add( "m-oid=" + OID );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertFalse( "adding new attributeType to disabled schema should not register it into the registries", 
+            getAttributeTypeRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
     }
     
     
     @Test
-    public void testDeleteAttributeType() throws Exception
+    public void testDeleteAttributeTypeFromEnabledSchema() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
 
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
         dn.add( "m-oid=" + OID );
+
+        // Check in Registries
+        assertTrue( "attributeType should be removed from the registry after being deleted", 
+            getAttributeTypeRegistry().contains( OID ) );
+
+        // Check on disk that the added SchemaObject exist
+        assertTrue( isOnDisk( dn ) );
         
         getSchemaContext( service ).destroySubcontext( dn );
 
+        // Check in Registries
         assertFalse( "attributeType should be removed from the registry after being deleted", 
             getAttributeTypeRegistry().contains( OID ) );
         
-        try
-        {
-            getAttributeTypeRegistry().lookup( OID );
-            fail( "attributeType lookup should fail after deleting it" );
-        }
-        catch( NamingException e )
-        {
-        }
+        // Check on disk that the deleted SchemaObject does not exist anymore
+        assertFalse( isOnDisk( dn ) );
+    }
+    
+    
+    @Test
+    public void testDeleteAttributeTypeFromDisabledSchema() throws Exception
+    {
+        testAddAttributeTypeToDisabledSchema();
+
+        LdapDN dn = getAttributeTypeContainer( "nis" );
+        dn.add( "m-oid=" + OID );
+
+        // Check in Registries
+        assertFalse( "attributeType should be removed from the registry after being deleted", 
+            getAttributeTypeRegistry().contains( OID ) );
+
+        // Check on disk that the added SchemaObject exist
+        assertTrue( isOnDisk( dn ) );
+        
+        getSchemaContext( service ).destroySubcontext( dn );
+
+        // Check in Registries
+        assertFalse( "attributeType should be removed from the registry after being deleted", 
+            getAttributeTypeRegistry().contains( OID ) );
+        
+        // Check on disk that the deleted SchemaObject does not exist anymore
+        assertFalse( isOnDisk( dn ) );
     }
 
 
     @Test
     public void testRenameAttributeType() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
 
         LdapContext schemaRoot = getSchemaContext( service );
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
@@ -178,7 +228,7 @@
     @Ignore
     public void testMoveAttributeType() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
         
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
         dn.add( "m-oid=" + OID );
@@ -200,7 +250,7 @@
     @Ignore
     public void testMoveAttributeTypeAndChangeRdn() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
         
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
         dn.add( "m-oid=" + OID );
@@ -224,7 +274,7 @@
     @Test
     public void testModifyAttributeTypeWithModificationItems() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
         
         AttributeType at = getAttributeTypeRegistry().lookup( OID );
         assertEquals( at.getDescription(), DESCRIPTION0 );
@@ -255,7 +305,7 @@
     @Test
     public void testModifyAttributeTypeWithAttributes() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
         
         AttributeType at = getAttributeTypeRegistry().lookup( OID );
         assertEquals( at.getDescription(), DESCRIPTION0 );
@@ -313,7 +363,7 @@
     @Test
     public void testDeleteAttributeTypeWhenInUse() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
 
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
         dn.add( "m-oid=" + OID );
@@ -338,7 +388,7 @@
     @Ignore
     public void testMoveAttributeTypeWhenInUse() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
         addDependeeAttributeType();
         
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
@@ -366,7 +416,7 @@
     @Ignore
     public void testMoveAttributeTypeAndChangeRdnWhenInUse() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
         addDependeeAttributeType();
         
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
@@ -393,7 +443,7 @@
     @Test
     public void testRenameAttributeTypeWhenInUse() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
 
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
         dn.add( "m-oid=" + OID );
@@ -426,7 +476,7 @@
     @Ignore
     public void testMoveAttributeTypeToTop() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
         
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
         dn.add( "m-oid=" + OID );
@@ -453,7 +503,7 @@
     @Ignore
     public void testMoveAttributeTypeToComparatorContainer() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
         
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
         dn.add( "m-oid=" + OID );
@@ -477,34 +527,10 @@
     
     
     @Test
-    public void testAddAttributeTypeToDisabledSchema() throws Exception
-    {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaAttributeType" );
-        attrs.put( oc );
-        attrs.put( "m-oid", OID );
-        attrs.put( "m-syntax", SchemaConstants.INTEGER_SYNTAX );
-        attrs.put( "m-description", DESCRIPTION0 );
-        attrs.put( "m-equality", "caseIgnoreMatch" );
-        attrs.put( "m-singleValue", "FALSE" );
-        attrs.put( "m-usage", "directoryOperation" );
-        
-        LdapDN dn = getAttributeTypeContainer( "nis" );
-        dn.add( "m-oid=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
-        
-        assertFalse( "adding new attributeType to disabled schema should not register it into the registries", 
-            getAttributeTypeRegistry().contains( OID ) );
-    }
-
-
-    @Test
     @Ignore
     public void testMoveAttributeTypeToDisabledSchema() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
         
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
         dn.add( "m-oid=" + OID );

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java Fri Oct  9 00:03:45 2009
@@ -41,8 +41,6 @@
 import org.apache.directory.server.core.integ.CiRunner;
 import org.apache.directory.server.core.integ.Level;
 import org.apache.directory.server.core.integ.annotations.CleanupLevel;
-import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
-import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
 import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
@@ -53,6 +51,7 @@
 import org.apache.directory.shared.ldap.schema.registries.ComparatorRegistry;
 import org.apache.directory.shared.ldap.schema.registries.MatchingRuleRegistry;
 import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -67,14 +66,14 @@
  */
 @RunWith ( CiRunner.class )
 @CleanupLevel( Level.CLASS )
-public class MetaComparatorHandlerIT
+public class MetaComparatorHandlerIT extends AbstractMetaSchemaObjectHandlerIT
 {
     private static final String OID = "1.3.6.1.4.1.18060.0.4.0.1.100000";
     private static final String NEW_OID = "1.3.6.1.4.1.18060.0.4.0.1.100001";
 
 
     public static DirectoryService service;
-
+    
     
     /**
      * Gets relative DN to ou=schema.
@@ -110,33 +109,53 @@
     // ----------------------------------------------------------------------
     // Test all core methods with normal operational pathways
     // ----------------------------------------------------------------------
-
-
     @Test
-    public void testAddComparator() throws Exception
+    public void testAddComparatorToEnabledSchema() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( SchemaConstants.OBJECT_CLASS_AT, "top" );
-        oc.add( MetaSchemaConstants.META_TOP_OC );
-        oc.add( MetaSchemaConstants.META_COMPARATOR_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_FQCN_AT, StringComparator.class.getName() );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test comparator" );
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaComparator",
+            "m-fqcn: " + StringComparator.class.getName(),
+            "m-oid: " + OID,
+            "m-description: A test comparator" );
         
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
         getSchemaContext( service ).createSubcontext( dn, attrs );
         
         assertTrue( getComparatorRegistry().contains( OID ) );
         assertEquals( getComparatorRegistry().getSchemaName( OID ), "apachemeta" );
         Class<?> clazz = getComparatorRegistry().lookup( OID ).getClass();
         assertEquals( clazz, StringComparator.class );
+        assertTrue( isOnDisk( dn ) );
     }
     
 
     @Test
-    public void testAddComparatorWithByteCode() throws Exception
+    public void testAddComparatorToDisabledSchema() throws Exception
+    {
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaComparator",
+            "m-fqcn: " + StringComparator.class.getName(),
+            "m-oid: " + OID,
+            "m-description: A test comparator" );
+        
+        // nis is by default inactive
+        LdapDN dn = getComparatorContainer( "nis" );
+        dn.add( "m-oid" + "=" + OID );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertFalse( "adding new comparator to disabled schema should not register it into the registries", 
+            getComparatorRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
+    }
+
+
+    @Test
+    public void testAddComparatorWithByteCodeToEnabledSchema() throws Exception
     {
         InputStream in = getClass().getResourceAsStream( "DummyComparator.bytecode" );
         ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -146,33 +165,68 @@
             out.write( in.read() );
         }
         
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( SchemaConstants.OBJECT_CLASS_AT, "top" );
-        oc.add( MetaSchemaConstants.META_TOP_OC );
-        oc.add( MetaSchemaConstants.META_COMPARATOR_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_FQCN_AT, "org.apache.directory.shared.ldap.schema.comparators.DummyComparator" );
-        attrs.put( MetaSchemaConstants.M_BYTECODE_AT, out.toByteArray() );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test comparator" );
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaComparator",
+            "m-fqcn: org.apache.directory.shared.ldap.schema.comparators.DummyComparator",
+            "m-bytecode", out.toByteArray(),
+            "m-oid", OID,
+            "m-description: A test comparator" );
         
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
         getSchemaContext( service ).createSubcontext( dn, attrs );
         
         assertTrue( getComparatorRegistry().contains( OID ) );
         assertEquals( getComparatorRegistry().getSchemaName( OID ), "apachemeta" );
         Class<?> clazz = getComparatorRegistry().lookup( OID ).getClass();
         assertEquals( clazz.getName(), "org.apache.directory.shared.ldap.schema.comparators.DummyComparator" );
+        assertTrue( isOnDisk( dn ) );
+    }
+    
+
+    @Test
+    public void testAddComparatorWithByteCodeToDisabledSchema() throws Exception
+    {
+        InputStream in = getClass().getResourceAsStream( "DummyComparator.bytecode" );
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        
+        while ( in.available() > 0 )
+        {
+            out.write( in.read() );
+        }
+        
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaComparator",
+            "m-fqcn: org.apache.directory.shared.ldap.schema.comparators.DummyComparator",
+            "m-bytecode", out.toByteArray(),
+            "m-oid", OID,
+            "m-description: A test comparator" );
+        
+        // nis is by default inactive
+        LdapDN dn = getComparatorContainer( "nis" );
+        dn.add( "m-oid" + "=" + OID );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertFalse( "adding new comparator to disabled schema should not register it into the registries", 
+            getComparatorRegistry().contains( OID ) );
+
+        assertTrue( isOnDisk( dn ) );
     }
     
 
     @Test
-    public void testDeleteComparator() throws Exception
+    public void testDeleteComparatorFromEnabledSchema() throws Exception
     {
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddComparator();
+        dn.add( "m-oid" + "=" + OID );
+        testAddComparatorToEnabledSchema();
+        
+        assertTrue( getComparatorRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
         
         getSchemaContext( service ).destroySubcontext( dn );
 
@@ -187,6 +241,37 @@
         catch( NamingException e )
         {
         }
+        
+        assertFalse( isOnDisk( dn ) );
+    }
+
+
+    @Test
+    public void testDeleteComparatorFromDisabledSchema() throws Exception
+    {
+        LdapDN dn = getComparatorContainer( "nis" );
+        dn.add( "m-oid" + "=" + OID );
+        testAddComparatorToDisabledSchema();
+
+        assertFalse( "comparator should be removed from the registry after being deleted", 
+            getComparatorRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
+        
+        getSchemaContext( service ).destroySubcontext( dn );
+
+        assertFalse( "comparator should be removed from the registry after being deleted", 
+            getComparatorRegistry().contains( OID ) );
+        
+        try
+        {
+            getComparatorRegistry().lookup( OID );
+            fail( "comparator lookup should fail after deleting the comparator" );
+        }
+        catch( NamingException e )
+        {
+        }
+        
+        assertFalse( isOnDisk( dn ) );
     }
 
 
@@ -194,11 +279,11 @@
     public void testRenameComparator() throws Exception
     {
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddComparator();
+        dn.add( "m-oid" + "=" + OID );
+        testAddComparatorToEnabledSchema();
         
         LdapDN newdn = getComparatorContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         getSchemaContext( service ).rename( dn, newdn );
 
         assertFalse( "old comparator OID should be removed from the registry after being renamed", 
@@ -223,13 +308,13 @@
     @Ignore
     public void testMoveComparator() throws Exception
     {
-        testAddComparator();
+        testAddComparatorToEnabledSchema();
         
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = getComparatorContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
@@ -248,13 +333,13 @@
     @Ignore
     public void testMoveComparatorAndChangeRdn() throws Exception
     {
-        testAddComparator();
+        testAddComparatorToEnabledSchema();
         
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = getComparatorContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
@@ -275,13 +360,13 @@
     @Test
     public void testModifyComparatorWithModificationItems() throws Exception
     {
-        testAddComparator();
+        testAddComparatorToEnabledSchema();
         
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
         
         ModificationItem[] mods = new ModificationItem[1];
-        Attribute attr = new BasicAttribute( MetaSchemaConstants.M_FQCN_AT, BooleanComparator.class.getName() );
+        Attribute attr = new BasicAttribute( "m-fqcn", BooleanComparator.class.getName() );
         mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
         getSchemaContext( service ).modifyAttributes( dn, mods );
 
@@ -299,13 +384,13 @@
     @Test
     public void testModifyComparatorWithAttributes() throws Exception
     {
-        testAddComparator();
+        testAddComparatorToEnabledSchema();
         
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
         
         Attributes mods = new BasicAttributes( true );
-        mods.put( MetaSchemaConstants.M_FQCN_AT, BooleanComparator.class.getName() );
+        mods.put( "m-fqcn", BooleanComparator.class.getName() );
         getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
 
         assertTrue( "comparator OID should still be present", 
@@ -328,8 +413,8 @@
     public void testDeleteComparatorWhenInUse() throws Exception
     {
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddComparator();
+        dn.add( "m-oid" + "=" + OID );
+        testAddComparatorToEnabledSchema();
         getMatchingRuleRegistry().register( new DummyMR() );
         
         try
@@ -353,14 +438,14 @@
     @Ignore
     public void testMoveComparatorWhenInUse() throws Exception
     {
-        testAddComparator();
+        testAddComparatorToEnabledSchema();
         getMatchingRuleRegistry().register( new DummyMR() );
         
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = getComparatorContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         try
         {
@@ -383,14 +468,14 @@
     @Ignore
     public void testMoveComparatorAndChangeRdnWhenInUse() throws Exception
     {
-        testAddComparator();
+        testAddComparatorToEnabledSchema();
         getMatchingRuleRegistry().register( new DummyMR() );
         
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = getComparatorContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         
         try
         {
@@ -413,12 +498,12 @@
     public void testRenameComparatorWhenInUse() throws Exception
     {
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddComparator();
+        dn.add( "m-oid" + "=" + OID );
+        testAddComparatorToEnabledSchema();
         getMatchingRuleRegistry().register( new DummyMR() );
         
         LdapDN newdn = getComparatorContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         
         try
         {
@@ -446,13 +531,13 @@
     @Ignore
     public void testMoveComparatorToTop() throws Exception
     {
-        testAddComparator();
+        testAddComparatorToEnabledSchema();
         
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN top = new LdapDN();
-        top.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        top.add( "m-oid" + "=" + OID );
         
         try
         {
@@ -473,13 +558,13 @@
     @Ignore
     public void testMoveComparatorToNormalizers() throws Exception
     {
-        testAddComparator();
+        testAddComparatorToEnabledSchema();
         
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = new LdapDN( "ou=normalizers,cn=apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         try
         {
@@ -497,39 +582,17 @@
     
     
     @Test
-    public void testAddComparatorToDisabledSchema() throws Exception
-    {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( SchemaConstants.OBJECT_CLASS_AT, "top" );
-        oc.add( MetaSchemaConstants.META_TOP_OC );
-        oc.add( MetaSchemaConstants.META_COMPARATOR_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_FQCN_AT, StringComparator.class.getName() );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test comparator" );
-        
-        // nis is by default inactive
-        LdapDN dn = getComparatorContainer( "nis" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
-        
-        assertFalse( "adding new comparator to disabled schema should not register it into the registries", 
-            getComparatorRegistry().contains( OID ) );
-    }
-
-
-    @Test
     @Ignore
     public void testMoveComparatorToDisabledSchema() throws Exception
     {
-        testAddComparator();
+        testAddComparatorToEnabledSchema();
         
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         // nis is inactive by default
         LdapDN newdn = getComparatorContainer( "nis" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
@@ -546,13 +609,13 @@
         
         // nis is inactive by default
         LdapDN dn = getComparatorContainer( "nis" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         assertFalse( "comparator OID should NOT be present when added to disabled nis schema", 
             getComparatorRegistry().contains( OID ) );
 
         LdapDN newdn = getComparatorContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 



Mime
View raw message