directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1070754 - in /directory: apacheds/branches/m1/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ apacheds/branches/m1/core/src/test/java/org/apache/directory/server/core/changelog/ shared/branches/m1/i...
Date Tue, 15 Feb 2011 02:04:53 GMT
Author: elecharny
Date: Tue Feb 15 02:04:52 2011
New Revision: 1070754

URL: http://svn.apache.org/viewvc?rev=1070754&view=rev
Log:
o Added a DefaultSchemaManager() constructor which loads the enabled schemas
o Used this constructor in the tests and in the server
o Moved some tests from shared-model to shared-integ
o Removed some uesless systemOut

Added:
    directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/entry/
    directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/entry/EntryTest.java
      - copied, changed from r1070415, directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntryTest.java
    directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/
    directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
      - copied, changed from r1070415, directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java
    directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/MultiThreadedTest.java
      - copied, changed from r1070415, directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/MultiThreadedTest.java
Removed:
    directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntryTest.java
    directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java
    directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/MultiThreadedTest.java
Modified:
    directory/apacheds/branches/m1/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java
    directory/apacheds/branches/m1/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java
    directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/codec/api/StandaloneLdapCodecServiceTest.java
    directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
    directory/shared/branches/m1/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java

Modified: directory/apacheds/branches/m1/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java?rev=1070754&r1=1070753&r2=1070754&view=diff
==============================================================================
--- directory/apacheds/branches/m1/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java
(original)
+++ directory/apacheds/branches/m1/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java
Tue Feb 15 02:04:52 2011
@@ -161,7 +161,7 @@ public class SchemaSynchronizer implemen
         Dn dn = entry.getDn();
         Dn parentDn = dn;
         parentDn = parentDn.remove( parentDn.size() - 1 );
