directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r896599 [18/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/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java Wed Jan  6 18:26:43 2010
@@ -20,21 +20,38 @@
 package org.apache.directory.server.core.authz.support;
 
 
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.Control;
+import javax.naming.ldap.LdapContext;
+
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.DefaultCoreSession;
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.LdapPrincipal;
 import org.apache.directory.server.core.OperationManager;
 import org.apache.directory.server.core.ReferralHandlingMode;
 import org.apache.directory.server.core.ReferralManager;
-import org.apache.directory.server.core.authn.LdapPrincipal;
 import org.apache.directory.server.core.changelog.ChangeLog;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.event.EventService;
-import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.filtering.BaseEntryFilteringCursor;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.Interceptor;
 import org.apache.directory.server.core.interceptor.InterceptorChain;
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
@@ -56,12 +73,10 @@
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
 import org.apache.directory.server.core.interceptor.context.UnbindOperationContext;
 import org.apache.directory.server.core.journal.Journal;
+import org.apache.directory.server.core.partition.DefaultPartitionNexus;
 import org.apache.directory.server.core.partition.Partition;
-import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.core.replication.ReplicationConfiguration;
-import org.apache.directory.server.core.schema.SchemaOperationControl;
 import org.apache.directory.server.core.schema.SchemaService;
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.aci.ACITuple;
 import org.apache.directory.shared.ldap.aci.MicroOperation;
@@ -75,24 +90,10 @@
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.name.LdapDN;
-
-import javax.naming.NamingException;
-import javax.naming.ldap.Control;
-import javax.naming.ldap.LdapContext;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-import org.junit.Test;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.junit.BeforeClass;
-import static org.junit.Assert.assertEquals;
+import org.junit.Test;
 
 
 /**
@@ -118,13 +119,13 @@
     private static DirectoryService service;
 
     
-    @BeforeClass public static void setup() throws NamingException
+    @BeforeClass public static void setup() throws Exception
     {
         service = new DefaultDirectoryService();
 
         ENTRY_NAME = new LdapDN( "ou=test, ou=system" );
         PROTECTED_ITEMS.add( new ProtectedItem.MaxImmSub( 2 ) );
-        ENTRY = new DefaultServerEntry( service.getRegistries(), ENTRY_NAME );
+        ENTRY = new DefaultServerEntry( service.getSchemaManager(), ENTRY_NAME );
     }
 
 
@@ -497,7 +498,7 @@
         }
 
 
-        public PartitionNexus getPartitionNexus()
+        public DefaultPartitionNexus getPartitionNexus()
         {
             return null;
         }
@@ -519,7 +520,7 @@
         }
 
 
-        public Registries getRegistries()
+        public SchemaManager getSchemaManager()
         {
             return null;
         }
@@ -553,17 +554,6 @@
         }
 
 
-        public SchemaOperationControl getSchemaManager()
-        {
-            return null;
-        }
-
-
-        public void setSchemaManager( SchemaOperationControl schemaManager )
-        {
-        }
-
-
         public void startup() throws NamingException
         {
         }
@@ -830,7 +820,7 @@
             return false;
         }
         
-        public void setPassordHidden( boolean passwordHidden )
+        public void setPasswordHidden( boolean passwordHidden )
         {
         }
 
@@ -886,6 +876,12 @@
             // TODO Auto-generated method stub
             return null;
         }
+
+        public void setSchemaManager( SchemaManager schemaManager )
+        {
+            // TODO Auto-generated method stub
+            
+        }
     }
 
     
@@ -1055,7 +1051,7 @@
 
         public ServerEntry get() throws Exception
         {
-            return new DefaultServerEntry( service.getRegistries() );
+            return new DefaultServerEntry( service.getSchemaManager() );
         }
 
 

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxValueCountFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxValueCountFilterTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxValueCountFilterTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxValueCountFilterTest.java Wed Jan  6 18:26:43 2010
@@ -20,6 +20,9 @@
 package org.apache.directory.server.core.authz.support;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -28,11 +31,6 @@
 
 import javax.naming.NamingException;
 
-
-import org.apache.directory.server.core.DefaultDirectoryService;
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.authz.support.MaxValueCountFilter;
-import org.apache.directory.server.core.authz.support.OperationScope;
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.shared.ldap.aci.ACITuple;
@@ -42,12 +40,14 @@
 import org.apache.directory.shared.ldap.aci.ProtectedItem.MaxValueCountItem;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.loader.ldif.JarLdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-
 
 /**
  * Tests {@link MaxValueCountFilter}.
@@ -75,20 +75,29 @@
     }
 
 
-    /** A reference to the directory service */
-    private static DirectoryService service;
+    /** A reference to the schemaManager */
+    private static SchemaManager schemaManager;
 
     
-    @BeforeClass public static void init() throws NamingException
+    @BeforeClass public static void init() throws Exception
     {
-        service = new DefaultDirectoryService();
+        JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
+
+        schemaManager = new DefaultSchemaManager( loader );
+
+        boolean loaded = schemaManager.loadAllEnabled();
+
+        if ( !loaded )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) );
+        }
     }
     
     @Before public void setup() throws NamingException
     {
         LdapDN entryName = new LdapDN( "ou=test, ou=system" );
-        ENTRY = new DefaultServerEntry( service.getRegistries(), entryName );
-        FULL_ENTRY = new DefaultServerEntry( service.getRegistries(), entryName );
+        ENTRY = new DefaultServerEntry( schemaManager, entryName );
+        FULL_ENTRY = new DefaultServerEntry( schemaManager, entryName );
         
         ENTRY.put( "cn", "1" );
         FULL_ENTRY.put( "cn", "1", "2", "3" );

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MicroOperationFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MicroOperationFilterTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MicroOperationFilterTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MicroOperationFilterTest.java Wed Jan  6 18:26:43 2010
@@ -26,8 +26,7 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
 
 import org.apache.directory.server.core.authz.support.MicroOperationFilter;
 import org.apache.directory.server.core.authz.support.OperationScope;
@@ -36,6 +35,7 @@
 import org.apache.directory.shared.ldap.aci.ProtectedItem;
 import org.apache.directory.shared.ldap.aci.UserClass;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
+import org.junit.Test;
 
 
 /**
@@ -44,7 +44,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class MicroOperationFilterTest extends TestCase
+public class MicroOperationFilterTest
 {
     private static final Collection<ACITuple> EMPTY_ACI_TUPLE_COLLECTION = Collections.unmodifiableCollection( new ArrayList<ACITuple>() );
     private static final Collection<UserClass> EMPTY_USER_CLASS_COLLECTION = Collections.unmodifiableCollection( new ArrayList<UserClass>() );
@@ -66,15 +66,17 @@
     }
 
 
+    @Test
     public void testZeroTuple() throws Exception
     {
         MicroOperationFilter filter = new MicroOperationFilter();
 
-        Assert.assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, 
+        assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, 
             null, null, null, null, null, null, null, null, null, null, null ).size() );
     }
 
 
+    @Test
     public void testOneTuple() throws Exception
     {
         MicroOperationFilter filter = new MicroOperationFilter();
@@ -83,9 +85,9 @@
         tuples.add( new ACITuple( EMPTY_USER_CLASS_COLLECTION, AuthenticationLevel.NONE, EMPTY_PROTECTED_ITEM_COLLECTION, 
             TUPLE_OPERATIONS, true, 0 ) );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null, null,
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null, null,
             null, null, USER_OPERATIONS_A, null ).size() );
-        Assert.assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null, null,
+        assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null, null,
             null, null, USER_OPERATIONS_B, null ).size() );
     }
 }

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MostSpecificProtectedItemFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MostSpecificProtectedItemFilterTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MostSpecificProtectedItemFilterTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MostSpecificProtectedItemFilterTest.java Wed Jan  6 18:26:43 2010
@@ -29,8 +29,8 @@
 
 import javax.naming.directory.Attribute;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
 
 import org.apache.directory.server.core.authz.support.MostSpecificProtectedItemFilter;
 import org.apache.directory.server.core.authz.support.OperationScope;
@@ -40,6 +40,7 @@
 import org.apache.directory.shared.ldap.aci.UserClass;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.filter.PresenceNode;
+import org.junit.Test;
 
 
 /**
@@ -48,7 +49,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class MostSpecificProtectedItemFilterTest extends TestCase
+public class MostSpecificProtectedItemFilterTest
 {
     private static final Collection<String> EMPTY_STRING_COLLECTION = Collections.unmodifiableCollection( new ArrayList<String>() );
     
@@ -143,21 +144,23 @@
     }
 
 
+    @Test
     public void testZeroOrOneTuple() throws Exception
     {
         MostSpecificProtectedItemFilter filter = new MostSpecificProtectedItemFilter();
 
-        Assert.assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
+        assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
             null, null, null, null, null, null, null, null, null ).size() );
 
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
         tuples.add( new ACITuple( EMPTY_USER_CLASS_COLLECTION, AuthenticationLevel.NONE, EMPTY_PROTECTED_ITEM_COLLECTION, EMPTY_MICRO_OPERATION_SET, false, 0 ) );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
             null, null, null, null, null, null, null ).size() );
     }
 
 
+    @Test
     public void testTuplesA() throws Exception
     {
         MostSpecificProtectedItemFilter filter = new MostSpecificProtectedItemFilter();
@@ -166,14 +169,15 @@
         tuples = ( List<ACITuple> ) filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null, null, null,
             null, null, null );
 
-        Assert.assertEquals( 4, tuples.size() );
-        Assert.assertSame( TUPLES_A.get( 0 ), tuples.get( 0 ) );
-        Assert.assertSame( TUPLES_A.get( 1 ), tuples.get( 1 ) );
-        Assert.assertSame( TUPLES_A.get( 2 ), tuples.get( 2 ) );
-        Assert.assertSame( TUPLES_A.get( 3 ), tuples.get( 3 ) );
+        assertEquals( 4, tuples.size() );
+        assertSame( TUPLES_A.get( 0 ), tuples.get( 0 ) );
+        assertSame( TUPLES_A.get( 1 ), tuples.get( 1 ) );
+        assertSame( TUPLES_A.get( 2 ), tuples.get( 2 ) );
+        assertSame( TUPLES_A.get( 3 ), tuples.get( 3 ) );
     }
 
 
+    @Test
     public void testTuplesB() throws Exception
     {
         MostSpecificProtectedItemFilter filter = new MostSpecificProtectedItemFilter();
@@ -182,13 +186,14 @@
         tuples = ( List<ACITuple> ) filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null, null, null,
             null, null, null );
 
-        Assert.assertEquals( 3, tuples.size() );
-        Assert.assertSame( TUPLES_B.get( 0 ), tuples.get( 0 ) );
-        Assert.assertSame( TUPLES_B.get( 1 ), tuples.get( 1 ) );
-        Assert.assertSame( TUPLES_B.get( 2 ), tuples.get( 2 ) );
+        assertEquals( 3, tuples.size() );
+        assertSame( TUPLES_B.get( 0 ), tuples.get( 0 ) );
+        assertSame( TUPLES_B.get( 1 ), tuples.get( 1 ) );
+        assertSame( TUPLES_B.get( 2 ), tuples.get( 2 ) );
     }
 
 
+    @Test
     public void testTuplesC() throws Exception
     {
         MostSpecificProtectedItemFilter filter = new MostSpecificProtectedItemFilter();
@@ -197,12 +202,13 @@
         tuples = ( List<ACITuple> ) filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null, null, null,
             null, null, null );
 
-        Assert.assertEquals( 2, tuples.size() );
-        Assert.assertSame( TUPLES_C.get( 0 ), tuples.get( 0 ) );
-        Assert.assertSame( TUPLES_C.get( 1 ), tuples.get( 1 ) );
+        assertEquals( 2, tuples.size() );
+        assertSame( TUPLES_C.get( 0 ), tuples.get( 0 ) );
+        assertSame( TUPLES_C.get( 1 ), tuples.get( 1 ) );
     }
 
 
+    @Test
     public void testTuplesD() throws Exception
     {
         MostSpecificProtectedItemFilter filter = new MostSpecificProtectedItemFilter();
@@ -211,11 +217,12 @@
         tuples = ( List<ACITuple> ) filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null, null, null,
             null, null, null );
 
-        Assert.assertEquals( 1, tuples.size() );
-        Assert.assertSame( TUPLES_D.get( 0 ), tuples.get( 0 ) );
+        assertEquals( 1, tuples.size() );
+        assertSame( TUPLES_D.get( 0 ), tuples.get( 0 ) );
     }
 
 
+    @Test
     public void testTuplesE() throws Exception
     {
         MostSpecificProtectedItemFilter filter = new MostSpecificProtectedItemFilter();
@@ -224,8 +231,8 @@
         tuples = ( List<ACITuple> ) filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null, null, null,
             null, null, null );
 
-        Assert.assertEquals( 2, tuples.size() );
-        Assert.assertSame( TUPLES_E.get( 0 ), tuples.get( 0 ) );
-        Assert.assertSame( TUPLES_E.get( 1 ), tuples.get( 1 ) );
+        assertEquals( 2, tuples.size() );
+        assertSame( TUPLES_E.get( 0 ), tuples.get( 0 ) );
+        assertSame( TUPLES_E.get( 1 ), tuples.get( 1 ) );
     }
 }

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MostSpecificUserClassFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MostSpecificUserClassFilterTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MostSpecificUserClassFilterTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MostSpecificUserClassFilterTest.java Wed Jan  6 18:26:43 2010
@@ -27,8 +27,8 @@
 import java.util.List;
 import java.util.Set;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
 
 import org.apache.directory.server.core.authz.support.MostSpecificUserClassFilter;
 import org.apache.directory.server.core.authz.support.OperationScope;
@@ -39,6 +39,7 @@
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.subtree.SubtreeSpecification;
+import org.junit.Test;
 
 
 /**
@@ -47,7 +48,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class MostSpecificUserClassFilterTest extends TestCase
+public class MostSpecificUserClassFilterTest
 {
     private static final Set<LdapDN> EMPTY_NAME_SET = Collections.unmodifiableSet( new HashSet<LdapDN>() );
     private static final Set<MicroOperation> EMPTY_MICRO_OPERATION_SET = Collections.unmodifiableSet( new HashSet<MicroOperation>() );
@@ -105,21 +106,23 @@
     }
 
 
+    @Test
     public void testZeroOrOneTuple() throws Exception
     {
         MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
 
-        Assert.assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
+        assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
             null, null, null, null, null, null, null, null, null ).size() );
 
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
         tuples.add( new ACITuple( EMPTY_USER_CLASS_COLLECTION, AuthenticationLevel.NONE, EMPTY_PROTECTED_ITEM_COLLECTION, EMPTY_MICRO_OPERATION_SET, false, 0 ) );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
             null, null, null, null, null, null, null ).size() );
     }
 
 
+    @Test
     public void testNameAndThisEntry() throws Exception
     {
         MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
@@ -128,12 +131,13 @@
         tuples = ( List<ACITuple> ) filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null, null, null,
             null, null, null );
 
-        Assert.assertEquals( 2, tuples.size() );
-        Assert.assertSame( TUPLES_A.get( 0 ), tuples.get( 0 ) );
-        Assert.assertSame( TUPLES_A.get( 1 ), tuples.get( 1 ) );
+        assertEquals( 2, tuples.size() );
+        assertSame( TUPLES_A.get( 0 ), tuples.get( 0 ) );
+        assertSame( TUPLES_A.get( 1 ), tuples.get( 1 ) );
     }
 
 
+    @Test
     public void testThisEntry() throws Exception
     {
         MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
@@ -142,11 +146,12 @@
         tuples = ( List<ACITuple> ) filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null, null, null,
             null, null, null );
 
-        Assert.assertEquals( 1, tuples.size() );
-        Assert.assertSame( TUPLES_B.get( 0 ), tuples.get( 0 ) );
+        assertEquals( 1, tuples.size() );
+        assertSame( TUPLES_B.get( 0 ), tuples.get( 0 ) );
     }
 
 
+    @Test
     public void testUserGroup() throws Exception
     {
         MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
@@ -155,11 +160,12 @@
         tuples = ( List<ACITuple> ) filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null, null, null,
             null, null, null );
 
-        Assert.assertEquals( 1, tuples.size() );
-        Assert.assertSame( TUPLES_C.get( 0 ), tuples.get( 0 ) );
+        assertEquals( 1, tuples.size() );
+        assertSame( TUPLES_C.get( 0 ), tuples.get( 0 ) );
     }
 
 
+    @Test
     public void testSubtree() throws Exception
     {
         MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
@@ -168,11 +174,12 @@
         tuples = ( List<ACITuple> ) filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null, null, null,
             null, null, null );
 
-        Assert.assertEquals( 1, tuples.size() );
-        Assert.assertSame( TUPLES_D.get( 0 ), tuples.get( 0 ) );
+        assertEquals( 1, tuples.size() );
+        assertSame( TUPLES_D.get( 0 ), tuples.get( 0 ) );
     }
 
 
+    @Test
     public void testOthers() throws Exception
     {
         MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
@@ -181,8 +188,8 @@
         tuples = (List<ACITuple>)filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null, null, null,
             null, null, null );
 
-        Assert.assertEquals( 2, tuples.size() );
-        Assert.assertSame( TUPLES_E.get( 0 ), tuples.get( 0 ) );
-        Assert.assertSame( TUPLES_E.get( 1 ), tuples.get( 1 ) );
+        assertEquals( 2, tuples.size() );
+        assertSame( TUPLES_E.get( 0 ), tuples.get( 0 ) );
+        assertSame( TUPLES_E.get( 1 ), tuples.get( 1 ) );
     }
 }

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/OperationScopeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/OperationScopeTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/OperationScopeTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/OperationScopeTest.java Wed Jan  6 18:26:43 2010
@@ -20,10 +20,9 @@
 package org.apache.directory.server.core.authz.support;
 
 
-import org.apache.directory.server.core.authz.support.OperationScope;
+import static org.junit.Assert.assertEquals;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import org.junit.Test;
 
 
 /**
@@ -33,21 +32,23 @@
  * @version $Rev$, $Date$
  *
  */
-public class OperationScopeTest extends TestCase
+public class OperationScopeTest
 {
+    @Test
     public void testGetName() throws Exception
     {
-        Assert.assertEquals( "Entry", OperationScope.ENTRY.getName() );
-        Assert.assertEquals( "Attribute Type", OperationScope.ATTRIBUTE_TYPE.getName() );
-        Assert.assertEquals( "Attribute Type & Value", OperationScope.ATTRIBUTE_TYPE_AND_VALUE.getName() );
+        assertEquals( "Entry", OperationScope.ENTRY.getName() );
+        assertEquals( "Attribute Type", OperationScope.ATTRIBUTE_TYPE.getName() );
+        assertEquals( "Attribute Type & Value", OperationScope.ATTRIBUTE_TYPE_AND_VALUE.getName() );
     }
 
 
+    @Test
     public void testGetNameAndToStringEquality()
     {
-        Assert.assertEquals( OperationScope.ENTRY.getName(), OperationScope.ENTRY.toString() );
-        Assert.assertEquals( OperationScope.ATTRIBUTE_TYPE.getName(), OperationScope.ATTRIBUTE_TYPE.toString() );
-        Assert.assertEquals( OperationScope.ATTRIBUTE_TYPE_AND_VALUE.getName(), OperationScope.ATTRIBUTE_TYPE_AND_VALUE
+        assertEquals( OperationScope.ENTRY.getName(), OperationScope.ENTRY.toString() );
+        assertEquals( OperationScope.ATTRIBUTE_TYPE.getName(), OperationScope.ATTRIBUTE_TYPE.toString() );
+        assertEquals( OperationScope.ATTRIBUTE_TYPE_AND_VALUE.getName(), OperationScope.ATTRIBUTE_TYPE_AND_VALUE
             .toString() );
     }
 }

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java Wed Jan  6 18:26:43 2010
@@ -20,20 +20,17 @@
 package org.apache.directory.server.core.authz.support;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
-import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 
-import org.apache.directory.server.core.DefaultDirectoryService;
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.authz.support.OperationScope;
-import org.apache.directory.server.core.authz.support.RelatedProtectedItemFilter;
-import org.apache.directory.server.core.authz.support.RelatedUserClassFilter;
 import org.apache.directory.server.core.entry.DefaultServerAttribute;
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerAttribute;
@@ -42,8 +39,6 @@
 import org.apache.directory.server.core.event.ExpressionEvaluator;
 import org.apache.directory.server.core.subtree.RefinementEvaluator;
 import org.apache.directory.server.core.subtree.RefinementLeafEvaluator;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.shared.ldap.aci.ACITuple;
 import org.apache.directory.shared.ldap.aci.MicroOperation;
 import org.apache.directory.shared.ldap.aci.ProtectedItem;
@@ -54,12 +49,14 @@
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
-
-
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.loader.ldif.JarLdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
 
 /**
  * Tests {@link RelatedUserClassFilter}.
@@ -78,41 +75,45 @@
     private static Set<LdapDN> USER_NAMES = new HashSet<LdapDN>();
     private static Set<LdapDN> GROUP_NAMES = new HashSet<LdapDN>();
 
-    private static final AttributeTypeRegistry ATTR_TYPE_REGISTRY_A = new DummyAttributeTypeRegistry( false );
-    private static final AttributeTypeRegistry ATTR_TYPE_REGISTRY_B = new DummyAttributeTypeRegistry( true );
+    private static SchemaManager schemaManager;
+    //private static AttributeTypeRegistry atRegistryA;
+    //private static AttributeTypeRegistry atRegistryB;
     private static OidRegistry OID_REGISTRY;
 
     private static RelatedProtectedItemFilter filterA;
     private static RelatedProtectedItemFilter filterB;
-
-    /** A reference to the directory service */
-    private static DirectoryService service;
     
     /** The CN attribute Type */
     private static AttributeType CN_AT;
 
-    /** The SN attribute Type */
-    private static AttributeType SN_AT;
-
     
-    @BeforeClass public static void setup() throws NamingException
+    @BeforeClass public static void setup() throws Exception
     {
-        service = new DefaultDirectoryService();
-        OID_REGISTRY = service.getRegistries().getOidRegistry();
+        JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
+
+        schemaManager = new DefaultSchemaManager( loader );
+
+        boolean loaded = schemaManager.loadAllEnabled();
+
+        if ( !loaded )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) );
+        }
+
+        OID_REGISTRY = schemaManager.getGlobalOidRegistry();
 
         GROUP_NAME = new LdapDN( "ou=test,ou=groups,ou=system" );
         USER_NAME = new LdapDN( "ou=test, ou=users, ou=system" );
