directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r615444 - in /directory/apacheds/branches/bigbang/core-entry/src: main/java/org/apache/directory/server/core/entry/ test/java/org/apache/directory/server/core/entry/
Date Sat, 26 Jan 2008 11:30:37 GMT
Author: elecharny
Date: Sat Jan 26 03:30:24 2008
New Revision: 615444

URL: http://svn.apache.org/viewvc?rev=615444&view=rev
Log:
Fixed some issues in ObjectClassAttribute : the ObjectClasses names were added more than once in the ancestors

Added:
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/TestServerEntryUtils.java
Modified:
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ObjectClassAttribute.java
    directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java
    directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
    directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ObjectClassAttributeTest.java
    directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java
    directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ObjectClassAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ObjectClassAttribute.java?rev=615444&r1=615443&r2=615444&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ObjectClassAttribute.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ObjectClassAttribute.java Sat Jan 26 03:30:24 2008
@@ -298,7 +298,13 @@
     }
 
 
-    private Set<ObjectClass> addAncestors( ObjectClass descendant, Set<ObjectClass> ancestors ) throws NamingException
+    /**
+     * Recursively find all the objectClass ancestors.
+     * 
+     * The resultant Set conatins only one single occurence of each 
+     * ancestor.
+     */
+    private Set<ObjectClass> findAncestors( ObjectClass descendant, Set<ObjectClass> ancestors ) throws NamingException
     {
         if ( descendant == null )
         {
@@ -312,10 +318,15 @@
             return ancestors;
         }
 
-        for ( ObjectClass ancestor : superClasses )
+        for ( ObjectClass superClass : superClasses )
         {
-            ancestors.add( ancestor );
-            addAncestors( ancestor, ancestors );
+            if ( ancestors.contains( superClass ) )
+            {
+                continue;
+            }
+            
+            ancestors.add( superClass );
+            findAncestors( superClass, ancestors );
         }
 
         return ancestors;
@@ -332,38 +343,46 @@
         // add the value to the set of values
         //values.add( new ServerStringValue( attributeType, alias) );
 
-        Set<ObjectClass> ancestors = addAncestors( objectClass, new HashSet<ObjectClass>() );
+        Set<ObjectClass> ancestors = findAncestors( objectClass, new HashSet<ObjectClass>() );
         ancestors.add( objectClass );
         
         // now create sets of the different kinds of objectClasses
-        for ( ObjectClass oc : ancestors )
+        for ( ObjectClass ancestor : ancestors )
         {
-            values.add( new ServerStringValue( attributeType, oc.getName() ) );
-            switch ( oc.getType() )
+            ServerStringValue oc = new ServerStringValue( attributeType, ancestor.getName() );
+            
+            if ( values.contains( oc ) )
+            {
+                continue;
+            }
+            
+            values.add( oc );
+            
+            switch ( ancestor.getType() )
             {
                 case STRUCTURAL :
-                    structuralObjectClasses.add( oc );
+                    structuralObjectClasses.add( ancestor );
                     break;
                     
                 case AUXILIARY :
-                    auxiliaryObjectClasses.add( oc );
+                    auxiliaryObjectClasses.add( ancestor );
                     break;
                     
                 case ABSTRACT :
-                    abstractObjectClasses.add( oc );
+                    abstractObjectClasses.add( ancestor );
                     break;
                     
                 default:
-                    String message = "Unrecognized objectClass type value: " + oc.getType();
+                    String message = "Unrecognized objectClass type value: " + ancestor.getType();
                     LOG.error( message );
                     throw new UnsupportedOperationException( message );
             }
 
-            allObjectClasses.add( oc );
+            allObjectClasses.add( ancestor );
             
             // now go through all objectClassses to collect the must an may list attributes
-            Collections.addAll( mayList, oc.getMayList() );
-            Collections.addAll( mustList, oc.getMustList() );
+            Collections.addAll( mayList, ancestor.getMayList() );
+            Collections.addAll( mustList, ancestor.getMustList() );
         }
 
         return true;

Added: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/TestServerEntryUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/TestServerEntryUtils.java?rev=615444&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/TestServerEntryUtils.java (added)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/TestServerEntryUtils.java Sat Jan 26 03:30:24 2008
@@ -0,0 +1,414 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.entry;
+
+import java.util.Comparator;
+
+import javax.naming.NamingException;
+import javax.naming.directory.InvalidAttributeValueException;
+
+import org.apache.directory.shared.ldap.schema.AbstractAttributeType;
+import org.apache.directory.shared.ldap.schema.AbstractMatchingRule;
+import org.apache.directory.shared.ldap.schema.AbstractSyntax;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.ByteArrayComparator;
+import org.apache.directory.shared.ldap.schema.MatchingRule;
+import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.schema.Syntax;
+import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+/**
+ * Some common declaration used by the serverEntry tests.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class TestServerEntryUtils
+{
+    /**
+     * A local Syntax class for tests
+     */
+    static class AT extends AbstractAttributeType
+    {
+        public static final long serialVersionUID = 0L;
+        AttributeType superior;
+        Syntax syntax;
+        MatchingRule equality;
+        MatchingRule ordering;
+        MatchingRule substr;
+
+        protected AT( String oid )
+        {
+            super( oid );
+        }
+
+        public AttributeType getSuperior() throws NamingException
+        {
+            return superior;
+        }
+
+
+        public Syntax getSyntax() throws NamingException
+        {
+            return syntax;
+        }
+
+
+        public MatchingRule getEquality() throws NamingException
+        {
+            return equality;
+        }
+
+
+        public MatchingRule getOrdering() throws NamingException
+        {
+            return ordering;
+        }
+
+
+        public MatchingRule getSubstr() throws NamingException
+        {
+            return substr;
+        }
+
+
+        public void setSuperior( AttributeType superior )
+        {
+            this.superior = superior;
+        }
+
+
+        public void setSyntax( Syntax syntax )
+        {
+            this.syntax = syntax;
+        }
+
+
+        public void setEquality( MatchingRule equality )
+        {
+            this.equality = equality;
+        }
+
+
+        public void setOrdering( MatchingRule ordering )
+        {
+            this.ordering = ordering;
+        }
+
+
+        public void setSubstr( MatchingRule substr )
+        {
+            this.substr = substr;
+        }
+    }
+
+    /**
+     * A local MatchingRule class for tests
+     */
+    static class MR extends AbstractMatchingRule
+    {
+        public static final long serialVersionUID = 0L;
+        Syntax syntax;
+        Comparator comparator;
+        Normalizer normalizer;
+
+        protected MR( String oid )
+        {
+            super( oid );
+        }
+
+        public Syntax getSyntax() throws NamingException
+        {
+            return syntax;
+        }
+
+        public Comparator getComparator() throws NamingException
+        {
+            return comparator;
+        }
+
+
+        public Normalizer getNormalizer() throws NamingException
+        {
+            return normalizer;
+        }
+
+
+        public void setSyntax( Syntax syntax )
+        {
+            this.syntax = syntax;
+        }
+
+
+        public void setComparator( Comparator<?> comparator )
+        {
+            this.comparator = comparator;
+        }
+
+
+        public void setNormalizer( Normalizer normalizer )
+        {
+            this.normalizer = normalizer;
+        }
+    }
+
+
+    /**
+     * A local Syntax class used for the tests
+     */
+    static class S extends AbstractSyntax
+    {
+        public static final long serialVersionUID = 0L;
+        SyntaxChecker checker;
+
+        public S( String oid, boolean humanReadible )
+        {
+            super( oid, humanReadible );
+        }
+
+        public void setSyntaxChecker( SyntaxChecker checker )
+        {
+            this.checker = checker;
+        }
+
+        public SyntaxChecker getSyntaxChecker() throws NamingException
+        {
+            return checker;
+        }
+    }
+
+    /* no protection*/ static AttributeType getCaseIgnoringAttributeNoNumbersType()
+    {
+        S s = new S( "1.1.1.1", true );
+
+        s.setSyntaxChecker( new SyntaxChecker()
+        {
+            public String getSyntaxOid()
+            {
+                return "1.1.1.1";
+            }
+            public boolean isValidSyntax( Object value )
+            {
+                if ( !( value instanceof String ) )
+                {
+                    return false;
+                }
+
+                String strval = ( String ) value;
+                
+                for ( char c:strval.toCharArray() )
+                {
+                    if ( Character.isDigit( c ) )
+                    {
+                        return false;
+                    }
+                }
+                return true;
+            }
+
+            public void assertSyntax( Object value ) throws NamingException
+            {
+                if ( ! isValidSyntax( value ) )
+                {
+                    throw new InvalidAttributeValueException();
+                }
+            }
+        } );
+
+        final MR mr = new MR( "1.1.2.1" );
+        mr.syntax = s;
+        mr.comparator = new Comparator<String>()
+        {
+            public int compare( String o1, String o2 )
+            {
+                return ( o1 == null ? 
+                    ( o2 == null ? 0 : -1 ) :
+                    ( o2 == null ? 1 : o1.compareTo( o2 ) ) );
+            }
+
+            int getValue( String val )
+            {
+                if ( val.equals( "LOW" ) ) 
+                {
+                    return 0;
+                }
+                else if ( val.equals( "MEDIUM" ) ) 
+                {
+                    return 1;
+                }
+                else if ( val.equals( "HIGH" ) ) 
+                {
+                    return 2;
+                }
+                
+                throw new IllegalArgumentException( "Not a valid value" );
+            }
+        };
+        
+        mr.normalizer = new Normalizer()
+        {
+            public static final long serialVersionUID = 1L;
+
+            public Object normalize( Object value ) throws NamingException
+            {
+                if ( value instanceof String )
+                {
+                    return ( ( String ) value ).toLowerCase();
+                }
+
+                throw new IllegalStateException( "expected string to normalize" );
+            }
+        };
+        
+        AT at = new AT( "1.1.3.1" );
+        at.setEquality( mr );
+        at.setSyntax( s );
+        return at;
+    }
+
+
+    /* no protection*/ static AttributeType getIA5StringAttributeType()
+    {
+        AT at = new AT( "1.1" );
+
+        S s = new S( "1.1.1", true );
+
+        s.setSyntaxChecker( new SyntaxChecker()
+        {
+            public String getSyntaxOid()
+            {
+                return "1.1.1";
+            }
+            public boolean isValidSyntax( Object value )
+            {
+                return ((String)value).length() < 5 ;
+            }
+
+            public void assertSyntax( Object value ) throws NamingException
+            {
+                if ( ! isValidSyntax( value ) )
+                {
+                    throw new InvalidAttributeValueException();
+                }
+            }
+        } );
+
+        final MR mr = new MR( "1.1.2" );
+        mr.syntax = s;
+        mr.comparator = new Comparator<String>()
+        {
+            public int compare( String o1, String o2 )
+            {
+                return ( ( o1 == null ) ? 
+                    ( o2 == null ? 0 : -1 ) :
+                    ( o2 == null ? 1 : o1.compareTo( o2 ) ) );
+            }
+        };
+        
+        mr.normalizer = new Normalizer()
+        {
+            public static final long serialVersionUID = 1L;
+            
+            public Object normalize( Object value ) throws NamingException
+            {
+                if ( value instanceof String )
+                {
+                    return ( ( String ) value ).toLowerCase();
+                }
+
+                throw new IllegalStateException( "expected string to normalize" );
+            }
+        };
+        
+        at.setEquality( mr );
+        at.setSyntax( s );
+        return at;
+    }
+
+
+    /* No protection */ static AttributeType getBytesAttributeType()
+    {
+        AT at = new AT( "1.1" );
+
+        S s = new S( "1.1.1", true );
+
+        s.setSyntaxChecker( new SyntaxChecker()
+        {
+            public String getSyntaxOid()
+            {
+                return "1.1.1";
+            }
+            public boolean isValidSyntax( Object value )
+            {
+                return ((byte[])value).length < 5 ;
+            }
+
+            public void assertSyntax( Object value ) throws NamingException
+            {
+                if ( ! isValidSyntax( value ) )
+                {
+                    throw new InvalidAttributeValueException();
+                }
+            }
+        } );
+
+        final MR mr = new MR( "1.1.2" );
+        mr.syntax = s;
+        mr.comparator = new Comparator<byte[]>()
+        {
+            public int compare( byte[] o1, byte[] o2 )
+            {
+                return ( ( o1 == null ) ? 
+                    ( o2 == null ? 0 : -1 ) :
+                    ( o2 == null ? 1 : ByteArrayComparator.INSTANCE.compare( o1, o2 ) ) );
+            }
+        };
+        
+        mr.normalizer = new Normalizer()
+        {
+            public static final long serialVersionUID = 1L;
+            
+            public Object normalize( Object value ) throws NamingException
+            {
+                if ( value instanceof byte[] )
+                {
+                    byte[] val = (byte[])value;
+                    // each byte will be changed to be > 0, and spaces will be trimmed
+                    byte[] newVal = new byte[ val.length ];
+                    int i = 0;
+                    
+                    for ( byte b:val )
+                    {
+                        newVal[i++] = (byte)(b & 0x007F); 
+                    }
+                    
+                    return StringTools.trim( newVal );
+                }
+
+                throw new IllegalStateException( "expected byte[] to normalize" );
+            }
+        };
+        
+        at.setEquality( mr );
+        at.setSyntax( s );
+        return at;
+    }
+}

