directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r924913 [1/2] - /directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/
Date Thu, 18 Mar 2010 17:34:58 GMT
Author: elecharny
Date: Thu Mar 18 17:34:57 2010
New Revision: 924913

URL: http://svn.apache.org/viewvc?rev=924913&view=rev
Log:
fixed the exceptions for core-integ/schema

Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaServiceIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryIT.java

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java?rev=924913&r1=924912&r2=924913&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java Thu Mar 18 17:34:57 2010
@@ -27,7 +27,7 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
+import javax.naming.OperationNotSupportedException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
@@ -93,7 +93,7 @@ public class MetaAttributeTypeHandlerIT 
         assertFalse( service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
 
         // Addition
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         // Post-checks
         assertTrue( service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
@@ -121,7 +121,7 @@ public class MetaAttributeTypeHandlerIT 
         
         try
         {
-            getSchemaContext( service ).createSubcontext( dn, attrs );
+            getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
             fail( "Should not be there" );
         }
         catch( NameNotFoundException nnfe )
@@ -154,7 +154,7 @@ public class MetaAttributeTypeHandlerIT 
         DN dn = getAttributeTypeContainer( "nis" );
         dn.add( "m-oid=" + OID );
         
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertFalse( "adding new attributeType to disabled schema should not register it into the registries", 
             service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
@@ -185,7 +185,7 @@ public class MetaAttributeTypeHandlerIT 
         // Check on disk that the added SchemaObject exist
         assertTrue( isOnDisk( dn ) );
         
-        getSchemaContext( service ).destroySubcontext( dn );
+        getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
 
         // Check in Registries
         assertFalse( "attributeType should be removed from the registry after being deleted", 
@@ -218,7 +218,7 @@ public class MetaAttributeTypeHandlerIT 
         assertTrue( isOnDisk( dn ) );
         
         // Remove the AT
-        getSchemaContext( service ).destroySubcontext( dn );
+        getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
 
         // Check in Registries
         assertFalse( "attributeType should be removed from the registry after being deleted", 
@@ -241,12 +241,11 @@ public class MetaAttributeTypeHandlerIT 
         
         try
         {
-            getSchemaContext( service ).destroySubcontext( dn );
+            getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
             fail( "should not be able to delete a attributeType in use" );
         }
-        catch( LdapUnwillingToPerformException e ) 
+        catch( OperationNotSupportedException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
         assertTrue( "attributeType should still be in the registry after delete failure", 
@@ -275,7 +274,7 @@ public class MetaAttributeTypeHandlerIT 
         mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
         attr = new BasicAttribute( "m-syntax", SchemaConstants.DIRECTORY_STRING_SYNTAX );
         mods[1] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        getSchemaContext( service ).modifyAttributes( dn, mods );
+        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), mods );
 
         assertTrue( "attributeType OID should still be present", 
             service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
@@ -305,7 +304,7 @@ public class MetaAttributeTypeHandlerIT 
         Attributes mods = new BasicAttributes( true );
         mods.put( "m-description", DESCRIPTION1 );
         mods.put( "m-syntax", SchemaConstants.DIRECTORY_STRING_SYNTAX );
-        getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
+        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );
 
         assertTrue( "attributeType OID should still be present", 
             service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
@@ -334,19 +333,13 @@ public class MetaAttributeTypeHandlerIT 
         
         DN newdn = getAttributeTypeContainer( "apachemeta" );
         newdn.add( "m-oid=" + NEW_OID );
-        schemaRoot.rename( dn, newdn );
+        schemaRoot.rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "old attributeType OID should be removed from the registry after being renamed", 
             service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
         
-        try
-        {
-            service.getSchemaManager().getAttributeTypeRegistry().lookup( OID );
-            fail( "attributeType lookup should fail after renaming the attributeType" );
-        }
-        catch( NamingException e )
-        {
-        }
+        service.getSchemaManager().getAttributeTypeRegistry().lookup( OID );
+        fail( "attributeType lookup should fail after renaming the attributeType" );
 
         assertTrue( service.getSchemaManager().getAttributeTypeRegistry().contains( NEW_OID ) );
     }
@@ -367,7 +360,7 @@ public class MetaAttributeTypeHandlerIT 
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to rename a attributeType in use" );
         }
         catch( LdapUnwillingToPerformException e ) 
@@ -395,7 +388,7 @@ public class MetaAttributeTypeHandlerIT 
         DN newdn = getAttributeTypeContainer( "apache" );
         newdn.add( "m-oid=" + OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertTrue( "attributeType OID should still be present",
                 service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
@@ -417,7 +410,7 @@ public class MetaAttributeTypeHandlerIT 
         DN newdn = getAttributeTypeContainer( "apache" );
         newdn.add( "m-oid=" + NEW_OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "old attributeType OID should NOT be present", 
             service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
@@ -444,7 +437,7 @@ public class MetaAttributeTypeHandlerIT 
         
         try
         {
-            getSchemaContext( service ).rename( dn, top );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( top ) );
             fail( "should not be able to move a attributeType up to ou=schema" );
         }
         catch( LdapInvalidDnException e ) 
@@ -471,7 +464,7 @@ public class MetaAttributeTypeHandlerIT 
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move a attributeType into comparators container" );
         }
         catch( LdapInvalidDnException e ) 
@@ -497,7 +490,7 @@ public class MetaAttributeTypeHandlerIT 
         DN newdn = getAttributeTypeContainer( "nis" );
         newdn.add( "m-oid=" + OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "attributeType OID should no longer be present", 
             service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
@@ -519,7 +512,7 @@ public class MetaAttributeTypeHandlerIT 
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move a attributeType in use" );
         }
         catch( LdapUnwillingToPerformException e ) 
@@ -547,7 +540,7 @@ public class MetaAttributeTypeHandlerIT 
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move a attributeType in use" );
         }
         catch( LdapUnwillingToPerformException e ) 
@@ -579,7 +572,7 @@ public class MetaAttributeTypeHandlerIT 
         
         DN dn = getAttributeTypeContainer( "apachemeta" );
         dn.add( "m-oid=" + DEPENDEE_OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertTrue( service.getSchemaManager().getAttributeTypeRegistry().contains( DEPENDEE_OID ) );
         assertEquals( service.getSchemaManager().getAttributeTypeRegistry().getSchemaName( DEPENDEE_OID ), "apachemeta" );

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java?rev=924913&r1=924912&r2=924913&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java Thu Mar 18 17:34:57 2010
@@ -30,7 +30,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 
 import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
+import javax.naming.OperationNotSupportedException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
@@ -40,6 +40,7 @@ import javax.naming.directory.Modificati
 
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.exception.LdapUnwillingToPerformException;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
@@ -109,7 +110,7 @@ public class MetaComparatorHandlerIT ext
         assertFalse( service.getSchemaManager().getComparatorRegistry().contains( OID ) );
 
         // Addition
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
 
         // Post-checks
         assertTrue( schemaManager.getComparatorRegistry().contains( OID ) );
@@ -136,7 +137,7 @@ public class MetaComparatorHandlerIT ext
         assertFalse( service.getSchemaManager().getComparatorRegistry().contains( OID ) );
 
         // Addition
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
 
         // Post-checks
         assertFalse( "adding new comparator to disabled schema should not register it into the registries",
@@ -163,7 +164,7 @@ public class MetaComparatorHandlerIT ext
         // Addition
         try
         {
-            getSchemaContext( service ).createSubcontext( dn, attrs );
+            getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
             fail( "Should not be there" );
         }
         catch ( NameNotFoundException nnfe )
@@ -202,7 +203,7 @@ public class MetaComparatorHandlerIT ext
         assertFalse( service.getSchemaManager().getComparatorRegistry().contains( OID ) );
 
         // Addition
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
 
         // Post-checks
         assertTrue( schemaManager.getComparatorRegistry().contains( OID ) );
@@ -238,7 +239,7 @@ public class MetaComparatorHandlerIT ext
         assertFalse( service.getSchemaManager().getComparatorRegistry().contains( OID ) );
 
         // Addition
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
 
         // Post-checks
         assertFalse( "adding new comparator to disabled schema should not register it into the registries",
@@ -264,7 +265,7 @@ public class MetaComparatorHandlerIT ext
         assertTrue( isOnDisk( dn ) );
 
         // Deletion
-        getSchemaContext( service ).destroySubcontext( dn );
+        getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
 
         // Post-checks
         assertFalse( "comparator should be removed from the registry after being deleted", schemaManager
@@ -275,7 +276,7 @@ public class MetaComparatorHandlerIT ext
             schemaManager.getComparatorRegistry().lookup( OID );
             fail( "comparator lookup should fail after deleting the comparator" );
         }
-        catch ( NamingException e )
+        catch ( LdapException e )
         {
         }
 
@@ -296,7 +297,7 @@ public class MetaComparatorHandlerIT ext
         assertTrue( isOnDisk( dn ) );
 
         // Deletion
-        getSchemaContext( service ).destroySubcontext( dn );
+        getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
 
         // Post-checks
         assertFalse( "comparator should be removed from the registry after being deleted", schemaManager
@@ -307,7 +308,7 @@ public class MetaComparatorHandlerIT ext
             schemaManager.getComparatorRegistry().lookup( OID );
             fail( "comparator lookup should fail after deleting the comparator" );
         }
-        catch ( NamingException e )
+        catch ( LdapException e )
         {
         }
 
@@ -343,7 +344,7 @@ public class MetaComparatorHandlerIT ext
         assertFalse( service.getSchemaManager().getMatchingRuleRegistry().contains( OID ) );
 
         // MatchingRule Addition
-        getSchemaContext( service ).createSubcontext( mrDn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( mrDn ), attrs );
 
         // Post-checks
         assertTrue( isOnDisk( mrDn ) );
@@ -351,12 +352,11 @@ public class MetaComparatorHandlerIT ext
 
         try
         {
-            getSchemaContext( service ).destroySubcontext( cDn );
+            getSchemaContext( service ).destroySubcontext( DN.toName( cDn ) );
             fail( "should not be able to delete a comparator in use" );
         }
-        catch ( LdapUnwillingToPerformException e )
+        catch ( OperationNotSupportedException e )
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
         assertTrue( "comparator should still be in the registry after delete failure", schemaManager
@@ -379,7 +379,7 @@ public class MetaComparatorHandlerIT ext
         ModificationItem[] mods = new ModificationItem[1];
         Attribute attr = new BasicAttribute( "m-fqcn", BooleanComparator.class.getName() );
         mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        getSchemaContext( service ).modifyAttributes( dn, mods );
+        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), mods );
 
         assertTrue( "comparator OID should still be present", schemaManager.getComparatorRegistry().contains( OID ) );
 
@@ -402,7 +402,7 @@ public class MetaComparatorHandlerIT ext
 
         Attributes mods = new BasicAttributes( true );
         mods.put( "m-fqcn", BooleanComparator.class.getName() );
-        getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
+        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );
 
         assertTrue( "comparator OID should still be present", schemaManager.getComparatorRegistry().contains( OID ) );
 
@@ -427,7 +427,7 @@ public class MetaComparatorHandlerIT ext
 
         DN newdn = getComparatorContainer( "apachemeta" );
         newdn.add( "m-oid" + "=" + NEW_OID );
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "old comparator OID should be removed from the registry after being renamed", schemaManager
             .getComparatorRegistry().contains( OID ) );
@@ -437,7 +437,7 @@ public class MetaComparatorHandlerIT ext
             schemaManager.getComparatorRegistry().lookup( OID );
             fail( "comparator lookup should fail after deleting the comparator" );
         }
-        catch ( NamingException e )
+        catch ( LdapException e )
         {
         }
 
@@ -461,7 +461,7 @@ public class MetaComparatorHandlerIT ext
 
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to rename a comparator in use" );
         }
         catch ( LdapUnwillingToPerformException e )
@@ -491,7 +491,7 @@ public class MetaComparatorHandlerIT ext
         DN newdn = getComparatorContainer( "apache" );
         newdn.add( "m-oid" + "=" + OID );
 
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertTrue( "comparator OID should still be present", schemaManager.getComparatorRegistry().contains( OID ) );
 
@@ -515,7 +515,7 @@ public class MetaComparatorHandlerIT ext
         DN newdn = getComparatorContainer( "apache" );
         newdn.add( "m-oid" + "=" + NEW_OID );
 
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "old comparator OID should NOT be present", schemaManager.getComparatorRegistry().contains( OID ) );
 
@@ -547,7 +547,7 @@ public class MetaComparatorHandlerIT ext
 
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move a comparator in use" );
         }
         catch ( LdapUnwillingToPerformException e )