-
+        
         filterA = new RelatedProtectedItemFilter( new RefinementEvaluator( new RefinementLeafEvaluator(
-            OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_A ), OID_REGISTRY, ATTR_TYPE_REGISTRY_A );
+            OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, schemaManager ), OID_REGISTRY, schemaManager );
 
         filterB = new RelatedProtectedItemFilter( new RefinementEvaluator( new RefinementLeafEvaluator(
-            OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_B ), OID_REGISTRY, ATTR_TYPE_REGISTRY_B );
+            OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, schemaManager ), OID_REGISTRY, schemaManager );
 
         USER_NAMES.add( USER_NAME );
         GROUP_NAMES.add( GROUP_NAME );
-        CN_AT = service.getRegistries().getAttributeTypeRegistry().lookup( "cn" );
-        SN_AT = service.getRegistries().getAttributeTypeRegistry().lookup( "sn" );
+        CN_AT = schemaManager.lookupAttributeTypeRegistry( "cn" );
     }
 
     
@@ -330,7 +331,7 @@
         attrTypes.add( "cn" );
         Collection<ACITuple> tuples = getTuples( new ProtectedItem.SelfValue( attrTypes ) );
 
-        ServerEntry entry = new DefaultServerEntry( service.getRegistries(), USER_NAME );
+        ServerEntry entry = new DefaultServerEntry( schemaManager, USER_NAME );
         entry.put( "cn", USER_NAME.toNormName() );
 
         // Test wrong scope

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedUserClassFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedUserClassFilterTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedUserClassFilterTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedUserClassFilterTest.java Wed Jan  6 18:26:43 2010
@@ -20,6 +20,8 @@
 package org.apache.directory.server.core.authz.support;
 
 
