directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r883838 - in /directory/shared/branches/shared-schema: ldap-schema-loader/src/test/java/org/apache/directory/server/schema/ ldap/src/main/java/org/apache/directory/shared/ldap/schema/
Date Tue, 24 Nov 2009 20:00:25 GMT
Author: elecharny
Date: Tue Nov 24 20:00:24 2009
New Revision: 883838

URL: http://svn.apache.org/viewvc?rev=883838&view=rev
Log:
o Added some equals() methods to all the SchemaObjects
o Created a preliminary SchemaManager test

Modified:
    directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerTest.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITStructureRule.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapComparator.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NameForm.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SyntaxChecker.java

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerTest.java?rev=883838&r1=883837&r2=883838&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerTest.java
(original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerTest.java
Tue Nov 24 20:00:24 2009
@@ -19,20 +19,199 @@
  */
 package org.apache.directory.server.schema;
 
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.schema.loader.ldif.LdifSchemaLoaderTest;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.schema.LdapComparator;
+import org.apache.directory.shared.ldap.schema.LdapSyntax;
+import org.apache.directory.shared.ldap.schema.MatchingRule;
+import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.SyntaxChecker;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.apache.directory.shared.schema.DefaultSchemaManager;
 import org.apache.directory.shared.schema.loader.ldif.JarLdifSchemaLoader;
+import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
+import org.apache.directory.shared.schema.loader.ldif.SchemaEntityFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 
+/**
+ * A test class for SchemaManager.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class SchemaManagerTest
 {
+    // A directory in which the ldif files will be stored
+    private static String workingDirectory;
+    
+    // A LDIF loader
+    private static LdifSchemaLoader ldifLoader;
+    
+    // A SchemaObject factory
+    private static SchemaEntityFactory factory;
+    
+    @BeforeClass
+    public static void setup() throws Exception
+    {
+        workingDirectory = System.getProperty( "workingDirectory" );
+
+        if ( workingDirectory == null )
+        {
+            String path = LdifSchemaLoaderTest.class.getResource( "" ).getPath();
+            int targetPos = path.indexOf( "target" );
+            workingDirectory = path.substring( 0, targetPos + 6 );
+        }
+        
+        // Cleanup the target directory
+        FileUtils.deleteDirectory( new File( workingDirectory + "/schema" ) );
+
+        SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory
) );
+        extractor.extractOrCopy();
+        
+        ldifLoader = new LdifSchemaLoader( new File( workingDirectory, "schema" ) );
+        factory = new SchemaEntityFactory();
+    }
+    
+    
+    @AfterClass
+    public static void cleanup() throws IOException
+    {
+        // Cleanup the target directory
+        FileUtils.deleteDirectory( new File( workingDirectory + "/schema" ) );
+    }
+    
+    
+    private void checkComparators( List<Entry> comparators, SchemaManager schemaManager,
Registries expectedRegistries ) throws Exception
+    {
+        for ( Entry entry : comparators )
+        {
+            LdapComparator<?> expectedComparator = factory.getLdapComparator( schemaManager,
entry, schemaManager.getRegistries(), "system" );
+            LdapComparator<?> comparator = schemaManager.getComparatorRegistry().lookup(
expectedComparator.getOid() );
+            
+            if ( !expectedComparator.equals( comparator ) )
+            {
+                fail();
+            }
+            
+            expectedRegistries.register( expectedComparator );
+        }
+    }
+    
+    
+    private void checkNormalizers( List<Entry> normalizers, SchemaManager schemaManager,
Registries expectedRegistries ) throws Exception
+    {
+        for ( Entry entry : normalizers )
+        {
+            Normalizer expectedNormalizer = factory.getNormalizer( schemaManager, entry,
schemaManager.getRegistries(), "system" );
+            Normalizer normalizer = schemaManager.getNormalizerRegistry().lookup( expectedNormalizer.getOid()
);
+            
+            if ( !expectedNormalizer.equals( normalizer ) )
+            {
+                fail();
+            }
+
+            expectedRegistries.register( expectedNormalizer );
+        }
+    }
+    
+    
+    private void checkSyntaxCheckers( List<Entry> syntaxCheckers, SchemaManager schemaManager,
Registries expectedRegistries ) throws Exception
+    {
+        for ( Entry entry : syntaxCheckers )
+        {
+            SyntaxChecker expectedSyntaxChecker = factory.getSyntaxChecker( schemaManager,
entry, schemaManager.getRegistries(), "system" );
+            SyntaxChecker syntaxChecker = schemaManager.getSyntaxCheckerRegistry().lookup(
expectedSyntaxChecker.getOid() );
+            
+            if ( !expectedSyntaxChecker.equals( syntaxChecker ) )
+            {
+                fail();
+            }
+            
+            expectedRegistries.register( expectedSyntaxChecker );
+        }
+    }
+    
+    
+    private void checkSyntaxes( List<Entry> syntaxes, SchemaManager schemaManager,
Registries expectedRegistries ) throws Exception
+    {
+        for ( Entry entry : syntaxes )
+        {
+            LdapSyntax expectedLdapSyntax = factory.getSyntax( schemaManager, entry, schemaManager.getRegistries(),
"system" );
+            LdapSyntax syntax = schemaManager.getLdapSyntaxRegistry().lookup( expectedLdapSyntax.getOid()
);
+            
+            expectedLdapSyntax.applyRegistries( expectedRegistries );
+            
+            if ( !expectedLdapSyntax.equals( syntax ) )
+            {
+                fail();
+            }
+            
+            expectedRegistries.register( expectedLdapSyntax );
+        }
+    }
+    
+    
+    private void checkMatchingRules( List<Entry> matchingRules, SchemaManager schemaManager,
Registries expectedRegistries ) throws Exception
+    {
+        for ( Entry entry : matchingRules )
+        {
+            MatchingRule expectedMatchingRule = factory.getMatchingRule( schemaManager, entry,
schemaManager.getRegistries(), "system" );
+            MatchingRule matchingRule = schemaManager.getMatchingRuleRegistry().lookup( expectedMatchingRule.getOid()
);
+            
+            expectedMatchingRule.applyRegistries( expectedRegistries );
+            
+            if ( !expectedMatchingRule.equals( matchingRule ) )
+            {
+                fail();
+            }
+            
+            expectedRegistries.register( expectedMatchingRule );
+        }
+    }
+    
+    
+    /**
+     * We will load the System schema, and test that the schemaManager is consistent
+     */
     @Test
-    public void testSchemaManager() throws Exception
+    public void testLoadSystem() throws Exception
     {
         JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
-        SchemaManager sm = new DefaultSchemaManager( loader );
+        SchemaManager schemaManager = new DefaultSchemaManager( loader );
+
+        Registries expectedRegistries = new Registries( null );
+
+        String schemaName = "system";
+        
+        schemaManager.loadWithDeps( schemaName );
+        
+        // Test Comparators
+        checkComparators( ldifLoader.loadComparators( schemaName ), schemaManager, expectedRegistries
);
+        
+        // Test Normalizers
+        checkNormalizers( ldifLoader.loadNormalizers( schemaName ), schemaManager, expectedRegistries
);
+        
+        // Test SyntaxCheckers
+        checkSyntaxCheckers( ldifLoader.loadSyntaxCheckers( schemaName ), schemaManager,
expectedRegistries );
+        
+        // Test LdapSyntax
+        checkSyntaxes( ldifLoader.loadSyntaxes( schemaName ), schemaManager, expectedRegistries
);
 
-        sm.loadWithDeps( /*"system", */"apachemeta" );
+        // Test MatchingRules
+        checkMatchingRules( ldifLoader.loadMatchingRules( schemaName ), schemaManager, expectedRegistries
);
+        
+        // Test ATs
     }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java?rev=883838&r1=883837&r2=883838&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
Tue Nov 24 20:00:24 2009
@@ -974,4 +974,156 @@
         superior = null;
         syntax = null;
     }