@@ -577,7 +577,7 @@ public class MetaComparatorHandlerIT ext
 
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move a comparator in use" );
         }
         catch ( LdapUnwillingToPerformException e )
@@ -610,7 +610,7 @@ public class MetaComparatorHandlerIT ext
 
         try
         {
-            getSchemaContext( service ).rename( dn, top );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( top ) );
             fail( "should not be able to move a comparator up to ou=schema" );
         }
         catch ( LdapInvalidDnException e )
@@ -637,7 +637,7 @@ public class MetaComparatorHandlerIT ext
 
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move a comparator up to normalizers container" );
         }
         catch ( LdapInvalidDnException e )
@@ -663,7 +663,7 @@ public class MetaComparatorHandlerIT ext
         DN newdn = getComparatorContainer( "nis" );
         newdn.add( "m-oid" + "=" + OID );
 
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "comparator OID should no longer be present", schemaManager.getComparatorRegistry().contains( OID ) );
     }
@@ -685,7 +685,7 @@ public class MetaComparatorHandlerIT ext
         DN newdn = getComparatorContainer( "apachemeta" );
         newdn.add( "m-oid" + "=" + OID );
 
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertTrue( "comparator OID should be present when moved to enabled schema", schemaManager
             .getComparatorRegistry().contains( OID ) );

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java?rev=924913&r1=924912&r2=924913&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java Thu Mar 18 17:34:57 2010
@@ -27,7 +27,6 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
@@ -37,6 +36,7 @@ import javax.naming.directory.Modificati
 
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
@@ -91,7 +91,7 @@ public class MetaMatchingRuleHandlerIT e
         dn.add( "m-oid" + "=" + OID );
         
         // Addition
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertTrue( isOnDisk( dn ) );
         assertTrue( service.getSchemaManager().getComparatorRegistry().contains( OID ) );