+import static org.junit.Assert.assertEquals;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -28,11 +30,6 @@
 
 import javax.naming.NamingException;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.directory.server.core.authz.support.OperationScope;
-import org.apache.directory.server.core.authz.support.RelatedUserClassFilter;
 import org.apache.directory.server.core.subtree.SubtreeEvaluator;
 import org.apache.directory.shared.ldap.aci.ACITuple;
 import org.apache.directory.shared.ldap.aci.MicroOperation;
@@ -40,6 +37,9 @@
 import org.apache.directory.shared.ldap.aci.UserClass;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 
 /**
@@ -48,25 +48,26 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class RelatedUserClassFilterTest extends TestCase
+public class RelatedUserClassFilterTest
 {
     private static final Collection<ACITuple> EMPTY_ACI_TUPLE_COLLECTION = Collections.unmodifiableCollection( new ArrayList<ACITuple>() );
     private static final Collection<ProtectedItem> EMPTY_PROTECTED_ITEM_COLLECTION = Collections.unmodifiableCollection( new ArrayList<ProtectedItem>() );
 
     private static final Set<MicroOperation> EMPTY_MICRO_OPERATION_SET = Collections.unmodifiableSet( new HashSet<MicroOperation>() );
 
-    private static final LdapDN GROUP_NAME;
-    private static final LdapDN USER_NAME;
+    private static LdapDN GROUP_NAME;
+    private static LdapDN USER_NAME;
     private static final Set<LdapDN> USER_NAMES = new HashSet<LdapDN>();
     private static final Set<LdapDN> GROUP_NAMES = new HashSet<LdapDN>();
 
-    private static final SubtreeEvaluator SUBTREE_EVALUATOR;
+    private static SubtreeEvaluator SUBTREE_EVALUATOR;
 
-    private static final RelatedUserClassFilter filter;
+    private static RelatedUserClassFilter filter;
 
-    static
+    @BeforeClass
+    public static void init() throws Exception
     {
-        SUBTREE_EVALUATOR = new SubtreeEvaluator( new DummyOidRegistry(), new DummyAttributeTypeRegistry(true) );
+        SUBTREE_EVALUATOR = new SubtreeEvaluator( new DummyOidRegistry(), new DefaultSchemaManager( null ) );
         filter = new RelatedUserClassFilter( SUBTREE_EVALUATOR );
         
         try
@@ -84,97 +85,105 @@
     }
 
 
+    @Test
     public void testZeroTuple() throws Exception
     {
-        Assert.assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
+        assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
             null, null, null, null, null, null, null, null, null ).size() );
     }
 
 
+    @Test
     public void testAllUsers() throws Exception
     {
         Collection<ACITuple> tuples = getTuples( UserClass.ALL_USERS );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
             AuthenticationLevel.NONE, null, null, null, null, null, null ).size() );
     }
 
 
+    @Test
     public void testThisEntry() throws Exception
     {
         Collection<ACITuple> tuples = getTuples( UserClass.THIS_ENTRY );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null,
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null,
             AuthenticationLevel.NONE, USER_NAME, null, null, null, null, null ).size() );
-        Assert.assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null,
+        assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null,
             AuthenticationLevel.NONE, new LdapDN( "ou=unrelated" ), null, null, null, null, null ).size() );
     }
     
     
+    @Test
     public void testParentOfEntry() throws Exception
     {
         Collection<ACITuple> tuples = getTuples( UserClass.PARENT_OF_ENTRY );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null,
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null,
             AuthenticationLevel.NONE, new LdapDN( "ou=phoneBook, ou=test, ou=users, ou=system" ), null, null, null, null, null ).size() );
-        Assert.assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null,
+        assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null,
             AuthenticationLevel.NONE, new LdapDN( "ou=unrelated" ), null, null, null, null, null ).size() );
     }
 
 
+    @Test
     public void testName() throws Exception
     {
         Collection<ACITuple> tuples = getTuples( new UserClass.Name( USER_NAMES ) );
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null,
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null,
             AuthenticationLevel.NONE, null, null, null, null, null, null ).size() );
-        Assert.assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, null,
+        assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, null,
             new LdapDN( "ou=unrelateduser, ou=users" ), null, AuthenticationLevel.NONE, USER_NAME, null, null, null,
             null, null ).size() );
     }
 
 
+    @Test
     public void testUserGroup() throws Exception
     {
         Collection<ACITuple> tuples = getTuples( new UserClass.UserGroup( GROUP_NAMES ) );
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, GROUP_NAMES, USER_NAME, null,
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, GROUP_NAMES, USER_NAME, null,
             AuthenticationLevel.NONE, null, null, null, null, null, null ).size() );
 
         Set<LdapDN> wrongGroupNames = new HashSet<LdapDN>();
         wrongGroupNames.add( new LdapDN( "ou=unrelatedgroup" ) );
 
-        Assert.assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, wrongGroupNames, USER_NAME, null,
+        assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, wrongGroupNames, USER_NAME, null,
             AuthenticationLevel.NONE, USER_NAME, null, null, null, null, null ).size() );
     }
 
 
+    @Test
     public void testSubtree() throws Exception
     {
         // TODO Don't know how to test yet.
     }
 
 
+    @Test
     public void testAuthenticationLevel() throws Exception
     {
         Collection<ACITuple> tuples = getTuples( AuthenticationLevel.SIMPLE, true );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
             AuthenticationLevel.STRONG, null, null, null, null, null, null ).size() );
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
             AuthenticationLevel.SIMPLE, null, null, null, null, null, null ).size() );
-        Assert.assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
+        assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
             AuthenticationLevel.NONE, null, null, null, null, null, null ).size() );
 
         tuples = getTuples( AuthenticationLevel.SIMPLE, false );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
             AuthenticationLevel.NONE, null, null, null, null, null, null ).size() );
 
-        Assert.assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
+        assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
             AuthenticationLevel.STRONG, null, null, null, null, null, null ).size() );
 
         tuples = getTuples( AuthenticationLevel.SIMPLE, false );
 
-        Assert.assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
+        assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
             AuthenticationLevel.SIMPLE, null, null, null, null, null, null ).size() );
     }
 

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java Wed Jan  6 18:26:43 2010
@@ -20,18 +20,15 @@
 package org.apache.directory.server.core.authz.support;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
-import javax.naming.NamingException;
-
-import org.apache.directory.server.core.DefaultDirectoryService;
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.authz.support.OperationScope;
-import org.apache.directory.server.core.authz.support.RestrictedByFilter;
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.shared.ldap.aci.ACITuple;
@@ -42,12 +39,13 @@
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.name.LdapDN;
-
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.loader.ldif.JarLdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-
 
 /**
  * Tests {@link RestrictedByFilter}.
@@ -73,17 +71,26 @@
     }
 
 
-    /** A reference to the directory service */
-    private static DirectoryService service;
+    /** A reference to the schemaManager */
+    private static SchemaManager schemaManager;
 
     
-    @BeforeClass public static void setup() throws NamingException
+    @BeforeClass public static void setup() throws Exception
     {
-        service = new DefaultDirectoryService();
+        JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
+
+        schemaManager = new DefaultSchemaManager( loader );
+
+        boolean loaded = schemaManager.loadAllEnabled();
+
+        if ( !loaded )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) );
+        }
 
         LdapDN entryName = new LdapDN( "ou=test, ou=system" );
         PROTECTED_ITEMS.add( new ProtectedItem.MaxImmSub( 2 ) );