+    
+    
+    /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object o )
+    {
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+
+        if ( !( o instanceof AttributeType ) )
+        {
+            return false;
+        }
+        
+        AttributeType that = (AttributeType)o;
+        
+        // The COLLECTIVE
+        if ( isCollective != that.isCollective )
+        {
+            return false;
+        }
+        
+        // The SINGLE_VALUE
+        if ( isSingleValued != that.isSingleValued )
+        {
+            return false;
+        }
+        
+        // The NO_USER_MODIFICATION
+        if ( canUserModify != that.canUserModify )
+        {
+            return false;
+        }
+        
+        // The USAGE
+        if ( usage != that.usage )
+        {
+            return false;
+        }
+        
+        // The equality
+        if ( !compareOid( equalityOid, that.equalityOid ) )
+        {
+            return false;
+        }
+        
+        if ( equality != null )
+        {
+            if ( !equality.equals( that.equality ) )
+            {
+                return false;
+            }
+        }
+        else
+        {
+            if ( that.equality != null )
+            {
+                return false;
+            }
+        }
+        
+        // The ordering
+        if ( !compareOid( orderingOid, that.orderingOid ) )
+        {
+            return false;
+        }
+
+        if ( ordering != null )
+        {
+            if ( !ordering.equals( that.ordering ) )
+            {
+                return false;
+            }
+        }
+        else
+        {
+            if ( that.ordering != null )
+            {
+                return false;
+            }
+        }
+        
+        // The substring
+        if ( !compareOid( substringOid, that.substringOid ) )
+        {
+            return false;
+        }
+        
+        if ( substring != null )
+        {
+            if ( !substring.equals( that.substring ) )
+            {
+                return false;
+            }
+        }
+        else
+        {
+            if ( that.substring != null )
+            {
+                return false;
+            }
+        }
+
+        // The superior
+        if ( !compareOid( superiorOid, that.superiorOid ) )
+        {
+            return false;
+        }
+        
+        if ( superior != null )
+        {
+            if ( !superior.equals( that.superior ) )
+            {
+                return false;
+            }
+        }
+        else
+        {
+            if ( that.superior != null )
+            {
+                return false;
+            }
+        }
+        
+        // The syntax
+        if ( !compareOid( syntaxOid, that.syntaxOid ) )
+        {
+            return false;
+        }
+        
+        if ( syntaxLength != that.syntaxLength )
+        {
+            return false;
+        }
+        
+        if ( syntax == null )
+        {
+            return that.syntax == null;
+        }
+
+        if ( syntax.equals(  that.syntax ) )
+        {
+            return syntaxLength == that.syntaxLength;
+        }
+        else
+        {
+            return false;
+        }
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java?rev=883838&r1=883837&r2=883838&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java
Tue Nov 24 20:00:24 2009
@@ -624,6 +624,27 @@
     
     
     /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object o )