Modified: directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java?rev=615444&r1=615443&r2=615444&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java Sat Jan 26 03:30:24 2008
@@ -19,7 +19,6 @@
  */
 package org.apache.directory.server.core.entry;
 
-import java.util.Comparator;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -27,14 +26,7 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.InvalidAttributeValueException;
 
-import org.apache.directory.shared.ldap.schema.AbstractAttributeType;
-import org.apache.directory.shared.ldap.schema.AbstractMatchingRule;
-import org.apache.directory.shared.ldap.schema.AbstractSyntax;
 import org.apache.directory.shared.ldap.schema.AttributeType;
-import org.apache.directory.shared.ldap.schema.MatchingRule;
-import org.apache.directory.shared.ldap.schema.Normalizer;
-import org.apache.directory.shared.ldap.schema.Syntax;
-import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
@@ -50,309 +42,9 @@
  */
 public class DefaultServerAttributeTest
 {
-    /**
-     * A local Syntax class for tests
-     */
-    static class AT extends AbstractAttributeType
-    {
-        public static final long serialVersionUID = 0L;
-        AttributeType superior;
-        Syntax syntax;
-        MatchingRule equality;
-        MatchingRule ordering;
-        MatchingRule substr;
-
-        protected AT( String oid )
-        {
-            super( oid );
-        }
-
-        public AttributeType getSuperior() throws NamingException
-        {
-            return superior;
-        }
-
-
-        public Syntax getSyntax() throws NamingException
-        {
-            return syntax;
-        }
-
-
-        public MatchingRule getEquality() throws NamingException
-        {
-            return equality;
-        }
-
-
-        public MatchingRule getOrdering() throws NamingException
-        {
-            return ordering;
-        }
-
-
-        public MatchingRule getSubstr() throws NamingException
-        {
-            return substr;
-        }
-
-
-        public void setSuperior( AttributeType superior )
-        {
-            this.superior = superior;
-        }
-
-
-        public void setSyntax( Syntax syntax )
-        {
-            this.syntax = syntax;
-        }
-
-
-        public void setEquality( MatchingRule equality )
-        {
-            this.equality = equality;
-        }
-
-
-        public void setOrdering( MatchingRule ordering )
-        {
-            this.ordering = ordering;
-        }
-
-
-        public void setSubstr( MatchingRule substr )
-        {
-            this.substr = substr;
-        }
-    }
-
-    /**
-     * A local MatchingRule class for tests
-     */
-    static class MR extends AbstractMatchingRule
-    {
-        public static final long serialVersionUID = 0L;
-        private Syntax syntax;
-        private Comparator comparator;
-        private Normalizer normalizer;
-
-        protected MR( String oid )
-        {
-            super( oid );
-        }
-
-        public Syntax getSyntax() throws NamingException
-        {
-            return syntax;
-        }
-
-        public Comparator getComparator() throws NamingException
-        {
-            return comparator;
-        }
-
-
-        public Normalizer getNormalizer() throws NamingException
-        {
-            return normalizer;
-        }
-
-
-        public void setSyntax( Syntax syntax )
-        {
-            this.syntax = syntax;
-        }
-
-
-        public void setComparator( Comparator<?> comparator )
-        {
-            this.comparator = comparator;
-        }
-
-
-        public void setNormalizer( Normalizer normalizer )
-        {
-            this.normalizer = normalizer;
-        }
-    }
-
-
-    /**
-     * A local Syntax class used for the tests
-     */
-    static class S extends AbstractSyntax
-    {
-        public static final long serialVersionUID = 0L;
-        SyntaxChecker checker;
-
-        public S( String oid, boolean humanReadible )
-        {
-            super( oid, humanReadible );
-        }
-
-        public void setSyntaxChecker( SyntaxChecker checker )
-        {
-            this.checker = checker;
-        }
-
-        public SyntaxChecker getSyntaxChecker() throws NamingException
-        {
-            return checker;
-        }
-    }
-
-    private AttributeType getCaseIgnoringAttributeNoNumbersType()
-    {
-        S s = new S( "1.1.1.1", true );
-
-        s.setSyntaxChecker( new SyntaxChecker()
-        {
-            public String getSyntaxOid()
-            {
-                return "1.1.1.1";
-            }
-            public boolean isValidSyntax( Object value )
-            {
-                if ( !( value instanceof String ) )
-                {
-                    return false;
-                }
-
-                String strval = ( String ) value;
-                
-                for ( char c:strval.toCharArray() )
-                {
-                    if ( Character.isDigit( c ) )
-                    {
-                        return false;
-                    }
-                }
-                return true;
-            }
-
-            public void assertSyntax( Object value ) throws NamingException
-            {
-                if ( ! isValidSyntax( value ) )
-                {
-                    throw new InvalidAttributeValueException();
-                }
-            }
-        } );
-
-        final MR mr = new MR( "1.1.2.1" );
-        mr.syntax = s;
-        mr.comparator = new Comparator<String>()
-        {
-            public int compare( String o1, String o2 )
-            {
-                return ( o1 == null ? 
-                    ( o2 == null ? 0 : -1 ) :
-                    ( o2 == null ? 1 : o1.compareTo( o2 ) ) );
-            }
-
-            int getValue( String val )
-            {
-                if ( val.equals( "LOW" ) ) 
-                {
-                    return 0;
-                }
-                else if ( val.equals( "MEDIUM" ) ) 
-                {
-                    return 1;
-                }
-                else if ( val.equals( "HIGH" ) ) 
-                {
-                    return 2;
-                }
-                
-                throw new IllegalArgumentException( "Not a valid value" );
-            }
-        };
-        
-        mr.normalizer = new Normalizer()
-        {
-            public static final long serialVersionUID = 1L;
-
-            public Object normalize( Object value ) throws NamingException
-            {
-                if ( value instanceof String )
-                {
-                    return ( ( String ) value ).toLowerCase();
-                }
-
-                throw new IllegalStateException( "expected string to normalize" );
-            }
-        };
-        
-        AT at = new AT( "1.1.3.1" );
-        at.setEquality( mr );
-        at.setSyntax( s );
-        return at;
-    }
-
-
-    private AttributeType getIA5StringAttributeType()
-    {
-        AT at = new AT( "1.1" );
-
-        S s = new S( "1.1.1", true );
-
-        s.setSyntaxChecker( new SyntaxChecker()
-        {
-            public String getSyntaxOid()
-            {
-                return "1.1.1";
-            }
-            public boolean isValidSyntax( Object value )
-            {
-                return ((String)value).length() < 5 ;
-            }
-
-            public void assertSyntax( Object value ) throws NamingException
-            {
-                if ( ! isValidSyntax( value ) )
-                {
-                    throw new InvalidAttributeValueException();
-                }
-            }
-        } );
-
-        final MR mr = new MR( "1.1.2" );
-        mr.syntax = s;
-        mr.comparator = new Comparator<String>()
-        {
-            public int compare( String o1, String o2 )
-            {
-                return ( ( o1 == null ) ? 
-                    ( o2 == null ? 0 : -1 ) :
-                    ( o2 == null ? 1 : o1.compareTo( o2 ) ) );
-            }
-        };
-        
-        mr.normalizer = new Normalizer()
-        {
-            public static final long serialVersionUID = 1L;
-            
-            public Object normalize( Object value ) throws NamingException
-            {
-                if ( value instanceof String )
-                {
-                    return ( ( String ) value ).toLowerCase();
-                }
-
-                throw new IllegalStateException( "expected string to normalize" );
-            }
-        };
-        
-        at.setEquality( mr );
-        at.setSyntax( s );
-        return at;
-    }
-
     @Test public void testAddOneValue() throws NamingException
     {
-        AttributeType at = getIA5StringAttributeType();
+        AttributeType at = TestServerEntryUtils.getIA5StringAttributeType();
         
         DefaultServerAttribute attr = new DefaultServerAttribute( at );
         
@@ -408,7 +100,7 @@
 
     @Test public void testAddTwoValue() throws NamingException
     {
-        AttributeType at = getIA5StringAttributeType();
+        AttributeType at = TestServerEntryUtils.getIA5StringAttributeType();
         
         DefaultServerAttribute attr = new DefaultServerAttribute( at );
         
@@ -442,7 +134,7 @@
 
     @Test public void testAddNullValue() throws NamingException
     {
-        AttributeType at = getIA5StringAttributeType();
+        AttributeType at = TestServerEntryUtils.getIA5StringAttributeType();
         
         DefaultServerAttribute attr = new DefaultServerAttribute( at );
         
@@ -461,7 +153,7 @@
     
     @Test public void testGetAttribute() throws NamingException
     {
-        AttributeType at = getIA5StringAttributeType();
+        AttributeType at = TestServerEntryUtils.getIA5StringAttributeType();
         
         DefaultServerAttribute attr = new DefaultServerAttribute( at );
         

Modified: directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java?rev=615444&r1=615443&r2=615444&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java Sat Jan 26 03:30:24 2008
@@ -69,7 +69,6 @@
     private static BootstrapSchemaLoader loader;
     private static Registries registries;
     private static OidRegistry oidRegistry;
-    //private static AttributeType AT;
     
     /**
      * Initialize the registries once for the whole test suite
@@ -91,280 +90,6 @@
         bootstrapSchemas.add( new CosineSchema() );
         loader.loadWithDependencies( bootstrapSchemas, registries );
         
-        /*
-        AT = new AttributeType()
-        {
-            private static final long serialVersionUID = 1L;
-
-            public boolean isSingleValue()
-            {
-                return false;
-            }
-
-
-            public boolean isCanUserModify()
-            {
-                return true;
-            }
-
-
-            public boolean isCollective()
-            {
-                return false;
-            }
-
-
-            public UsageEnum getUsage()
-            {
-                return null;
-            }
-
-
-            public AttributeType getSuperior() throws NamingException
-            {
-                return null;
-            }
-
-
-            public Syntax getSyntax() throws NamingException
-            {
-                return new Syntax()
-                {
-
-                    private static final long serialVersionUID = 1L;
-
-                    public boolean isHumanReadable()
-                    {
-                        return true;
-                    }
-
-                    public SyntaxChecker getSyntaxChecker() throws NamingException
-                    {
-                        return null;
-                    }
-
-                    public boolean isObsolete()
-                    {
-                        return false;
-                    }
-
-                    public String getOid()
-                    {
-                        return null;
-                    }
-
-                    public String[] getNames()
-                    {
-                        return null;
-                    }
-
-                    public String getName()
-                    {
-                        return null;
-                    }
-
-                    public String getDescription()
-                    {
-                        return null;
-                    }
-
-                    public String getSchema()
-                    {
-                        return null;
-                    }
-
-                    public void setSchema( String schemaName )
-                    {
-                    }
-                };
-            }
-
-
-            public int getLength()
-            {
-                return 0;
-            }
-
-
-            public MatchingRule getEquality() throws NamingException
-            {
-                return new MatchingRule()
-                {
-                    private static final long serialVersionUID = 1L;
-
-                    public Syntax getSyntax() throws NamingException
-                    {
-                        return new Syntax()
-                        {
-                            private static final long serialVersionUID = 1L;
-
-
-                            public boolean isHumanReadable()
-                            {
-                                return true;
-                            }
-
-                            public SyntaxChecker getSyntaxChecker() throws NamingException
-                            {
-                                return null;
-                            }
-
-                            public boolean isObsolete()
-                            {
-                                return false;
-                            }
-
-                            public String getOid()
-                            {
-                                return null;
-                            }
-
-                            public String[] getNames()
-                            {
-                                return null;
-                            }
-
-                            public String getName()
-                            {
-                                return null;
-                            }
-
-                            public String getDescription()
-                            {
-                                return null;
-                            }
-
-                            public String getSchema()
-                            {
-                                return null;
-                            }
-
-                            public void setSchema( String schemaName )
-                            {
-                            }
-                        };
-                    }
-
-                    public Comparator getComparator() throws NamingException
-                    {
-                        return null;
-                    }
-
-                    public Normalizer getNormalizer() throws NamingException
-                    {
-                        return new Normalizer()
-                        {
-                            private static final long serialVersionUID = 1L;
-
-                            public Object normalize( Object value ) throws NamingException
-                            {
-                                return StringTools.deepTrimToLower( value.toString() );
-                            }
-                        };
-                    }
-
-                    public boolean isObsolete()
-                    {
-                        return false;
-                    }
-
-                    public String getOid()
-                    {
-                        return null;
-                    }
-
-                    public String[] getNames()
-                    {
-                        return null;
-                    }
-
-                    public String getName()
-                    {
-                        return null;
-                    }
-
-                    public String getDescription()
-                    {
-                        return null;
-                    }
-
-                    public String getSchema()
-                    {
-                        return null;
-                    }
-
-                    public void setSchema( String schemaName )
-                    {
-                    }
-                };
-            }
-
-
-            public MatchingRule getOrdering() throws NamingException
-            {
-                return null;
-            }
-
-
-            public MatchingRule getSubstr() throws NamingException
-            {
-                return null;
-            }
-
-
-            public boolean isAncestorOf( AttributeType descendant ) throws NamingException
-            {
-                return false;
-            }
-
-
-            public boolean isDescentantOf( AttributeType ancestor ) throws NamingException
-            {
-                return false;
-            }
-
-
-            public boolean isObsolete()
-            {
-                return false;
-            }
-
-
-            public String getOid()
-            {
-                return "1.2.3";
-            }
-
-
-            public String[] getNames()
-            {
-                return new String[]
-                    { "test" };
-            }
-
-
-            public String getName()
-            {
-                return "test";
-            }
-
-
-            public String getDescription()
-            {
-                return "test";
-            }
-
-
-            public String getSchema()
-            {
-                return null;
-            }
-
-
-            public void setSchema( String schemaName )
-            {
-            }
-        };*/
     }
 
 

Modified: directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ObjectClassAttributeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ObjectClassAttributeTest.java?rev=615444&r1=615443&r2=615444&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ObjectClassAttributeTest.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ObjectClassAttributeTest.java Sat Jan 26 03:30:24 2008
@@ -19,8 +19,28 @@
  */
 package org.apache.directory.server.core.entry;
 
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.server.schema.bootstrap.ApacheSchema;
+import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
+import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
+import org.apache.directory.server.schema.bootstrap.CoreSchema;
+import org.apache.directory.server.schema.bootstrap.CosineSchema;
+import org.apache.directory.server.schema.bootstrap.InetorgpersonSchema;
+import org.apache.directory.server.schema.bootstrap.Schema;
+import org.apache.directory.server.schema.bootstrap.SystemSchema;
+import org.apache.directory.server.schema.registries.DefaultOidRegistry;
+import org.apache.directory.server.schema.registries.DefaultRegistries;
+import org.apache.directory.server.schema.registries.OidRegistry;
+import org.apache.directory.server.schema.registries.Registries;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
 
 
 /**
@@ -31,8 +51,48 @@
  */
 public class ObjectClassAttributeTest
 {
+    private static BootstrapSchemaLoader loader;
+    private static Registries registries;
+    private static OidRegistry oidRegistry;
+
+    /**
+     * Initialize the registries once for the whole test suite
+     */
+    @BeforeClass
+    public static void setup() throws NamingException
+    {
+        loader = new BootstrapSchemaLoader();
+        oidRegistry = new DefaultOidRegistry();
+        registries = new DefaultRegistries( "bootstrap", loader, oidRegistry );
+        
+        // load essential bootstrap schemas 
+        Set<Schema> bootstrapSchemas = new HashSet<Schema>();
+        bootstrapSchemas.add( new ApachemetaSchema() );
+        bootstrapSchemas.add( new ApacheSchema() );
+        bootstrapSchemas.add( new CoreSchema() );
+        bootstrapSchemas.add( new SystemSchema() );
+        bootstrapSchemas.add( new InetorgpersonSchema() );
+        bootstrapSchemas.add( new CosineSchema() );
+        loader.loadWithDependencies( bootstrapSchemas, registries );
+        
+    }
+
+    
     @Test public void testEmpty()
     {
         assertTrue( true );
+    }
+    
+    @Test public void TestAncestorsCreation() throws NamingException
+    {
+        ObjectClassAttribute oc = new ObjectClassAttribute( registries );
+        
+        oc.add( "top" );
+        oc.add( "person" );
+        oc.add( "inetorgPerson" );
+        
+        assertNotNull( oc.getAllObjectClasses() );
+        assertEquals( 4, oc.getAllObjectClasses().size() );
+        assertTrue( oc.contains( "top", "person", "inetOrgPerson", "organizationalPerson" ) );
     }
 }

Modified: directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java?rev=615444&r1=615443&r2=615444&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java Sat Jan 26 03:30:24 2008
@@ -20,22 +20,15 @@
 package org.apache.directory.server.core.entry;
 
 
-import org.apache.directory.shared.ldap.schema.AbstractAttributeType;
-import org.apache.directory.shared.ldap.schema.AbstractMatchingRule;
-import org.apache.directory.shared.ldap.schema.AbstractSyntax;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.ByteArrayComparator;
-import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.Normalizer;
-import org.apache.directory.shared.ldap.schema.Syntax;
 import org.apache.directory.shared.ldap.schema.syntax.AcceptAllSyntaxChecker;
-import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Before;
 import org.junit.Test;
 
 import javax.naming.NamingException;
-import javax.naming.directory.InvalidAttributeValueException;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -43,7 +36,6 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.Arrays;
-import java.util.Comparator;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -67,232 +59,9 @@
  */
 public class ServerBinaryValueTest
 {
-    static private S s;
-    static private AT at;
-    static private MR mr;
-    
-    /**
-     * A local Syntax class for tests
-     */
-    static class AT extends AbstractAttributeType
-    {
-        public static final long serialVersionUID = 0L;
-        AttributeType superior;
-        Syntax syntax;
-        MatchingRule equality;
-        MatchingRule ordering;
-        MatchingRule substr;
-
-        protected AT( String oid )
-        {
-            super( oid );
-        }
-
-        public AttributeType getSuperior() throws NamingException
-        {
-            return superior;
-        }
-
-
-        public Syntax getSyntax() throws NamingException
-        {
-            return syntax;
-        }
-
-
-        public MatchingRule getEquality() throws NamingException
-        {
-            return equality;
-        }
-
-
-        public MatchingRule getOrdering() throws NamingException
-        {
-            return ordering;
-        }
-
-
-        public MatchingRule getSubstr() throws NamingException
-        {
-            return substr;
-        }
-
-
-        public void setSuperior( AttributeType superior )
-        {
-            this.superior = superior;
-        }
-
-
-        public void setSyntax( Syntax syntax )
-        {
-            this.syntax = syntax;
-        }
-
-
-        public void setEquality( MatchingRule equality )
-        {
-            this.equality = equality;
-        }
-
-
-        public void setOrdering( MatchingRule ordering )
-        {
-            this.ordering = ordering;
-        }
-
-
-        public void setSubstr( MatchingRule substr )
-        {
-            this.substr = substr;
-        }
-    }
-
-    /**
-     * A local MatchingRule class for tests
-     */
-    static class MR extends AbstractMatchingRule
-    {
-        public static final long serialVersionUID = 0L;
-        private Syntax syntax;
-        private Comparator comparator;
-        private Normalizer normalizer;
-
-        protected MR( String oid )
-        {
-            super( oid );
-        }
-
-        public Syntax getSyntax() throws NamingException
-        {
-            return syntax;
-        }
-
-        public Comparator getComparator() throws NamingException
-        {
-            return comparator;
-        }
-
-
-        public Normalizer getNormalizer() throws NamingException
-        {
-            return normalizer;
-        }
-
-
-        public void setSyntax( Syntax syntax )
-        {
-            this.syntax = syntax;
-        }
-
-
-        public void setComparator( Comparator<?> comparator )
-        {
-            this.comparator = comparator;
-        }
-
-
-        public void setNormalizer( Normalizer normalizer )
-        {
-            this.normalizer = normalizer;
-        }
-    }
-
-
-    /**
-     * A local Syntax class used for the tests
-     */
-    static class S extends AbstractSyntax
-    {
-        public static final long serialVersionUID = 0L;
-        SyntaxChecker checker;
-
-        public S( String oid, boolean humanReadible )
-        {
-            super( oid, humanReadible );
-        }
-
-        public void setSyntaxChecker( SyntaxChecker checker )
-        {
-            this.checker = checker;
-        }
-
-        public SyntaxChecker getSyntaxChecker() throws NamingException
-        {
-            return checker;
-        }
-    }
-
-
-
-    private AttributeType getBytesAttributeType()
-    {
-        AT at = new AT( "1.1" );
-
-        S s = new S( "1.1.1", true );
-
-        s.setSyntaxChecker( new SyntaxChecker()
-        {
-            public String getSyntaxOid()
-            {
-                return "1.1.1";
-            }
-            public boolean isValidSyntax( Object value )
-            {
-                return ((byte[])value).length < 5 ;
-            }
-
-            public void assertSyntax( Object value ) throws NamingException
-            {
-                if ( ! isValidSyntax( value ) )
-                {
-                    throw new InvalidAttributeValueException();
-                }
-            }
-        } );
-
-        final MR mr = new MR( "1.1.2" );
-        mr.syntax = s;
-        mr.comparator = new Comparator<byte[]>()
-        {
-            public int compare( byte[] o1, byte[] o2 )
-            {
-                return ( ( o1 == null ) ? 
-                    ( o2 == null ? 0 : -1 ) :
-                    ( o2 == null ? 1 : ByteArrayComparator.INSTANCE.compare( o1, o2 ) ) );
-            }
-        };
-        
-        mr.normalizer = new Normalizer()
-        {
-            public static final long serialVersionUID = 1L;
-            
-            public Object normalize( Object value ) throws NamingException
-            {
-                if ( value instanceof byte[] )
-                {
-                    byte[] val = (byte[])value;
-                    // each byte will be changed to be > 0, and spaces will be trimmed
-                    byte[] newVal = new byte[ val.length ];
-                    int i = 0;
-                    
-                    for ( byte b:val )
-                    {
-                        newVal[i++] = (byte)(b & 0x007F); 
-                    }
-                    
-                    return StringTools.trim( newVal );
-                }
-
-                throw new IllegalStateException( "expected byte[] to normalize" );
-            }
-        };
-        
-        at.setEquality( mr );
-        at.setSyntax( s );
-        return at;
-    }
-
+    static private TestServerEntryUtils.S s;
+    static private TestServerEntryUtils.AT at;
+    static private TestServerEntryUtils.MR mr;
     
     /**
      * Initialize an AttributeType and the associated MatchingRule 
@@ -300,9 +69,9 @@
      */
     @Before public void initAT()
     {
-        s = new S( "1.1.1.1", false );
+        s = new TestServerEntryUtils.S( "1.1.1.1", false );
         s.setSyntaxChecker( new AcceptAllSyntaxChecker( "1.1.1.1" ) );
-        mr = new MR( "1.1.2.1" );
+        mr = new TestServerEntryUtils.MR( "1.1.2.1" );
         mr.syntax = s;
         mr.comparator = new ByteArrayComparator();
         mr.normalizer = new Normalizer()
@@ -329,7 +98,7 @@
                 throw new IllegalStateException( "expected byte[] to normalize" );
             }
         };
-        at = new AT( "1.1.3.1" );
+        at = new TestServerEntryUtils.AT( "1.1.3.1" );
         at.setEquality( mr );
         at.setOrdering( mr );
         at.setSubstr( mr );
@@ -353,7 +122,7 @@
         }
         
         // create a AT without any syntax
-        AttributeType at = new AT( "1.1.3.1" );
+        AttributeType at = new TestServerEntryUtils.AT( "1.1.3.1" );
         
         try
         {
@@ -372,7 +141,7 @@
      */
     @Test public void testNullValue()
     {
-        AttributeType at = getBytesAttributeType();
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
         
         ServerBinaryValue value = new ServerBinaryValue( at, null );
         
@@ -386,7 +155,7 @@
      */
     @Test public void testEquals()
     {
-        AttributeType at = getBytesAttributeType();
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
         
         ServerBinaryValue value1 = new ServerBinaryValue( at, new byte[]{0x01, (byte)0x02} );
         ServerBinaryValue value2 = new ServerBinaryValue( at, new byte[]{0x01, (byte)0x02} );
@@ -411,7 +180,7 @@
      */
     @Test public void testGetNormalized() throws NamingException
     {
-        AttributeType at = getBytesAttributeType();
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
         
         ServerBinaryValue value = new ServerBinaryValue( at, new byte[]{0x01, (byte)0x82} );
         
@@ -431,7 +200,7 @@
      */
     @Test public void testIsValid() throws NamingException
     {
-        AttributeType at = getBytesAttributeType();
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
         
         ServerBinaryValue value = new ServerBinaryValue( at, new byte[]{0x01, 0x02} );
         
@@ -449,7 +218,7 @@
      */
     @Test public void testHashCodeValidEquals() throws Exception
     {
-        AttributeType at = getBytesAttributeType();
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
         ServerBinaryValue v0 = new ServerBinaryValue( at, new byte[]{0x01, 0x02} );
         ServerBinaryValue v1 = new ServerBinaryValue( at, new byte[]{(byte)0x81, (byte)0x82} );
         ServerBinaryValue v2 = new ServerBinaryValue( at, new byte[]{0x01, 0x02} );

Modified: directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java?rev=615444&r1=615443&r2=615444&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java Sat Jan 26 03:30:24 2008
@@ -70,324 +70,26 @@
  */
 public class ServerStringValueTest
 {
-    static private S s;
-    static private AT at;
-    static private MR mr;
+    static private TestServerEntryUtils.S s;
+    static private TestServerEntryUtils.AT at;
+    static private TestServerEntryUtils.MR mr;
     
-    /**
-     * A local Syntax class for tests
-     */
-    static class AT extends AbstractAttributeType
-    {
-        public static final long serialVersionUID = 0L;
-        AttributeType superior;
-        Syntax syntax;
-        MatchingRule equality;
-        MatchingRule ordering;
-        MatchingRule substr;
-
-        protected AT( String oid )
-        {
-            super( oid );
-        }
-
-        public AttributeType getSuperior() throws NamingException
-        {
-            return superior;
-        }
-
-
-        public Syntax getSyntax() throws NamingException
-        {
-            return syntax;
-        }
-
-
-        public MatchingRule getEquality() throws NamingException
-        {
-            return equality;
-        }
-
-
-        public MatchingRule getOrdering() throws NamingException
-        {
-            return ordering;
-        }
-
-
-        public MatchingRule getSubstr() throws NamingException
-        {
-            return substr;
-        }
-
-
-        public void setSuperior( AttributeType superior )
-        {
-            this.superior = superior;
-        }
-
-
-        public void setSyntax( Syntax syntax )
-        {
-            this.syntax = syntax;
-        }
-
-
-        public void setEquality( MatchingRule equality )
-        {
-            this.equality = equality;
-        }
-
-
-        public void setOrdering( MatchingRule ordering )
-        {
-            this.ordering = ordering;
-        }
-
-
-        public void setSubstr( MatchingRule substr )
-        {
-            this.substr = substr;
-        }
-    }
-
-    /**
-     * A local MatchingRule class for tests
-     */
-    static class MR extends AbstractMatchingRule
-    {
-        public static final long serialVersionUID = 0L;
-        private Syntax syntax;
-        private Comparator comparator;
-        private Normalizer normalizer;
-
-        protected MR( String oid )
-        {
-            super( oid );
-        }
-
-        public Syntax getSyntax() throws NamingException
-        {
-            return syntax;
-        }
-
-        public Comparator getComparator() throws NamingException
-        {
-            return comparator;
-        }
-
-
-        public Normalizer getNormalizer() throws NamingException
-        {
-            return normalizer;
-        }
-
-
-        public void setSyntax( Syntax syntax )
-        {
-            this.syntax = syntax;
-        }
-
-
-        public void setComparator( Comparator<?> comparator )
-        {
-            this.comparator = comparator;
-        }
-
-
-        public void setNormalizer( Normalizer normalizer )
-        {
-            this.normalizer = normalizer;
-        }
-    }
-
-
-    /**
-     * A local Syntax class used for the tests
-     */
-    static class S extends AbstractSyntax
-    {
-        public static final long serialVersionUID = 0L;
-        SyntaxChecker checker;
-
-        public S( String oid, boolean humanReadible )
-        {
-            super( oid, humanReadible );
-        }
-
-        public void setSyntaxChecker( SyntaxChecker checker )
-        {
-            this.checker = checker;
-        }
-
-        public SyntaxChecker getSyntaxChecker() throws NamingException
-        {
-            return checker;
-        }
-    }
-
-    private AttributeType getCaseIgnoringAttributeNoNumbersType()
-    {
-        S s = new S( "1.1.1.1", true );
-
-        s.setSyntaxChecker( new SyntaxChecker()
-        {
-            public String getSyntaxOid()
-            {
-                return "1.1.1.1";
-            }
-            public boolean isValidSyntax( Object value )
-            {
-                if ( !( value instanceof String ) )
-                {
-                    return false;
-                }
-
-                String strval = ( String ) value;
-                
-                for ( char c:strval.toCharArray() )
-                {
-                    if ( Character.isDigit( c ) )
-                    {
-                        return false;
-                    }
-                }
-                return true;
-            }
-
-            public void assertSyntax( Object value ) throws NamingException
-            {
-                if ( ! isValidSyntax( value ) )
-                {
-                    throw new InvalidAttributeValueException();
-                }
-            }
-        } );
-
-        final MR mr = new MR( "1.1.2.1" );
-        mr.syntax = s;
-        mr.comparator = new Comparator<String>()
-        {
-            public int compare( String o1, String o2 )
-            {
-                return ( o1 == null ? 
-                    ( o2 == null ? 0 : -1 ) :
-                    ( o2 == null ? 1 : o1.compareTo( o2 ) ) );
-            }
-
-            int getValue( String val )
-            {
-                if ( val.equals( "LOW" ) ) 
-                {
-                    return 0;
-                }
-                else if ( val.equals( "MEDIUM" ) ) 
-                {
-                    return 1;
-                }
-                else if ( val.equals( "HIGH" ) ) 
-                {
-                    return 2;
-                }
-                
-                throw new IllegalArgumentException( "Not a valid value" );
-            }
-        };
-        
-        mr.normalizer = new Normalizer()
-        {
-            public static final long serialVersionUID = 1L;
-
-            public Object normalize( Object value ) throws NamingException
-            {
-                if ( value instanceof String )
-                {
-                    return ( ( String ) value ).toLowerCase();
-                }
-
-                throw new IllegalStateException( "expected string to normalize" );
-            }
-        };
-        
-        AT at = new AT( "1.1.3.1" );
-        at.setEquality( mr );
-        at.setSyntax( s );
-        return at;
-    }
-
-
-    private AttributeType getIA5StringAttributeType()
-    {
-        AT at = new AT( "1.1" );
-
-        S s = new S( "1.1.1", true );
-
-        s.setSyntaxChecker( new SyntaxChecker()
-        {
-            public String getSyntaxOid()
-            {
-                return "1.1.1";
-            }
-            public boolean isValidSyntax( Object value )
-            {
-                return ((String)value).length() < 5 ;
-            }
-
-            public void assertSyntax( Object value ) throws NamingException
-            {
-                if ( ! isValidSyntax( value ) )
-                {
-                    throw new InvalidAttributeValueException();
-                }
-            }
-        } );
 
-        final MR mr = new MR( "1.1.2" );
-        mr.syntax = s;
-        mr.comparator = new Comparator<String>()
-        {
-            public int compare( String o1, String o2 )
-            {
-                return ( ( o1 == null ) ? 
-                    ( o2 == null ? 0 : -1 ) :
-                    ( o2 == null ? 1 : o1.compareTo( o2 ) ) );
-            }
-        };
-        
-        mr.normalizer = new Normalizer()
-        {
-            public static final long serialVersionUID = 1L;
-            
-            public Object normalize( Object value ) throws NamingException
-            {
-                if ( value instanceof String )
-                {
-                    return ( ( String ) value ).toLowerCase();
-                }
 
-                throw new IllegalStateException( "expected string to normalize" );
-            }
-        };
-        
-        at.setEquality( mr );
-        at.setSyntax( s );
-        return at;
-    }
 
-    
     /**
      * Initialize an AttributeType and the associated MatchingRule 
      * and Syntax
      */
     @Before public void initAT()
     {
-        s = new S( "1.1.1.1", false );
+        s = new TestServerEntryUtils.S( "1.1.1.1", false );
         s.setSyntaxChecker( new AcceptAllSyntaxChecker( "1.1.1.1" ) );
-        mr = new MR( "1.1.2.1" );
+        mr = new TestServerEntryUtils.MR( "1.1.2.1" );
         mr.syntax = s;
         mr.comparator = new ByteArrayComparator();
         mr.normalizer = new DeepTrimToLowerNormalizer();
-        at = new AT( "1.1.3.1" );
+        at = new TestServerEntryUtils.AT( "1.1.3.1" );
         at.setEquality( mr );
         at.setOrdering( mr );
         at.setSubstr( mr );
@@ -411,7 +113,7 @@
         }
         
         // create a AT without any syntax
-        AttributeType at = new AT( "1.1.3.1" );
+        AttributeType at = new TestServerEntryUtils.AT( "1.1.3.1" );
         
         try
         {
@@ -430,7 +132,7 @@
      */
     @Test public void testNullValue()
     {
-        AttributeType at = getIA5StringAttributeType();
+        AttributeType at = TestServerEntryUtils.getIA5StringAttributeType();
         
         ServerStringValue value = new ServerStringValue( at, null );
         
@@ -444,7 +146,7 @@
      */
     @Test public void testEquals()
     {
-        AttributeType at = getIA5StringAttributeType();
+        AttributeType at = TestServerEntryUtils.getIA5StringAttributeType();
         
         ServerStringValue value1 = new ServerStringValue( at, "test" );
         ServerStringValue value2 = new ServerStringValue( at, "test" );
@@ -469,7 +171,7 @@
      */
     @Test public void testGetNormalized() throws NamingException
     {
-        AttributeType at = getIA5StringAttributeType();
+        AttributeType at = TestServerEntryUtils.getIA5StringAttributeType();
         
         ServerStringValue value = new ServerStringValue( at, "TEST" );
         
@@ -488,7 +190,7 @@
      */
     @Test public void testIsValid() throws NamingException
     {
-        AttributeType at = getIA5StringAttributeType();
+        AttributeType at = TestServerEntryUtils.getIA5StringAttributeType();
         
         ServerStringValue value = new ServerStringValue( at, "test" );
         
@@ -506,7 +208,7 @@
      */
     @Test public void testHashCodeValidEquals() throws Exception
     {
-        AttributeType at = getCaseIgnoringAttributeNoNumbersType();
+        AttributeType at = TestServerEntryUtils.getCaseIgnoringAttributeNoNumbersType();
         ServerStringValue v0 = new ServerStringValue( at, "Alex" );
         ServerStringValue v1 = new ServerStringValue( at, "ALEX" );
         ServerStringValue v2 = new ServerStringValue( at, "alex" );
@@ -540,8 +242,6 @@
      */
     @Test public void testConstrainedString() throws Exception
     {
-        S s = new S( "1.1.1.1", true );
-            
         s.setSyntaxChecker( new SyntaxChecker() {
             public String getSyntaxOid() { return "1.1.1.1"; }
             public boolean isValidSyntax( Object value )
@@ -557,7 +257,6 @@
             { if ( ! isValidSyntax( value ) ) throw new InvalidAttributeValueException(); }
         });
 
-        final MR mr = new MR( "1.1.2.1" );
         mr.syntax = s;
         mr.comparator = new Comparator<String>()
         {
@@ -598,7 +297,6 @@
             }
         };
         mr.normalizer = new NoOpNormalizer();
-        AT at = new AT( "1.1.3.1" );
         at.setEquality( mr );
         at.setSyntax( s );
 



Mime
View raw message