-        ENTRY = new DefaultServerEntry( service.getRegistries(), entryName );
+        ENTRY = new DefaultServerEntry( schemaManager, entryName );
 
         ENTRY.put( "cn", "1", "2" );
     }

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java Wed Jan  6 18:26:43 2010
@@ -30,7 +30,7 @@
 
 import javax.naming.NamingException;
 
-import org.apache.directory.server.core.authn.LdapPrincipal;
+import org.apache.directory.server.core.LdapPrincipal;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.ldif.ChangeType;
@@ -67,13 +67,21 @@
     {
         store = new MemoryChangeLogStore();
 
-        oidsMap.put( SchemaConstants.UID_AT, new OidNormalizer( SchemaConstants.UID_AT_OID, new NoOpNormalizer() ) );
-        oidsMap.put( SchemaConstants.USER_ID_AT, new OidNormalizer( SchemaConstants.UID_AT_OID, new NoOpNormalizer() ) );
-        oidsMap.put( SchemaConstants.UID_AT_OID, new OidNormalizer( SchemaConstants.UID_AT_OID, new NoOpNormalizer() ) );
-        
-        oidsMap.put( SchemaConstants.OU_AT, new OidNormalizer( SchemaConstants.OU_AT_OID, new NoOpNormalizer()  ) );
-        oidsMap.put( SchemaConstants.ORGANIZATIONAL_UNIT_NAME_AT, new OidNormalizer( SchemaConstants.OU_AT_OID, new NoOpNormalizer()  ) );
-        oidsMap.put( SchemaConstants.OU_AT_OID, new OidNormalizer( SchemaConstants.OU_AT_OID, new NoOpNormalizer()  ) );
+        // The uid/UserId/0.9.2342.19200300.100.1.1 normalizer
+        OidNormalizer uidOidNormalizer = new OidNormalizer( SchemaConstants.UID_AT_OID, 
+            new NoOpNormalizer( SchemaConstants.UID_AT_OID ) );
+        
+        oidsMap.put( SchemaConstants.UID_AT, uidOidNormalizer );
+        oidsMap.put( SchemaConstants.USER_ID_AT, uidOidNormalizer );
+        oidsMap.put( SchemaConstants.UID_AT_OID, uidOidNormalizer );
+        
+        // The ou/organizationalUnit/2.5.4.11 normalizer
+        OidNormalizer ouOidNormalizer = new OidNormalizer( SchemaConstants.OU_AT_OID, 
+            new NoOpNormalizer( SchemaConstants.OU_AT_OID ) );
+        
+        oidsMap.put( SchemaConstants.OU_AT, ouOidNormalizer );
+        oidsMap.put( SchemaConstants.ORGANIZATIONAL_UNIT_NAME_AT, ouOidNormalizer );
+        oidsMap.put( SchemaConstants.OU_AT_OID, ouOidNormalizer );
     }
 
 

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java Wed Jan  6 18:26:43 2010
@@ -20,14 +20,25 @@
 package org.apache.directory.server.core.interceptor;
 
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Set;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
 
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.DefaultCoreSession;
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.LdapPrincipal;
 import org.apache.directory.server.core.OperationManager;
 import org.apache.directory.server.core.ReferralManager;