+    {
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+
+        if ( !( o instanceof DITContentRule ) )
+        {
+            return false;
+        }
+        
+        DITContentRule that = (DITContentRule)o;
+
+        // TODO : complete the check
+        return true;
+    }
+        
+    /**
      * {@inheritDoc}
      */
     public void clear()

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITStructureRule.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITStructureRule.java?rev=883838&r1=883837&r2=883838&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITStructureRule.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITStructureRule.java
Tue Nov 24 20:00:24 2009
@@ -230,6 +230,28 @@
     
     
     /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object o )
+    {
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+
+        if ( !( o instanceof DITStructureRule ) )
+        {
+            return false;
+        }
+        
+        DITStructureRule that = (DITStructureRule)o;
+        
+        // TODO : complete the test
+        return true;
+    }
+    
+    
+    /**
      * {@inheritDoc}
      */
     public void clear()

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapComparator.java?rev=883838&r1=883837&r2=883838&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapComparator.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapComparator.java
Tue Nov 24 20:00:24 2009
@@ -54,6 +54,20 @@
     {
         // Do nothing (general case).
     }
+    
+    
+    /**
+     * @see Object#equals()
+     */
+    public boolean equals( Object o )
+    {
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+
+        return o instanceof LdapComparator<?>;
+    }
 
     
     /**

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java?rev=883838&r1=883837&r2=883838&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java
Tue Nov 24 20:00:24 2009
@@ -232,6 +232,34 @@
     
     
     /**
+     * @see Object#equals()
+     */
+    public boolean equals( Object o )
+    {
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+
+        if ( !( o instanceof LdapSyntax ) )
+        {
+            return false;
+        }
+        
+        LdapSyntax that = (LdapSyntax)o;
+        
+        // IsHR
+        if ( isHumanReadable != that.isHumanReadable )
+        {
+            return false;
+        }
+        
+        // Check the SyntaxChecker (not a equals)
+        return syntaxChecker.getOid().equals( that.syntaxChecker.getOid() );
+    }
+
+    
+    /**
      * {@inheritDoc}
      */
     public void clear()

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java?rev=883838&r1=883837&r2=883838&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java
Tue Nov 24 20:00:24 2009
@@ -117,4 +117,37 @@
     {
         return null;
     }