-        parentDn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping()
);
+        parentDn.normalize( schemaManager );
 
         if ( !parentDn.equals(ouSchemaDn) )
         {

Modified: directory/apacheds/branches/m1/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java?rev=1070754&r1=1070753&r2=1070754&view=diff
==============================================================================
--- directory/apacheds/branches/m1/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java
(original)
+++ directory/apacheds/branches/m1/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java
Tue Feb 15 02:04:52 2011
@@ -29,19 +29,16 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.util.HashMap;
-import java.util.Map;
 
 import org.apache.directory.server.core.LdapPrincipal;
 import org.apache.directory.shared.ldap.model.constants.AuthenticationLevel;
-import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.ldif.ChangeType;
 import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.model.ldif.LdifRevertor;
 import org.apache.directory.shared.ldap.model.name.Dn;
-import org.apache.directory.shared.ldap.model.schema.normalizers.NoOpNormalizer;
-import org.apache.directory.shared.ldap.model.schema.normalizers.OidNormalizer;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
 import org.apache.directory.shared.util.DateUtils;
 import org.apache.directory.shared.util.Strings;
 import org.junit.AfterClass;
@@ -64,29 +61,14 @@ public class MemoryChangeLogStoreTest
 {
     private static MemoryChangeLogStore store;
 
-    private static Map<String, OidNormalizer> oidsMap = new HashMap<String, OidNormalizer>();
-    
+    private static SchemaManager schemaManager;
     
     @BeforeClass
     public static void setUp() throws Exception
     {
-        store = new MemoryChangeLogStore();
+        schemaManager = new DefaultSchemaManager();
 
-        // 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 );
+        store = new MemoryChangeLogStore();
     }
 
 
@@ -118,10 +100,10 @@ public class MemoryChangeLogStoreTest
     public void testChangeLogSerialization() throws LdapException, IOException, ClassNotFoundException
     {
         Dn systemDn = new Dn( "ou=system" );
-        systemDn.normalize( oidsMap );
+        systemDn.normalize( schemaManager );
         
         Dn adminDn = new Dn( "uid=admin, ou=system" );
-        adminDn.normalize( oidsMap );
+        adminDn.normalize( schemaManager );
 
         LdifEntry forward = new LdifEntry();
         forward.setDn( systemDn );
@@ -130,7 +112,7 @@ public class MemoryChangeLogStoreTest
         forward.putAttribute( "ou", "system" );
         
         Dn reverseDn = forward.getDn();
-        reverseDn.normalize( oidsMap );
+        reverseDn.normalize( schemaManager );
 
         LdifEntry reverse = LdifRevertor.reverseAdd( reverseDn );
 

Modified: directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/codec/api/StandaloneLdapCodecServiceTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/codec/api/StandaloneLdapCodecServiceTest.java?rev=1070754&r1=1070753&r2=1070754&view=diff
==============================================================================
--- directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/codec/api/StandaloneLdapCodecServiceTest.java
(original)
+++ directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/codec/api/StandaloneLdapCodecServiceTest.java
Tue Feb 15 02:04:52 2011
@@ -23,8 +23,6 @@ package org.apache.directory.shared.ldap
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import java.util.Iterator;
-
 import org.apache.directory.shared.ldap.codec.standalone.StandaloneLdapCodecService;
 import org.apache.directory.shared.ldap.extras.controls.PasswordPolicy;
 import org.apache.directory.shared.ldap.model.message.Control;
@@ -45,11 +43,6 @@ public class StandaloneLdapCodecServiceT
     public void testLoadingExtras()
     {
         StandaloneLdapCodecService codec = new StandaloneLdapCodecService();
-        Iterator<String> oids = codec.registeredControls();
-        while ( oids.hasNext() )
-        {
-            System.out.println( "Registered OID = " + oids.next() );
-        }
         
         assertTrue( codec.isControlRegistered( PasswordPolicy.OID ) );
 

Copied: directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/entry/EntryTest.java
(from r1070415, directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntryTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/entry/EntryTest.java?p2=directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/entry/EntryTest.java&p1=directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntryTest.java&r1=1070415&r2=1070754&rev=1070754&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntryTest.java
(original)
+++ directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/entry/EntryTest.java
Tue Feb 15 02:04:52 2011
@@ -16,14 +16,14 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.directory.shared.ldap.model.entry;
+package org.apache.directory.shared.ldap.entry;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.io.ByteArrayInputStream;
@@ -32,25 +32,30 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
-import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.model.entry.BinaryValue;
+import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
+import org.apache.directory.shared.ldap.model.entry.DefaultEntryAttribute;
+import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.model.entry.StringValue;
+import org.apache.directory.shared.ldap.model.entry.Value;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.name.Dn;
-import org.apache.directory.shared.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer;
-import org.apache.directory.shared.ldap.model.schema.normalizers.OidNormalizer;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
 import org.apache.directory.shared.util.Strings;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 /**
  * A test class for the DefaultEntry class
  * 
@@ -64,8 +69,8 @@ public class EntryTest
     private static final byte[] BYTES1 = new byte[]{ 'a', 'b' };
     private static final byte[] BYTES2 = new byte[]{ 'b' };
     private static final byte[] BYTES3 = new byte[]{ 'c' };
-    private static Map<String, OidNormalizer> oids;
     
+    private static SchemaManager schemaManager;
     
     /**
      * Helper method which creates an entry with 4 attributes.
@@ -174,24 +179,7 @@ public class EntryTest
     public static void setUpBeforeClass() throws Exception
     {
         EXAMPLE_DN = new Dn( "dc=example,dc=com" );
-
-        oids = new HashMap<String, OidNormalizer>();
-
-        // DC normalizer
-        OidNormalizer dcOidNormalizer = new OidNormalizer( "dc",
-            new DeepTrimToLowerNormalizer( SchemaConstants.DOMAIN_COMPONENT_AT_OID ) );
-        
-        oids.put( "dc", dcOidNormalizer );
-        oids.put( "domaincomponent", dcOidNormalizer );
-        oids.put( "0.9.2342.19200300.100.1.25", dcOidNormalizer );
-
-        // OU normalizer
-        OidNormalizer ouOidNormalizer = new OidNormalizer( "ou",
-            new DeepTrimToLowerNormalizer( SchemaConstants.OU_AT_OID ) );
-        
-        oids.put( "ou", ouOidNormalizer );
-        oids.put( "organizationalUnitName", ouOidNormalizer );
-        oids.put( "2.5.4.11", ouOidNormalizer );
+        schemaManager = new DefaultSchemaManager();
     }
 
 
@@ -1271,7 +1259,7 @@ public class EntryTest
     {
         Dn dn = new Dn( "ou=system" );
         
-        dn.normalize( oids );
+        dn.normalize( schemaManager );
         
         byte[] password = Strings.getBytesUtf8("secret");
         Entry entry = new DefaultEntry( dn);
@@ -1325,7 +1313,7 @@ public class EntryTest
     {
         Dn dn = new Dn( "ou=system" );
         
-        dn.normalize( oids );
+        dn.normalize( schemaManager );
         
         Entry entry = new DefaultEntry( dn );
 

Copied: directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
(from r1070415, directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java?p2=directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java&p1=directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java&r1=1070415&r2=1070754&rev=1070754&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java
(original)
+++ directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
Tue Feb 15 02:04:52 2011
@@ -17,7 +17,7 @@
  *  under the License.
  *
  */
-package org.apache.directory.shared.ldap.model.name;
+package org.apache.directory.shared.ldap.name;
 
 
 import static junit.framework.Assert.assertNotNull;
@@ -38,23 +38,27 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import javax.naming.InvalidNameException;
 import javax.naming.ldap.LdapName;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer;
-import org.apache.directory.shared.ldap.model.schema.normalizers.OidNormalizer;
+import org.apache.directory.shared.ldap.model.name.Ava;
+import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.name.DnParser;
+import org.apache.directory.shared.ldap.model.name.DnSerializer;
+import org.apache.directory.shared.ldap.model.name.Rdn;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
 import org.apache.directory.shared.util.Strings;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 
 /**
  * Test the class Dn
@@ -65,41 +69,18 @@ import org.junit.runner.RunWith;
 @Concurrency()
 public class DnTest
 {
-    private static Map<String, OidNormalizer> oids;
-    private static Map<String, OidNormalizer> oidOids;
-
+    private static SchemaManager schemaManager;
 
     /**
      * Initialize OIDs maps for normalization
      */
     @BeforeClass
-    public static void initMapOids()
+    public static void setup() throws Exception
     {
-        oids = new HashMap<String, OidNormalizer>();
-
-        oids.put( "dc", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "domaincomponent", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer()
) );
-        oids.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer()
) );
-
-        oids.put( "ou", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer()
) );
-        oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() )
);
-
-        // Another map where we store OIDs instead of names.
-        oidOids = new HashMap<String, OidNormalizer>();
-
-        oidOids.put( "dc", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer()
) );
-        oidOids.put( "domaincomponent", new OidNormalizer( "0.9.2342.19200300.100.1.25",
-            new DeepTrimToLowerNormalizer() ) );
-        oidOids.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "0.9.2342.19200300.100.1.25",
-            new DeepTrimToLowerNormalizer() ) );
-        oidOids.put( "ou", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer()
) );
-        oidOids.put( "organizationalUnitName", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer()
) );
-        oidOids.put( "2.5.4.11", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer()
) );
+        schemaManager = new DefaultSchemaManager();
     }
 
 