-import org.apache.directory.server.core.authn.LdapPrincipal;
 import org.apache.directory.server.core.changelog.ChangeLog;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.event.EventService;
@@ -35,26 +46,19 @@
 import org.apache.directory.server.core.invocation.InvocationStack;
 import org.apache.directory.server.core.journal.Journal;
 import org.apache.directory.server.core.partition.ByPassConstants;
+import org.apache.directory.server.core.partition.DefaultPartitionNexus;
 import org.apache.directory.server.core.partition.Partition;
-import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.core.replication.ReplicationConfiguration;
-import org.apache.directory.server.core.schema.SchemaOperationControl;
 import org.apache.directory.server.core.schema.SchemaService;
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.csn.Csn;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.name.LdapDN;
-
-import javax.naming.NamingException;
-import javax.naming.ldap.LdapContext;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Set;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 
 /**
@@ -64,7 +68,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class InterceptorChainTest extends TestCase
+public class InterceptorChainTest
 {
     private static final int INTERCEPTOR_COUNT = 5;
     private InterceptorChain chain;
@@ -76,7 +80,8 @@
     }
     
     
-    protected void setUp() throws Exception
+    @Before
+    public void setUp() throws Exception
     {
         chain = new InterceptorChain();
 
@@ -91,13 +96,15 @@
     }
 
 
-    protected void tearDown() throws Exception
+    @After
+    public void tearDown() throws Exception
     {
         chain = null;
         interceptors.clear();
     }
 
 
+    @Test
     public void testNoBypass() throws Exception
     {
         LdapDN dn = new LdapDN( "ou=system" );
@@ -123,6 +130,7 @@
     }
 
 
+    @Test
     public void testSingleBypass() throws Exception
     {
         LdapDN dn = new LdapDN( "ou=system" );
@@ -149,6 +157,7 @@
     }
 
 
+    @Test
     public void testAdjacentDoubleBypass() throws Exception
     {
         LdapDN dn = new LdapDN( "ou=system" );
@@ -178,6 +187,7 @@
     }
 
 
+    @Test
     public void testFrontAndBackDoubleBypass() throws Exception
     {
         LdapDN dn = new LdapDN( "ou=system" );
@@ -206,6 +216,7 @@
     }
 
 
+    @Test
     public void testDoubleBypass() throws Exception
     {
         LdapDN dn = new LdapDN( "ou=system" );
@@ -234,6 +245,7 @@
     }
 
 
+    @Test
     public void testCompleteBypass() throws Exception
     {
         LdapDN dn = new LdapDN( "ou=system" );
@@ -281,7 +293,7 @@
         }
 
 
-        public PartitionNexus getPartitionNexus()
+        public DefaultPartitionNexus getPartitionNexus()
         {
             return null;
         }
@@ -314,7 +326,7 @@
         }
 
 
-        public Registries getRegistries()
+        public SchemaManager getSchemaManager()
         {
             return null;
         }
@@ -337,17 +349,6 @@
         }
 
 
-        public SchemaOperationControl getSchemaManager()
-        {
-            return null;
-        }
-
-
-        public void setSchemaManager( SchemaOperationControl schemaManager )
-        {
-        }
-
-
         public void startup() throws NamingException
         {
         }
@@ -640,7 +641,7 @@
         }
         
         
-        public void setPassordHidden( boolean passwordHidden )
+        public void setPasswordHidden( boolean passwordHidden )
         {
         }
 
@@ -700,5 +701,12 @@
             // TODO Auto-generated method stub
             return null;
         }
+
+
+        public void setSchemaManager( SchemaManager schemaManager )
+        {
+            // TODO Auto-generated method stub
+            
+        }
     }
 }

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/normalization/NormalizationVisitorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/normalization/NormalizationVisitorTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/normalization/NormalizationVisitorTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/normalization/NormalizationVisitorTest.java Wed Jan  6 18:26:43 2010
@@ -19,23 +19,26 @@
  */
 package org.apache.directory.server.core.normalization;
 
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.text.ParseException;
 
