directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r896599 [11/30] - in /directory/apacheds/trunk: ./ avl-partition/ avl-partition/src/ avl-partition/src/main/ avl-partition/src/main/java/ avl-partition/src/main/java/org/ avl-partition/src/main/java/org/apache/ avl-partition/src/main/java/o...
Date Wed, 06 Jan 2010 18:27:19 GMT
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerIT.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerIT.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerIT.java
Wed Jan  6 18:26:43 2010
@@ -20,28 +20,17 @@
 package org.apache.directory.server.core.schema;
 
 
-import org.apache.directory.server.constants.MetaSchemaConstants;
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.integ.CiRunner;
 import static org.apache.directory.server.core.integ.IntegrationUtils.getRootContext;
 import static org.apache.directory.server.core.integ.IntegrationUtils.getSchemaContext;
-import org.apache.directory.server.schema.registries.MatchingRuleRegistry;
-import org.apache.directory.server.schema.registries.SyntaxRegistry;
-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;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.schema.Syntax;
-import org.apache.directory.shared.ldap.schema.syntaxes.AcceptAllSyntaxChecker;
-
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import org.junit.Test;
-import org.junit.runner.RunWith;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.NameNotFoundException;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
@@ -53,8 +42,19 @@
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 
-import java.util.ArrayList;
-import java.util.List;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.LdapSyntax;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.syntaxCheckers.OctetStringSyntaxChecker;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
 
 /**
@@ -64,8 +64,8 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-@RunWith ( CiRunner.class )
-public class MetaSyntaxHandlerIT
+@RunWith(FrameworkRunner.class)
+public class MetaSyntaxHandlerIT extends AbstractMetaSchemaObjectHandler
 {
     private static final String DESCRIPTION0 = "A test normalizer";
     private static final String DESCRIPTION1 = "An alternate description";
@@ -78,207 +78,278 @@
 
     private static final String SUBSCHEMA_SUBENTRY = "subschemaSubentry";
 
-
-    public static DirectoryService service;
+    public static SchemaManager schemaManager;
 
 
-    private static SyntaxRegistry getSyntaxRegistry()
+    @Before
+    public void setup()
     {
-        return service.getRegistries().getSyntaxRegistry();
+        schemaManager = service.getSchemaManager();
     }
 
 
-    private static MatchingRuleRegistry getMatchingRuleRegistry()
+    // ----------------------------------------------------------------------
+    // Test all core methods with normal operational pathways
+    // ----------------------------------------------------------------------
+    @Test
+    public void testAddSyntaxToEnabledSchema() throws Exception
     {
-        return service.getRegistries().getMatchingRuleRegistry();
+        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 );
+        createDummySyntaxChecker( OID, "apachemeta" );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertTrue( schemaManager.getLdapSyntaxRegistry().contains( OID ) );
+        assertEquals( schemaManager.getLdapSyntaxRegistry().getSchemaName( OID ), "apachemeta"
);
+        assertTrue( isOnDisk( dn ) );
     }
-
     
-    /**
-     * Gets relative DN to ou=schema.
-     *
-     * @param schemaName the name of the schema
-     * @return the dn of the container for the syntax entities
-     * @throws Exception on error
-     */
-    private LdapDN getSyntaxContainer( String schemaName ) throws Exception
+    
+    @Test
+    public void testAddSyntaxToDisabledSchema() throws Exception
     {
-        return new LdapDN( "ou=syntaxes,cn=" + schemaName );
+        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", 
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
     }
-    
-    
-    // ----------------------------------------------------------------------
-    // Test all core methods with normal operational pathways
-    // ----------------------------------------------------------------------
 
     
     @Test
-    public void testAddSyntax() throws Exception
+    public void testAddSyntaxToUnloadedSchema() 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_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION0 );
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaSyntax",
+            "m-oid", OID,
+            "m-description", DESCRIPTION0 );
         
-        LdapDN dn = getSyntaxContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        createDummySyntaxChecker( OID, "apachemeta" );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        // nis is by default inactive
+        LdapDN dn = getSyntaxContainer( "notloaded" );
+        dn.add( "m-oid" + "=" + OID );
+        createDummySyntaxChecker( OID, "nis" );
         