+    
+    
+    /**
+     * @see Object#equals()
+     */
+    public boolean equals( Object o )
+    {
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+
+        if ( !( o instanceof LoadableSchemaObject ) )
+        {
+            return false;
+        }
+        
+        LoadableSchemaObject that = (LoadableSchemaObject)o;
+        
+        // Check the byteCode
+        // TODO
+        
+        // Check the FQCN
+        if ( fqcn == null )
+        {
+            return that.fqcn == null;
+        }
+        else
+        {
+            return fqcn.equals( that.fqcn );
+        }
+       
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java?rev=883838&r1=883837&r2=883838&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
Tue Nov 24 20:00:24 2009
@@ -328,6 +328,66 @@
     
     
     /**
+     * @see Object#equals()
+     */
+    public boolean equals( Object o )
+    {
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+
+        if ( !( o instanceof MatchingRule ) )
+        {
+            return false;
+        }
+        
+        MatchingRule that = (MatchingRule)o;
+        
+        // Check the Comparator
+        if ( ldapComparator != null )
+        {
+            if ( !ldapComparator.equals( that.ldapComparator ) )
+            {
+                return false;
+            }
+        }
+        else
+        {
+            if ( that.ldapComparator != null )
+            {
+                return false;
+            }
+        }
+            
+        
+        // Check the Normalizer
+        if ( normalizer != null )
+        {
+            if ( !normalizer.equals( that.normalizer ) )
+            {
+                return false;
+            }
+        }
+        else
+        {
+            if ( that.normalizer != null )
+            {
+                return false;
+            }
+        }
+        
+        // Check the Syntax
+        if ( !compareOid( ldapSyntaxOid, that.ldapSyntaxOid ) )
+        {
+            return false;
+        }
+        
+        return ldapSyntax.equals( that.ldapSyntax );
+    }
+    
+    
+    /**
      * {@inheritDoc}
      */
     public void clear()

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java?rev=883838&r1=883837&r2=883838&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java
Tue Nov 24 20:00:24 2009
@@ -258,6 +258,28 @@
     
     
     /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object o )
+    {
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+
+        if ( !( o instanceof MatchingRuleUse ) )
+        {
+            return false;
+        }
+        
+        MatchingRuleUse that = (MatchingRuleUse)o;
+        
+        // TODO : complete the checks
+        return true;
+    }
+    
+    
+    /**
      * {@inheritDoc}
      */
     public void clear()

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NameForm.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NameForm.java?rev=883838&r1=883837&r2=883838&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NameForm.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NameForm.java
Tue Nov 24 20:00:24 2009
@@ -470,6 +470,28 @@
     
     
     /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object o )
+    {
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+
+        if ( !( o instanceof NameForm ) )
+        {
+            return false;
+        }
+        
+        NameForm that = (NameForm)o;
+        
+        // TODO : complete the checks
+        return true;
+    }
+    
+    
+    /**
      * {@inheritDoc}
      */
     public void clear()

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java?rev=883838&r1=883837&r2=883838&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java
Tue Nov 24 20:00:24 2009
@@ -100,6 +100,20 @@
         // Do nothing (general case).
     }
     