-import org.apache.directory.server.core.DefaultDirectoryService;
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.schema.ConcreteNameComponentNormalizer;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.FilterParser;
 import org.apache.directory.shared.ldap.filter.NotNode;
 import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
-import org.junit.Before;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.loader.ldif.JarLdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.schema.normalizers.ConcreteNameComponentNormalizer;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
+import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
 
 
 /**
@@ -49,18 +52,25 @@
     /** a filter node value normalizer and undefined node remover */
     private static FilterNormalizingVisitor normVisitor;
     
-    /** A reference to the directory service */
-    private static DirectoryService service;
+    /** A reference to the schemaManager */
+    private static SchemaManager schemaManager;
     
-    @Before
-    public void init() throws Exception
+    @BeforeClass
+    public static void init() throws Exception
     {
-        service = new DefaultDirectoryService();
+        JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
+
+        schemaManager = new DefaultSchemaManager( loader );
+
+        boolean loaded = schemaManager.loadAllEnabled();
+
+        if ( !loaded )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) );
+        }
 
-        OidRegistry oidRegistry = service.getRegistries().getOidRegistry();
-        AttributeTypeRegistry attributeRegistry = service.getRegistries().getAttributeTypeRegistry();
-        NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( attributeRegistry, oidRegistry );
-        normVisitor = new FilterNormalizingVisitor( ncn, service.getRegistries() );
+        NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( schemaManager );
+        normVisitor = new FilterNormalizingVisitor( ncn, schemaManager );
     }
 
     @Test

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/prefs/PreferencesUtilsTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/prefs/PreferencesUtilsTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/prefs/PreferencesUtilsTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/prefs/PreferencesUtilsTest.java Wed Jan  6 18:26:43 2010
@@ -25,8 +25,9 @@
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.prefs.PreferencesUtils;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.junit.Test;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
 
 
 /**
@@ -35,7 +36,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class PreferencesUtilsTest extends TestCase
+public class PreferencesUtilsTest
 {
     /**
      * Tests to confirm the toSysDn() method can translate an absolute
@@ -43,6 +44,7 @@
      *
      * @throws NamingException if there are problems transforming the name
      */
+    @Test
     public void testToSysDn() throws NamingException
     {
         // simple test
@@ -53,7 +55,7 @@
 
         LdapDN dn = ( LdapDN ) PreferencesUtils.toSysDn( test );
 
-        assertEquals( expectedDN, dn.getUpName() );
+        assertEquals( expectedDN, dn.getName() );
 
         // simple test without trailing '/'
 
@@ -61,7 +63,7 @@
 
         dn = ( LdapDN ) PreferencesUtils.toSysDn( test );
 
-        assertEquals( expectedDN, dn.getUpName() );
+        assertEquals( expectedDN, dn.getName() );
 
         // basis condition tests
 
@@ -69,7 +71,7 @@
 
         dn = ( LdapDN ) PreferencesUtils.toSysDn( test );
 
-        assertEquals( ServerDNConstants.SYSPREFROOT_SYSTEM_DN, dn.getUpName() );
+        assertEquals( ServerDNConstants.SYSPREFROOT_SYSTEM_DN, dn.getName() );
 
         // endpoint tests
 
@@ -77,7 +79,7 @@
 
         dn = ( LdapDN ) PreferencesUtils.toSysDn( test );
 
-        assertEquals( ServerDNConstants.SYSPREFROOT_SYSTEM_DN, dn.getUpName() );
+        assertEquals( ServerDNConstants.SYSPREFROOT_SYSTEM_DN, dn.getName() );
 
     }
 }

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java Wed Jan  6 18:26:43 2010
@@ -20,7 +20,14 @@
 package org.apache.directory.server.core.schema;
 
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 import javax.naming.NamingException;
 