-    // ~ Methods
     // ------------------------------------------------------------------------------------
     // CONSTRUCTOR functions --------------------------------------------------
 
@@ -418,7 +399,7 @@ public class DnTest
         assertEquals( "ou = \\#this is a sharp", dn.getName() );
 
         // Check the normalization now
-        Dn ndn = dn.normalize( oidOids );
+        Dn ndn = dn.normalize( schemaManager );
 
         assertEquals( "ou = \\#this is a sharp", ndn.getName() );
         assertEquals( "2.5.4.11=\\#this is a sharp", ndn.getNormName() );
@@ -438,7 +419,7 @@ public class DnTest
         assertEquals( "ou = AC\\\\DC", dn.getName() );
 
         // Check the normalization now
-        Dn ndn = dn.normalize( oidOids );
+        Dn ndn = dn.normalize( schemaManager );
         assertEquals( "ou = AC\\\\DC", ndn.getName() );
         assertEquals( "2.5.4.11=ac\\\\dc", ndn.getNormName() );
     }
@@ -2380,8 +2361,7 @@ public class DnTest
     /**
      * Class to test for String toString()
      *
-     * @throws Exception
-     *             if anything goes wrong
+     * @throws Exception if anything goes wrong
      */
     @Test
     public void testToString() throws Exception
@@ -2423,7 +2403,7 @@ public class DnTest
         assertEquals( "o=acme", two.getParent().getName() );
 
         Dn three = new Dn( "cn=test,dc=example,dc=com" );
-        three.normalize( oids );
+        three.normalize( schemaManager );
         Dn threeParent = three.getParent();
         assertNotNull( threeParent );
         assertTrue( threeParent.isNormalized() );
@@ -2510,9 +2490,9 @@ public class DnTest
 
         assertTrue( name.getName().equals( "ou= Some   People   ,dc = eXample,dc= cOm" )
);
 