@@ -124,7 +124,7 @@ public class MetaMatchingRuleHandlerIT e
         assertFalse( service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
 
         // Addition
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         // Post-checks
         assertTrue( service.getSchemaManager().getMatchingRuleRegistry().contains( OID ) );
@@ -148,7 +148,7 @@ public class MetaMatchingRuleHandlerIT e
         
         DN dn = getMatchingRuleContainer( "nis" );
         dn.add( "m-oid" + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertFalse( "adding new matchingRule to disabled schema should not register it into the registries", 
             schemaManager.getMatchingRuleRegistry().contains( OID ) );
@@ -174,7 +174,7 @@ public class MetaMatchingRuleHandlerIT e
         
         try
         {
-            getSchemaContext( service ).createSubcontext( dn, attrs );
+            getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
             fail( "Should not be there" );
         }
         catch( NameNotFoundException nnfe )
@@ -202,7 +202,7 @@ public class MetaMatchingRuleHandlerIT e
             schemaManager.getMatchingRuleRegistry().contains( OID ) );
         assertTrue( isOnDisk( dn ) );
         
-        getSchemaContext( service ).destroySubcontext( dn );
+        getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
 
         assertFalse( "matchingRule should be removed from the registry after being deleted", 
             schemaManager.getMatchingRuleRegistry().contains( OID ) );
@@ -212,7 +212,7 @@ public class MetaMatchingRuleHandlerIT e
             schemaManager.getMatchingRuleRegistry().lookup( OID );
             fail( "matchingRule lookup should fail after deleting it" );
         }
-        catch( NamingException e )
+        catch( LdapException e )
         {
         }
 
@@ -231,7 +231,7 @@ public class MetaMatchingRuleHandlerIT e
             schemaManager.getMatchingRuleRegistry().contains( OID ) );
         assertTrue( isOnDisk( dn ) );
         
-        getSchemaContext( service ).destroySubcontext( dn );
+        getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
 
         assertFalse( "matchingRule should be removed from the registry after being deleted", 
             schemaManager.getMatchingRuleRegistry().contains( OID ) );
@@ -260,7 +260,7 @@ public class MetaMatchingRuleHandlerIT e
         mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
         attr = new BasicAttribute( "m-syntax", SchemaConstants.DIRECTORY_STRING_SYNTAX );
         mods[1] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        getSchemaContext( service ).modifyAttributes( dn, mods );
+        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), mods );
 
         assertTrue( "matchingRule OID should still be present", 
             schemaManager.getMatchingRuleRegistry().contains( OID ) );
@@ -290,7 +290,7 @@ public class MetaMatchingRuleHandlerIT e
         Attributes mods = new BasicAttributes( true );
         mods.put( "m-description", DESCRIPTION1 );
         mods.put( "m-syntax", SchemaConstants.DIRECTORY_STRING_SYNTAX );
-        getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
+        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );
 
         assertTrue( "matchingRule OID should still be present", 
             schemaManager.getMatchingRuleRegistry().contains( OID ) );
@@ -317,7 +317,7 @@ public class MetaMatchingRuleHandlerIT e
         
         DN newdn = getMatchingRuleContainer( "apachemeta" );
         newdn.add( "m-oid" + "=" + NEW_OID );
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "old matchingRule OID should be removed from the registry after being renamed", 
             schemaManager.getMatchingRuleRegistry().contains( OID ) );
@@ -327,7 +327,7 @@ public class MetaMatchingRuleHandlerIT e
             schemaManager.getMatchingRuleRegistry().lookup( OID );
             fail( "matchingRule lookup should fail after renaming the matchingRule" );
         }
-        catch( NamingException e )
+        catch( LdapException e )
         {
         }
 
@@ -350,7 +350,7 @@ public class MetaMatchingRuleHandlerIT e
         DN newdn = getMatchingRuleContainer( "apache" );
         newdn.add( "m-oid" + "=" + OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertTrue( "matchingRule OID should still be present", 
             schemaManager.getMatchingRuleRegistry().contains( OID ) );
@@ -372,7 +372,7 @@ public class MetaMatchingRuleHandlerIT e
         DN newdn = getMatchingRuleContainer( "apache" );
         newdn.add( "m-oid" + "=" + NEW_OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "old matchingRule OID should NOT be present", 
             schemaManager.getMatchingRuleRegistry().contains( OID ) );
@@ -399,7 +399,7 @@ public class MetaMatchingRuleHandlerIT e
 //        
 //        try
 //        {
-//            super.schemaRoot.destroySubcontext( dn );
+//            super.schemaRoot.destroySubcontext( DN.toName( dn ) );
 //            fail( "should not be able to delete a syntax in use" );
 //        }
 //        catch( LdapUnwillingToPerformException e ) 
@@ -425,7 +425,7 @@ public class MetaMatchingRuleHandlerIT e
 //        
 //        try
 //        {
-//            super.schemaRoot.rename( dn, newdn );
+//            super.schemaRoot.rename( DN.toName( dn ), DN.toName( newdn ) );
 //            fail( "should not be able to move a syntax in use" );
 //        }
 //        catch( LdapUnwillingToPerformException e ) 
@@ -451,7 +451,7 @@ public class MetaMatchingRuleHandlerIT e
 //        
 //        try
 //        {
-//            super.schemaRoot.rename( dn, newdn );
+//            super.schemaRoot.rename( DN.toName( dn ), DN.toName( newdn ) );
 //            fail( "should not be able to move a syntax in use" );
 //        }
 //        catch( LdapUnwillingToPerformException e ) 
@@ -485,7 +485,7 @@ public class MetaMatchingRuleHandlerIT e
 //        
 //        try
 //        {
-//            super.schemaRoot.rename( dn, newdn );
+//            super.schemaRoot.rename( DN.toName( dn ), DN.toName( newdn ) );
 //            fail( "should not be able to rename a syntax in use" );
 //        }
 //        catch( LdapUnwillingToPerformException e ) 
@@ -517,7 +517,7 @@ public class MetaMatchingRuleHandlerIT e
         
         try
         {
-            getSchemaContext( service ).rename( dn, top );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( top ) );
             fail( "should not be able to move a matchingRule up to ou=schema" );
         }
         catch( LdapInvalidDnException e ) 
@@ -544,7 +544,7 @@ public class MetaMatchingRuleHandlerIT e
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move a matchingRule into comparators container" );
         }
         catch( LdapInvalidDnException e ) 
