directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r823360 [3/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-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.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/MetaMatchingRuleHandlerIT.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java Fri Oct  9 00:03:45 2009
@@ -38,13 +38,13 @@
 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.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.registries.MatchingRuleRegistry;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -59,7 +59,7 @@
  */
 @RunWith ( CiRunner.class )
 @CleanupLevel( Level.CLASS )
-public class MetaMatchingRuleHandlerIT
+public class MetaMatchingRuleHandlerIT extends AbstractMetaSchemaObjectHandlerIT
 {
     private static final String DESCRIPTION0 = "A test matchingRule";
     private static final String DESCRIPTION1 = "An alternate description";
@@ -96,32 +96,57 @@
 
 
     @Test
-    public void testAddMatchingRule() throws Exception
+    public void testAddMatchingRuleToEnabledSchema() 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_MATCHING_RULE_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_SYNTAX_AT, SchemaConstants.INTEGER_SYNTAX );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION0 );
-        
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaMatchingRule",
+            "m-oid", OID,
+            "m-syntax", SchemaConstants.INTEGER_SYNTAX,
+            "m-description", DESCRIPTION0 );
+
         LdapDN dn = getMatchingRuleContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
         getSchemaContext( service ).createSubcontext( dn, attrs );
         
         assertTrue( getMatchingRuleRegistry().contains( OID ) );
         assertEquals( getMatchingRuleRegistry().getSchemaName( OID ), "apachemeta" );
+        assertTrue( isOnDisk( dn ) );
+    }
+    
+    
+    @Test
+    public void testAddMatchingRuleToDisabledSchema() throws Exception
+    {
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaMatchingRule",
+            "m-oid", OID,
+            "m-syntax", SchemaConstants.INTEGER_SYNTAX,
+            "m-description", DESCRIPTION0 );
+        
+        LdapDN dn = getMatchingRuleContainer( "nis" );
+        dn.add( "m-oid" + "=" + OID );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertFalse( "adding new matchingRule to disabled schema should not register it into the registries", 
+            getMatchingRuleRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
     }
     
 
     @Test