-        Dn result = Dn.normalize(name, oids);
+        Dn result = name.normalize( schemaManager );
 
-        assertTrue( ( result ).getNormName().equals( "ou=some people,dc=example,dc=com" )
);
+        assertEquals( "2.5.4.11=some people,0.9.2342.19200300.100.1.25=example,0.9.2342.19200300.100.1.25=com",
result.getNormName() );
     }
 
 
@@ -2529,7 +2509,7 @@ public class DnTest
         assertEquals( "ou", rdn.getNormType() );
         assertEquals( "ou", rdn.getUpType() );
 
-        Dn result = Dn.normalize(name, oidOids);
+        Dn result = name.normalize( schemaManager );
 
         assertTrue( result.getNormName().equals(
             "2.5.4.11=some people,0.9.2342.19200300.100.1.25=example,0.9.2342.19200300.100.1.25=com"
) );
@@ -2551,7 +2531,7 @@ public class DnTest
     {
         Dn name = new Dn();
 
-        Dn result = Dn.normalize(name, oids);
+        Dn result = name.normalize( schemaManager );
         assertTrue( result.toString().equals( "" ) );
     }
 
@@ -2565,7 +2545,7 @@ public class DnTest
         Dn name = new Dn(
             "2.5.4.11= Some   People   + 0.9.2342.19200300.100.1.25=  And   Some anImAls,0.9.2342.19200300.100.1.25
= eXample,dc= cOm" );
 
-        Dn result = Dn.normalize(name, oidOids);
+        Dn result = name.normalize( schemaManager );
 
         assertEquals(
             ( result ).getNormName(),
@@ -2586,7 +2566,7 @@ public class DnTest
         Dn name = new Dn(
             "2.5.4.11= Some   People   + domainComponent=  And   Some anImAls,DomainComponent
= eXample,0.9.2342.19200300.100.1.25= cOm" );
 
-        Dn result = Dn.normalize(name, oidOids);
+        Dn result = name.normalize( schemaManager);
 
         assertTrue( result
             .getNormName()
@@ -2606,14 +2586,12 @@ public class DnTest
     public void testLdapNameHashCode() throws Exception
     {
         Dn name1 = Dn
-            .normalize(
-                    "2.5.4.11= Some   People   + domainComponent=  And   Some anImAls,DomainComponent
= eXample,0.9.2342.19200300.100.1.25= cOm",
-                    oids);
+            .normalize( schemaManager,
+                    "2.5.4.11= Some   People   + domainComponent=  And   Some anImAls,DomainComponent
= eXample,0.9.2342.19200300.100.1.25= cOm" );
 
         Dn name2 = Dn
-            .normalize(
-                    "2.5.4.11=some people+domainComponent=and some animals,DomainComponent=example,0.9.2342.19200300.100.1.25=com",
-                    oids);
+            .normalize( schemaManager,
+                    "2.5.4.11=some people+domainComponent=and some animals,DomainComponent=example,0.9.2342.19200300.100.1.25=com"
);
 
         assertEquals( name1.hashCode(), name2.hashCode() );
     }
@@ -3168,7 +3146,7 @@ public class DnTest
     public void testNameSerialization() throws Exception
     {
         Dn dn = new Dn( "ou= Some   People   + dc=  And   Some anImAls,dc = eXample,dc= cOm"
);
-        dn.normalize( oids );
+        dn.normalize( schemaManager );
 
         assertEquals( dn, deserializeDN( serializeDN( dn ) ) );
     }
@@ -3192,7 +3170,7 @@ public class DnTest
     public void testNameStaticSerialization() throws Exception
     {
         Dn dn = new Dn( "ou= Some   People   + dc=  And   Some anImAls,dc = eXample,dc= cOm"
);
-        dn.normalize( oids );
+        dn.normalize( schemaManager );
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
@@ -3355,32 +3333,32 @@ public class DnTest
     public void testTrailingEscapedSpace() throws Exception
     {
         Dn dn1 = new Dn( "ou=A\\ ,ou=system" );
-        dn1.normalize( oids );
+        dn1.normalize( schemaManager );
         assertEquals( "ou=A\\ ,ou=system", dn1.getName() );
-        assertEquals( "ou=a,ou=system", dn1.getNormName() );
+        assertEquals( "2.5.4.11=a,2.5.4.11=system", dn1.getNormName() );
         assertEquals( "ou=A\\ ", dn1.getRdn().getName() );
-        assertEquals( "ou=a", dn1.getRdn().getNormName() );
+        assertEquals( "2.5.4.11=a", dn1.getRdn().getNormName() );
 
         Dn dn2 = new Dn( "ou=A\\20,ou=system" );
-        dn2.normalize( oids );
+        dn2.normalize( schemaManager );
         assertEquals( "ou=A\\20,ou=system", dn2.getName() );
-        assertEquals( "ou=a,ou=system", dn2.getNormName() );
+        assertEquals( "2.5.4.11=a,2.5.4.11=system", dn2.getNormName() );
         assertEquals( "ou=A\\20", dn2.getRdn().getName() );
-        assertEquals( "ou=a", dn2.getRdn().getNormName() );
+        assertEquals( "2.5.4.11=a", dn2.getRdn().getNormName() );
 
         Dn dn3 = new Dn( "ou=\\ ,ou=system" );
-        dn3.normalize( oids );
+        dn3.normalize( schemaManager );
         assertEquals( "ou=\\ ,ou=system", dn3.getName() );
-        assertEquals( "ou=\\ ,ou=system", dn3.getNormName() );
+        assertEquals( "2.5.4.11=\\ ,2.5.4.11=system", dn3.getNormName() );
         assertEquals( "ou=\\ ", dn3.getRdn().getName() );
-        assertEquals( "ou=\\ ", dn3.getRdn().getNormName() );
+        assertEquals( "2.5.4.11=\\ ", dn3.getRdn().getNormName() );
 
         Dn dn4 = new Dn( "ou=\\20,ou=system" );
-        dn4.normalize( oids );
+        dn4.normalize( schemaManager );
         assertEquals( "ou=\\20,ou=system", dn4.getName() );
-        assertEquals( "ou=\\ ,ou=system", dn4.getNormName() );
+        assertEquals( "2.5.4.11=\\ ,2.5.4.11=system", dn4.getNormName() );
         assertEquals( "ou=\\20", dn4.getRdn().getName() );
-        assertEquals( "ou=\\ ", dn4.getRdn().getNormName() );
+        assertEquals( "2.5.4.11=\\ ", dn4.getRdn().getNormName() );
     }
 
 
@@ -3427,7 +3405,7 @@ public class DnTest
     {
         Dn dn = new Dn( "  ou  =  Example ,  ou  =  COM " );
 
-        dn.normalize( oidOids );
+        dn.normalize( schemaManager );
         assertEquals( "2.5.4.11=example,2.5.4.11=com", dn.getNormName() );
         assertEquals( "  ou  =  Example ,  ou  =  COM ", dn.getName() );
 
@@ -3457,7 +3435,7 @@ public class DnTest
     {
         Dn dn = new Dn( "  ou  =  Example + ou = TEST ,  ou  =  COM " );
 
-        dn.normalize( oidOids );
+        dn.normalize( schemaManager );
         assertEquals( "2.5.4.11=example+2.5.4.11=test,2.5.4.11=com", dn.getNormName() );
         assertEquals( "  ou  =  Example + ou = TEST ,  ou  =  COM ", dn.getName() );
 
@@ -3508,7 +3486,7 @@ public class DnTest
     {
         Dn dn = new Dn( "  ou  =  Ex\\+mple ,  ou  =  COM " );
 
-        dn.normalize( oidOids );
+        dn.normalize( schemaManager );
         assertEquals( "2.5.4.11=ex\\+mple,2.5.4.11=com", dn.getNormName() );
         assertEquals( "  ou  =  Ex\\+mple ,  ou  =  COM ", dn.getName() );
 
@@ -3589,7 +3567,7 @@ public class DnTest
 
         // ------------------------------------------------------------------
         // Now normalize the Dn
-        dn.normalize( oidOids );
+        dn.normalize( schemaManager );
 
         assertEquals( "  OU  =  Ex\\+mple + ou = T\\+ST\\  ,  ou  =  COM ", dn.getName()
);
         assertEquals( "2.5.4.11=ex\\+mple+2.5.4.11=t\\+st,2.5.4.11=com", dn.getNormName()
);
@@ -3733,16 +3711,16 @@ public class DnTest
         dn = dn.add( "ou=users" );
         assertFalse( dn.isNormalized() );
 
-        dn.normalize( oidOids );
+        dn.normalize( schemaManager );
         assertTrue( dn.isNormalized() );
 
         dn = dn.add( "ou=x" );
-        assertFalse( dn.isNormalized() );
+        assertTrue( dn.isNormalized() );
 
-        assertEquals( "ou=x,2.5.4.11=users,2.5.4.11=system", dn.getNormName() );
+        assertEquals( "2.5.4.11=x,2.5.4.11=users,2.5.4.11=system", dn.getNormName() );
         assertEquals( "ou=x,ou=users,ou=system", dn.getName() );
 
-        dn.normalize( oidOids );
+        dn.normalize( schemaManager );
         assertEquals( "2.5.4.11=x,2.5.4.11=users,2.5.4.11=system", dn.getNormName() );
         assertEquals( "ou=x,ou=users,ou=system", dn.getName() );
 
@@ -3753,15 +3731,15 @@ public class DnTest
         dn = dn.add( rdn );
         assertFalse( dn.isNormalized() );
 
-        dn.normalize( oidOids );
+        dn.normalize( schemaManager );
         assertTrue( dn.isNormalized() );
 
         Dn anotherDn = new Dn( "ou=x,ou=users" );
 
         dn = dn.addAll( anotherDn );
-        assertFalse( dn.isNormalized() );
+        assertTrue( dn.isNormalized() );
 
-        dn.normalize( oidOids );
+        dn.normalize( schemaManager );
         assertTrue( dn.isNormalized() );
 
         dn = dn.remove( 0 );
@@ -3775,7 +3753,7 @@ public class DnTest
         String dnStr = "dc=/vehicles/v1/";
 
         Dn dn = new Dn( dnStr );
-        dn.normalize( oids );
+        dn.normalize( schemaManager );
 
         assertEquals( dnStr, dn.toString() );
     }

Copied: directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/MultiThreadedTest.java
(from r1070415, directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/MultiThreadedTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/MultiThreadedTest.java?p2=directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/MultiThreadedTest.java&p1=directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/MultiThreadedTest.java&r1=1070415&r2=1070754&rev=1070754&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/MultiThreadedTest.java
(original)
+++ directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/MultiThreadedTest.java
Tue Feb 15 02:04:52 2011
@@ -17,26 +17,26 @@
  *  under the License.
  *
  */
-package org.apache.directory.shared.ldap.model.name;
+package org.apache.directory.shared.ldap.name;
 
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
-import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
-import org.apache.directory.shared.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer;
-import org.apache.directory.shared.ldap.model.schema.normalizers.OidNormalizer;
+import org.apache.directory.shared.ldap.model.name.Ava;
+import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.name.Rdn;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
 import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 
 /**
  * Multi-threaded 
@@ -50,8 +50,6 @@ public class MultiThreadedTest
     @Rule
     public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( 100, 1000 );
 
-    private static Map<String, OidNormalizer> oidsMap;
-
     private static Dn referenceDn;
     private static Dn sharedDn;
     private static Rdn referenceRdn;
@@ -59,30 +57,22 @@ public class MultiThreadedTest
     private static Ava referenceAva;
     private static Ava sharedAva;
 
+    private static SchemaManager schemaManager;
 
     @BeforeClass
-    public static void initMapOids() throws LdapInvalidDnException
+    public static void setup() throws Exception
     {
-        // Another map where we store OIDs instead of names.
-        oidsMap = new HashMap<String, OidNormalizer>();
-        oidsMap.put( "dc", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer()
) );
-        oidsMap.put( "domaincomponent", new OidNormalizer( "0.9.2342.19200300.100.1.25",
-            new DeepTrimToLowerNormalizer() ) );
-        oidsMap.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "0.9.2342.19200300.100.1.25",
-            new DeepTrimToLowerNormalizer() ) );
-        oidsMap.put( "ou", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer()
) );
-        oidsMap.put( "organizationalUnitName", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer()
) );
-        oidsMap.put( "2.5.4.11", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer()
) );
+        schemaManager = new DefaultSchemaManager();
 
         referenceDn = new Dn( "dc=example,dc=com" );
-        referenceDn.normalize( oidsMap );
+        referenceDn.normalize( schemaManager );
         sharedDn = new Dn( "dc=example,dc=com" );
-        sharedDn.normalize( oidsMap );
+        sharedDn.normalize( schemaManager );
 
         referenceRdn = new Rdn( "ou=system" );
-        referenceRdn.normalize( oidsMap );
+        referenceRdn.normalize( schemaManager );
         sharedRdn = new Rdn( "ou=system" );
-        sharedRdn.normalize( oidsMap );
+        sharedRdn.normalize( schemaManager );
 
         referenceAva = new Ava( "ou", "2.5.4.11", "System", "system" );
         referenceAva.normalize();
@@ -96,10 +86,10 @@ public class MultiThreadedTest
     {
         sharedAva.normalize();
 
-        sharedRdn.normalize( oidsMap );
+        sharedRdn.normalize( schemaManager );
         assertTrue( sharedRdn.isNormalized() );
 
-        sharedDn.normalize( oidsMap );
+        sharedDn.normalize( schemaManager );
         assertTrue( sharedDn.isNormalized() );
     }
 
@@ -110,10 +100,10 @@ public class MultiThreadedTest
         sharedAva.normalize();
         assertEquals( referenceAva.hashCode(), sharedAva.hashCode() );
 
-        sharedRdn.normalize( oidsMap );
+        sharedRdn.normalize( schemaManager );
         assertEquals( referenceRdn.hashCode(), sharedRdn.hashCode() );
 
-        sharedDn.normalize( oidsMap );
+        sharedDn.normalize( schemaManager );
         assertEquals( referenceDn.hashCode(), sharedDn.hashCode() );
     }
 
@@ -126,12 +116,12 @@ public class MultiThreadedTest
         assertTrue( referenceAva.equals( sharedAva ) );
         assertTrue( sharedAva.equals( referenceAva ) );
 
-        sharedRdn.normalize( oidsMap );
+        sharedRdn.normalize( schemaManager );
         assertEquals( referenceRdn, sharedRdn );
         assertTrue( referenceRdn.equals( sharedRdn ) );
         assertTrue( sharedRdn.equals( referenceRdn ) );
 
-        sharedDn.normalize( oidsMap );
+        sharedDn.normalize( schemaManager );
         assertEquals( referenceDn, sharedDn );
         assertTrue( referenceDn.equals( sharedDn ) );
         assertTrue( sharedDn.equals( referenceDn ) );
@@ -145,11 +135,11 @@ public class MultiThreadedTest
         assertEquals( 0, sharedAva.compareTo( referenceAva ) );
         assertEquals( 0, referenceAva.compareTo( sharedAva ) );
 
-        sharedRdn.normalize( oidsMap );
+        sharedRdn.normalize( schemaManager );
         assertEquals( 0, referenceRdn.compareTo( sharedRdn ) );
         assertEquals( 0, sharedRdn.compareTo( referenceRdn ) );
 
-        sharedDn.normalize( oidsMap );
+        sharedDn.normalize( schemaManager );
         assertEquals( 0, referenceDn.compareTo( sharedDn ) );
         assertEquals( 0, sharedDn.compareTo( referenceDn ) );
     }

Modified: directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java?rev=1070754&r1=1070753&r2=1070754&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
(original)
+++ directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
Tue Feb 15 02:04:52 2011
@@ -171,11 +171,13 @@ public class Dn implements Cloneable, Se
 
 
     /**
-     * Construct an empty Dn object
+     * Construct an empty Schema aware Dn object
+     * 
+     *  @param schemaManager The SchemaManager to use
      */
-    public Dn(SchemaManager schemaManger)
+    public Dn( SchemaManager schemaManager )
     {
-        this.schemaManager = schemaManger;
+        this.schemaManager = schemaManager;
         upName = "";
         normName = "";
         normalized = new AtomicBoolean( true );
@@ -183,9 +185,9 @@ public class Dn implements Cloneable, Se
 
 
     /**
-     * @see #Dn(String, SchemaManager)
+     * @see #Dn( SchemaManager, String )
      */
-    public Dn(String upName) throws LdapInvalidDnException
+    public Dn( String upName ) throws LdapInvalidDnException
     {
         this( null, upName );
     }
@@ -246,12 +248,14 @@ public class Dn implements Cloneable, Se
      * If the String contains a '=' symbol, the the constructor will assume that
      * the String arg contains afull Rdn, otherwise, it will consider that the
      * following arg is the value.
+     * The created Dn is Schema aware.
+     * <br/>
      * An example of usage would be :
      * <pre>
      * String exampleName = "example";
      * String baseDn = "dc=apache,dc=org";
      *
-     * Dn dn = new Dn(
+     * Dn dn = new Dn( DefaultSchemaManager.INSTANCE,
      *     "cn=Test",
      *     "ou", exampleName,
      *     baseDn);
@@ -261,7 +265,7 @@ public class Dn implements Cloneable, Se
      * @param upRdns
      * @throws LdapInvalidDnException
      */
-    public Dn(SchemaManager schemaManager, String... upRdns) throws LdapInvalidDnException
+    public Dn( SchemaManager schemaManager, String... upRdns ) throws LdapInvalidDnException
     {
         StringBuilder sb = new StringBuilder();
         boolean valueExpected = false;
@@ -404,10 +408,10 @@ public class Dn implements Cloneable, Se
      * @throws LdapInvalidNameException If the Dn is invalid.
      * @throws LdapInvalidDnException If something went wrong.
      */
-    /* No qualifier */static Dn normalize( String name, Map<String, OidNormalizer>
oidsMap )
+    public static Dn normalize( SchemaManager schemaManager, String name )
         throws LdapInvalidDnException
     {
-        if ( ( name == null ) || ( name.length() == 0 ) || ( oidsMap == null ) || ( oidsMap.isEmpty()
) )
+        if ( ( name == null ) || ( name.length() == 0 ) || ( schemaManager == null ) )
         {
             return Dn.EMPTY_DN;
         }
@@ -417,7 +421,7 @@ public class Dn implements Cloneable, Se
         for ( Rdn rdn : newDn.rdns )
         {
             String upName = rdn.getName();
-            rdnOidToName( rdn, oidsMap );
+            rdnOidToName( rdn, schemaManager.getNormalizerMapping() );
             rdn.normalize();
             rdn.setUpName( upName );
         }
@@ -1167,6 +1171,7 @@ public class Dn implements Cloneable, Se
         }
 
         clonedDn.toUpName();
+        clonedDn.toNormName();
 
         return clonedDn;
     }
@@ -1338,7 +1343,7 @@ public class Dn implements Cloneable, Se
      * {@inheritDoc}
      */
     @Override
-    protected Dn clone()
+    public Dn clone()
     {
         try
         {
@@ -1567,7 +1572,7 @@ public class Dn implements Cloneable, Se
      * @throws LdapInvalidDnException If something went wrong.
      * @return The normalized Dn
      */
-    public Dn normalize( Map<String, OidNormalizer> oidsMap ) throws LdapInvalidDnException
+    private Dn normalize( Map<String, OidNormalizer> oidsMap ) throws LdapInvalidDnException
     {
         if ( ( oidsMap == null ) || ( oidsMap.isEmpty() ) )
         {

Modified: directory/shared/branches/m1/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java?rev=1070754&r1=1070753&r2=1070754&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java
(original)
+++ directory/shared/branches/m1/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java
Tue Feb 15 02:04:52 2011
@@ -80,6 +80,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.schema.registries.Schema;
 import org.apache.directory.shared.ldap.model.schema.registries.SchemaLoader;
 import org.apache.directory.shared.ldap.model.schema.registries.SyntaxCheckerRegistry;
+import org.apache.directory.shared.ldap.schemaloader.JarLdifSchemaLoader;
 import org.apache.directory.shared.ldap.schemaloader.SchemaEntityFactory;
 import org.apache.directory.shared.util.Strings;
 import org.apache.directory.shared.util.exception.NotImplementedException;
@@ -127,6 +128,23 @@ public class DefaultSchemaManager implem
 
     /** Two flags for RELAXED and STRICT, this is RELAXED */
     public static final boolean RELAXED = true;
+    
+    /**
+     * Creates a new instance of DefaultSchemaManager with the default schema schemaLoader
+     *
+     * @param loader The schema loader to use
+     */
+    public DefaultSchemaManager() throws Exception
+    {
+        // Default to the the root (one schemaManager for all the entries
+        namingContext = Dn.ROOT_DSE;
+        this.schemaLoader = new JarLdifSchemaLoader();
+        errors = new ArrayList<Throwable>();
+        registries = new Registries( this );
+        factory = new SchemaEntityFactory();
+        isRelaxed = STRICT;
+        loadAllEnabled();
+    }
 
 
     /**
@@ -1376,8 +1394,7 @@ public class DefaultSchemaManager implem
         try
         {
             schemaModificationAttributesDn = new Dn( SchemaConstants.SCHEMA_MODIFICATIONS_DN
);
-            schemaModificationAttributesDn
-                .normalize( getRegistries().getAttributeTypeRegistry().getNormalizerMapping()
);
+            schemaModificationAttributesDn.normalize( new DefaultSchemaManager() );
         }
         catch ( LdapInvalidDnException e )
         {



Mime
View raw message