@@ -570,7 +570,7 @@ public class MetaMatchingRuleHandlerIT e
         DN newdn = getMatchingRuleContainer( "nis" );
         newdn.add( "m-oid" + "=" + OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "matchingRule OID should no longer be present", 
             schemaManager.getMatchingRuleRegistry().contains( OID ) );
@@ -593,7 +593,7 @@ public class MetaMatchingRuleHandlerIT e
         DN newdn = getMatchingRuleContainer( "apachemeta" );
         newdn.add( "m-oid" + "=" + OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertTrue( "matchingRule OID should be present when moved to enabled schema", 
             schemaManager.getMatchingRuleRegistry().contains( OID ) );

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java?rev=924913&r1=924912&r2=924913&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java Thu Mar 18 17:34:57 2010
@@ -30,7 +30,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 
 import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
+import javax.naming.OperationNotSupportedException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
@@ -40,8 +40,9 @@ import javax.naming.directory.Modificati
 
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
-import org.apache.directory.shared.ldap.exception.LdapUnwillingToPerformException;
+//import org.apache.directory.shared.ldap.exception.LdapUnwillingToPerformException;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.DN;
@@ -94,7 +95,7 @@ public class MetaNormalizerHandlerIT ext
         
         DN dn = getNormalizerContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertTrue( schemaManager.getNormalizerRegistry().contains( OID ) );
         assertEquals( schemaManager.getNormalizerRegistry().getSchemaName( OID ), "apachemeta" );
@@ -118,7 +119,7 @@ public class MetaNormalizerHandlerIT ext
         // nis is by default inactive
         DN dn = getNormalizerContainer( "nis" );
         dn.add( "m-oid" + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertFalse( "adding new normalizer to disabled schema should not register it into the registries", 
             schemaManager.getNormalizerRegistry().contains( OID ) );
@@ -143,7 +144,7 @@ public class MetaNormalizerHandlerIT ext
 
         try
         {
-            getSchemaContext( service ).createSubcontext( dn, attrs );
+            getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
             fail( "Should not be there" );
         }
         catch( NameNotFoundException nnfe )
@@ -179,7 +180,7 @@ public class MetaNormalizerHandlerIT ext
         
         DN dn = getNormalizerContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertTrue( schemaManager.getNormalizerRegistry().contains( OID ) );
         assertEquals( schemaManager.getNormalizerRegistry().getSchemaName( OID ), "apachemeta" );
@@ -211,7 +212,7 @@ public class MetaNormalizerHandlerIT ext
         
         DN dn = getNormalizerContainer( "nis" );
         dn.add( "m-oid" + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertFalse( schemaManager.getNormalizerRegistry().contains( OID ) );
         assertTrue( isOnDisk( dn ) );
@@ -229,7 +230,7 @@ public class MetaNormalizerHandlerIT ext
             schemaManager.getNormalizerRegistry().contains( OID ) );
         assertTrue( isOnDisk( dn ) );
         
-        getSchemaContext( service ).destroySubcontext( dn );
+        getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
 
         assertFalse( "normalizer should be removed from the registry after being deleted", 
             schemaManager.getNormalizerRegistry().contains( OID ) );
@@ -239,7 +240,7 @@ public class MetaNormalizerHandlerIT ext
             schemaManager.getNormalizerRegistry().lookup( OID );
             fail( "normalizer lookup should fail after deleting the normalizer" );
         }
-        catch( NamingException e )
+        catch( LdapException e )
         {
         }
 
@@ -258,7 +259,7 @@ public class MetaNormalizerHandlerIT ext
             schemaManager.getNormalizerRegistry().contains( OID ) );
         assertTrue( isOnDisk( dn ) );
         
-        getSchemaContext( service ).destroySubcontext( dn );
+        getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
 
         assertFalse( "normalizer should be removed from the registry after being deleted", 
             schemaManager.getNormalizerRegistry().contains( OID ) );
@@ -268,7 +269,7 @@ public class MetaNormalizerHandlerIT ext
             schemaManager.getNormalizerRegistry().lookup( OID );
             fail( "normalizer lookup should fail after deleting the normalizer" );
         }
-        catch( NamingException e )
+        catch( LdapException e )
         {
         }
 
@@ -286,7 +287,7 @@ public class MetaNormalizerHandlerIT ext
         
         DN newdn = getNormalizerContainer( "apachemeta" );
         newdn.add( "m-oid" + "=" + NEW_OID );
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "old normalizer OID should be removed from the registry after being renamed", 
             schemaManager.getNormalizerRegistry().contains( OID ) );
@@ -297,7 +298,7 @@ public class MetaNormalizerHandlerIT ext
             schemaManager.getNormalizerRegistry().lookup( OID );
             fail( "normalizer lookup should fail after deleting the normalizer" );
         }
-        catch( NamingException e )
+        catch( LdapException e )
         {
         }
 
@@ -319,7 +320,7 @@ public class MetaNormalizerHandlerIT ext
         DN newdn = getNormalizerContainer( "apache" );
         newdn.add( "m-oid" + "=" + OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertTrue( "normalizer OID should still be present", 
             schemaManager.getNormalizerRegistry().contains( OID ) );
@@ -344,7 +345,7 @@ public class MetaNormalizerHandlerIT ext
         DN newdn = getNormalizerContainer( "apache" );
         newdn.add( "m-oid" + "=" + NEW_OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "old normalizer OID should NOT be present", 
             schemaManager.getNormalizerRegistry().contains( OID ) );
@@ -372,7 +373,7 @@ public class MetaNormalizerHandlerIT ext
         ModificationItem[] mods = new ModificationItem[1];
         Attribute attr = new BasicAttribute( "m-fqcn", DeepTrimNormalizer.class.getName() );
         mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        getSchemaContext( service ).modifyAttributes( dn, mods );
+        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), mods );
 
         assertTrue( "normalizer OID should still be present", 
             schemaManager.getNormalizerRegistry().contains( OID ) );
@@ -396,7 +397,7 @@ public class MetaNormalizerHandlerIT ext
         
         Attributes mods = new BasicAttributes( true );
         mods.put( "m-fqcn", DeepTrimNormalizer.class.getName() );
-        getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
+        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );
 
         assertTrue( "normalizer OID should still be present", 
             schemaManager.getNormalizerRegistry().contains( OID ) );
@@ -440,7 +441,7 @@ public class MetaNormalizerHandlerIT ext
         assertFalse( service.getSchemaManager().getMatchingRuleRegistry().contains( OID ) );
 
         // MatchingRule Addition
-        getSchemaContext( service ).createSubcontext( mrDn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( mrDn ), attrs );
 
         // Post-checks
         assertTrue( isOnDisk( mrDn ) );
@@ -448,12 +449,11 @@ public class MetaNormalizerHandlerIT ext
 
         try
         {
-            getSchemaContext( service ).destroySubcontext( nDn );
+            getSchemaContext( service ).destroySubcontext( DN.toName( nDn ) );
             fail( "should not be able to delete a Normalizer in use" );
         }