-        assertTrue( getSyntaxRegistry().hasSyntax( OID ) );
-        assertEquals( getSyntaxRegistry().getSchemaName( OID ), "apachemeta" );
+        try
+        {
+            getSchemaContext( service ).createSubcontext( dn, attrs );
+            fail( "Should not be there" );
+        }
+        catch( NameNotFoundException nnfe )
+        {
+            // Expected result.
+        }
+        
+        assertFalse( "adding new syntax to disabled schema should not register it into the
registries", 
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
+        assertFalse( isOnDisk( dn ) );
     }
     
     
     @Test
-    public void testDeleteSyntax() throws Exception
+    public void testDeleteSyntaxFromEnabledSchema() throws Exception
     {
         LdapDN dn = getSyntaxContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddSyntax();
+        dn.add( "m-oid" + "=" + OID );
+        testAddSyntaxToEnabledSchema();
+        
+        assertTrue( isOnDisk( dn ) );
+        assertTrue( "syntax should be removed from the registry after being deleted", 
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
         
         getSchemaContext( service ).destroySubcontext( dn );
 
         assertFalse( "syntax should be removed from the registry after being deleted", 
-            getSyntaxRegistry().hasSyntax( OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
+
+        try
+        {
+            schemaManager.getLdapSyntaxRegistry().lookup( OID );
+            fail( "syntax lookup should fail after deleting it" );
+        }
+        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", 
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
+
+        getSchemaContext( service ).destroySubcontext( dn );
+
+        assertFalse( "syntax should be removed from the registry after being deleted", 
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
 
-        //noinspection EmptyCatchBlock
         try
         {
-            getSyntaxRegistry().lookup( OID );
+            schemaManager.getLdapSyntaxRegistry().lookup( OID );
             fail( "syntax lookup should fail after deleting it" );
         }
         catch( NamingException e )
         {
         }
+        
+        assertFalse( isOnDisk( dn ) );
     }
 
 
     @Test
+    @Ignore
     public void testRenameSyntax() throws Exception
     {
         LdapDN dn = getSyntaxContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddSyntax();
+        dn.add( "m-oid" + "=" + OID );
+        testAddSyntaxToEnabledSchema();
         
         LdapDN newdn = getSyntaxContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         getSchemaContext( service ).rename( dn, newdn );
 
         assertFalse( "old syntax OID should be removed from the registry after being renamed",

-            getSyntaxRegistry().hasSyntax( OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
 
         //noinspection EmptyCatchBlock
         try
         {
-            getSyntaxRegistry().lookup( OID );
+            schemaManager.getLdapSyntaxRegistry().lookup( OID );
             fail( "syntax lookup should fail after deleting the syntax" );
         }
         catch( NamingException e )
         {
         }
 
-        assertTrue( getSyntaxRegistry().hasSyntax( NEW_OID ) );
+        assertTrue( schemaManager.getLdapSyntaxRegistry().contains( NEW_OID ) );
     }
 
 
     @Test
+    @Ignore
     public void testMoveSyntax() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         
         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 );
         
         getSchemaContext( service ).rename( dn, newdn );
 
         assertTrue( "syntax OID should still be present", 
-            getSyntaxRegistry().hasSyntax( OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
         
         assertEquals( "syntax schema should be set to apache not apachemeta", 
-            getSyntaxRegistry().getSchemaName( OID ), "apache" );
+            schemaManager.getLdapSyntaxRegistry().getSchemaName( OID ), "apache" );
     }
 
 
     @Test
+    @Ignore
     public void testMoveSyntaxAndChangeRdn() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         
         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 + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
         assertFalse( "old syntax OID should NOT be present", 
-            getSyntaxRegistry().hasSyntax( OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
         
         assertTrue( "new syntax OID should be present", 
-            getSyntaxRegistry().hasSyntax( NEW_OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( NEW_OID ) );
         
         assertEquals( "syntax with new oid should have schema set to apache NOT apachemeta",

-            getSyntaxRegistry().getSchemaName( NEW_OID ), "apache" );
+            schemaManager.getLdapSyntaxRegistry().getSchemaName( NEW_OID ), "apache" );
     }
 
     
     @Test
+    @Ignore
     public void testModifySyntaxWithModificationItems() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         
-        Syntax syntax = getSyntaxRegistry().lookup( OID );
+        LdapSyntax syntax = schemaManager.getLdapSyntaxRegistry().lookup( OID );
         assertEquals( syntax.getDescription(), DESCRIPTION0 );
 
         LdapDN dn = getSyntaxContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
         
         ModificationItem[] mods = new ModificationItem[1];
-        Attribute attr = new BasicAttribute( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION1
);
+        Attribute attr = new BasicAttribute( "m-description", DESCRIPTION1 );
         mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
         getSchemaContext( service ).modifyAttributes( dn, mods );
 
         assertTrue( "syntax OID should still be present", 
-            getSyntaxRegistry().hasSyntax( OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
         
         assertEquals( "syntax schema should be set to apachemeta", 
-            getSyntaxRegistry().getSchemaName( OID ), "apachemeta" );
+            schemaManager.getLdapSyntaxRegistry().getSchemaName( OID ), "apachemeta" );
         
-        syntax = getSyntaxRegistry().lookup( OID );
+        syntax = schemaManager.getLdapSyntaxRegistry().lookup( OID );
         assertEquals( syntax.getDescription(), DESCRIPTION1 );
     }
 
     
     @Test
+    @Ignore
     public void testModifySyntaxWithAttributes() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         
-        Syntax syntax = getSyntaxRegistry().lookup( OID );
+        LdapSyntax syntax = schemaManager.getLdapSyntaxRegistry().lookup( OID );
         assertEquals( syntax.getDescription(), DESCRIPTION0 );
 
         LdapDN dn = getSyntaxContainer( "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( "m-description", DESCRIPTION1 );
         getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods
);
 
         assertTrue( "syntax OID should still be present", 
-            getSyntaxRegistry().hasSyntax( OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
         
         assertEquals( "syntax schema should be set to apachemeta", 
-            getSyntaxRegistry().getSchemaName( OID ), "apachemeta" );
+            schemaManager.getLdapSyntaxRegistry().getSchemaName( OID ), "apachemeta" );
 
-        syntax = getSyntaxRegistry().lookup( OID );
+        syntax = schemaManager.getLdapSyntaxRegistry().lookup( OID );
         assertEquals( syntax.getDescription(), DESCRIPTION1 );
     }
     
@@ -292,8 +363,8 @@
     public void testDeleteSyntaxWhenInUse() throws Exception
     {
         LdapDN dn = getSyntaxContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddSyntax();
+        dn.add( "m-oid" + "=" + OID );
+        testAddSyntaxToEnabledSchema();
         addDependeeMatchingRule( OID );
         
         try
@@ -307,21 +378,22 @@
         }
 
         assertTrue( "syntax should still be in the registry after delete failure", 
-            getSyntaxRegistry().hasSyntax( OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
     }
     
     
     @Test
+    @Ignore
     public void testMoveSyntaxWhenInUse() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         addDependeeMatchingRule( OID );
         
         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
         {
@@ -334,21 +406,22 @@
         }
 
         assertTrue( "syntax should still be in the registry after move failure", 
-            getSyntaxRegistry().hasSyntax( OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
     }
 
 
     @Test
+    @Ignore
     public void testMoveSyntaxAndChangeRdnWhenInUse() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         addDependeeMatchingRule( OID );
         
         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 + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         
         try
         {
@@ -361,53 +434,40 @@
         }
 
         assertTrue( "syntax should still be in the registry after move failure", 
-            getSyntaxRegistry().hasSyntax( OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
     }
 
     
-    /**
-     * Gets relative DN to ou=schema.
-     *
-     * @param schemaName the name of the schmea
-     * @return the dn of the container entry holding matchingRules
-     * @throws Exception on parse errors
-     */
-    private LdapDN getMatchingRuleContainer( String schemaName ) throws Exception
-    {
-        return new LdapDN( "ou=matchingRules,cn=" + schemaName );
-    }
-    
-    
     private void addDependeeMatchingRule( String oid ) 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, MR_OID );
-        attrs.put( MetaSchemaConstants.M_SYNTAX_AT, OID );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, 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( MetaSchemaConstants.M_OID_AT + "=" + MR_OID );
+        dn.add( "m-oid" + "=" + MR_OID );
         getSchemaContext( service ).createSubcontext( dn, attrs );
         
-        assertTrue( getMatchingRuleRegistry().hasMatchingRule( MR_OID ) );
-        assertEquals( getMatchingRuleRegistry().getSchemaName( MR_OID ), "apachemeta" );
+        assertTrue( schemaManager.getMatchingRuleRegistry().contains( MR_OID ) );
+        assertEquals( schemaManager.getMatchingRuleRegistry().getSchemaName( MR_OID ), "apachemeta"
);
     }
 
     
     @Test
+    @Ignore
     public void testRenameNormalizerWhenInUse() throws Exception
     {
         LdapDN dn = getSyntaxContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddSyntax();
+        dn.add( "m-oid" + "=" + OID );
+        testAddSyntaxToEnabledSchema();
         addDependeeMatchingRule( OID );
         
         LdapDN newdn = getSyntaxContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         
         try
         {
@@ -420,7 +480,7 @@
         }
 
         assertTrue( "syntax should still be in the registry after rename failure", 
-            getSyntaxRegistry().hasSyntax( OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
     }
 
 
@@ -430,15 +490,16 @@
 
 
     @Test
+    @Ignore
     public void testMoveSyntaxToTop() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         
         LdapDN dn = getSyntaxContainer( "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
         {
@@ -451,20 +512,21 @@
         }
 
         assertTrue( "syntax should still be in the registry after move failure", 
-            getSyntaxRegistry().hasSyntax( OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
     }
 
 
     @Test
+    @Ignore
     public void testMoveSyntaxToComparatorContainer() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         
         LdapDN dn = getSyntaxContainer( "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
         {
@@ -477,80 +539,60 @@
         }
 
         assertTrue( "syntax should still be in the registry after move failure", 
-            getSyntaxRegistry().hasSyntax( OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
     }
     
     
     @Test
-    public void testAddSyntaxToDisabledSchema() 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_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION0 );
-        
-        // nis is by default inactive
-        LdapDN dn = getSyntaxContainer( "nis" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        createDummySyntaxChecker( OID, "nis" );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
-        
-        assertFalse( "adding new syntax to disabled schema should not register it into the
registries", 
-            getSyntaxRegistry().hasSyntax( OID ) );
-    }
-
-
-    @Test
+    @Ignore
     public void testMoveSyntaxToDisabledSchema() throws Exception
     {
-        testAddSyntax();
+        testAddSyntaxToEnabledSchema();
         
         LdapDN dn = getSyntaxContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         // nis is inactive by default
         LdapDN newdn = getSyntaxContainer( "nis" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
         assertFalse( "syntax OID should no longer be present", 
-            getSyntaxRegistry().hasSyntax( OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
     }
 
 
     @Test
+    @Ignore
     public void testMoveSyntaxToEnabledSchema() throws Exception
     {
         testAddSyntaxToDisabledSchema();
         
         // nis is inactive by default
         LdapDN dn = getSyntaxContainer( "nis" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         assertFalse( "syntax OID should NOT be present when added to disabled nis schema",

-            getSyntaxRegistry().hasSyntax( OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
 
         LdapDN newdn = getSyntaxContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid" + "=" + OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
         assertTrue( "syntax OID should be present when moved to enabled schema", 
-            getSyntaxRegistry().hasSyntax( OID ) );
+            schemaManager.getLdapSyntaxRegistry().contains( OID ) );
         
         assertEquals( "syntax should be in apachemeta schema after move", 
-            getSyntaxRegistry().getSchemaName( OID ), "apachemeta" );
+            schemaManager.getLdapSyntaxRegistry().getSchemaName( OID ), "apachemeta" );
     }
 
 
     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" );
     }
@@ -559,8 +601,9 @@
     private void modify( int op, List<String> descriptions, String opAttr ) throws
Exception
     {
         LdapDN dn = new LdapDN( getSubschemaSubentryDN() );
-        dn.normalize( service.getRegistries().getAttributeTypeRegistry().getNormalizerMapping()
);
+        dn.normalize( service.getSchemaManager().getNormalizerMapping() );
         Attribute attr = new BasicAttribute( opAttr );
+        
         for ( String description : descriptions )
         {
             attr.add( description );

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateIT.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateIT.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateIT.java
Wed Jan  6 18:26:43 2010
@@ -20,17 +20,12 @@
 package org.apache.directory.server.core.schema;
 
 
-import org.apache.directory.server.constants.MetaSchemaConstants;
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.integ.CiRunner;
-import static org.apache.directory.server.core.integ.IntegrationUtils.*;
-import org.apache.directory.shared.ldap.name.LdapDN;
+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.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-import org.junit.runner.RunWith;
 
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
@@ -42,16 +37,20 @@
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
 
-@RunWith ( CiRunner.class )
-public class ObjectClassCreateIT
+@RunWith(FrameworkRunner.class)
+public class ObjectClassCreateIT extends AbstractLdapTestUnit
 {
     private String testOID = "1.3.6.1.4.1.18060.0.4.0.3.1.555555.5555.5555555";
 
 
-    public static DirectoryService service;
-
-    
     private void injectSchema() throws Exception
     {
         //--------------------------------------------------------------------

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceIT.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceIT.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceIT.java
Wed Jan  6 18:26:43 2010
@@ -20,22 +20,17 @@
 package org.apache.directory.server.core.schema;
 
 
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.integ.CiRunner;
 import static org.apache.directory.server.core.integ.IntegrationUtils.getRootContext;
 import static org.apache.directory.server.core.integ.IntegrationUtils.getSchemaContext;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescription;
-import org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescriptionSchemaParser;
-
 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 java.util.ArrayList;
+import java.util.List;
 
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
@@ -48,8 +43,14 @@
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 
-import java.util.ArrayList;
-import java.util.List;
+import org.apache.directory.server.core.annotations.CreateDS;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescriptionSchemaParser;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
 
 /**
@@ -59,14 +60,13 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-@RunWith(CiRunner.class)
-public class SchemaPersistenceIT
+@RunWith(FrameworkRunner.class)
+@CreateDS( name="SchemaPersistenceIT-class" )
+public class SchemaPersistenceIT extends AbstractLdapTestUnit
 {
     private static final String SUBSCHEMA_SUBENTRY = "subschemaSubentry";
     private static final AttributeTypeDescriptionSchemaParser ATTRIBUTE_TYPE_DESCRIPTION_SCHEMA_PARSER
= new AttributeTypeDescriptionSchemaParser();
 
-    public static DirectoryService service;
-
 
     /**
      * Tests to see if an attributeType is persisted when added, then server 
@@ -86,13 +86,25 @@
             // test successful add with everything
             // -------------------------------------------------------------------
 
-            descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.2.10000 NAME 'type0' " + "OBSOLETE
SUP 2.5.4.41 "
-                + "EQUALITY caseExactIA5Match " + "ORDERING octetStringOrderingMatch "
-                + "SUBSTR caseExactIA5SubstringsMatch COLLECTIVE " + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
"
-                + "SINGLE-VALUE USAGE userApplications X-SCHEMA 'nis' )" );
-            descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.2.10001 NAME ( 'type1' 'altName'
) "
-                + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SUP 2.5.4.41 "
-                + "NO-USER-MODIFICATION USAGE directoryOperation X-SCHEMA 'nis' )" );
+            descriptions.add( 
+                "( 1.3.6.1.4.1.18060.0.4.1.2.10000 " +
+                "  NAME 'type0' " + 
+                "  OBSOLETE SUP 2.5.4.41 " +
+                "  EQUALITY caseExactIA5Match " + 
+                "  ORDERING octetStringOrderingMatch " +
+                "  SUBSTR caseExactIA5SubstringsMatch " +
+                "  COLLECTIVE " + 
+                "  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " +
+                "  SINGLE-VALUE USAGE userApplications " +
+                "  X-SCHEMA 'nis' )" );
+            
+            descriptions.add( 
+                "( 1.3.6.1.4.1.18060.0.4.1.2.10001 " +
+                "  NAME ( 'type1' 'altName' ) " +
+                "  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " + 
+                "  SUP 2.5.4.41 " +
+                "  USAGE userApplications " +
+                "  X-SCHEMA 'nis' )" );
 
             modify( DirContext.ADD_ATTRIBUTE, descriptions, "attributeTypes" );
 
@@ -200,13 +212,15 @@
 
         Attributes attrs = getSubschemaSubentryAttributes();
         Attribute attrTypes = attrs.get( "attributeTypes" );
-        AttributeTypeDescription attributeTypeDescription = null;
+        AttributeType attributeType = null;
+        
         for ( int ii = 0; ii < attrTypes.size(); ii++ )
         {
             String desc = ( String ) attrTypes.get( ii );
+            
             if ( desc.indexOf( oid ) != -1 )
             {
-                attributeTypeDescription = ATTRIBUTE_TYPE_DESCRIPTION_SCHEMA_PARSER
+                attributeType = ATTRIBUTE_TYPE_DESCRIPTION_SCHEMA_PARSER
                     .parseAttributeTypeDescription( desc );
                 break;
             }
@@ -214,12 +228,12 @@
 
         if ( isPresent )
         {
-            assertNotNull( attributeTypeDescription );
-            assertEquals( oid, attributeTypeDescription.getNumericOid() );
+            assertNotNull( attributeType );
+            assertEquals( oid, attributeType.getOid() );
         }
         else
         {
-            assertNull( attributeTypeDescription );
+            assertNull( attributeType );
         }
 
         // -------------------------------------------------------------------
@@ -254,11 +268,11 @@
 
         if ( isPresent )
         {
-            assertTrue( service.getRegistries().getAttributeTypeRegistry().hasAttributeType(
oid ) );
+            assertTrue( service.getSchemaManager().getAttributeTypeRegistry().contains( oid
) );
         }
         else
         {
-            assertFalse( service.getRegistries().getAttributeTypeRegistry().hasAttributeType(
oid ) );
+            assertFalse( service.getSchemaManager().getAttributeTypeRegistry().contains(
oid ) );
         }
     }
 }

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaServiceIT.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaServiceIT.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaServiceIT.java
Wed Jan  6 18:26:43 2010
@@ -20,9 +20,19 @@
 package org.apache.directory.server.core.schema;
 
 
+import static org.apache.directory.server.core.integ.IntegrationUtils.getRootContext;
+import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+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 java.io.StringReader;
 import java.util.HashMap;
 import java.util.Map;
+
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
@@ -32,24 +42,14 @@
 import javax.naming.directory.SearchResult;
 import javax.naming.ldap.LdapContext;
 
-import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.annotations.ApplyLdifs;
 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.getRootContext;
-import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext;
-import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
-
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.ldif.LdifReader;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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;
 
@@ -63,29 +63,26 @@
  */
 @ApplyLdifs( {
     // Entry # 1
-    "dn: cn=person0,ou=system\n" +
-    "objectClass: person\n" +
-    "cn: person0\n" +
+    "dn: cn=person0,ou=system",
+    "objectClass: person",
+    "cn: person0",
     "sn: sn_person0\n",
     // Entry # 2
-    "dn: cn=person1,ou=system\n" +
-    "objectClass: organizationalPerson\n" +
-    "cn: person1\n" +
-    "sn: sn_person1\n" +
-    "seealso: cn=Good One,ou=people,o=sevenSeas\n" +
+    "dn: cn=person1,ou=system",
+    "objectClass: organizationalPerson",
+    "cn: person1",
+    "sn: sn_person1",
+    "seealso: cn=Good One,ou=people,o=sevenSeas",
     "seealso:: Y249QmFkIEXDqWvDoCxvdT1wZW9wbGUsbz1zZXZlblNlYXM=\n",
     // Entry # 3
-    "dn: cn=person2,ou=system\n" +
-    "objectClass: inetOrgPerson\n" +
-    "cn: person2\n" +
-    "sn: sn_person2\n" }
+    "dn: cn=person2,ou=system",
+    "objectClass: inetOrgPerson",
+    "cn: person2",
+    "sn: sn_person2" }
     )
-@RunWith ( CiRunner.class )
-public class SchemaServiceIT
+@RunWith(FrameworkRunner.class)
+public class SchemaServiceIT extends AbstractLdapTestUnit
 {
-    /** The Directory service */
-    public static DirectoryService service;
-
 
     /**
      * For <a href="https://issues.apache.org/jira/browse/DIRSERVER-925">DIRSERVER-925</a>.
@@ -180,13 +177,13 @@
         
         // should be fine with unique OID
         service.getAdminSession().add( 
-            new DefaultServerEntry( service.getRegistries(), numberOfGunsAttrEntry.getEntry()
) ); 
+            new DefaultServerEntry( service.getSchemaManager(), numberOfGunsAttrEntry.getEntry()
) ); 
 
         // should blow chuncks using same OID
         try
         {
             service.getAdminSession().add( 
-                new DefaultServerEntry( service.getRegistries(), shipOCEntry.getEntry() )
); 
+                new DefaultServerEntry( service.getSchemaManager(), shipOCEntry.getEntry()
) ); 
             
             fail( "Should not be possible to create two schema entities with the same OID."
);
         }



Mime
View raw message