+    
+    /**
+     * @see Object#equals()
+     */
+    public boolean equals( Object o )
+    {
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+
+        return o instanceof Normalizer;
+    }
+    
 
     /**
      * @see Object#toString()

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java?rev=883838&r1=883837&r2=883838&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
Tue Nov 24 20:00:24 2009
@@ -613,6 +613,177 @@
     
     
     /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object o )
+    {
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+
+        if ( !( o instanceof ObjectClass ) )
+        {
+            return false;
+        }
+        
+        ObjectClass that = (ObjectClass)o;
+        
+        // The ObjectClassType
+        if ( objectClassType != that.objectClassType )
+        {
+            return false;
+        }
+        
+        // The Superiors OIDs
+        if ( superiorOids.size() != that.superiorOids.size() )
+        {
+            return false;
+        }
+        
+        // One way
+        for ( String oid : superiorOids )
+        {
+            if ( !that.superiorOids.contains( oid ) )
+            {
+                return false;
+            }
+        }
+
+        // The other way
+        for ( String oid : that.superiorOids )
+        {
+            if ( !superiorOids.contains( oid ) )
+            {
+                return false;
+            }
+        }
+
+        // The Superiors
+        if ( superiors.size() != that.superiors.size() )
+        {
+            return false;
+        }
+        
+        // One way
+        for ( ObjectClass oid : superiors )
+        {
+            if ( !that.superiors.contains( oid ) )
+            {
+                return false;
+            }
+        }
+
+        // The other way
+        for ( ObjectClass oid : that.superiors )
+        {
+            if ( !superiors.contains( oid ) )
+            {
+                return false;
+            }
+        }
+        
+        // The MAY OIDs
+        if ( mayAttributeTypeOids.size() != that.mayAttributeTypeOids.size() )
+        {
+            return false;
+        }
+        
+        // One way
+        for ( String oid : mayAttributeTypeOids )
+        {
+            if ( !that.mayAttributeTypeOids.contains( oid ) )
+            {
+                return false;
+            }
+        }
+
+        // The other way
+        for ( String oid : that.mayAttributeTypeOids )
+        {
+            if ( !mayAttributeTypeOids.contains( oid ) )
+            {
+                return false;
+            }
+        }
+
+        // The MAY
+        if ( mayAttributeTypes.size() != that.mayAttributeTypes.size() )
+        {
+            return false;
+        }
+        
+        // One way
+        for ( AttributeType oid : mayAttributeTypes )
+        {
+            if ( !that.mayAttributeTypes.contains( oid ) )
+            {
+                return false;
+            }
+        }
+
+        // The other way
+        for ( AttributeType oid : that.mayAttributeTypes )
+        {
+            if ( !mayAttributeTypes.contains( oid ) )
+            {
+                return false;
+            }
+        }
+
+        // The MUST OIDs
+        if ( mustAttributeTypeOids.size() != that.mustAttributeTypeOids.size() )
+        {
+            return false;
+        }
+        
+        // One way
+        for ( String oid : mustAttributeTypeOids )
+        {
+            if ( !that.mustAttributeTypeOids.contains( oid ) )
+            {
+                return false;
+            }
+        }
+
+        // The other way
+        for ( String oid : that.mustAttributeTypeOids )
+        {
+            if ( !mustAttributeTypeOids.contains( oid ) )
+            {
+                return false;
+            }
+        }
+
+        // The MUST
+        if ( mustAttributeTypes.size() != that.mustAttributeTypes.size() )
+        {
+            return false;
+        }
+        
+        // One way
+        for ( AttributeType oid : mustAttributeTypes )
+        {
+            if ( !that.mustAttributeTypes.contains( oid ) )
+            {
+                return false;
+            }
+        }
+
+        // The other way
+        for ( AttributeType oid : that.mustAttributeTypes )
+        {
+            if ( !mustAttributeTypes.contains( oid ) )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+    
+    
+    /**
      * {@inheritDoc}
      */
     public void clear()

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java?rev=883838&r1=883837&r2=883838&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
Tue Nov 24 20:00:24 2009
@@ -588,8 +588,9 @@
         
         // Two schemaObject are equals if their oid is equal,
         // their ObjectType is equal, their names are equals
-        // their schema name is the same, and their extensions are equals
-        if ( !oid.equals( that.oid ) )
+        // their schema name is the same, all their flags are equals,
+        // the description is the same and their extensions are equals
+        if ( !compareOid( oid, that.oid ) )
         {
             return false;
         }
@@ -636,11 +637,7 @@
         }
         else
         {
-            if ( that.schemaName == null )
-            {
-                return false;
-            }
-            else if ( !schemaName.equalsIgnoreCase( this.schemaName ) )
+            if ( !schemaName.equalsIgnoreCase( that.schemaName ) )
             {
                 return false;
             }
@@ -690,8 +687,6 @@
                         return false;
                     }
                 }
-                
-                return true;
             }
         }
         else if ( that.extensions != null )
@@ -699,7 +694,29 @@
             return false;
         }
         
-        return false;
+        if ( this.isEnabled != that.isEnabled )
+        {
+            return false;
+        }
+        
+        if ( this.isObsolete != that.isObsolete )
+        {
+            return false;
+        }
+        
+        if ( this.isReadOnly != that.isReadOnly )
+        {
+            return false;
+        }
+        
+        if ( this.description == null )
+        {
+            return that.description == null;
+        }
+        else
+        {
+            return this.description.equalsIgnoreCase( that.description );
+        }
     }
     
     
@@ -710,6 +727,22 @@
      */
     public abstract SchemaObject copy();
     
+    
+    /**
+     * Compare two oids, and return true if they are both null or
+     * equals
+     */
+    protected boolean compareOid( String oid1, String oid2 )
+    {
+        if ( oid1 == null )
+        {
+            return oid2 == null;
+        }
+        else
+        {
+            return oid1.equals( oid2 );
+        }
+    }
 
     /**
      * Copy a SchemaObject.

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SyntaxChecker.java?rev=883838&r1=883837&r2=883838&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SyntaxChecker.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SyntaxChecker.java
Tue Nov 24 20:00:24 2009
@@ -85,6 +85,20 @@
 
 
     /**
+     * @see Object#equals()
+     */
+    public boolean equals( Object o )
+    {
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+
+        return o instanceof SyntaxChecker;
+    }
+
+    
+    /**
      * @see Object#toString()
      */
     public String toString()



Mime
View raw message