@@ -28,35 +35,24 @@
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.schema.SchemaChecker;
-import org.apache.directory.server.schema.bootstrap.ApacheSchema;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
-import org.apache.directory.server.schema.bootstrap.CoreSchema;
-import org.apache.directory.server.schema.bootstrap.Schema;
-import org.apache.directory.server.schema.bootstrap.SystemSchema;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.schema.registries.DefaultOidRegistry;
-import org.apache.directory.server.schema.registries.DefaultRegistries;
-import org.apache.directory.server.schema.registries.ObjectClassRegistry;
-import org.apache.directory.server.schema.registries.OidRegistry;
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
+import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.HashSet;
-
 
 /**
  * Tests to make sure the schema checker is operating correctly.
@@ -64,30 +60,34 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class SchemaCheckerTest extends TestCase
+public class SchemaCheckerTest
 {
-    static Registries registries;
+    static SchemaManager schemaManager;
 
 
     @BeforeClass
-    protected void setUp() throws Exception
+    public static void setUp() throws Exception
     {
-        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-        registries = new DefaultRegistries( "bootstrap", loader, new DefaultOidRegistry() );
+    	String workingDirectory = System.getProperty( "workingDirectory" );
 
-        Set<Schema> schemas = new HashSet<Schema>();
-        schemas.add( new SystemSchema() );
-        schemas.add( new ApacheSchema() );
-        schemas.add( new CoreSchema() );
-        loader.loadWithDependencies( schemas,registries );
+        if ( workingDirectory == null )
+        {
+            String path = SchemaCheckerTest.class.getResource( "" ).getPath();
+            int targetPos = path.indexOf( "target" );
+            workingDirectory = path.substring( 0, targetPos + 6 );
+        }
 
-        List<Throwable> errors = registries.checkRefInteg();
-        
-        if ( !errors.isEmpty() )
+        File schemaRepository = new File( workingDirectory, "schema" );
+        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
+        extractor.extractOrCopy( true );
+        LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
+        schemaManager = new DefaultSchemaManager( loader );
+
+        boolean loaded = schemaManager.loadAllEnabled();
+
+        if ( !loaded )
         {
-            NamingException e = new NamingException();
-            e.setRootCause( ( Throwable ) errors.get( 0 ) );
-            throw e;
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) );
         }
     }
 
@@ -101,23 +101,21 @@
     {
         LdapDN name = new LdapDN( "uid=akarasulu,ou=users,dc=example,dc=com" );
         ModificationOperation mod = ModificationOperation.REPLACE_ATTRIBUTE;
-        ServerEntry modifyAttributes = new DefaultServerEntry( registries );
-        AttributeType atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
+        ServerEntry modifyAttributes = new DefaultServerEntry( schemaManager );
+        AttributeType atCN = schemaManager.lookupAttributeTypeRegistry( "cn" );
         modifyAttributes.put( new DefaultServerAttribute( atCN ) );
 
-        ObjectClassRegistry ocRegistry = registries.getObjectClassRegistry();
-
         // this should pass
-        SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod, modifyAttributes );
+        SchemaChecker.preventStructuralClassRemovalOnModifyReplace( schemaManager.getObjectClassRegistry(), name, mod, modifyAttributes );
 
         // this should succeed since person is still in replaced set and is structural
         modifyAttributes.removeAttributes( atCN );
-        AttributeType atOC = registries.getAttributeTypeRegistry().lookup( "objectClass" );
+        AttributeType atOC = schemaManager.lookupAttributeTypeRegistry( "objectClass" );
         EntryAttribute objectClassesReplaced = new DefaultServerAttribute( atOC );
         objectClassesReplaced.add( "top" );
         objectClassesReplaced.add( "person" );
         modifyAttributes.put( objectClassesReplaced );
-        SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod, modifyAttributes );
+        SchemaChecker.preventStructuralClassRemovalOnModifyReplace( schemaManager.getObjectClassRegistry(), name, mod, modifyAttributes );
 
         // this should fail since only top is left
         objectClassesReplaced = new DefaultServerAttribute( atOC );
@@ -125,7 +123,7 @@
         modifyAttributes.put( objectClassesReplaced );
         try
         {
-            SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod, modifyAttributes );
+            SchemaChecker.preventStructuralClassRemovalOnModifyReplace( schemaManager.getObjectClassRegistry(), name, mod, modifyAttributes );
             fail( "should never get here due to an LdapSchemaViolationException" );
         }
         catch ( LdapSchemaViolationException e )
@@ -140,7 +138,7 @@
         modifyAttributes.put( objectClassesReplaced );
         try
         {
-            SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod, modifyAttributes );
+            SchemaChecker.preventStructuralClassRemovalOnModifyReplace( schemaManager.getObjectClassRegistry(), name, mod, modifyAttributes );
             fail( "should never get here due to an LdapSchemaViolationException" );
         }
         catch ( LdapSchemaViolationException e )
@@ -223,19 +221,19 @@
     {
         ModificationOperation mod = ModificationOperation.REMOVE_ATTRIBUTE;
         LdapDN name = new LdapDN( "ou=user,dc=example,dc=com" );
-        ServerEntry attributes = new DefaultServerEntry( registries, name );
+        ServerEntry attributes = new DefaultServerEntry( schemaManager, name );
         attributes.put( "cn", "does not matter" );
 
         // postive test which should pass
-        SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, registries.getOidRegistry() );
+        SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, schemaManager );
 
         // test should fail since we are removing the ou attribute
-        AttributeType OU_AT = registries.getAttributeTypeRegistry().lookup( "ou" );
+        AttributeType OU_AT = schemaManager.lookupAttributeTypeRegistry( "ou" );
         attributes.put( new DefaultServerAttribute( "ou", OU_AT ) );
 
         try
         {
-            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, registries.getOidRegistry() );
+            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, schemaManager );
             fail( "should never get here due to a LdapSchemaViolationException being thrown" );
         }
         catch ( LdapSchemaViolationException e )
@@ -245,17 +243,17 @@
 
         // test success using more than one attribute for the Rdn but not modifying rdn attribute
         name = new LdapDN( "ou=users+cn=system users,dc=example,dc=com" );
-        attributes = new DefaultServerEntry( registries, name );
+        attributes = new DefaultServerEntry( schemaManager, name );
         attributes.put( "sn", "does not matter" );
-        SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, registries.getOidRegistry() );
+        SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, schemaManager );
 
         // test for failure when modifying Rdn attribute in multi attribute Rdn
-        AttributeType CN_AT = registries.getAttributeTypeRegistry().lookup( "cn" );
+        AttributeType CN_AT = schemaManager.lookupAttributeTypeRegistry( "cn" );
         attributes.put( new DefaultServerAttribute( "cn", CN_AT ) );
         
         try
         {
-            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, registries.getOidRegistry() );
+            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, schemaManager );
             fail( "should never get here due to a LdapSchemaViolationException being thrown" );
         }
         catch ( LdapSchemaViolationException e )
@@ -265,16 +263,16 @@
 
         // should succeed since the value being deleted from the rdn attribute is
         // is not used when composing the Rdn
-        attributes = new DefaultServerEntry( registries, name );
+        attributes = new DefaultServerEntry( schemaManager, name );
         attributes.put( "ou", "container" );
-        SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, registries.getOidRegistry() );
+        SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, schemaManager );
 
         // now let's make it fail again just by providing the right value for ou (users)
-        attributes = new DefaultServerEntry( registries, name );
+        attributes = new DefaultServerEntry( schemaManager, name );
         attributes.put( "ou", "users" );
         try
         {
-            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, registries.getOidRegistry() );
+            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, schemaManager );
             fail( "should never get here due to a LdapSchemaViolationException being thrown" );
         }
         catch ( LdapSchemaViolationException e )
@@ -293,18 +291,18 @@
     {
         ModificationOperation mod = ModificationOperation.REPLACE_ATTRIBUTE;
         LdapDN name = new LdapDN( "ou=user,dc=example,dc=com" );
-        ServerEntry attributes = new DefaultServerEntry( registries, name );
+        ServerEntry attributes = new DefaultServerEntry( schemaManager, name );
         attributes.put( "cn", "does not matter" );
 
         // postive test which should pass
-        SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, registries.getOidRegistry() );
+        SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, schemaManager );
 
         // test should fail since we are removing the ou attribute
         attributes.put( "ou", (String)null );
         
         try
         {
-            SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, registries.getOidRegistry() );
+            SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, schemaManager );
             fail( "should never get here due to a LdapSchemaViolationException being thrown" );
         }
         catch ( LdapSchemaViolationException e )
@@ -314,16 +312,16 @@
 
         // test success using more than one attribute for the Rdn but not modifying rdn attribute
         name = new LdapDN( "ou=users+cn=system users,dc=example,dc=com" );
-        attributes = new DefaultServerEntry( registries, name );
+        attributes = new DefaultServerEntry( schemaManager, name );
         attributes.put( "sn", "does not matter" );
-        SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, registries.getOidRegistry() );
+        SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, schemaManager );
 
         // test for failure when modifying Rdn attribute in multi attribute Rdn
         attributes.put("cn", (String)null );
         
         try
         {
-            SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, registries.getOidRegistry() );
+            SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, schemaManager );
             fail( "should never get here due to a LdapSchemaViolationException being thrown" );
         }
         catch ( LdapSchemaViolationException e )
@@ -333,17 +331,17 @@
 
         // should succeed since the values being replaced from the rdn attribute is
         // is includes the old Rdn attribute value
-        attributes = new DefaultServerEntry( registries, name );
+        attributes = new DefaultServerEntry( schemaManager, name );
         attributes.put( "ou", "container" );
         attributes.put( "ou", "users" );
-        SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, registries.getOidRegistry() );
+        SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, schemaManager );
 
         // now let's make it fail by not including the old value for ou (users)
-        attributes = new DefaultServerEntry( registries, name );
+        attributes = new DefaultServerEntry( schemaManager, name );
         attributes.put( "ou", "container" );
         try
         {
-            SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, registries.getOidRegistry() );
+            SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, schemaManager );
             fail( "should never get here due to a LdapSchemaViolationException being thrown" );
         }
         catch ( LdapSchemaViolationException e )
@@ -364,27 +362,26 @@
     @Test
     public void testPreventStructuralClassRemovalOnModifyReplaceAttribute() throws Exception
     {
-        ObjectClassRegistry ocRegistry = registries.getObjectClassRegistry();
-        AttributeType OBJECT_CLASS = registries.getAttributeTypeRegistry().lookup( "objectClass" );
-        AttributeType CN_AT = registries.getAttributeTypeRegistry().lookup( "cn" );
+        AttributeType OBJECT_CLASS = schemaManager.lookupAttributeTypeRegistry( "objectClass" );
+        AttributeType CN_AT = schemaManager.lookupAttributeTypeRegistry( "cn" );
 
         // this should pass
         LdapDN name = new LdapDN( "uid=akarasulu,ou=users,dc=example,dc=com" );
         ModificationOperation mod = ModificationOperation.REPLACE_ATTRIBUTE;
-        SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod, new DefaultServerAttribute( "cn", CN_AT ) );
+        SchemaChecker.preventStructuralClassRemovalOnModifyReplace( schemaManager, name, mod, new DefaultServerAttribute( "cn", CN_AT ) );
 
         // this should succeed since person is still in replaced set and is structural
         ServerAttribute objectClassesReplaced = new DefaultServerAttribute( "objectClass", OBJECT_CLASS );
         objectClassesReplaced.add( "top" );
         objectClassesReplaced.add( "person" );
-        SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod, objectClassesReplaced );
+        SchemaChecker.preventStructuralClassRemovalOnModifyReplace( schemaManager, name, mod, objectClassesReplaced );
 
         // this should fail since only top is left
         objectClassesReplaced = new DefaultServerAttribute( "objectClass", OBJECT_CLASS );
         objectClassesReplaced.add( "top" );
         try
         {
-            SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod, objectClassesReplaced );
+            SchemaChecker.preventStructuralClassRemovalOnModifyReplace( schemaManager, name, mod, objectClassesReplaced );
             fail( "should never get here due to an LdapSchemaViolationException" );
         }
         catch ( LdapSchemaViolationException e )
@@ -397,7 +394,7 @@
         objectClassesReplaced = new DefaultServerAttribute( "objectClass", OBJECT_CLASS );
         try
         {
-            SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod, objectClassesReplaced );
+            SchemaChecker.preventStructuralClassRemovalOnModifyReplace( schemaManager, name, mod, objectClassesReplaced );
             fail( "should never get here due to an LdapSchemaViolationException" );
         }
         catch ( LdapSchemaViolationException e )
@@ -414,29 +411,26 @@
     @Test
     public void testPreventStructuralClassRemovalOnModifyRemoveAttribute() throws Exception
     {
-        AttributeTypeRegistry atReg = registries.getAttributeTypeRegistry();
         LdapDN name = new LdapDN( "uid=akarasulu,ou=users,dc=example,dc=com" );
         ModificationOperation mod = ModificationOperation.REMOVE_ATTRIBUTE;
-        AttributeType ocAt = atReg.lookup( "objectClass" );
+        AttributeType ocAt = schemaManager.lookupAttributeTypeRegistry( "objectClass" );
         
         ServerAttribute entryObjectClasses = new DefaultServerAttribute( "objectClass", ocAt );
         entryObjectClasses.add( "top", "person", "organizationalPerson" );
 
-        ObjectClassRegistry ocRegistry = registries.getObjectClassRegistry();
-
         // this should pass
         SchemaChecker.preventStructuralClassRemovalOnModifyRemove( 
-            ocRegistry, 
+            schemaManager, 
             name, 
             mod, 
-            new DefaultServerAttribute( "cn", atReg.lookup( "cn" ) ),
+            new DefaultServerAttribute( "cn", schemaManager.lookupAttributeTypeRegistry( "cn" ) ),
             entryObjectClasses );
 
         // this should succeed since person is left and is structural
         ServerAttribute objectClassesRemoved = new DefaultServerAttribute( 
             "objectClass", ocAt );
         objectClassesRemoved.add( "person" );
-        SchemaChecker.preventStructuralClassRemovalOnModifyRemove( ocRegistry, name, mod, objectClassesRemoved,
+        SchemaChecker.preventStructuralClassRemovalOnModifyRemove( schemaManager, name, mod, objectClassesRemoved,
             entryObjectClasses );
 
         // this should fail since only top is left
@@ -445,7 +439,7 @@
         
         try
         {
-            SchemaChecker.preventStructuralClassRemovalOnModifyRemove( ocRegistry, name, mod, objectClassesRemoved,
+            SchemaChecker.preventStructuralClassRemovalOnModifyRemove( schemaManager, name, mod, objectClassesRemoved,
                 entryObjectClasses );
             fail( "should never get here due to an LdapSchemaViolationException" );
         }
@@ -460,7 +454,7 @@
 
         try
         {
-            SchemaChecker.preventStructuralClassRemovalOnModifyRemove( ocRegistry, name, mod, objectClassesRemoved,
+            SchemaChecker.preventStructuralClassRemovalOnModifyRemove( schemaManager, name, mod, objectClassesRemoved,
                 entryObjectClasses );
             fail( "should never get here due to an LdapSchemaViolationException" );
         }
@@ -478,22 +472,22 @@
     @Test
     public void testPreventRdnChangeOnModifyRemoveAttribute() throws Exception
     {
-        OidRegistry registry = new MockOidRegistry();
+        Map<String, OidNormalizer> oidNormalizers = schemaManager.getAttributeTypeRegistry().getNormalizerMapping();
         ModificationOperation mod = ModificationOperation.REMOVE_ATTRIBUTE;
-        LdapDN name = new LdapDN( "ou=user,dc=example,dc=com" );
-        AttributeType cnAt = registries.getAttributeTypeRegistry().lookup( "cn" );
-        AttributeType ouAt = registries.getAttributeTypeRegistry().lookup( "ou" );
-        AttributeType snAt = registries.getAttributeTypeRegistry().lookup( "sn" );
+        LdapDN name = new LdapDN( "ou=user,dc=example,dc=com" ).normalize( oidNormalizers );
+        AttributeType cnAt = schemaManager.lookupAttributeTypeRegistry( "cn" );
+        AttributeType ouAt = schemaManager.lookupAttributeTypeRegistry( "ou" );
+        AttributeType snAt = schemaManager.lookupAttributeTypeRegistry( "sn" );
 
         // postive test which should pass
         SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, 
-            new DefaultServerAttribute( "cn", cnAt, "does not matter" ), registry );
+            new DefaultServerAttribute( "cn", cnAt, "does not matter" ), schemaManager );
 
         // test should fail since we are removing the ou attribute
         try
         {
             SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, 
-                new DefaultServerAttribute( "ou", ouAt ), registry );
+                new DefaultServerAttribute( "ou", ouAt ), schemaManager );
             fail( "should never get here due to a LdapSchemaViolationException being thrown" );
         }
         catch ( LdapSchemaViolationException e )
@@ -503,14 +497,15 @@
 
         // test success using more than one attribute for the Rdn but not modifying rdn attribute
         name = new LdapDN( "ou=users+cn=system users,dc=example,dc=com" );
+        name.normalize( oidNormalizers );
         SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, 
-            new DefaultServerAttribute( "sn", snAt, "does not matter" ), registry );
+            new DefaultServerAttribute( "sn", snAt, "does not matter" ), schemaManager );
 
         // test for failure when modifying Rdn attribute in multi attribute Rdn
         try
         {
             SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, 
-                new DefaultServerAttribute( "cn", cnAt ), registry );
+                new DefaultServerAttribute( "cn", cnAt ), schemaManager );
             fail( "should never get here due to a LdapSchemaViolationException being thrown" );
         }
         catch ( LdapSchemaViolationException e )
@@ -521,13 +516,13 @@
         // should succeed since the value being deleted from the rdn attribute is
         // is not used when composing the Rdn
         SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, 
-            new DefaultServerAttribute( "ou", ouAt, "container" ), registry );
+            new DefaultServerAttribute( "ou", ouAt, "container" ), schemaManager );
 
         // now let's make it fail again just by providing the right value for ou (users)
         try
         {
             SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, 
-                new DefaultServerAttribute( "ou", ouAt, "users" ), registry );
+                new DefaultServerAttribute( "ou", ouAt, "users" ), schemaManager );
             fail( "should never get here due to a LdapSchemaViolationException being thrown" );
         }
         catch ( LdapSchemaViolationException e )
@@ -597,7 +592,7 @@
 //    }
 
 
-    class MockOidRegistry implements OidRegistry
+    class MockOidRegistry extends OidRegistry
     {
         public String getOid( String name ) throws NamingException
         {
@@ -614,12 +609,12 @@
             return oid;
         }
 
-        public List getNameSet( String oid ) throws NamingException
+        public List<String> getNameSet( String oid ) throws NamingException
         {
             return Collections.singletonList( oid );
         }
 
-        public Iterator list()
+        public Iterator<String> list()
         {
             return Collections.EMPTY_LIST.iterator();
         }



Mime
View raw message