-        catch ( LdapUnwillingToPerformException e )
+        catch ( OperationNotSupportedException e )
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
         assertTrue( "Normalizer should still be in the registry after delete failure", schemaManager
@@ -476,12 +476,11 @@ public class MetaNormalizerHandlerIT ext
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move a normalizer in use" );
         }
-        catch( LdapUnwillingToPerformException e ) 
+        catch( OperationNotSupportedException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
         assertTrue( "normalizer should still be in the registry after move failure", 
@@ -506,12 +505,11 @@ public class MetaNormalizerHandlerIT ext
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move a normalizer in use" );
         }
-        catch( LdapUnwillingToPerformException e ) 
+        catch( OperationNotSupportedException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
         assertTrue( "normalizer should still be in the registry after move failure", 
@@ -535,12 +533,11 @@ public class MetaNormalizerHandlerIT ext
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to rename a normalizer in use" );
         }
-        catch( LdapUnwillingToPerformException e ) 
+        catch( OperationNotSupportedException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
         assertTrue( "normalizer should still be in the registry after rename failure", 
@@ -569,7 +566,7 @@ public class MetaNormalizerHandlerIT ext
         
         try
         {
-            getSchemaContext( service ).rename( dn, top );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( top ) );
             fail( "should not be able to move a normalizer up to ou=schema" );
         }
         catch( LdapInvalidDnException e ) 
@@ -596,7 +593,7 @@ public class MetaNormalizerHandlerIT ext
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move a normalizer into comparators container" );
         }
         catch( LdapInvalidDnException e ) 
@@ -622,7 +619,7 @@ public class MetaNormalizerHandlerIT ext
         DN newdn = getNormalizerContainer( "nis" );
         newdn.add( "m-oid" + "=" + OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "normalizer OID should no longer be present", 
             schemaManager.getNormalizerRegistry().contains( OID ) );
@@ -645,7 +642,7 @@ public class MetaNormalizerHandlerIT ext
         DN newdn = getNormalizerContainer( "apachemeta" );
         newdn.add( "m-oid" + "=" + OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertTrue( "normalizer OID should be present when moved to enabled schema", 
             schemaManager.getNormalizerRegistry().contains( OID ) );

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java?rev=924913&r1=924912&r2=924913&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java Thu Mar 18 17:34:57 2010
@@ -26,8 +26,10 @@ import static org.junit.Assert.assertFal
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import javax.naming.InvalidNameException;
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
+import javax.naming.OperationNotSupportedException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
@@ -36,10 +38,8 @@ import javax.naming.directory.DirContext
 import javax.naming.directory.ModificationItem;
 
 import org.apache.directory.server.core.integ.FrameworkRunner;
-import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
-import org.apache.directory.shared.ldap.exception.LdapUnwillingToPerformException;
+import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.schema.ObjectClass;
 import org.apache.directory.shared.ldap.schema.registries.ObjectClassRegistry;
@@ -91,7 +91,7 @@ public class MetaObjectClassHandlerIT ex
         
         DN dn = getObjectClassContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         return dn;
     }
@@ -141,7 +141,7 @@ public class MetaObjectClassHandlerIT ex
         
         try
         {
-            getSchemaContext( service ).createSubcontext( dn, attrs );
+            getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
             fail( "Should not be there" );
         }
         catch( NameNotFoundException nnfe )
@@ -166,7 +166,7 @@ public class MetaObjectClassHandlerIT ex
             getObjectClassRegistry().contains( OID ) );
         assertTrue( isOnDisk( dn ) );
 
-        getSchemaContext( service ).destroySubcontext( dn );
+        getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
 
         assertFalse( "objectClass should be removed from the registry after being deleted", 
             getObjectClassRegistry().contains( OID ) );
@@ -176,7 +176,7 @@ public class MetaObjectClassHandlerIT ex
             getObjectClassRegistry().lookup( OID );
             fail( "objectClass lookup should fail after deleting it" );
         }
-        catch( NamingException e )
+        catch( LdapException e )
         {
         }
 
@@ -195,7 +195,7 @@ public class MetaObjectClassHandlerIT ex
             getObjectClassRegistry().contains( OID ) );
         assertTrue( isOnDisk( dn ) );
         
-        getSchemaContext( service ).destroySubcontext( dn );
+        getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
 
         assertFalse( "objectClass should be removed from the registry after being deleted", 
             getObjectClassRegistry().contains( OID ) );
@@ -205,7 +205,7 @@ public class MetaObjectClassHandlerIT ex
             getObjectClassRegistry().lookup( OID );
             fail( "objectClass lookup should fail after deleting it" );
         }
-        catch( NamingException e )
+        catch( LdapException e )
         {
         }
         
@@ -223,7 +223,7 @@ public class MetaObjectClassHandlerIT ex
         
         DN newdn = getObjectClassContainer( "apachemeta" );
         newdn.add( "m-oid" + "=" + NEW_OID );
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "old objectClass OID should be removed from the registry after being renamed", 
             getObjectClassRegistry().contains( OID ) );
@@ -234,7 +234,7 @@ public class MetaObjectClassHandlerIT ex
             getObjectClassRegistry().lookup( OID );
             fail( "objectClass lookup should fail after renaming the objectClass" );
         }
-        catch( NamingException e )
+        catch( LdapException e )
         {
         }
 
@@ -254,7 +254,7 @@ public class MetaObjectClassHandlerIT ex
         DN newdn = getObjectClassContainer( "apache" );
         newdn.add( "m-oid" + "=" + OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertTrue( "objectClass OID should still be present", 
             getObjectClassRegistry().contains( OID ) );
@@ -276,7 +276,7 @@ public class MetaObjectClassHandlerIT ex
         DN newdn = getObjectClassContainer( "apache" );
         newdn.add( "m-oid" + "=" + NEW_OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "old objectClass OID should NOT be present", 
             getObjectClassRegistry().contains( OID ) );
@@ -307,7 +307,7 @@ public class MetaObjectClassHandlerIT ex
         mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
         attr = new BasicAttribute( "m-name", NEW_NAME );
         mods[1] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        getSchemaContext( service ).modifyAttributes( dn, mods );
+        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), mods );
 
         assertTrue( "objectClass OID should still be present", 
             getObjectClassRegistry().contains( OID ) );
@@ -337,7 +337,7 @@ public class MetaObjectClassHandlerIT ex
         Attributes mods = new BasicAttributes( true );
         mods.put( "m-description", DESCRIPTION1 );
         mods.put( "m-name", NEW_NAME );
-        getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
+        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );
 
         assertTrue( "objectClass OID should still be present", 
             getObjectClassRegistry().contains( OID ) );
@@ -371,7 +371,7 @@ public class MetaObjectClassHandlerIT ex
         
         DN dn = getObjectClassContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + DEPENDEE_OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertTrue( getObjectClassRegistry().contains( DEPENDEE_OID ) );
         assertEquals( getObjectClassRegistry().getSchemaName( DEPENDEE_OID ), "apachemeta" );