-    public void testDeleteMatchingRule() throws Exception
+    public void testDeleteMatchingRuleFromEnabledSchema() throws Exception
     {
         LdapDN dn = getMatchingRuleContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddMatchingRule();
+        dn.add( "m-oid" + "=" + OID );
+        testAddMatchingRuleToEnabledSchema();
+        
+        assertTrue( "matchingRule should be removed from the registry after being deleted", 
+            getMatchingRuleRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
         
         getSchemaContext( service ).destroySubcontext( dn );
 
@@ -136,6 +161,27 @@
         catch( NamingException e )
         {
         }
+
+        assertFalse( isOnDisk( dn ) );
+    }
+
+
+    @Test
+    public void testDeleteMatchingRuleFromDisabledSchema() throws Exception
+    {
+        LdapDN dn = getMatchingRuleContainer( "nis" );
+        dn.add( "m-oid" + "=" + OID );
+        testAddMatchingRuleToDisabledSchema();
+        
+        assertFalse( "matchingRule should be removed from the registry after being deleted", 
+            getMatchingRuleRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
+        
+        getSchemaContext( service ).destroySubcontext( dn );
+
+        assertFalse( "matchingRule should be removed from the registry after being deleted", 
+            getMatchingRuleRegistry().contains( OID ) );
+        assertFalse( isOnDisk( dn ) );
     }
 
 
@@ -143,11 +189,11 @@
     public void testRenameMatchingRule() throws Exception
     {
         LdapDN dn = getMatchingRuleContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddMatchingRule();
+        dn.add( "m-oid" + "=" + OID );
+        testAddMatchingRuleToEnabledSchema();
         
         LdapDN newdn = getMatchingRuleContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         getSchemaContext( service ).rename( dn, newdn );
 
         assertFalse( "old matchingRule OID should be removed from the registry after being renamed", 
@@ -170,13 +216,13 @@
     @Ignore
     public void testMoveMatchingRule() throws Exception
     {
-        testAddMatchingRule();
+        testAddMatchingRuleToEnabledSchema();
         
         LdapDN dn = getMatchingRuleContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = getMatchingRuleContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
@@ -192,13 +238,13 @@
     @Ignore
     public void testMoveMatchingRuleAndChangeRdn() throws Exception
     {
-        testAddMatchingRule();
+        testAddMatchingRuleToEnabledSchema();
         
         LdapDN dn = getMatchingRuleContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = getMatchingRuleContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
@@ -216,19 +262,19 @@
     @Test
     public void testModifyMatchingRuleWithModificationItems() throws Exception
     {
-        testAddMatchingRule();
+        testAddMatchingRuleToEnabledSchema();
         
         MatchingRule mr = getMatchingRuleRegistry().lookup( OID );
         assertEquals( mr.getDescription(), DESCRIPTION0 );
         assertEquals( mr.getSyntax().getOid(), SchemaConstants.INTEGER_SYNTAX );
 
         LdapDN dn = getMatchingRuleContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
         
         ModificationItem[] mods = new ModificationItem[2];
-        Attribute attr = new BasicAttribute( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION1 );
+        Attribute attr = new BasicAttribute( "m-description", DESCRIPTION1 );
         mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        attr = new BasicAttribute( MetaSchemaConstants.M_SYNTAX_AT, SchemaConstants.DIRECTORY_STRING_SYNTAX );
+        attr = new BasicAttribute( "m-syntax", SchemaConstants.DIRECTORY_STRING_SYNTAX );
         mods[1] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
         getSchemaContext( service ).modifyAttributes( dn, mods );
 
@@ -247,18 +293,18 @@
     @Test
     public void testModifyMatchingRuleWithAttributes() throws Exception
     {
-        testAddMatchingRule();
+        testAddMatchingRuleToEnabledSchema();
         
         MatchingRule mr = getMatchingRuleRegistry().lookup( OID );
         assertEquals( mr.getDescription(), DESCRIPTION0 );
         assertEquals( mr.getSyntax().getOid(), SchemaConstants.INTEGER_SYNTAX );
 
         LdapDN dn = getMatchingRuleContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
         
         Attributes mods = new BasicAttributes( true );
-        mods.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION1 );
-        mods.put( MetaSchemaConstants.M_SYNTAX_AT, SchemaConstants.DIRECTORY_STRING_SYNTAX );
+        mods.put( "m-description", DESCRIPTION1 );
+        mods.put( "m-syntax", SchemaConstants.DIRECTORY_STRING_SYNTAX );
         getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
 
         assertTrue( "matchingRule OID should still be present", 
@@ -281,7 +327,7 @@
 //    public void testDeleteSyntaxWhenInUse() throws NamingException
 //    {
 //        LdapDN dn = getSyntaxContainer( "apachemeta" );
-//        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+//        dn.add( "m-oid" + "=" + OID );
 //        testAddSyntax();
 //        addDependeeMatchingRule();
 //        
@@ -306,10 +352,10 @@
 //        addDependeeMatchingRule();
 //        
 //        LdapDN dn = getSyntaxContainer( "apachemeta" );
-//        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+//        dn.add( "m-oid" + "=" + OID );
 //
 //        LdapDN newdn = getSyntaxContainer( "apache" );
-//        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+//        newdn.add( "m-oid" + "=" + OID );
 //        
 //        try
 //        {
@@ -332,10 +378,10 @@
 //        addDependeeMatchingRule()
 //        
 //        LdapDN dn = getSyntaxContainer( "apachemeta" );
-//        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );s
+//        dn.add( "m-oid" + "=" + OID );s
 //
 //        LdapDN newdn = getSyntaxContainer( "apache" );
-//        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+//        newdn.add( "m-oid" + "=" + NEW_OID );
 //        
 //        try
 //        {
@@ -364,12 +410,12 @@
 //    public void testRenameNormalizerWhenInUse() throws NamingException
 //    {
 //        LdapDN dn = getSyntaxContainer( "apachemeta" );
-//        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+//        dn.add( "m-oid" + "=" + OID );
 //        testAddSyntax();
 //        addDependeeMatchingRule();
 //        
 //        LdapDN newdn = getSyntaxContainer( "apachemeta" );
-//        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+//        newdn.add( "m-oid" + "=" + NEW_OID );
 //        
 //        try
 //        {
@@ -395,13 +441,13 @@
     @Ignore
     public void testMoveMatchingRuleToTop() throws Exception
     {
-        testAddMatchingRule();
+        testAddMatchingRuleToEnabledSchema();
         
         LdapDN dn = getMatchingRuleContainer( "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
         {
@@ -422,13 +468,13 @@
     @Ignore
     public void testMoveMatchingRuleToComparatorContainer() throws Exception
     {
-        testAddMatchingRule();
+        testAddMatchingRuleToEnabledSchema();
         
         LdapDN dn = getMatchingRuleContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = new LdapDN( "ou=comparators,cn=apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         try
         {
@@ -446,38 +492,17 @@
     
     
     @Test
-    public void testAddMatchingRuleToDisabledSchema() 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_MATCHING_RULE_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_SYNTAX_AT, SchemaConstants.INTEGER_SYNTAX );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION0 );
-        
-        LdapDN dn = getMatchingRuleContainer( "nis" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
-        
-        assertFalse( "adding new matchingRule to disabled schema should not register it into the registries", 
-            getMatchingRuleRegistry().contains( OID ) );
-    }
-
-
-    @Test
     @Ignore
     public void testMoveMatchingRuleToDisabledSchema() throws Exception
     {
-        testAddMatchingRule();
+        testAddMatchingRuleToEnabledSchema();
         
         LdapDN dn = getMatchingRuleContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         // nis is inactive by default
         LdapDN newdn = getMatchingRuleContainer( "nis" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
@@ -494,13 +519,13 @@
         
         // nis is inactive by default
         LdapDN dn = getMatchingRuleContainer( "nis" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         assertFalse( "matchingRule OID should NOT be present when added to disabled nis schema", 
             getMatchingRuleRegistry().contains( OID ) );
 
         LdapDN newdn = getMatchingRuleContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.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/MetaNormalizerHandlerIT.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.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.MatchingRuleRegistry;
 import org.apache.directory.shared.ldap.schema.registries.NormalizerRegistry;
 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,7 +66,7 @@
  */
 @RunWith ( CiRunner.class )
 @CleanupLevel( Level.CLASS )
-public class MetaNormalizerHandlerIT
+public class MetaNormalizerHandlerIT 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";
@@ -113,72 +112,127 @@
 
 
     @Test
-    public void testAddNormalizer() throws Exception
+    public void testAddNormalizerToEnabledSchema() 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_NORMALIZER_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_FQCN_AT, NoOpNormalizer.class.getName() );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test normalizer" );
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaNormalizer",
+            "m-fqcn", NoOpNormalizer.class.getName(),
+            "m-oid", OID,
+            "m-description: A test normalizer" );
         
         LdapDN dn = getNormalizerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
         getSchemaContext( service ).createSubcontext( dn, attrs );
         
         assertTrue( getNormalizerRegistry().contains( OID ) );
         assertEquals( getNormalizerRegistry().getSchemaName( OID ), "apachemeta" );
         Class<?> clazz = getNormalizerRegistry().lookup( OID ).getClass();
         assertEquals( clazz, NoOpNormalizer.class );
+        assertTrue( isOnDisk( dn ) );
     }
     
     
     @Test
-    public void testAddNormalizerWithByteCode() throws Exception
+    public void testAddNormalizerToDisabledSchema() throws Exception
+    {
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaNormalizer",
+            "m-fqcn", NoOpNormalizer.class.getName(),
+            "m-oid", OID,
+            "m-description: A test normalizer" );
+        
+        // nis is by default inactive
+        LdapDN dn = getNormalizerContainer( "nis" );
+        dn.add( "m-oid" + "=" + OID );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertFalse( "adding new normalizer to disabled schema should not register it into the registries", 
+            getNormalizerRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
+    }
+    
+    
+    @Test
+    public void testAddNormalizerWithByteCodeToEnabledSchema() throws Exception
     {
         InputStream in = getClass().getResourceAsStream( "DummyNormalizer.bytecode" );
         ByteArrayOutputStream out = new ByteArrayOutputStream();
+        
         while ( in.available() > 0 )
         {
             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_NORMALIZER_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_FQCN_AT, "org.apache.directory.shared.ldap.schema.normalizers.DummyNormalizer" );
-        attrs.put( MetaSchemaConstants.M_BYTECODE_AT, out.toByteArray() );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test normalizer" );
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaNormalizer",
+            "m-fqcn", "org.apache.directory.shared.ldap.schema.normalizers.DummyNormalizer",
+            "m-bytecode", out.toByteArray(),
+            "m-oid", OID,
+            "m-description: A test normalizer" );
         
         LdapDN dn = getNormalizerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
         getSchemaContext( service ).createSubcontext( dn, attrs );
         
         assertTrue( getNormalizerRegistry().contains( OID ) );
         assertEquals( getNormalizerRegistry().getSchemaName( OID ), "apachemeta" );
         Class<?> clazz = getNormalizerRegistry().lookup( OID ).getClass();
         assertEquals( clazz.getName(), "org.apache.directory.shared.ldap.schema.normalizers.DummyNormalizer" );
+        assertTrue( isOnDisk( dn ) );
+    }
+    
+    
+    @Test
+    public void testAddNormalizerWithByteCodeToDisabledSchema() throws Exception
+    {
+        InputStream in = getClass().getResourceAsStream( "DummyNormalizer.bytecode" );
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        
+        while ( in.available() > 0 )
+        {
+            out.write( in.read() );
+        }
+        
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaNormalizer",
+            "m-fqcn", "org.apache.directory.shared.ldap.schema.normalizers.DummyNormalizer",
+            "m-bytecode", out.toByteArray(),
+            "m-oid", OID,
+            "m-description: A test normalizer" );
+        
+        LdapDN dn = getNormalizerContainer( "nis" );
+        dn.add( "m-oid" + "=" + OID );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertFalse( getNormalizerRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
     }
     
     
     @Test
-    public void testDeleteNormalizer() throws Exception
+    public void testDeleteNormalizerFromEnabledSchema() throws Exception
     {
         LdapDN dn = getNormalizerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddNormalizer();
+        dn.add( "m-oid" + "=" + OID );
+        testAddNormalizerToEnabledSchema();
+        
+        assertTrue( "normalizer should be removed from the registry after being deleted", 
+            getNormalizerRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
         
         getSchemaContext( service ).destroySubcontext( dn );
 
         assertFalse( "normalizer should be removed from the registry after being deleted", 
             getNormalizerRegistry().contains( OID ) );
 
-        //noinspection EmptyCatchBlock
         try
         {
             getNormalizerRegistry().lookup( OID );
@@ -187,6 +241,37 @@
         catch( NamingException e )
         {
         }
+
+        assertFalse( isOnDisk( dn ) );
+    }
+
+
+    @Test
+    public void testDeleteNormalizerFromDisabledSchema() throws Exception
+    {
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( "m-oid" + "=" + OID );
+        testAddNormalizerToEnabledSchema();
+
+        assertTrue( "normalizer should be removed from the registry after being deleted", 
+            getNormalizerRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
+        
+        getSchemaContext( service ).destroySubcontext( dn );
+
+        assertFalse( "normalizer should be removed from the registry after being deleted", 
+            getNormalizerRegistry().contains( OID ) );
+
+        try
+        {
+            getNormalizerRegistry().lookup( OID );
+            fail( "normalizer lookup should fail after deleting the normalizer" );
+        }
+        catch( NamingException e )
+        {
+        }
+
+        assertFalse( isOnDisk( dn ) );
     }
 
 
@@ -194,11 +279,11 @@
     public void testRenameNormalizer() throws Exception
     {
         LdapDN dn = getNormalizerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddNormalizer();
+        dn.add( "m-oid" + "=" + OID );
+        testAddNormalizerToEnabledSchema();
         
         LdapDN newdn = getNormalizerContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         getSchemaContext( service ).rename( dn, newdn );
 
         assertFalse( "old normalizer OID should be removed from the registry after being renamed", 
@@ -224,13 +309,13 @@
     @Ignore
     public void testMoveNormalizer() throws Exception
     {
-        testAddNormalizer();
+        testAddNormalizerToEnabledSchema();
         
         LdapDN dn = getNormalizerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = getNormalizerContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
@@ -249,13 +334,13 @@
     @Ignore
     public void testMoveNormalizerAndChangeRdn() throws Exception
     {
-        testAddNormalizer();
+        testAddNormalizerToEnabledSchema();
         
         LdapDN dn = getNormalizerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = getNormalizerContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
@@ -276,13 +361,13 @@
     @Test
     public void testModifyNormalizerWithModificationItems() throws Exception
     {
-        testAddNormalizer();
+        testAddNormalizerToEnabledSchema();
         
         LdapDN dn = getNormalizerContainer( "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, DeepTrimNormalizer.class.getName() );
+        Attribute attr = new BasicAttribute( "m-fqcn", DeepTrimNormalizer.class.getName() );
         mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
         getSchemaContext( service ).modifyAttributes( dn, mods );
 
@@ -300,13 +385,13 @@
     @Test
     public void testModifyNormalizerWithAttributes() throws Exception
     {
-        testAddNormalizer();
+        testAddNormalizerToEnabledSchema();
         
         LdapDN dn = getNormalizerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
         
         Attributes mods = new BasicAttributes( true );
-        mods.put( MetaSchemaConstants.M_FQCN_AT, DeepTrimNormalizer.class.getName() );
+        mods.put( "m-fqcn", DeepTrimNormalizer.class.getName() );
         getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
 
         assertTrue( "normalizer OID should still be present", 
@@ -329,8 +414,8 @@
     public void testDeleteNormalizerWhenInUse() throws Exception
     {
         LdapDN dn = getNormalizerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddNormalizer();
+        dn.add( "m-oid" + "=" + OID );
+        testAddNormalizerToEnabledSchema();
         getMatchingRuleRegistry().register( new DummyMR() );
         
         try
@@ -354,14 +439,14 @@
     @Ignore
     public void testMoveNormalizerWhenInUse() throws Exception
     {
-        testAddNormalizer();
+        testAddNormalizerToEnabledSchema();
         getMatchingRuleRegistry().register( new DummyMR() );
         
         LdapDN dn = getNormalizerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = getNormalizerContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         try
         {
@@ -384,14 +469,14 @@
     @Ignore
     public void testMoveNormalizerAndChangeRdnWhenInUse() throws Exception
     {
-        testAddNormalizer();
+        testAddNormalizerToEnabledSchema();
         getMatchingRuleRegistry().register( new DummyMR() );
         
         LdapDN dn = getNormalizerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = getNormalizerContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         
         try
         {
@@ -414,12 +499,12 @@
     public void testRenameNormalizerWhenInUse() throws Exception
     {
         LdapDN dn = getNormalizerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddNormalizer();
+        dn.add( "m-oid" + "=" + OID );
+        testAddNormalizerToEnabledSchema();
         getMatchingRuleRegistry().register( new DummyMR() );
         
         LdapDN newdn = getNormalizerContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         
         try
         {
@@ -447,13 +532,13 @@
     @Ignore
     public void testMoveNormalizerToTop() throws Exception
     {
-        testAddNormalizer();
+        testAddNormalizerToEnabledSchema();
         
         LdapDN dn = getNormalizerContainer( "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
         {
@@ -474,13 +559,13 @@
     @Ignore
     public void testMoveNormalizerToComparatorContainer() throws Exception
     {
-        testAddNormalizer();
+        testAddNormalizerToEnabledSchema();
         
         LdapDN dn = getNormalizerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = new LdapDN( "ou=comparators,cn=apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         try
         {
@@ -495,42 +580,20 @@
         assertTrue( "normalizer should still be in the registry after move failure", 
             getNormalizerRegistry().contains( OID ) );
     }
-    
-    
-    @Test
-    public void testAddNormalizerToDisabledSchema() 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_NORMALIZER_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_FQCN_AT, NoOpNormalizer.class.getName() );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test normalizer" );
-        
-        // nis is by default inactive
-        LdapDN dn = getNormalizerContainer( "nis" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
-        
-        assertFalse( "adding new normalizer to disabled schema should not register it into the registries", 
-            getNormalizerRegistry().contains( OID ) );
-    }
 
 
     @Test
     @Ignore
     public void testMoveNormalizerToDisabledSchema() throws Exception
     {
-        testAddNormalizer();
+        testAddNormalizerToEnabledSchema();
         
         LdapDN dn = getNormalizerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         // nis is inactive by default
         LdapDN newdn = getNormalizerContainer( "nis" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
@@ -547,13 +610,13 @@
         
         // nis is inactive by default
         LdapDN dn = getNormalizerContainer( "nis" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         assertFalse( "normalizer OID should NOT be present when added to disabled nis schema", 
             getNormalizerRegistry().contains( OID ) );
 
         LdapDN newdn = getNormalizerContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 

Copied: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java (from r822146, directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java?p2=directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java&p1=directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java&r1=822146&r2=823360&rev=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java Fri Oct  9 00:03:45 2009
@@ -44,6 +44,7 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.ObjectClass;
 import org.apache.directory.shared.ldap.schema.registries.ObjectClassRegistry;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -58,7 +59,7 @@
  */
 @RunWith ( CiRunner.class )
 @CleanupLevel( Level.CLASS )
-public class MetaObjectClassHandlerIT
+public class MetaObjectClassHandlerIT extends AbstractMetaSchemaObjectHandlerIT
 {
     private static final String NAME = "testObjectClass";
     private static final String NEW_NAME = "alternateName";
@@ -94,54 +95,68 @@
     }
     
     
-    private void addObjectClass() throws Exception
+    private LdapDN addObjectClass() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaObjectClass" );
-        attrs.put( oc );
-        attrs.put( "m-oid", OID );
-        attrs.put( "m-name", NAME);
-        attrs.put( "m-description", DESCRIPTION0 );
-        attrs.put( "m-typeObjectClass", "AUXILIARY" );
-        attrs.put( "m-must", "cn" );
-        attrs.put( "m-may", "ou" );
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaObjectClass",
+            "m-oid: " + OID,
+            "m-name: " + NAME,
+            "m-description: " + DESCRIPTION0,
+            "m-typeObjectClass: AUXILIARY",
+            "m-must: cn",
+            "m-may: ou" );
         
         LdapDN dn = getObjectClassContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
         getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        return dn;
     }
 
     
     // ----------------------------------------------------------------------
     // Test all core methods with normal operational pathways
     // ----------------------------------------------------------------------
-
-
     @Test
-    public void testAddObjectClass() throws Exception
+    public void testAddObjectClassToEnabledSchema() throws Exception
     {
-        addObjectClass();
+        LdapDN dn = addObjectClass();
         
         assertTrue( getObjectClassRegistry().contains( OID ) );
         assertEquals( getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
+        assertTrue( isOnDisk( dn ) );
     }
     
     
     @Test
-    public void testDeleteObjectClass() throws Exception
+    public void testAddObjectClassToDisabledSchema1() throws Exception
+    {
+        LdapDN dn = addObjectClassToDisabledSchema();
+        
+        assertFalse( "adding new objectClass to disabled schema should not register it into the registries", 
+            getObjectClassRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
+    }
+
+
+    @Test
+    public void testDeleteObjectClassFromEnabledSchema() throws Exception
     {
         LdapDN dn = getObjectClassContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
         addObjectClass();
-        
+
+        assertTrue( "objectClass should be removed from the registry after being deleted", 
+            getObjectClassRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
+
         getSchemaContext( service ).destroySubcontext( dn );
 
         assertFalse( "objectClass should be removed from the registry after being deleted", 
             getObjectClassRegistry().contains( OID ) );
 
-        //noinspection EmptyCatchBlock
         try
         {
             getObjectClassRegistry().lookup( OID );
@@ -150,8 +165,39 @@
         catch( NamingException e )
         {
         }
+
+        assertFalse( isOnDisk( dn ) );
     }
 
+    
+    @Test
+    public void testDeleteObjectClassFromDisabledSchema() throws Exception
+    {
+        LdapDN dn = getObjectClassContainer( "nis" );
+        dn.add( "m-oid" + "=" + OID );
+        addObjectClassToDisabledSchema();
+        
+        assertFalse( "objectClass should be removed from the registry after being deleted", 
+            getObjectClassRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
+        
+        getSchemaContext( service ).destroySubcontext( dn );
+
+        assertFalse( "objectClass should be removed from the registry after being deleted", 
+            getObjectClassRegistry().contains( OID ) );
+
+        try
+        {
+            getObjectClassRegistry().lookup( OID );
+            fail( "objectClass lookup should fail after deleting it" );
+        }
+        catch( NamingException e )
+        {
+        }
+        
+        assertFalse( isOnDisk( dn ) );
+    }
+    
 
     @Test
     public void testRenameObjectClassType() throws Exception
@@ -477,35 +523,26 @@
     }
 
     
-    private void addObjectClassToDisabledSchema() throws Exception
+    private LdapDN addObjectClassToDisabledSchema() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaObjectClass" );
-        attrs.put( oc );
-        attrs.put( "m-oid", OID );
-        attrs.put( "m-name", NAME);
-        attrs.put( "m-description", DESCRIPTION0 );
-        attrs.put( "m-typeObjectClass", "AUXILIARY" );
-        attrs.put( "m-must", "cn" );
-        attrs.put( "m-may", "ou" );
-        
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaObjectClass",
+            "m-oid: " + OID,
+            "m-name: " + NAME,
+            "m-description: " + DESCRIPTION0,
+            "m-typeObjectClass: AUXILIARY",
+            "m-must: cn",
+            "m-may: ou" );
+
         LdapDN dn = getObjectClassContainer( "nis" );
         dn.add( "m-oid" + "=" + OID );
         getSchemaContext( service ).createSubcontext( dn, attrs );
-    }
-    
-    @Test
-    public void testAddObjectClassToDisabledSchema1() throws Exception
-    {
-        addObjectClassToDisabledSchema();
         
-        assertFalse( "adding new objectClass to disabled schema should not register it into the registries", 
-            getObjectClassRegistry().contains( OID ) );
+        return dn;
     }
-
-
+    
     @Test
     @Ignore
     public void testMoveObjectClassToDisabledSchema() throws Exception

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.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/MetaSchemaHandlerIT.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java Fri Oct  9 00:03:45 2009
@@ -47,6 +47,7 @@
 import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -61,7 +62,7 @@
  */
 @RunWith ( CiRunner.class )
 @CleanupLevel( Level.CLASS )
-public class MetaSchemaHandlerIT
+public class MetaSchemaHandlerIT extends AbstractMetaSchemaObjectHandlerIT
 {
     /** a test attribute in the test schema: uidNumber in nis schema */
     private static final String TEST_ATTR_OID = "1.3.6.1.1.1.1.0";
@@ -181,7 +182,6 @@
         }
     }
     
-    
     /**
      * Tests the addition of a new metaSchema object that is enabled 
      * on addition and has no dependencies.
@@ -192,9 +192,12 @@
     public void testAddEnabledSchemaNoDeps() throws Exception
     {
         LdapContext schemaRoot = getSchemaContext( service );
-        Attributes dummySchema = new BasicAttributes( "objectClass", "top", true );
-        dummySchema.get( "objectClass" ).add( MetaSchemaConstants.META_SCHEMA_OC );
-        dummySchema.put( "cn", "dummy" );
+        Attributes dummySchema = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaSchema",
+            "cn: dummy"
+            );
+
         schemaRoot.createSubcontext( "cn=dummy", dummySchema );
         
         assertTrue( IntegrationUtils.isEnabled( service, "dummy" ) );

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerIT.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/MetaSyntaxCheckerHandlerIT.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerIT.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;
@@ -52,7 +50,8 @@
 import org.apache.directory.shared.ldap.schema.registries.LdapSyntaxRegistry;
 import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
 import org.apache.directory.shared.ldap.schema.registries.SyntaxCheckerRegistry;
-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.AttributeUtils;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -67,7 +66,7 @@
  */
 @RunWith ( CiRunner.class )
 @CleanupLevel( Level.CLASS )
-public class MetaSyntaxCheckerHandlerIT
+public class MetaSyntaxCheckerHandlerIT extends AbstractMetaSchemaObjectHandlerIT
 {
     private static final String OID = "1.3.6.1.4.1.18060.0.4.0.0.100000";
     private static final String NEW_OID = "1.3.6.1.4.1.18060.0.4.0.0.100001";
@@ -110,75 +109,128 @@
     // ----------------------------------------------------------------------
     // Test all core methods with normal operational pathways
     // ----------------------------------------------------------------------
-
-
     @Test
-    public void testAddSyntaxChecker() throws Exception
+    public void testAddSyntaxCheckerToEnabledSchema() 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_SYNTAX_CHECKER_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_FQCN_AT, AcceptAllSyntaxChecker.class.getName() );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test syntaxChecker" );
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaSyntaxChecker",
+            "m-fqcn", OctetStringSyntaxChecker.class.getName(),
+            "m-oid", OID,
+            "m-description: A test syntaxChecker" );
         
         LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
         getSchemaContext( service ).createSubcontext( dn, attrs );
         
         assertTrue( getSyntaxCheckerRegistry().contains( OID ) );
         assertEquals( getSyntaxCheckerRegistry().getSchemaName( OID ), "apachemeta" );
         Class<?> clazz = getSyntaxCheckerRegistry().lookup( OID ).getClass();
-        assertEquals( clazz, AcceptAllSyntaxChecker.class );
+        assertEquals( clazz, OctetStringSyntaxChecker.class );
+        assertTrue( isOnDisk( dn ) );
     }
     
     
     @Test
-    public void testAddSyntaxCheckerWithByteCode() throws Exception
+    public void testAddSyntaxCheckerToDisabledSchema() throws Exception
+    {
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaSyntaxChecker",
+            "m-fqcn", OctetStringSyntaxChecker.class.getName(),
+            "m-oid", OID,
+            "m-description: A test syntaxChecker" );
+        
+        // nis is by default inactive
+        LdapDN dn = getSyntaxCheckerContainer( "nis" );
+        dn.add( "m-oid" + "=" + OID );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertFalse( "adding new syntaxChecker to disabled schema should not register it into the registries", 
+            getSyntaxCheckerRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
+    }
+
+
+    @Test
+    public void testAddSyntaxCheckerWithByteCodeOnEnabledSchema() throws Exception
     {
         InputStream in = getClass().getResourceAsStream( "DummySyntaxChecker.bytecode" );
         ByteArrayOutputStream out = new ByteArrayOutputStream();
+        
         while ( in.available() > 0 )
         {
             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_SYNTAX_CHECKER_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_FQCN_AT, "org.apache.directory.shared.ldap.schema.syntaxCheckers.DummySyntaxChecker" );
-        attrs.put( MetaSchemaConstants.M_BYTECODE_AT, out.toByteArray() );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test syntaxChecker" );
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaSyntaxChecker",
+            "m-fqcn", "org.apache.directory.shared.ldap.schema.syntaxCheckers.DummySyntaxChecker",
+            "m-bytecode", out.toByteArray(),
+            "m-oid", OID,
+            "m-description: A test syntaxChecker" );
         
         LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
         getSchemaContext( service ).createSubcontext( dn, attrs );
         
         assertTrue( getSyntaxCheckerRegistry().contains( OID ) );
         assertEquals( getSyntaxCheckerRegistry().getSchemaName( OID ), "apachemeta" );
         Class<?> clazz = getSyntaxCheckerRegistry().lookup( OID ).getClass();
         assertEquals( clazz.getName(), "org.apache.directory.shared.ldap.schema.syntaxCheckers.DummySyntaxChecker" );
+        assertTrue( isOnDisk( dn ) );
+    }
+
+
+    @Test
+    public void testAddSyntaxCheckerWithByteCodeOnDisabledSchema() throws Exception
+    {
+        InputStream in = getClass().getResourceAsStream( "DummySyntaxChecker.bytecode" );
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        
+        while ( in.available() > 0 )
+        {
+            out.write( in.read() );
+        }
+        
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaSyntaxChecker",
+            "m-fqcn", "org.apache.directory.shared.ldap.schema.syntaxCheckers.DummySyntaxChecker",
+            "m-bytecode", out.toByteArray(),
+            "m-oid", OID,
+            "m-description: A test syntaxChecker" );
+        
+        LdapDN dn = getSyntaxCheckerContainer( "nis" );
+        dn.add( "m-oid" + "=" + OID );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertFalse( getSyntaxCheckerRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
     }
     
     
     @Test
-    public void testDeleteSyntaxChecker() throws Exception
+    public void testDeleteSyntaxCheckerFromEnabledSchema() throws Exception
     {
         LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddSyntaxChecker();
+        dn.add( "m-oid" + "=" + OID );
+        testAddSyntaxCheckerToEnabledSchema();
+        
+        assertTrue( "syntaxChecker should be removed from the registry after being deleted", 
+            getSyntaxCheckerRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
         
         getSchemaContext( service ).destroySubcontext( dn );
 
         assertFalse( "syntaxChecker should be removed from the registry after being deleted", 
             getSyntaxCheckerRegistry().contains( OID ) );
 
-        //noinspection EmptyCatchBlock
         try
         {
             getSyntaxCheckerRegistry().lookup( OID );
@@ -187,6 +239,37 @@
         catch( NamingException e )
         {
         }
+        
+        assertFalse( isOnDisk( dn ) );
+    }
+    
+    
+    @Test
+    public void testDeleteSyntaxCheckerFromDisabledSchema() throws Exception
+    {
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( "m-oid" + "=" + OID );
+        testAddSyntaxCheckerToEnabledSchema();
+        
+        assertTrue( "syntaxChecker should be removed from the registry after being deleted", 
+            getSyntaxCheckerRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
+
+        getSchemaContext( service ).destroySubcontext( dn );
+
+        assertFalse( "syntaxChecker should be removed from the registry after being deleted", 
+            getSyntaxCheckerRegistry().contains( OID ) );
+
+        try
+        {
+            getSyntaxCheckerRegistry().lookup( OID );
+            fail( "syntaxChecker lookup should fail after deleting the syntaxChecker" );
+        }
+        catch( NamingException e )
+        {
+        }
+        
+        assertFalse( isOnDisk( dn ) );
     }
 
 
@@ -194,11 +277,11 @@
     public void testRenameSyntaxChecker() throws Exception
     {
         LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddSyntaxChecker();
+        dn.add( "m-oid" + "=" + OID );
+        testAddSyntaxCheckerToEnabledSchema();
         
         LdapDN newdn = getSyntaxCheckerContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         getSchemaContext( service ).rename( dn, newdn );
 
         assertFalse( "old syntaxChecker OID should be removed from the registry after being renamed", 
@@ -216,7 +299,7 @@
 
         assertTrue( getSyntaxCheckerRegistry().contains( NEW_OID ) );
         Class<?> clazz = getSyntaxCheckerRegistry().lookup( NEW_OID ).getClass();
-        assertEquals( clazz, AcceptAllSyntaxChecker.class );
+        assertEquals( clazz, OctetStringSyntaxChecker.class );
     }
 
 
@@ -224,13 +307,13 @@
     @Ignore
     public void testMoveSyntaxChecker() throws Exception
     {
-        testAddSyntaxChecker();
+        testAddSyntaxCheckerToEnabledSchema();
         
         LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = getSyntaxCheckerContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
@@ -241,7 +324,7 @@
             getSyntaxCheckerRegistry().getSchemaName( OID ), "apache" );
 
         Class<?> clazz = getSyntaxCheckerRegistry().lookup( OID ).getClass();
-        assertEquals( clazz, AcceptAllSyntaxChecker.class );
+        assertEquals( clazz, OctetStringSyntaxChecker.class );
     }
 
 
@@ -249,13 +332,13 @@
     @Ignore
     public void testMoveSyntaxCheckerAndChangeRdn() throws Exception
     {
-        testAddSyntaxChecker();
+        testAddSyntaxCheckerToEnabledSchema();
         
         LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = getSyntaxCheckerContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
@@ -269,20 +352,20 @@
             getSyntaxCheckerRegistry().getSchemaName( NEW_OID ), "apache" );
 
         Class<?> clazz = getSyntaxCheckerRegistry().lookup( NEW_OID ).getClass();
-        assertEquals( clazz, AcceptAllSyntaxChecker.class );
+        assertEquals( clazz, OctetStringSyntaxChecker.class );
     }
 
     
     @Test
     public void testModifySyntaxCheckerWithModificationItems() throws Exception
     {
-        testAddSyntaxChecker();
+        testAddSyntaxCheckerToEnabledSchema();
         
         LdapDN dn = getSyntaxCheckerContainer( "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, BogusSyntaxChecker.class.getName() );
+        Attribute attr = new BasicAttribute( "m-fqcn", BogusSyntaxChecker.class.getName() );
         mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
         getSchemaContext( service ).modifyAttributes( dn, mods );
 
@@ -300,13 +383,13 @@
     @Test
     public void testModifySyntaxCheckerWithAttributes() throws Exception
     {
-        testAddSyntaxChecker();
+        testAddSyntaxCheckerToEnabledSchema();
         
         LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
         
         Attributes mods = new BasicAttributes( true );
-        mods.put( MetaSchemaConstants.M_FQCN_AT, BogusSyntaxChecker.class.getName() );
+        mods.put( "m-fqcn", BogusSyntaxChecker.class.getName() );
         getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
 
         assertTrue( "syntaxChecker OID should still be present", 
@@ -329,8 +412,8 @@
     public void testDeleteSyntaxCheckerWhenInUse() throws Exception
     {
         LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddSyntaxChecker();
+        dn.add( "m-oid" + "=" + OID );
+        testAddSyntaxCheckerToEnabledSchema();
         getLdapSyntaxRegistry().register( new DummySyntax() );
         
         try
@@ -354,14 +437,14 @@
     @Ignore
     public void testMoveSyntaxCheckerWhenInUse() throws Exception
     {
-        testAddSyntaxChecker();
+        testAddSyntaxCheckerToEnabledSchema();
         getLdapSyntaxRegistry().register( new DummySyntax() );
         
         LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = getSyntaxCheckerContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         try
         {
@@ -384,14 +467,14 @@
     @Ignore
     public void testMoveSyntaxCheckerAndChangeRdnWhenInUse() throws Exception
     {
-        testAddSyntaxChecker();
+        testAddSyntaxCheckerToEnabledSchema();
         getLdapSyntaxRegistry().register( new DummySyntax() );
         
         LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = getSyntaxCheckerContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         
         try
         {
@@ -414,12 +497,12 @@
     public void testRenameSyntaxCheckerWhenInUse() throws Exception
     {
         LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddSyntaxChecker();
+        dn.add( "m-oid" + "=" + OID );
+        testAddSyntaxCheckerToEnabledSchema();
         getLdapSyntaxRegistry().register( new DummySyntax() );
         
         LdapDN newdn = getSyntaxCheckerContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         
         try
         {
@@ -447,13 +530,13 @@
     @Ignore
     public void testMoveSyntaxCheckerToTop() throws Exception
     {
-        testAddSyntaxChecker();
+        testAddSyntaxCheckerToEnabledSchema();
         
         LdapDN dn = getSyntaxCheckerContainer( "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
         {
@@ -474,13 +557,13 @@
     @Ignore
     public void testMoveSyntaxCheckerToComparatorContainer() throws Exception
     {
-        testAddSyntaxChecker();
+        testAddSyntaxCheckerToEnabledSchema();
         
         LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = new LdapDN( "ou=comparators,cn=apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         try
         {
@@ -498,39 +581,17 @@
     
     
     @Test
-    public void testAddSyntaxCheckerToDisabledSchema() 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_SYNTAX_CHECKER_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_FQCN_AT, AcceptAllSyntaxChecker.class.getName() );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test syntaxChecker" );
-        
-        // nis is by default inactive
-        LdapDN dn = getSyntaxCheckerContainer( "nis" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
-        
-        assertFalse( "adding new syntaxChecker to disabled schema should not register it into the registries", 
-            getSyntaxCheckerRegistry().contains( OID ) );
-    }
-
-
-    @Test
     @Ignore
     public void testMoveSyntaxCheckerToDisabledSchema() throws Exception
     {
-        testAddSyntaxChecker();
+        testAddSyntaxCheckerToEnabledSchema();
         
         LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         // nis is inactive by default
         LdapDN newdn = getSyntaxCheckerContainer( "nis" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
@@ -547,13 +608,13 @@
         
         // nis is inactive by default
         LdapDN dn = getSyntaxCheckerContainer( "nis" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         assertFalse( "syntaxChecker OID should NOT be present when added to disabled nis schema", 
             getSyntaxCheckerRegistry().contains( OID ) );
 
         LdapDN newdn = getSyntaxCheckerContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerIT.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/MetaSyntaxHandlerIT.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerIT.java Fri Oct  9 00:03:45 2009
@@ -52,7 +52,8 @@
 import org.apache.directory.shared.ldap.schema.LdapSyntax;
 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.syntaxCheckers.AcceptAllSyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntaxCheckers.OctetStringSyntaxChecker;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -67,7 +68,7 @@
  */
 @RunWith ( CiRunner.class )
 @CleanupLevel( Level.CLASS )
-public class MetaSyntaxHandlerIT
+public class MetaSyntaxHandlerIT extends AbstractMetaSchemaObjectHandlerIT
 {
     private static final String DESCRIPTION0 = "A test normalizer";
     private static final String DESCRIPTION1 = "An alternate description";
@@ -115,15 +116,14 @@
 
     
     @Test
-    public void testAddSyntax() throws Exception
+    public void testAddSyntaxToEnabledSchema() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaSyntax" );
-        attrs.put( oc );
-        attrs.put( "m-oid", OID );
-        attrs.put( "m-description", DESCRIPTION0 );
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaSyntax",
+            "m-oid", OID,
+            "m-description", DESCRIPTION0 );
         
         LdapDN dn = getSyntaxContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
@@ -132,22 +132,48 @@
         
         assertTrue( getLdapSyntaxRegistry().contains( OID ) );
         assertEquals( getLdapSyntaxRegistry().getSchemaName( OID ), "apachemeta" );
+        assertTrue( isOnDisk( dn ) );
     }
     
     
     @Test
-    public void testDeleteSyntax() throws Exception
+    public void testAddSyntaxToDisabledSchema() throws Exception
+    {
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaSyntax",
+            "m-oid", OID,
+            "m-description", DESCRIPTION0 );
+        
+        // nis is by default inactive
+        LdapDN dn = getSyntaxContainer( "nis" );
+        dn.add( "m-oid" + "=" + OID );
+        createDummySyntaxChecker( OID, "nis" );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertFalse( "adding new syntax to disabled schema should not register it into the registries", 
+            getLdapSyntaxRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
+    }
+
+
+    @Test
+    public void testDeleteSyntaxFromEnabledSchema() throws Exception
     {
         LdapDN dn = getSyntaxContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
+        
+        assertTrue( isOnDisk( dn ) );
+        assertTrue( "syntax should be removed from the registry after being deleted", 
+            getLdapSyntaxRegistry().contains( OID ) );
         
         getSchemaContext( service ).destroySubcontext( dn );
 
         assertFalse( "syntax should be removed from the registry after being deleted", 
             getLdapSyntaxRegistry().contains( OID ) );
 
-        //noinspection EmptyCatchBlock
         try
         {
             getLdapSyntaxRegistry().lookup( OID );
@@ -156,6 +182,37 @@
         catch( NamingException e )
         {
         }
+
+        assertFalse( isOnDisk( dn ) );
+    }
+
+
+    @Test
+    public void testDeleteSyntaxFromDisabledSchema() throws Exception
+    {
+        LdapDN dn = getSyntaxContainer( "nis" );
+        dn.add( "m-oid" + "=" + OID );
+        testAddSyntaxToDisabledSchema();
+
+        assertTrue( isOnDisk( dn ) );
+        assertFalse( "syntax should be removed from the registry after being deleted", 
+            getLdapSyntaxRegistry().contains( OID ) );
+
+        getSchemaContext( service ).destroySubcontext( dn );
+
+        assertFalse( "syntax should be removed from the registry after being deleted", 
+            getLdapSyntaxRegistry().contains( OID ) );
+
+        try
+        {
+            getLdapSyntaxRegistry().lookup( OID );
+            fail( "syntax lookup should fail after deleting it" );
+        }
+        catch( NamingException e )
+        {
+        }
+        
+        assertFalse( isOnDisk( dn ) );
     }
 
 
@@ -164,7 +221,7 @@
     {
         LdapDN dn = getSyntaxContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         
         LdapDN newdn = getSyntaxContainer( "apachemeta" );
         newdn.add( "m-oid" + "=" + NEW_OID );
@@ -191,7 +248,7 @@
     @Ignore
     public void testMoveSyntax() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         
         LdapDN dn = getSyntaxContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
@@ -213,7 +270,7 @@
     @Ignore
     public void testMoveSyntaxAndChangeRdn() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         
         LdapDN dn = getSyntaxContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
@@ -237,7 +294,7 @@
     @Test
     public void testModifySyntaxWithModificationItems() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         
         LdapSyntax syntax = getLdapSyntaxRegistry().lookup( OID );
         assertEquals( syntax.getDescription(), DESCRIPTION0 );
@@ -264,7 +321,7 @@
     @Test
     public void testModifySyntaxWithAttributes() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         
         LdapSyntax syntax = getLdapSyntaxRegistry().lookup( OID );
         assertEquals( syntax.getDescription(), DESCRIPTION0 );
@@ -297,7 +354,7 @@
     {
         LdapDN dn = getSyntaxContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         addDependeeMatchingRule( OID );
         
         try
@@ -319,7 +376,7 @@
     @Ignore
     public void testMoveSyntaxWhenInUse() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         addDependeeMatchingRule( OID );
         
         LdapDN dn = getSyntaxContainer( "apachemeta" );
@@ -347,7 +404,7 @@
     @Ignore
     public void testMoveSyntaxAndChangeRdnWhenInUse() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         addDependeeMatchingRule( OID );
         
         LdapDN dn = getSyntaxContainer( "apachemeta" );
@@ -386,14 +443,13 @@
     
     private void addDependeeMatchingRule( String oid ) throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaMatchingRule" );
-        attrs.put( oc );
-        attrs.put( "m-oid", MR_OID );
-        attrs.put( "m-syntax", OID );
-        attrs.put( "m-description", MR_DESCRIPTION );
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaMatchingRule",
+            "m-oid", MR_OID,
+            "m-syntax", OID,
+            "m-description", MR_DESCRIPTION );
         
         LdapDN dn = getMatchingRuleContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + MR_OID );
@@ -409,7 +465,7 @@
     {
         LdapDN dn = getSyntaxContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         addDependeeMatchingRule( OID );
         
         LdapDN newdn = getSyntaxContainer( "apachemeta" );
@@ -439,7 +495,7 @@
     @Ignore
     public void testMoveSyntaxToTop() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         
         LdapDN dn = getSyntaxContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
@@ -466,7 +522,7 @@
     @Ignore
     public void testMoveSyntaxToComparatorContainer() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         
         LdapDN dn = getSyntaxContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
@@ -490,32 +546,10 @@
     
     
     @Test
-    public void testAddSyntaxToDisabledSchema() throws Exception
-    {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaSyntax" );
-        attrs.put( oc );
-        attrs.put( "m-oid", OID );
-        attrs.put( "m-description", DESCRIPTION0 );
-        
-        // nis is by default inactive
-        LdapDN dn = getSyntaxContainer( "nis" );
-        dn.add( "m-oid" + "=" + OID );
-        createDummySyntaxChecker( OID, "nis" );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
-        
-        assertFalse( "adding new syntax to disabled schema should not register it into the registries", 
-            getLdapSyntaxRegistry().contains( OID ) );
-    }
-
-
-    @Test
     @Ignore
     public void testMoveSyntaxToDisabledSchema() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         
         LdapDN dn = getSyntaxContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
@@ -560,7 +594,7 @@
     private void createDummySyntaxChecker( String oid, String schema ) throws Exception
     {
         List<String> descriptions = new ArrayList<String>();
-        descriptions.add( "( " + oid + " DESC 'bogus desc' FQCN " + AcceptAllSyntaxChecker.class.getName() 
+        descriptions.add( "( " + oid + " DESC 'bogus desc' FQCN " + OctetStringSyntaxChecker.class.getName() 
             + " X-SCHEMA '" + schema + "' )" );
         modify( DirContext.ADD_ATTRIBUTE, descriptions, "syntaxCheckers" );
     }

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryIT.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/SubschemaSubentryIT.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryIT.java Fri Oct  9 00:03:45 2009
@@ -79,7 +79,7 @@
 import org.apache.directory.shared.ldap.schema.parsers.ObjectClassDescriptionSchemaParser;
 import org.apache.directory.shared.ldap.schema.parsers.SyntaxCheckerDescription;
 import org.apache.directory.shared.ldap.schema.parsers.SyntaxCheckerDescriptionSchemaParser;
-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.Base64;
 import org.apache.directory.shared.ldap.util.DateUtils;
 import org.apache.directory.shared.schema.loader.ldif.SchemaEntityFactory;
@@ -238,6 +238,7 @@
         Attributes attrs = getSubschemaSubentryAttributes();
         Attribute attrTypes = attrs.get( "syntaxCheckers" );
         SyntaxCheckerDescription syntaxCheckerDescription = null; 
+
         for ( int ii = 0; ii < attrTypes.size(); ii++ )
         {
             String desc = ( String ) attrTypes.get( ii );
@@ -272,7 +273,7 @@
             
             ServerEntry serverEntry = ServerEntryUtils.toServerEntry( attrs, LdapDN.EMPTY_LDAPDN, service.getRegistries() );
 
-            SyntaxChecker syntaxChecker = factory.getSyntaxChecker( serverEntry, service.getRegistries() );
+            SyntaxChecker syntaxChecker = factory.getSyntaxChecker( serverEntry, service.getRegistries(), schemaName );
             assertEquals( oid, syntaxChecker.getOid() );
         }
         else
@@ -320,9 +321,9 @@
         
         // ( 1.3.6.1.4.1.18060.0.4.0.2.10000 DESC 'bogus desc' FQCN org.foo.Bar BYTECODE 14561234 )
         descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.0.10000 DESC 'bogus desc' FQCN " 
-            + AcceptAllSyntaxChecker.class.getName() + " X-SCHEMA 'nis' )" );
+            + OctetStringSyntaxChecker.class.getName() + " X-SCHEMA 'nis' )" );
         descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.0.10001 DESC 'bogus desc' FQCN " 
-            + AcceptAllSyntaxChecker.class.getName() + " X-SCHEMA 'nis' )" );
+            + OctetStringSyntaxChecker.class.getName() + " X-SCHEMA 'nis' )" );
 
         // -------------------------------------------------------------------
         // add and check
@@ -819,11 +820,11 @@
 
         descriptions.clear();
         descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.0.10000 DESC 'bogus desc' FQCN " 
-            + AcceptAllSyntaxChecker.class.getName() + " X-SCHEMA 'nis' )" );
+            + OctetStringSyntaxChecker.class.getName() + " X-SCHEMA 'nis' )" );
         descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.0.10001 DESC 'bogus desc' FQCN " 
-            + AcceptAllSyntaxChecker.class.getName() + " X-SCHEMA 'nis' )" );
+            + OctetStringSyntaxChecker.class.getName() + " X-SCHEMA 'nis' )" );
         descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.0.10002 DESC 'bogus desc' FQCN " 
-            + AcceptAllSyntaxChecker.class.getName() + " X-SCHEMA 'nis' )" );
+            + OctetStringSyntaxChecker.class.getName() + " X-SCHEMA 'nis' )" );
 
         modify( DirContext.ADD_ATTRIBUTE, descriptions, "syntaxCheckers" );
         checkSyntaxCheckerPresent( "1.3.6.1.4.1.18060.0.4.1.0.10000", "nis", true );

Modified: directory/apacheds/branches/apacheds-schema/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java Fri Oct  9 00:03:45 2009
@@ -20,6 +20,30 @@
 package org.apache.directory.server.core.jndi;
 
 
+import java.io.Serializable;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.Name;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InvalidSearchFilterException;
+import javax.naming.directory.ModificationItem;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.event.EventDirContext;
+import javax.naming.event.NamingListener;
+import javax.naming.spi.DirStateFactory;
+import javax.naming.spi.DirectoryManager;
+
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.LdapPrincipal;
@@ -49,29 +73,6 @@
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
 
-import javax.naming.Name;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.Referenceable;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.InvalidSearchFilterException;
-import javax.naming.directory.ModificationItem;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.event.EventDirContext;
-import javax.naming.event.NamingListener;
-import javax.naming.spi.DirStateFactory;
-import javax.naming.spi.DirectoryManager;
-import java.io.Serializable;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-
 
 /**
  * The DirContext implementation for the Server Side JNDI LDAP provider.
@@ -468,7 +469,9 @@
      */
     public DirContext createSubcontext( String name, Attributes attrs ) throws NamingException
     {
-        return createSubcontext( new LdapDN( name ), AttributeUtils.toCaseInsensitive( attrs ) );
+        LdapDN dn = new LdapDN( name );
+        Attributes attributes = AttributeUtils.toCaseInsensitive( attrs );
+        return createSubcontext( dn, attributes );
     }
 
 

Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java Fri Oct  9 00:03:45 2009
@@ -221,7 +221,16 @@
             // @todo make sure we're not putting in operational attributes that cannot be user modified
             serverEntry = getAttributes( opContext );
         }
+        
+        // Duplicate modifications so that the reverse does not contain the operational attributes
+        List<Modification> clonedMods = new ArrayList<Modification>(); 
+
+        for ( Modification mod : opContext.getModItems() )
+        {
+            clonedMods.add( mod.clone() );
+        }
 
+        // Call the next interceptor
         next.modify( opContext );
 
         // @TODO: needs big consideration!!!
@@ -249,9 +258,9 @@
         forward.setChangeType( ChangeType.Modify );
         forward.setDn( opContext.getDn() );
         
-        List<Modification> mods = new ArrayList<Modification>( opContext.getModItems().size() );
+        List<Modification> mods = new ArrayList<Modification>( clonedMods.size() );
         
-        for ( Modification modItem : opContext.getModItems() )
+        for ( Modification modItem : clonedMods )
         {
             Modification mod = ((ServerModification)modItem).toClientModification();
             

Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java?rev=823360&r1=823359&r2=823360&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java Fri Oct  9 00:03:45 2009
@@ -162,7 +162,7 @@
             name ) );
         
         // we're adding the suffix entry so just ignore stuff to mess with the parent
-        if ( suffix.getNormName().equals( name.getNormName() ) )
+        if ( suffix.equals( name ) )
         {
             nextInterceptor.add( opContext );
             return;



Mime
View raw message