@@ -388,12 +388,11 @@ public class MetaObjectClassHandlerIT ex
         
         try
         {
-            getSchemaContext( service ).destroySubcontext( dn );
+            getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
             fail( "should not be able to delete a objectClass in use" );
         }
-        catch( LdapUnwillingToPerformException e ) 
+        catch( OperationNotSupportedException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
         assertTrue( "objectClass should still be in the registry after delete failure", 
@@ -416,12 +415,11 @@ public class MetaObjectClassHandlerIT ex
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move a objectClass in use" );
         }
-        catch( LdapUnwillingToPerformException e ) 
+        catch( OperationNotSupportedException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
         assertTrue( "objectClass should still be in the registry after move failure", 
@@ -444,12 +442,11 @@ public class MetaObjectClassHandlerIT ex
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move an objectClass in use" );
         }
-        catch( LdapUnwillingToPerformException e ) 
+        catch( OperationNotSupportedException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
         assertTrue( "ObjectClass should still be in the registry after move failure", 
@@ -471,12 +468,11 @@ public class MetaObjectClassHandlerIT ex
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to rename an objectClass in use" );
         }
-        catch( LdapUnwillingToPerformException e ) 
+        catch( OperationNotSupportedException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
         assertTrue( "objectClass should still be in the registry after rename failure", 
@@ -501,12 +497,11 @@ public class MetaObjectClassHandlerIT ex
         
         try
         {
-            getSchemaContext( service ).rename( dn, top );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( top ) );
             fail( "should not be able to move a objectClass up to ou=schema" );
         }
-        catch( LdapInvalidDnException e ) 
+        catch( InvalidNameException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
         }
 
         assertTrue( "objectClass should still be in the registry after move failure", 
@@ -528,12 +523,11 @@ public class MetaObjectClassHandlerIT ex
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move a objectClass into comparators container" );
         }
-        catch( LdapInvalidDnException e ) 
+        catch( InvalidNameException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
         }
 
         assertTrue( "objectClass should still be in the registry after move failure", 
@@ -556,7 +550,7 @@ public class MetaObjectClassHandlerIT ex
 
         DN dn = getObjectClassContainer( "nis" );
         dn.add( "m-oid" + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         return dn;
     }
@@ -575,7 +569,7 @@ public class MetaObjectClassHandlerIT ex
         DN newdn = getObjectClassContainer( "nis" );
         newdn.add( "m-oid" + "=" + OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "objectClass OID should no longer be present", 
             getObjectClassRegistry().contains( OID ) );
@@ -598,7 +592,7 @@ public class MetaObjectClassHandlerIT ex
         DN newdn = getObjectClassContainer( "apachemeta" );
         newdn.add( "m-oid" + "=" + OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertTrue( "objectClass OID should be present when moved to enabled schema", 
             getObjectClassRegistry().contains( OID ) );
@@ -632,7 +626,7 @@ public class MetaObjectClassHandlerIT ex
         
         DN dn = getObjectClassContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertTrue( getObjectClassRegistry().contains( OID ) );
         assertEquals( getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
@@ -668,7 +662,7 @@ public class MetaObjectClassHandlerIT ex
         
         try
         {
-            getSchemaContext( service ).createSubcontext( dn, attrs );
+            getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
             fail();
         }
         catch ( NamingException ne )
@@ -707,7 +701,7 @@ public class MetaObjectClassHandlerIT ex
         
         try
         {
-            getSchemaContext( service ).createSubcontext( dn, attrs );
+            getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
             fail();
         }
         catch ( NamingException ne )
@@ -739,7 +733,7 @@ public class MetaObjectClassHandlerIT ex
         
         DN dn = getObjectClassContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + NEW_OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertTrue( getObjectClassRegistry().contains( NEW_OID ) );
         assertEquals( getObjectClassRegistry().getSchemaName( NEW_OID ), "apachemeta" );
@@ -772,7 +766,7 @@ public class MetaObjectClassHandlerIT ex
 
         DN dn = getObjectClassContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + NEW_OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertTrue( getObjectClassRegistry().contains( NEW_OID ) );
         assertEquals( getObjectClassRegistry().getSchemaName( NEW_OID ), "apachemeta" );
@@ -808,7 +802,7 @@ public class MetaObjectClassHandlerIT ex
         
         try
         {
-            getSchemaContext( service ).createSubcontext( dn, attrs );
+            getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
             fail();
         }
         catch ( NamingException ne )
@@ -840,7 +834,7 @@ public class MetaObjectClassHandlerIT ex
         
         DN dn = getObjectClassContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + NEW_OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertTrue( getObjectClassRegistry().contains( NEW_OID ) );
         assertEquals( getObjectClassRegistry().getSchemaName( NEW_OID ), "apachemeta" );
@@ -876,7 +870,7 @@ public class MetaObjectClassHandlerIT ex
         
         try
         {
-            getSchemaContext( service ).createSubcontext( dn, attrs );
+            getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
             fail();
         }
         catch ( NamingException ne )
@@ -912,7 +906,7 @@ public class MetaObjectClassHandlerIT ex
 
         DN dn = getObjectClassContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + NEW_OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertTrue( getObjectClassRegistry().contains( NEW_OID ) );
         assertEquals( getObjectClassRegistry().getSchemaName( NEW_OID ), "apachemeta" );

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java?rev=924913&r1=924912&r2=924913&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java Thu Mar 18 17:34:57 2010
@@ -27,7 +27,9 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
+import javax.naming.OperationNotSupportedException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
@@ -39,10 +41,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.integ.IntegrationUtils;
 import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.exception.LdapNoSuchObjectException;
-import org.apache.directory.shared.ldap.exception.LdapUnwillingToPerformException;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -203,7 +202,7 @@ public class MetaSchemaHandlerIT extends
             IntegrationUtils.enableSchema( service, "wrong" );
             fail();
         }
-        catch ( LdapNoSuchObjectException lnnfe )
+        catch ( NameNotFoundException lnnfe )
         {
             // Expected
             assertTrue( true );
@@ -313,7 +312,7 @@ public class MetaSchemaHandlerIT extends
             IntegrationUtils.disableSchema( service, "wrong" );
             fail();
         }
-        catch ( LdapNoSuchObjectException lnnfe )
+        catch ( NameNotFoundException lnnfe )
         {
             // Expected
             assertTrue( true );
@@ -461,9 +460,9 @@ public class MetaSchemaHandlerIT extends
             schemaRoot.createSubcontext( "cn=dummy", dummySchema );
             fail();
         }
-        catch ( LdapUnwillingToPerformException lonse )
+        catch ( OperationNotSupportedException lonse )
         {
-            assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, lonse.getResultCode() );
+            // expected        
         }
         
         assertFalse( IntegrationUtils.isLoaded( service, "dummy" ) );
@@ -495,9 +494,9 @@ public class MetaSchemaHandlerIT extends
             schemaRoot.createSubcontext( "cn=dummy", dummySchema );
             fail();
         }
-        catch ( LdapUnwillingToPerformException lonse )
+        catch ( OperationNotSupportedException lonse )
         {
-            assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, lonse.getResultCode() );
+            // expected       
         }
         
         assertFalse( IntegrationUtils.isLoaded( service, "dummy" ) );
@@ -606,9 +605,9 @@ public class MetaSchemaHandlerIT extends
         {
             schemaRoot.createSubcontext( "cn=dummy", dummySchema );
         } 
-        catch( LdapUnwillingToPerformException e )
+        catch( OperationNotSupportedException e )
         {
-            assertTrue( e.getResultCode().equals( ResultCodeEnum.UNWILLING_TO_PERFORM ) );
+            // expected        
         }
         
         assertFalse( IntegrationUtils.isEnabled( service, "dummy" ) );
@@ -670,9 +669,9 @@ public class MetaSchemaHandlerIT extends
             schemaRoot.createSubcontext( "cn=dummy", dummySchema );
             fail( "should not be able to add enabled schema with deps on disabled schemas" );
         }
-        catch( LdapUnwillingToPerformException e )
+        catch( OperationNotSupportedException e )
         {
-            assertTrue( e.getResultCode().equals( ResultCodeEnum.UNWILLING_TO_PERFORM ) );
+            // expected        
         }
         
         assertFalse( IntegrationUtils.isEnabled( service, "dummy" ) );
@@ -742,9 +741,9 @@ public class MetaSchemaHandlerIT extends
             schemaRoot.destroySubcontext( "cn=dummy" );
             fail( "should not be able to delete a schema with dependents" );
         }
-        catch ( LdapUnwillingToPerformException e )
+        catch ( OperationNotSupportedException e )
         {
-            assertTrue( e.getResultCode().equals( ResultCodeEnum.UNWILLING_TO_PERFORM ) );
+            // expected        
         }
 
         assertTrue( IntegrationUtils.isEnabled( service, "dummy" ) );
@@ -774,9 +773,9 @@ public class MetaSchemaHandlerIT extends
             schemaRoot.createSubcontext( "cn=dummy", dummySchema );
             fail( "should not be able to add enabled schema with deps on missing schemas" );
         }
-        catch( LdapUnwillingToPerformException e )
+        catch( OperationNotSupportedException e )
         {
-            assertTrue( e.getResultCode().equals( ResultCodeEnum.UNWILLING_TO_PERFORM ) );
+            // expected        
         }
         
         assertFalse( IntegrationUtils.isEnabled( service, "dummy" ) );
@@ -840,9 +839,9 @@ public class MetaSchemaHandlerIT extends
             schemaRoot.modifyAttributes( "cn=nis", mods );
             fail( "attempt to disable schema with enabled dependents should fail" );
         }
-        catch ( LdapUnwillingToPerformException e )
+        catch ( OperationNotSupportedException e )
         {
-            assertTrue( e.getResultCode().equals( ResultCodeEnum.UNWILLING_TO_PERFORM ) );
+            // expected        
         }
         
         // now test that both schema are still loaded 
@@ -887,7 +886,7 @@ public class MetaSchemaHandlerIT extends
             schemaRoot.lookup( "cn=samba" );
             fail( "the samba schema should not be present after a rename to foo" );
         }
-        catch( LdapNoSuchObjectException e )
+        catch( NameNotFoundException e )
         {
         }
     }
@@ -910,9 +909,9 @@ public class MetaSchemaHandlerIT extends
             schemaRoot.rename( "cn=nis", "cn=foo" );
             fail( "should not be able to rename nis which has samba as it's dependent" );
         }
-        catch ( LdapUnwillingToPerformException e )
+        catch ( OperationNotSupportedException onse )
         {
-            assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, e.getResultCode() );
+            // expected        
         }
         
         assertNotNull( schemaRoot.lookup( "cn=nis" ) );
@@ -923,7 +922,7 @@ public class MetaSchemaHandlerIT extends
             schemaRoot.lookup( "cn=foo" );
             fail( "the foo schema should not be present after rejecting the rename" );
         }
-        catch( LdapNoSuchObjectException e )
+        catch( NameNotFoundException e )
         {
         }
     }
@@ -957,7 +956,7 @@ public class MetaSchemaHandlerIT extends
             schemaRoot.lookup( "cn=samba" );
             fail( "the samba schema should not be present after a rename to foo" );
         }
-        catch( LdapNoSuchObjectException e )
+        catch( NameNotFoundException e )
         {
         }
     }
@@ -987,9 +986,9 @@ public class MetaSchemaHandlerIT extends
             schemaRoot.modifyAttributes( "cn=nis", mods );
             fail( "Should not be able to add bogus dependency to schema" );
         }
-        catch ( LdapUnwillingToPerformException e )
+        catch ( OperationNotSupportedException onse )
         {
-            assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, e.getResultCode() );
+            // expected        
         }
     }
 
@@ -1017,9 +1016,9 @@ public class MetaSchemaHandlerIT extends
             schemaRoot.modifyAttributes( "cn=nis", mods );
             fail( "Should not be able to add disabled dependency to schema" );
         }
-        catch ( LdapUnwillingToPerformException e )
+        catch ( OperationNotSupportedException onse )
         {
-            assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, e.getResultCode() );
+            // expected        
         }
     }
 

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerIT.java?rev=924913&r1=924912&r2=924913&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerIT.java Thu Mar 18 17:34:57 2010
@@ -29,8 +29,9 @@ import static org.junit.Assert.fail;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 
+import javax.naming.InvalidNameException;
 import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
+import javax.naming.OperationNotSupportedException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
@@ -39,10 +40,8 @@ import javax.naming.directory.DirContext
 import javax.naming.directory.ModificationItem;
 
 import org.apache.directory.server.core.integ.FrameworkRunner;
-import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
-import org.apache.directory.shared.ldap.exception.LdapUnwillingToPerformException;
+import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.schema.LdapSyntax;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
@@ -93,7 +92,7 @@ public class MetaSyntaxCheckerHandlerIT 
         
         DN dn = getSyntaxCheckerContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertTrue( schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
         assertEquals( schemaManager.getSyntaxCheckerRegistry().getSchemaName( OID ), "apachemeta" );
@@ -117,7 +116,7 @@ public class MetaSyntaxCheckerHandlerIT 
         // nis is by default inactive
         DN dn = getSyntaxCheckerContainer( "nis" );
         dn.add( "m-oid" + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertFalse( "adding new syntaxChecker to disabled schema should not register it into the registries", 
             schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
@@ -142,7 +141,7 @@ public class MetaSyntaxCheckerHandlerIT 
 
         try
         {
-            getSchemaContext( service ).createSubcontext( dn, attrs );
+            getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
             fail( "Should not be there" );
         }
         catch( NameNotFoundException nnfe )
@@ -178,7 +177,7 @@ public class MetaSyntaxCheckerHandlerIT 
         
         DN dn = getSyntaxCheckerContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertTrue( schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
         assertEquals( schemaManager.getSyntaxCheckerRegistry().getSchemaName( OID ), "apachemeta" );
@@ -210,7 +209,7 @@ public class MetaSyntaxCheckerHandlerIT 
         
         DN dn = getSyntaxCheckerContainer( "nis" );
         dn.add( "m-oid" + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
         
         assertFalse( schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
         assertTrue( isOnDisk( dn ) );
@@ -228,7 +227,7 @@ public class MetaSyntaxCheckerHandlerIT 
             schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
         assertTrue( isOnDisk( dn ) );
         
-        getSchemaContext( service ).destroySubcontext( dn );
+        getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
 
         assertFalse( "syntaxChecker should be removed from the registry after being deleted", 
             schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
@@ -238,7 +237,7 @@ public class MetaSyntaxCheckerHandlerIT 
             schemaManager.getSyntaxCheckerRegistry().lookup( OID );
             fail( "syntaxChecker lookup should fail after deleting the syntaxChecker" );
         }
-        catch( NamingException e )
+        catch( LdapException e )
         {
         }
         
@@ -257,7 +256,7 @@ public class MetaSyntaxCheckerHandlerIT 
             schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
         assertTrue( isOnDisk( dn ) );
 
-        getSchemaContext( service ).destroySubcontext( dn );
+        getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
 
         assertFalse( "syntaxChecker should be removed from the registry after being deleted", 
             schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
@@ -267,7 +266,7 @@ public class MetaSyntaxCheckerHandlerIT 
             schemaManager.getSyntaxCheckerRegistry().lookup( OID );
             fail( "syntaxChecker lookup should fail after deleting the syntaxChecker" );
         }
-        catch( NamingException e )
+        catch( LdapException e )
         {
         }
         
@@ -285,7 +284,7 @@ public class MetaSyntaxCheckerHandlerIT 
         
         DN newdn = getSyntaxCheckerContainer( "apachemeta" );
         newdn.add( "m-oid" + "=" + NEW_OID );
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "old syntaxChecker OID should be removed from the registry after being renamed", 
             schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
@@ -296,7 +295,7 @@ public class MetaSyntaxCheckerHandlerIT 
             schemaManager.getSyntaxCheckerRegistry().lookup( OID );
             fail( "syntaxChecker lookup should fail after deleting the syntaxChecker" );
         }
-        catch( NamingException e )
+        catch( LdapException e )
         {
         }
 
@@ -318,7 +317,7 @@ public class MetaSyntaxCheckerHandlerIT 
         DN newdn = getSyntaxCheckerContainer( "apache" );
         newdn.add( "m-oid" + "=" + OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertTrue( "syntaxChecker OID should still be present", 
             schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
@@ -343,7 +342,7 @@ public class MetaSyntaxCheckerHandlerIT 
         DN newdn = getSyntaxCheckerContainer( "apache" );
         newdn.add( "m-oid" + "=" + NEW_OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "old syntaxChecker OID should NOT be present", 
             schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
@@ -371,7 +370,7 @@ public class MetaSyntaxCheckerHandlerIT 
         ModificationItem[] mods = new ModificationItem[1];
         Attribute attr = new BasicAttribute( "m-fqcn", BogusSyntaxChecker.class.getName() );
         mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        getSchemaContext( service ).modifyAttributes( dn, mods );
+        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), mods );
 
         assertTrue( "syntaxChecker OID should still be present", 
             schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
@@ -395,7 +394,7 @@ public class MetaSyntaxCheckerHandlerIT 
         
         Attributes mods = new BasicAttributes( true );
         mods.put( "m-fqcn", BogusSyntaxChecker.class.getName() );
-        getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
+        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );
 
         assertTrue( "syntaxChecker OID should still be present", 
             schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
@@ -438,7 +437,7 @@ public class MetaSyntaxCheckerHandlerIT 
         assertFalse( service.getSchemaManager().getLdapSyntaxRegistry().contains( OID ) );
 
         // Syntax Addition
-        getSchemaContext( service ).createSubcontext( sDn, attrs );
+        getSchemaContext( service ).createSubcontext( DN.toName( sDn ), attrs );
 
         // Post-checks
         assertTrue( isOnDisk( sDn ) );
@@ -446,12 +445,11 @@ public class MetaSyntaxCheckerHandlerIT 
         
         try
         {
-            getSchemaContext( service ).destroySubcontext( scDn );
+            getSchemaContext( service ).destroySubcontext( DN.toName( scDn ) );
             fail( "should not be able to delete a syntaxChecker in use" );
         }
-        catch( LdapUnwillingToPerformException e ) 
+        catch( OperationNotSupportedException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
         assertTrue( "syntaxChecker should still be in the registry after delete failure", 
@@ -474,12 +472,11 @@ public class MetaSyntaxCheckerHandlerIT 
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move a syntaxChecker in use" );
         }
-        catch( LdapUnwillingToPerformException e ) 
+        catch( OperationNotSupportedException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
         assertTrue( "syntaxChecker should still be in the registry after move failure", 
@@ -504,12 +501,11 @@ public class MetaSyntaxCheckerHandlerIT 
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move a syntaxChecker in use" );
         }
-        catch( LdapUnwillingToPerformException e ) 
+        catch( OperationNotSupportedException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
         assertTrue( "syntaxChecker should still be in the registry after move failure", 
@@ -533,12 +529,11 @@ public class MetaSyntaxCheckerHandlerIT 
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to rename a syntaxChecker in use" );
         }
-        catch( LdapUnwillingToPerformException e ) 
+        catch( OperationNotSupportedException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
         assertTrue( "syntaxChecker should still be in the registry after rename failure", 
@@ -567,12 +562,11 @@ public class MetaSyntaxCheckerHandlerIT 
         
         try
         {
-            getSchemaContext( service ).rename( dn, top );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( top ) );
             fail( "should not be able to move a syntaxChecker up to ou=schema" );
         }
-        catch( LdapInvalidDnException e ) 
+        catch( InvalidNameException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
         }
 
         assertTrue( "syntaxChecker should still be in the registry after move failure", 
@@ -594,12 +588,11 @@ public class MetaSyntaxCheckerHandlerIT 
         
         try
         {
-            getSchemaContext( service ).rename( dn, newdn );
+            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
             fail( "should not be able to move a syntaxChecker into comparators container" );
         }
-        catch( LdapInvalidDnException e ) 
+        catch( InvalidNameException e ) 
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
         }
 
         assertTrue( "syntaxChecker should still be in the registry after move failure", 
@@ -620,7 +613,7 @@ public class MetaSyntaxCheckerHandlerIT 
         DN newdn = getSyntaxCheckerContainer( "nis" );
         newdn.add( "m-oid" + "=" + OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertFalse( "syntaxChecker OID should no longer be present", 
             schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
@@ -643,7 +636,7 @@ public class MetaSyntaxCheckerHandlerIT 
         DN newdn = getSyntaxCheckerContainer( "apachemeta" );
         newdn.add( "m-oid" + "=" + OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
         assertTrue( "syntaxChecker OID should be present when moved to enabled schema", 
             schemaManager.getSyntaxCheckerRegistry().contains( OID ) );



Mime
View raw message