directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r896579 [8/14] - in /directory/shared/trunk: ./ ldap/ ldap/src/main/antlr/ ldap/src/main/java/org/apache/directory/shared/ldap/ ldap/src/main/java/org/apache/directory/shared/ldap/codec/ ldap/src/main/java/org/apache/directory/shared/ldap/c...
Date Wed, 06 Jan 2010 17:52:31 GMT
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/SyntaxCheckerDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/SyntaxCheckerDescriptionSchemaParser.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/SyntaxCheckerDescriptionSchemaParser.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/SyntaxCheckerDescriptionSchemaParser.java Wed Jan  6 17:52:15 2010
@@ -22,6 +22,8 @@
 
 import java.text.ParseException;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import antlr.RecognitionException;
 import antlr.TokenStreamException;
@@ -35,12 +37,15 @@
  */
 public class SyntaxCheckerDescriptionSchemaParser extends AbstractSchemaParser
 {
+    /** The LoggerFactory used by this class */
+    protected static final Logger LOG = LoggerFactory.getLogger( SyntaxCheckerDescriptionSchemaParser.class );
 
     /**
      * Creates a schema parser instance.
      */
     public SyntaxCheckerDescriptionSchemaParser()
     {
+        super();
     }
 
 
@@ -71,6 +76,7 @@
     public synchronized SyntaxCheckerDescription parseSyntaxCheckerDescription( String syntaxCheckerDescription )
         throws ParseException
     {
+        LOG.debug( "Parsing a SyntaxChecker : {}", syntaxCheckerDescription );
 
         if ( syntaxCheckerDescription == null )
         {
@@ -81,29 +87,40 @@
 
         try
         {
-            SyntaxCheckerDescription scd = parser.syntaxCheckerDescription();
-            return scd;
+        	SyntaxCheckerDescription syntaxChecker = parser.syntaxCheckerDescription();
+
+            // Update the schemaName
+            setSchemaName( syntaxChecker );
+
+            return syntaxChecker;
         }
         catch ( RecognitionException re )
         {
-            String msg = "Parser failure on syntax checker description:\n\t" + syntaxCheckerDescription;
-            msg += "\nAntlr message: " + re.getMessage();
-            msg += "\nAntlr column: " + re.getColumn();
+            String msg = "Parser failure on syntax checker description:\n\t" + syntaxCheckerDescription +
+                "\nAntlr message: " + re.getMessage() +
+                "\nAntlr column: " + re.getColumn();
+            LOG.error( msg );
             throw new ParseException( msg, re.getColumn() );
         }
         catch ( TokenStreamException tse )
         {
-            String msg = "Parser failure on syntax checker description:\n\t" + syntaxCheckerDescription;
-            msg += "\nAntlr message: " + tse.getMessage();
+            String msg = "Parser failure on syntax checker description:\n\t" + syntaxCheckerDescription +
+                "\nAntlr message: " + tse.getMessage();
+            LOG.error( msg );
             throw new ParseException( msg, 0 );
         }
 
     }
 
 
-    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    /**
+     * Parses a SyntaxChecker description
+     * 
+     * @param The SyntaxChecker description to parse
+     * @return An instance of SyntaxCheckerDescription
+     */
+    public SyntaxCheckerDescription parse( String schemaDescription ) throws ParseException
     {
         return parseSyntaxCheckerDescription( schemaDescription );
     }
-
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/BaseSubtreeSpecification.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/BaseSubtreeSpecification.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/BaseSubtreeSpecification.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/BaseSubtreeSpecification.java Wed Jan  6 17:52:15 2010
@@ -242,7 +242,7 @@
             buffer.append( "base" );
             buffer.append( ' ' );
             buffer.append( '"' );
-            buffer.append( base.getUpName() );
+            buffer.append( base.getName() );
             buffer.append( '"' );
             buffer.append( ',' );
         }
@@ -278,7 +278,7 @@
                 buffer.append( ':' );
                 buffer.append( ' ' );
                 buffer.append( '"' );
-                buffer.append( dn.getUpName() );
+                buffer.append( dn.getName() );
                 buffer.append( '"' );
 
                 if(it.hasNext())
@@ -302,7 +302,7 @@
                 buffer.append( ':' );
                 buffer.append( ' ' );
                 buffer.append( '"' );
-                buffer.append( dn.getUpName() );
+                buffer.append( dn.getName() );
                 buffer.append( '"' );
 
                 if(it.hasNext())

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/StoredProcedureParameter.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/StoredProcedureParameter.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/StoredProcedureParameter.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/StoredProcedureParameter.java Wed Jan  6 17:52:15 2010
@@ -54,7 +54,7 @@
         
         public String toString()
         {
-            return name + " \"" + ctxName.getUpName() + "\"";
+            return name + " \"" + ctxName.getName() + "\"";
         }
     }
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java Wed Jan  6 17:52:15 2010
@@ -21,9 +21,9 @@
 
 
 import java.text.ParseException;
-
 import java.util.Arrays;
 import java.util.Iterator;
+import java.util.List;
 
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
@@ -32,6 +32,7 @@
 import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.BasicAttributes;
 import javax.naming.directory.InvalidAttributeIdentifierException;
+import javax.naming.directory.InvalidAttributeValueException;
 
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
@@ -39,6 +40,7 @@
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
+import org.apache.directory.shared.ldap.ldif.LdifAttributesReader;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
@@ -67,7 +69,7 @@
 
         if ( attr == null )
         {
-            String[] aliases = type.getNamesRef();
+            List<String> aliases = type.getNames();
 
             for ( String alias : aliases )
             {
@@ -210,9 +212,9 @@
         }
 
         // optimization bypass to avoid cost of the loop below
-        if ( type.getNamesRef().length == 1 )
+        if ( type.getNames().size() == 1 )
         {
-            attr = attrs.get( type.getNamesRef()[0] );
+            attr = attrs.get( type.getNames().get( 0 ) );
 
             if ( attr != null )
             {
@@ -221,7 +223,7 @@
         }
 
         // iterate through aliases
-        for ( String alias : type.getNamesRef() )
+        for ( String alias : type.getNames() )
         {
             attr = attrs.get( alias );
 
@@ -258,11 +260,11 @@
 
         if ( matchingRule != null )
         {
-            normalizer = type.getEquality().getNormalizer();
+            normalizer = matchingRule.getNormalizer();
         }
         else
         {
-            normalizer = new NoOpNormalizer();
+            normalizer = new NoOpNormalizer( type.getOid() );
         }
 
         if ( type.getSyntax().isHumanReadable() )
@@ -1320,4 +1322,81 @@
             return null;
         }
     }
+    
+    
+    /**
+     * Build a new Attributes instance from a LDIF list of lines. The values can be 
+     * either a complete AVA, or a couple of AttributeType ID and a value (a String or 
+     * a byte[]). The following sample shows the three cases :
+     * 
+     * <pre>
+     * Attribute attr = AttributeUtils.createAttributes(
+     *     "objectclass: top",
+     *     "cn", "My name",
+     *     "jpegPhoto", new byte[]{0x01, 0x02} );
+     * </pre>
+     * 
+     * @param avas The AttributeType and Values, using a ldif format, or a couple of 
+     * Attribute ID/Value
+     * @return An Attributes instance
+     * @throws NamingException If the data are invalid
+     */
+    public static Attributes createAttributes( Object... avas ) throws NamingException
+    {
+        StringBuilder sb = new StringBuilder();
+        int pos = 0;
+        boolean valueExpected = false;
+        
+        for ( Object ava : avas)
+        {
+            if ( !valueExpected )
+            {
+                if ( !(ava instanceof String) )
+                {
+                    throw new InvalidAttributeValueException( "The Attribute ID #" + (pos+1) + " must be a String" );
+                }
+                
+                String attribute = (String)ava;
+                sb.append( attribute );
+                
+                if ( attribute.indexOf( ':' ) != -1 )
+                {
+                    sb.append( '\n' );
+                }
+                else
+                {
+                    valueExpected = true;
+                }
+            }
+            else
+            {
+                if ( ava instanceof String )
+                {
+                    sb.append( ": " ).append( (String)ava ).append( '\n' );
+                }
+                else if ( ava instanceof byte[] )
+                {
+                    sb.append( ":: " );
+                    sb.append( new String( Base64.encode( (byte[] )ava ) ) );
+                    sb.append( '\n' );
+                }
+                else
+                {
+                    throw new InvalidAttributeValueException( "The Attribute value #" + (pos+1) + " must be a String or a byte[]" );
+                }
+                
+                valueExpected = false;
+            }
+        }
+        
+        if ( valueExpected )
+        {
+            throw new InvalidAttributeValueException( "A value is missing at the end" );
+        }
+        
+        LdifAttributesReader reader = new LdifAttributesReader();
+        Attributes attributes = reader.parseAttributes( sb.toString() );
+
+        return attributes;
+    }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ExceptionUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ExceptionUtils.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ExceptionUtils.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ExceptionUtils.java Wed Jan  6 17:52:15 2010
@@ -964,4 +964,17 @@
         }
         return list;
     }
+    
+    
+    public static String printErrors( List<Throwable> errors )
+    {
+        StringBuilder sb = new StringBuilder();
+        
+        for ( Throwable error:errors )
+        {
+            sb.append( "Error : " ).append( error.getMessage() ).append( "\n" );
+        }
+        
+        return sb.toString();
+    }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ImmutableAttributeWrapper.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ImmutableAttributeWrapper.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ImmutableAttributeWrapper.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ImmutableAttributeWrapper.java Wed Jan  6 17:52:15 2010
@@ -19,10 +19,10 @@
 package org.apache.directory.shared.ldap.util;
 
 
-import javax.naming.directory.Attribute;
-import javax.naming.directory.DirContext;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.DirContext;
 
 
 /**
@@ -102,7 +102,6 @@
     }
 
 
-    @SuppressWarnings ( { "CloneDoesntCallSuperClone" } )
     public Object clone()
     {
         throw new IllegalStateException( "Now why would you ever want to clone an immutable object?" );

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ImmutableAttributesWrapper.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ImmutableAttributesWrapper.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ImmutableAttributesWrapper.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ImmutableAttributesWrapper.java Wed Jan  6 17:52:15 2010
@@ -90,7 +90,6 @@
     }
 
 
-    @SuppressWarnings ( { "CloneDoesntCallSuperClone" } )
     public Object clone()
     {
         throw new IllegalStateException( "Now why would you want to clone() an immutable object in the first place." );

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java Wed Jan  6 17:52:15 2010
@@ -1351,7 +1351,7 @@
 
         if ( dn != null )
         {
-            sb.append( '/' ).append( urlEncode( dn.getUpName(), false ) );
+            sb.append( '/' ).append( urlEncode( dn.getName(), false ) );
 
             if ( attributes.size() != 0 || forceScopeRendering
                 || ( ( scope != SearchControls.OBJECT_SCOPE ) || ( filter != null ) || ( extensionList.size() != 0 ) ) )

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java Wed Jan  6 17:52:15 2010
@@ -22,15 +22,15 @@
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileFilter;
 import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.io.FileFilter;
 import java.lang.reflect.Method;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
@@ -39,6 +39,8 @@
 import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 
+import com.sun.org.apache.regexp.internal.RESyntaxException;
+
 
 /**
  * Various string manipulation methods that are more efficient then chaining
@@ -410,6 +412,12 @@
         {};
 
     /**
+     * The empty String[]
+     */
+    public static final String[] EMPTY_STRINGS = new String[]
+        {};
+
+    /**
      * Trims several consecutive characters into one.
      * 
      * @param str
@@ -636,7 +644,7 @@
         
         for ( int i = 0; i < chars.length; i++ )
         {
-            chars[i] = LOWER_CASE[ chars[i] ];
+            chars[i] = TO_LOWER_CASE[ chars[i] ];
         }
         
         return new String( chars );
@@ -3191,9 +3199,43 @@
         StringBuilder sb = new StringBuilder();
         boolean isFirst = true;
 
-        Iterator<?> iter = list.iterator();
+        for ( Object elem : list )
+        {
+            if ( isFirst )
+            {
+                isFirst = false;
+            }
+            else
+            {
+                sb.append( ", " );
+            }
 
-        while ( iter.hasNext() )
+            sb.append( elem );
+        }
+
+        return sb.toString();
+    }
+
+
+
+
+    /**
+     * Utility method that return a String representation of a set
+     * 
+     * @param set The set to transform to a string
+     * @return A csv string
+     */
+    public static final String setToString( Set<?> set )
+    {
+        if ( ( set == null ) || ( set.size() == 0 ) )
+        {
+            return "";
+        }
+
+        StringBuilder sb = new StringBuilder();
+        boolean isFirst = true;
+
+        for ( Object elem : set )
         {
             if ( isFirst )
             {
@@ -3204,7 +3246,7 @@
                 sb.append( ", " );
             }
 
-            sb.append( iter.next() );
+            sb.append( elem );
         }
 
         return sb.toString();
@@ -3227,12 +3269,10 @@
 
         StringBuffer sb = new StringBuffer();
 
-        Iterator<?> iter = list.iterator();
-
-        while ( iter.hasNext() )
+        for ( Object elem : list )
         {
             sb.append( tabs );
-            sb.append( iter.next() );
+            sb.append( elem );
             sb.append( '\n' );
         }
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java Wed Jan  6 17:52:15 2010
@@ -35,6 +35,7 @@
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
 import org.apache.directory.shared.ldap.codec.search.SearchRequestCodec;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.schema.normalizers.DeepTrimToLowerNormalizer;
@@ -62,14 +63,28 @@
     @BeforeClass
     public static void setUp() throws Exception
     {
-        oids.put( "dc", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "domaincomponent", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "ou", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "objectclass", new OidNormalizer( "objectclass", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "2.5.4.0", new OidNormalizer( "objectclass", new DeepTrimToLowerNormalizer() ) );
+        // DC normalizer
+        OidNormalizer dcOidNormalizer = new OidNormalizer( "dc",
+            new DeepTrimToLowerNormalizer( SchemaConstants.DOMAIN_COMPONENT_AT_OID ) );
+        
+        oids.put( "dc", dcOidNormalizer );
+        oids.put( "domaincomponent", dcOidNormalizer );
+        oids.put( "0.9.2342.19200300.100.1.25", dcOidNormalizer );
+
+        // OU normalizer
+        OidNormalizer ouOidNormalizer = new OidNormalizer( "ou",
+            new DeepTrimToLowerNormalizer( SchemaConstants.OU_AT_OID ) );
+        
+        oids.put( "ou", ouOidNormalizer );
+        oids.put( "organizationalUnitName",ouOidNormalizer );
+        oids.put( "2.5.4.11", ouOidNormalizer );
+        
+        // ObjectClass normalizer
+        OidNormalizer objectClassOidNormalizer = new OidNormalizer( "objectClass",
+            new DeepTrimToLowerNormalizer( SchemaConstants.OBJECT_CLASS_AT_OID ) );
+        
+        oids.put( "objectclass", objectClassOidNormalizer );
+        oids.put( "2.5.4.0", objectClassOidNormalizer );
     }
 
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java Wed Jan  6 17:52:15 2010
@@ -36,6 +36,7 @@
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.search.SearchRequestCodec;
 import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.schema.normalizers.DeepTrimToLowerNormalizer;
@@ -61,14 +62,29 @@
     @BeforeClass
     public static void setUp() throws Exception
     {
-        oids.put( "dc", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "domaincomponent", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "ou", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "objectclass", new OidNormalizer( "objectclass", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "2.5.4.0", new OidNormalizer( "objectclass", new DeepTrimToLowerNormalizer() ) );
+        // DC normalizer
+        OidNormalizer dcOidNormalizer = new OidNormalizer( "dc",
+            new DeepTrimToLowerNormalizer( SchemaConstants.DOMAIN_COMPONENT_AT_OID ) );
+        
+        oids.put( "dc", dcOidNormalizer );
+        oids.put( "domaincomponent", dcOidNormalizer );
+        oids.put( "0.9.2342.19200300.100.1.25", dcOidNormalizer );
+        
+        
+        // OU normalizer
+        OidNormalizer ouOidNormalizer = new OidNormalizer( "ou",
+            new DeepTrimToLowerNormalizer( SchemaConstants.OU_AT_OID ) );
+        
+        oids.put( "ou", ouOidNormalizer );
+        oids.put( "organizationalUnitName", ouOidNormalizer );
+        oids.put( "2.5.4.11", ouOidNormalizer );
+
+        // ObjectClass normalizer
+        OidNormalizer objectClassOidNormalizer = new OidNormalizer( "objectClass",
+            new DeepTrimToLowerNormalizer( SchemaConstants.OBJECT_CLASS_AT_OID ) );
+        
+        oids.put( "objectclass", objectClassOidNormalizer );
+        oids.put( "2.5.4.0", objectClassOidNormalizer );
     }
 
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java Wed Jan  6 17:52:15 2010
@@ -46,6 +46,7 @@
 import org.apache.directory.shared.ldap.codec.search.PresentFilter;
 import org.apache.directory.shared.ldap.codec.search.SearchRequestCodec;
 import org.apache.directory.shared.ldap.codec.search.controls.subEntry.SubEntryControlCodec;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.message.InternalMessage;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
@@ -74,14 +75,29 @@
     @Before
     public void setUp() throws Exception
     {
-        oids.put( "dc", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "domaincomponent", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "ou", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "objectclass", new OidNormalizer( "objectclass", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "2.5.4.0", new OidNormalizer( "objectclass", new DeepTrimToLowerNormalizer() ) );
+        // DC normalizer
+        OidNormalizer dcOidNormalizer = new OidNormalizer( "dc",
+            new DeepTrimToLowerNormalizer( SchemaConstants.DOMAIN_COMPONENT_AT_OID ) );
+        
+        oids.put( "dc", dcOidNormalizer );
+        oids.put( "domaincomponent", dcOidNormalizer );
+        oids.put( "0.9.2342.19200300.100.1.25", dcOidNormalizer );
+        
+        
+        // OU normalizer
+        OidNormalizer ouOidNormalizer = new OidNormalizer( "ou",
+            new DeepTrimToLowerNormalizer( SchemaConstants.OU_AT_OID ) );
+        
+        oids.put( "ou", ouOidNormalizer );
+        oids.put( "organizationalUnitName", ouOidNormalizer );
+        oids.put( "2.5.4.11", ouOidNormalizer );
+
+        // ObjectClass normalizer
+        OidNormalizer objectClassOidNormalizer = new OidNormalizer( "objectClass",
+            new DeepTrimToLowerNormalizer( SchemaConstants.OBJECT_CLASS_AT_OID ) );
+        
+        oids.put( "objectclass", objectClassOidNormalizer );
+        oids.put( "2.5.4.0", objectClassOidNormalizer );
     }
 
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValueTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValueTest.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValueTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValueTest.java Wed Jan  6 17:52:15 2010
@@ -33,7 +33,6 @@
 import java.util.Arrays;
 
 import javax.naming.NamingException;
-import javax.naming.directory.InvalidAttributeValueException;
 
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.schema.Normalizer;
@@ -55,7 +54,7 @@
     private static final byte[] INVALID_BYTES = new byte[]{0x01, 0x02, 0x03, 0x04, 0x05};
     private static final byte[] BYTES_MOD = new byte[]{0x11, 0x02, 0x03, 0x04};
     
-    private static final Normalizer BINARY_NORMALIZER = new Normalizer()
+    private static final Normalizer BINARY_NORMALIZER = new Normalizer( "1.1.1" )
     {
         private static final long serialVersionUID = 1L;
         
@@ -89,7 +88,7 @@
     /**
      * A binary normalizer which set the normalized value to a empty byte array
      */
-    private static final Normalizer BINARY_NORMALIZER_EMPTY = new Normalizer()
+    private static final Normalizer BINARY_NORMALIZER_EMPTY = new Normalizer( "1.1.1" )
     {
         private static final long serialVersionUID = 1L;
         
@@ -110,12 +109,8 @@
     };
 
     
-    private static final SyntaxChecker BINARY_CHECKER = new SyntaxChecker()
+    private static final SyntaxChecker BINARY_CHECKER = new SyntaxChecker( "1.1.1" )
     {
-        public String getSyntaxOid()
-        {
-            return "1.1.1";
-        }
         public boolean isValidSyntax( Object value )
         {
             if ( value == null )
@@ -125,14 +120,6 @@
             
             return ((byte[])value).length < 5 ;
         }
-
-        public void assertSyntax( Object value ) throws NamingException
-        {
-            if ( ! isValidSyntax( value ) )
-            {
-                throw new InvalidAttributeValueException();
-            }
-        }
     };
     
     

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientStringValueTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientStringValueTest.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientStringValueTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientStringValueTest.java Wed Jan  6 17:52:15 2010
@@ -34,7 +34,7 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.schema.normalizers.DeepTrimToLowerNormalizer;
-import org.apache.directory.shared.ldap.schema.syntaxes.Ia5StringSyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntaxCheckers.Ia5StringSyntaxChecker;
 import org.junit.Test;
 
 /**
@@ -306,7 +306,7 @@
         csv.set(  "  This is    a   TEST  " );
         assertFalse( csv.isNormalized() );
         
-        csv.normalize( new DeepTrimToLowerNormalizer() );
+        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
         
         assertEquals( "this is a test", csv.getNormalizedValue() );
         assertTrue( csv.isNormalized() );
@@ -332,7 +332,7 @@
         csv.set(  "  This is    a   TEST  " );
         assertFalse( csv.isNormalized() );
         
-        csv.normalize( new DeepTrimToLowerNormalizer() );
+        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
         
         assertEquals( "this is a test", csv.getNormalizedValue() );
         assertTrue( csv.isNormalized() );
@@ -341,7 +341,7 @@
         assertEquals( "this is a test", csv.getNormalizedValue() );
         assertFalse( csv.isNormalized() );
 
-        csv.normalize( new DeepTrimToLowerNormalizer() );
+        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
         csv.clear();
         assertFalse( csv.isNormalized() );
     }
@@ -360,7 +360,7 @@
         csv.set(  "  This is    a   TEST  " );
         assertEquals( "  This is    a   TEST  ", csv.getNormalizedValue() );
         
-        csv.normalize( new DeepTrimToLowerNormalizer() );
+        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
         
         assertEquals( "this is a test", csv.getNormalizedValue() );
 
@@ -383,7 +383,7 @@
         csv.set(  "  This is    a   TEST  " );
         assertEquals( "  This is    a   TEST  ", csv.getNormalizedValueCopy() );
         
-        csv.normalize( new DeepTrimToLowerNormalizer() );
+        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
         
         assertEquals( "this is a test", csv.getNormalizedValueCopy() );
 
@@ -401,17 +401,17 @@
     {
         ClientStringValue csv = new ClientStringValue();
 
-        csv.normalize( new DeepTrimToLowerNormalizer() );
+        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
         assertEquals( null, csv.getNormalizedValue() );
         
         csv.set( "" );
-        csv.normalize( new DeepTrimToLowerNormalizer() );
+        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
         assertEquals( "", csv.getNormalizedValue() );
 
         csv.set(  "  This is    a   TEST  " );
         assertEquals( "  This is    a   TEST  ", csv.getNormalizedValue() );
         
-        csv.normalize( new DeepTrimToLowerNormalizer() );
+        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
         
         assertEquals( "this is a test", csv.getNormalizedValue() );
     }
@@ -453,7 +453,7 @@
         // Now check that the equals method works on normalized values.
         csv1.set(  "  This is    a TEST   " );
         csv2.set( "this is a test" );
-        csv1.normalize( new DeepTrimToLowerNormalizer() );
+        csv1.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
         assertEquals( 0, csv1.compareTo( csv2 ) );
         
         csv1.set( "a" );
@@ -489,7 +489,7 @@
         
         assertEquals( csv, csv1 );
         
-        csv.normalize( new DeepTrimToLowerNormalizer() );
+        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
         
         assertNotSame( csv, csv1 );
     }
@@ -515,7 +515,7 @@
         // Now check that the equals method works on normalized values.
         csv1.set(  "  This is    a TEST   " );
         csv2.set( "this is a test" );
-        csv1.normalize( new DeepTrimToLowerNormalizer() );
+        csv1.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
         assertEquals( csv1, csv2 );
     }
 
@@ -549,7 +549,7 @@
     {
         ClientStringValue csv = new ClientStringValue( "TEST");
         csv.setNormalized( true );
-        csv.normalize( new DeepTrimToLowerNormalizer() );
+        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
         csv.isValid( new Ia5StringSyntaxChecker() );
 
         ClientStringValue csvSer = deserializeValue( serializeValue( csv ) );
@@ -589,7 +589,7 @@
         ClientStringValue csv = new ClientStringValue( "  " );
         csv.setNormalized( true );
         csv.isValid( new Ia5StringSyntaxChecker() );
-        csv.normalize( new DeepTrimToLowerNormalizer() );
+        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
 
         ClientStringValue csvSer = deserializeValue( serializeValue( csv ) );
          assertNotSame( csv, csvSer );
@@ -609,7 +609,7 @@
         ClientStringValue csv = new ClientStringValue( null );
         csv.setNormalized( true );
         csv.isValid( new Ia5StringSyntaxChecker() );
-        csv.normalize( new DeepTrimToLowerNormalizer() );
+        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
 
         ClientStringValue csvSer = deserializeValue( serializeValue( csv ) );
          assertNotSame( csv, csvSer );
@@ -629,7 +629,7 @@
         ClientStringValue csv = new ClientStringValue( "" );
         csv.setNormalized( true );
         csv.isValid( new Ia5StringSyntaxChecker() );
-        csv.normalize( new DeepTrimToLowerNormalizer() );
+        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
 
         ClientStringValue csvSer = deserializeValue( serializeValue( csv ) );
          assertNotSame( csv, csvSer );

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttributeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttributeTest.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttributeTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttributeTest.java Wed Jan  6 17:52:15 2010
@@ -40,7 +40,7 @@
 
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Value;
-import org.apache.directory.shared.ldap.schema.syntaxes.Ia5StringSyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntaxCheckers.Ia5StringSyntaxChecker;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.BeforeClass;
 import org.junit.Test;

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java Wed Jan  6 17:52:15 2010
@@ -42,6 +42,7 @@
 import javax.naming.InvalidNameException;
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Value;
@@ -177,13 +178,21 @@
 
         oids = new HashMap<String, OidNormalizer>();
 
-        oids.put( "dc", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "domaincomponent", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
-
-        oids.put( "ou", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
-        oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
+        // DC normalizer
+        OidNormalizer dcOidNormalizer = new OidNormalizer( "dc",
+            new DeepTrimToLowerNormalizer( SchemaConstants.DOMAIN_COMPONENT_AT_OID ) );
+        
+        oids.put( "dc", dcOidNormalizer );
+        oids.put( "domaincomponent", dcOidNormalizer );
+        oids.put( "0.9.2342.19200300.100.1.25", dcOidNormalizer );
+
+        // OU normalizer
+        OidNormalizer ouOidNormalizer = new OidNormalizer( "ou",
+            new DeepTrimToLowerNormalizer( SchemaConstants.OU_AT_OID ) );
+        
+        oids.put( "ou", ouOidNormalizer );
+        oids.put( "organizationalUnitName", ouOidNormalizer );
+        oids.put( "2.5.4.11", ouOidNormalizer );
     }
 
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterCloneTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterCloneTest.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterCloneTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterCloneTest.java Wed Jan  6 17:52:15 2010
@@ -27,8 +27,6 @@
 
 import java.text.ParseException;
 
-import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
-import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Test;
 
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java Wed Jan  6 17:52:15 2010
@@ -20,23 +20,17 @@
 package org.apache.directory.shared.ldap.filter;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.io.UnsupportedEncodingException;
 import java.text.ParseException;
 
-import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
-import org.apache.directory.shared.ldap.filter.BranchNode;
-import org.apache.directory.shared.ldap.filter.ExtensibleNode;
-import org.apache.directory.shared.ldap.filter.PresenceNode;
-import org.apache.directory.shared.ldap.filter.SimpleNode;
-import org.apache.directory.shared.ldap.filter.SubstringNode;
-import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertNull;
 
 
 /**
@@ -723,7 +717,6 @@
     }
 
 
-    @SuppressWarnings("unchecked")
     @Test
     public void testTwoByteUTF8Raw() throws ParseException
     {
@@ -732,7 +725,7 @@
 
         try
         {
-            String s = new String( bytes, "UTF-8" );
+            new String( bytes, "UTF-8" );
             String str = "(cn=\\C2\\A2)";
             SimpleNode<?> node = ( SimpleNode<?> ) FilterParser.parse( str );
 
@@ -749,7 +742,6 @@
     }
 
 
-    @SuppressWarnings("unchecked")
     @Test
     public void testTwoByteUTF8Escaped() throws ParseException
     {
@@ -759,7 +751,7 @@
         try
         {
             String str = "(cn=\\C2\\A2)";
-            String s = new String( bytes, "UTF-8" );
+            new String( bytes, "UTF-8" );
 
             SimpleNode<?> node = ( SimpleNode<?> ) FilterParser.parse( str );
 
@@ -776,7 +768,6 @@
     }
 
 
-    @SuppressWarnings("unchecked")
     @Test
     public void testThreeByteUTF8Raw() throws ParseException
     {
@@ -785,7 +776,7 @@
 
         try
         {
-            String s = new String( bytes, "UTF-8" );
+            new String( bytes, "UTF-8" );
             String str = "(cn=\\E2\\89\\A0)";
             SimpleNode<?> node = ( SimpleNode<?> ) FilterParser.parse( str );
 
@@ -802,7 +793,6 @@
     }
 
 
-    @SuppressWarnings("unchecked")
     @Test
     public void testThreeByteUTF8Escaped() throws ParseException
     {
@@ -812,7 +802,7 @@
         try
         {
             String str = "(cn=\\E2\\89\\A0aa)";
-            String s = new String( bytes, "UTF-8" );
+            new String( bytes, "UTF-8" );
 
             SimpleNode<?> node = ( SimpleNode<?> ) FilterParser.parse( str );
 
@@ -829,7 +819,6 @@
     }
 
 
-    @SuppressWarnings("unchecked")
     @Test
     public void testThreeByteJapaneseUTF8Raw() throws ParseException
     {
@@ -838,7 +827,7 @@
 
         try
         {
-            String s = new String( bytes, "UTF-8" );
+            new String( bytes, "UTF-8" );
             String str = "(cn=\\E3\\81\\99)";
             SimpleNode<?> node = ( SimpleNode<?> ) FilterParser.parse( str );
 
@@ -855,7 +844,6 @@
     }
 
 
-    @SuppressWarnings("unchecked")
     @Test
     public void testThreeByteJapaneseUTF8Escaped() throws ParseException
     {
@@ -865,7 +853,7 @@
         try
         {
             String str = "(cn=\\E3\\81\\99)";
-            String s = new String( bytes, "UTF-8" );
+            new String( bytes, "UTF-8" );
 
             SimpleNode<?> node = ( SimpleNode<?> ) FilterParser.parse( str );
             assertEquals( "cn", node.getAttribute() );
@@ -1055,19 +1043,10 @@
     */
 
 
-
-
-    @SuppressWarnings("unchecked")
     @Test
     public void testBinaryValueEscaped() throws ParseException
     {
-        byte[] bytes =
-            {   0x29, 0x4C, 0x04, (byte)0xB5, 
-                (byte)0xD4, (byte)0xED, 0x38, 0x46, 
-                (byte)0x87, (byte)0xEE, 0x77, 0x58, 
-                0x5C, 0x32, (byte)0xAD, (byte)0x91 }; 
-
         String str = "(objectguid=\\29\\4C\\04\\B5\\D4\\ED\\38\\46\\87\\EE\\77\\58\\5C\\32\\AD\\91)";
-        SimpleNode<String> node = ( SimpleNode<String> ) FilterParser.parse( str );
+        FilterParser.parse( str );
     }
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java Wed Jan  6 17:52:15 2010
@@ -20,6 +20,13 @@
 package org.apache.directory.shared.ldap.ldif;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.io.DataOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -28,7 +35,6 @@
 import java.util.List;
 
 import javax.naming.ldap.Control;
-import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
@@ -37,12 +43,6 @@
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
 
 /**
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -91,7 +91,7 @@
     }
 
     @Test
-    public void testLdifNull() throws NamingException
+    public void testLdifNull() throws Exception
     {
         String ldif = null;
 
@@ -101,30 +101,34 @@
         assertEquals( 0, entries.size() );
     }
 
+    
     @Test
-    public void testLdifEmpty() throws NamingException
+    public void testLdifEmpty() throws Exception
     {
         String ldif = "";
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         assertEquals( 0, entries.size() );
     }
 
+    
     @Test
-    public void testLdifEmptyLines() throws NamingException
+    public void testLdifEmptyLines() throws Exception
     {
         String ldif = "\n\n\r\r\n";
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         assertEquals( 0, entries.size() );
     }
 
     @Test
-    public void testLdifComments() throws NamingException
+    public void testLdifComments() throws Exception
     {
         String ldif = 
             "#Comment 1\r" + 
@@ -135,12 +139,14 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         assertEquals( 0, entries.size() );
     }
+    
 
     @Test
-    public void testLdifVersion() throws NamingException
+    public void testLdifVersion() throws Exception
     {
         String ldif = 
             "#Comment 1\r" + 
@@ -154,13 +160,15 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         assertEquals( 0, entries.size() );
         assertEquals( 1, reader.getVersion() );
     }
 
+    
     @Test
-    public void testLdifVersionStart() throws NamingException
+    public void testLdifVersionStart() throws Exception
     {
         String ldif = 
             "version:\n" + 
@@ -177,6 +185,7 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         assertEquals( 1, reader.getVersion() );
         assertNotNull( entries );
@@ -185,18 +194,19 @@
 
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getUpName() );
+        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getName() );
 
         EntryAttribute attr = entry.get( "displayname" );
         assertTrue( attr.contains( "app1" ) );
     }
+    
 
     /**
      * Test the ldif parser with a file without a version. It should default to 1
-     * @throws NamingException
+     * @throws Exception
      */
     @Test
-    public void testLdifWithoutVersion() throws NamingException
+    public void testLdifWithoutVersion() throws Exception
     {
         String ldif = 
             "#Comment 1\r" + 
@@ -208,18 +218,20 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         assertEquals( 0, entries.size() );
         assertEquals( 1, reader.getVersion() );
     }
+    
 
     /**
      * Spaces at the end of values should not be included into values.
      * 
-     * @throws NamingException
+     * @throws Exception
      */
     @Test
-    public void testLdifParserEndSpaces() throws NamingException
+    public void testLdifParserEndSpaces() throws Exception
     {
         String ldif = 
             "version:   1\n" + 
@@ -234,21 +246,24 @@
         LdifReader reader = new LdifReader();
 
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
+
         assertNotNull( entries );
 
         LdifEntry entry = (LdifEntry) entries.get( 0 );
 
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getUpName() );
+        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getName() );
 
         EntryAttribute attr = entry.get( "displayname" );
         assertTrue( attr.contains( "app1" ) );
 
     }
 
+    
     @Test
-    public void testLdifParserAddAttrCaseInsensitiveAttrId() throws NamingException
+    public void testLdifParserAddAttrCaseInsensitiveAttrId() throws Exception
     {
         // test that mixed case attr ids work at all
         String ldif =
@@ -272,20 +287,22 @@
 
         testReaderAttrIdCaseInsensitive( ldif );
     }
+    
 
     private void testReaderAttrIdCaseInsensitive( String ldif )
-            throws NamingException
+            throws Exception
     {
         LdifReader reader = new LdifReader();
 
         List<LdifEntry> entries = reader.parseLdif( ldif );
         assertNotNull( entries );
+        reader.close();
 
         LdifEntry entry = ( LdifEntry ) entries.get( 0 );
 
         assertTrue( entry.isChangeModify() );
 
-        assertEquals( "dc=example,dc=com", entry.getDn().getUpName() );
+        assertEquals( "dc=example,dc=com", entry.getDn().getName() );
 
         List<Modification> mods = entry.getModificationItems( );
         assertTrue( mods.size() == 1 );
@@ -293,14 +310,15 @@
         assertTrue( attr.getId().equals( "administrativerole"));
         assertEquals( attr.getString(), "accessControlSpecificArea" );
     }
+    
 
     /**
      * Changes and entries should not be mixed
      * 
-     * @throws NamingException
+     * @throws Exception
      */
     @Test
-    public void testLdifParserCombinedEntriesChanges()
+    public void testLdifParserCombinedEntriesChanges() throws Exception
     {
         String ldif = 
             "version:   1\n" + 
@@ -327,19 +345,24 @@
             reader.parseLdif( ldif );
             fail();
         }
-        catch (NamingException ne)
+        catch (Exception ne)
         {
             assertTrue( true );
         }
+        finally
+        {
+            reader.close();
+        }
     }
+    
 
     /**
      * Changes and entries should not be mixed
      * 
-     * @throws NamingException
+     * @throws Exception
      */
     @Test
-    public void testLdifParserCombinedEntriesChanges2()
+    public void testLdifParserCombinedEntriesChanges2() throws Exception
     {
         String ldif = 
             "version:   1\n" + 
@@ -365,19 +388,24 @@
             reader.parseLdif( ldif );
             fail();
         }
-        catch (NamingException ne)
+        catch (Exception ne)
         {
             assertTrue( true );
         }
+        finally
+        {
+            reader.close();
+        }
     }
+    
 
     /**
      * Changes and entries should not be mixed
      * 
-     * @throws NamingException
+     * @throws Exception
      */
     @Test
-    public void testLdifParserCombinedChangesEntries()
+    public void testLdifParserCombinedChangesEntries() throws Exception
     {
         String ldif = 
             "version:   1\n" + 
@@ -404,19 +432,24 @@
             reader.parseLdif( ldif );
             fail();
         }
-        catch (NamingException ne)
+        catch (Exception ne)
         {
             assertTrue( true );
         }
+        finally
+        {
+            reader.close();
+        }
     }
+    
 
     /**
      * Changes and entries should not be mixed
      * 
-     * @throws NamingException
+     * @throws Exception
      */
     @Test
-    public void testLdifParserCombinedChangesEntries2()
+    public void testLdifParserCombinedChangesEntries2() throws Exception
     {
         String ldif = 
             "version:   1\n" + 
@@ -442,14 +475,19 @@
             reader.parseLdif( ldif );
             fail();
         }
-        catch (NamingException ne)
+        catch (Exception ne)
         {
             assertTrue( true );
         }
+        finally
+        {
+            reader.close();
+        }
     }
+    
 
     @Test
-    public void testLdifParser() throws NamingException
+    public void testLdifParser() throws Exception
     {
         String ldif = 
             "version:   1\n" + 
@@ -463,13 +501,14 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         assertNotNull( entries );
 
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getUpName() );
+        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getName() );
 
         EntryAttribute attr = entry.get( "cn" );
         assertTrue( attr.contains( "app1" ) );
@@ -487,9 +526,10 @@
         attr = entry.get( "envvars" );
         assertNull( attr.get().get() );
     }
+    
 
     @Test
-    public void testLdifParserMuiltiLineComments() throws NamingException
+    public void testLdifParserMuiltiLineComments() throws Exception
     {
         String ldif = 
             "#comment\n" + 
@@ -507,13 +547,14 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         assertNotNull( entries );
 
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getUpName() );
+        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getName() );
 
         EntryAttribute attr = entry.get( "cn" );
         assertTrue( attr.contains( "app1#another comment" ) );
@@ -532,8 +573,9 @@
         assertNull( attr.get().get() );
     }
 
+    
     @Test
-    public void testLdifParserMultiLineEntries() throws NamingException
+    public void testLdifParserMultiLineEntries() throws Exception
     {
         String ldif = 
             "#comment\n" + 
@@ -551,13 +593,14 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         assertNotNull( entries );
 
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getUpName() );
+        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getName() );
 
         EntryAttribute attr = entry.get( "cn" );
         assertTrue( attr.contains( "app1#another comment" ) );
@@ -575,9 +618,10 @@
         attr = entry.get( "envvars" );
         assertNull( attr.get().get() );
     }
+    
 
     @Test
-    public void testLdifParserBase64() throws NamingException, UnsupportedEncodingException
+    public void testLdifParserBase64() throws Exception, UnsupportedEncodingException
     {
         String ldif = 
             "#comment\n" + 
@@ -594,13 +638,14 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         assertNotNull( entries );
 
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getUpName() );
+        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getName() );
 
         EntryAttribute attr = entry.get( "cn" );
         assertTrue( attr.contains( "Emmanuel L\u00e9charny".getBytes( "UTF-8" ) ) );
@@ -618,9 +663,10 @@
         attr = entry.get( "envvars" );
         assertNull( attr.get().get() );
     }
+    
 
     @Test
-    public void testLdifParserBase64MultiLine() throws NamingException, UnsupportedEncodingException
+    public void testLdifParserBase64MultiLine() throws Exception, UnsupportedEncodingException
     {
         String ldif = 
             "#comment\n" + 
@@ -638,13 +684,14 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         assertNotNull( entries );
 
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getUpName() );
+        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getName() );
 
         EntryAttribute attr = entry.get( "cn" );
         assertTrue( attr.contains( "Emmanuel L\u00e9charny  ".getBytes( "UTF-8" ) ) );
@@ -662,9 +709,10 @@
         attr = entry.get( "envvars" );
         assertNull( attr.get().get() );
     }
+    
 
     @Test
-    public void testLdifParserRFC2849Sample1() throws NamingException
+    public void testLdifParserRFC2849Sample1() throws Exception
     {
         String ldif = 
             "version: 1\n" + 
@@ -690,6 +738,7 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         assertEquals( 2, entries.size() );
 
@@ -697,7 +746,7 @@
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com", entry.getDn().getUpName() );
+        assertEquals( "cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com", entry.getDn().getName() );
 
         EntryAttribute attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
@@ -726,7 +775,7 @@
         assertTrue( entry.isChangeAdd() );
 
         attr = entry.get( "dn" );
-        assertEquals( "cn=Bjorn Jensen, ou=Accounting, dc=airius, dc=com", entry.getDn().getUpName() );
+        assertEquals( "cn=Bjorn Jensen, ou=Accounting, dc=airius, dc=com", entry.getDn().getName() );
 
         attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
@@ -743,8 +792,9 @@
         assertTrue( attr.contains( "+1 408 555 1212" ) );
     }
 
+    
     @Test
-    public void testLdifParserRFC2849Sample2() throws NamingException
+    public void testLdifParserRFC2849Sample2() throws Exception
     {
         String ldif = 
             "version: 1\n" + 
@@ -764,6 +814,7 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         assertEquals( 1, entries.size() );
 
@@ -771,7 +822,7 @@
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com", entry.getDn().getUpName() );
+        assertEquals( "cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com", entry.getDn().getName() );
 
         EntryAttribute attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
@@ -798,11 +849,11 @@
 
         attr = entry.get( "title" );
         assertTrue( attr.contains( "Product Manager, Rod and Reel Division" ) );
-
     }
 
+    
     @Test
-    public void testLdifParserRFC2849Sample3() throws NamingException, Exception
+    public void testLdifParserRFC2849Sample3() throws Exception, Exception
     {
         String ldif = 
             "version: 1\n" + 
@@ -822,6 +873,7 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         assertEquals( 1, entries.size() );
 
@@ -829,7 +881,7 @@
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com", entry.getDn().getUpName() );
+        assertEquals( "cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com", entry.getDn().getName() );
 
         EntryAttribute attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
@@ -854,9 +906,10 @@
                 .contains( "What a careful reader you are!  This value is base-64-encoded because it has a control character in it (a CR).\r  By the way, you should really get out more."
                         .getBytes( "UTF-8" ) ) );
     }
+    
 
     @Test
-    public void testLdifParserRFC2849Sample3VariousSpacing() throws NamingException, Exception
+    public void testLdifParserRFC2849Sample3VariousSpacing() throws Exception, Exception
     {
         String ldif = 
             "version:1\n" + 
@@ -876,6 +929,7 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         assertEquals( 1, entries.size() );
 
@@ -883,7 +937,7 @@
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com", entry.getDn().getUpName() );
+        assertEquals( "cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com", entry.getDn().getName() );
 
         EntryAttribute attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
@@ -909,8 +963,9 @@
                         .getBytes( "UTF-8" ) ) );
     }
 
+    
     @Test
-    public void testLdifParserRFC2849Sample4() throws NamingException, Exception
+    public void testLdifParserRFC2849Sample4() throws Exception, Exception
     {
         String ldif = 
             "version: 1\n" + 
@@ -969,6 +1024,7 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         String[][][] values =
             {
@@ -1023,7 +1079,7 @@
             {
                 if ( "dn".equalsIgnoreCase( values[i][j][0] ) )
                 {
-                    assertEquals( values[i][j][1], entry.getDn().getUpName() );
+                    assertEquals( values[i][j][1], entry.getDn().getName() );
                 }
                 else
                 {
@@ -1041,9 +1097,10 @@
             }
         }
     }
+    
 
     @Test
-    public void testLdifParserRFC2849Sample5() throws NamingException, Exception
+    public void testLdifParserRFC2849Sample5() throws Exception, Exception
     {
         String ldif = 
             "version: 1\n" + 
@@ -1060,6 +1117,7 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         String[][] values =
             {
@@ -1085,7 +1143,7 @@
         {
             if ( "dn".equalsIgnoreCase( values[i][0] ) )
             {
-                assertEquals( values[i][1], entry.getDn().getUpName() );
+                assertEquals( values[i][1], entry.getDn().getName() );
             }
             else if ( "jpegphoto".equalsIgnoreCase( values[i][0] ) )
             {
@@ -1107,6 +1165,7 @@
             }
         }
     }
+    
 
     @Test
     public void testLdifParserRFC2849Sample5WithSizeLimit() throws Exception
@@ -1126,20 +1185,22 @@
 
         LdifReader reader = new LdifReader();
         reader.setSizeLimit( 128 );
+        reader.close();
 
         try
         {
             reader.parseLdif( ldif );
             fail();
         }
-        catch (NamingException ne)
+        catch (Exception ne)
         {
             assertEquals( "Error while parsing the ldif buffer", ne.getMessage() );
         }
     }
 
+    
     @Test
-    public void testLdifParserRFC2849Sample6() throws NamingException, Exception
+    public void testLdifParserRFC2849Sample6() throws Exception, Exception
     {
         String ldif = 
             "version: 1\n" +
@@ -1212,6 +1273,7 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         String[][][] values =
             {
@@ -1271,7 +1333,7 @@
         {
             if ( "dn".equalsIgnoreCase( values[0][i][0] ) )
             {
-                assertEquals( values[0][i][1], entry.getDn().getUpName() );
+                assertEquals( values[0][i][1], entry.getDn().getName() );
             }
             else if ( "jpegphoto".equalsIgnoreCase( values[0][i][0] ) )
             {
@@ -1296,19 +1358,19 @@
         // Second entry
         entry = (LdifEntry) entries.get( 1 );
         assertTrue( entry.isChangeDelete() );
-        assertEquals( values[1][0][1], entry.getDn().getUpName() );
+        assertEquals( values[1][0][1], entry.getDn().getName() );
 
         // Third entry
         entry = (LdifEntry) entries.get( 2 );
         assertTrue( entry.isChangeModRdn() );
-        assertEquals( values[2][0][1], entry.getDn().getUpName() );
+        assertEquals( values[2][0][1], entry.getDn().getName() );
         assertEquals( values[2][1][0], entry.getNewRdn() );
         assertTrue( entry.isDeleteOldRdn() );
 
         // Forth entry
         entry = (LdifEntry) entries.get( 3 );
         assertTrue( entry.isChangeModDn() );
-        assertEquals( values[3][0][1], entry.getDn().getUpName() );
+        assertEquals( values[3][0][1], entry.getDn().getName() );
         assertEquals( values[3][1][0], entry.getNewRdn() );
         assertFalse( entry.isDeleteOldRdn() );
         assertEquals( values[3][2][0], entry.getNewSuperior() );
@@ -1318,7 +1380,7 @@
         List<Modification> modifs = entry.getModificationItems();
 
         assertTrue( entry.isChangeModify() );
-        assertEquals( values[4][0][1], entry.getDn().getUpName() );
+        assertEquals( values[4][0][1], entry.getDn().getName() );
 
         // "add: postaladdress"
         // "postaladdress: 123 Anystreet $ Sunnyvale, CA $ 94086"
@@ -1355,7 +1417,7 @@
         modifs = entry.getModificationItems();
 
         assertTrue( entry.isChangeModify() );
-        assertEquals( values[5][0][1], entry.getDn().getUpName() );
+        assertEquals( values[5][0][1], entry.getDn().getName() );
 
         // "replace: postaladdress"
         item = (Modification) modifs.get( 0 );
@@ -1368,8 +1430,9 @@
         assertEquals( values[5][2][0], item.getAttribute().getId() );
     }
 
+    
     @Test
-    public void testLdifParserRFC2849Sample7() throws NamingException, Exception
+    public void testLdifParserRFC2849Sample7() throws Exception, Exception
     {
         String ldif = 
             "version: 1\n" + 
@@ -1383,10 +1446,11 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         LdifEntry entry = (LdifEntry) entries.get( 0 );
 
-        assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn().getUpName() );
+        assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn().getName() );
         assertTrue( entry.isChangeDelete() );
 
         // Check the control
@@ -1395,9 +1459,10 @@
         assertEquals( "1.2.840.113556.1.4.805", control.getID() );
         assertTrue( control.isCritical() );
     }
+    
 
     @Test
-    public void testLdifParserRFC2849Sample7NoValueNoCritical() throws NamingException, Exception
+    public void testLdifParserRFC2849Sample7NoValueNoCritical() throws Exception, Exception
     {
         String ldif = 
             "version: 1\n" + 
@@ -1411,10 +1476,11 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         LdifEntry entry = (LdifEntry) entries.get( 0 );
 
-        assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn().getUpName() );
+        assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn().getName() );
         assertTrue( entry.isChangeDelete() );
 
         // Check the control
@@ -1423,9 +1489,10 @@
         assertEquals( "1.2.840.11556.1.4.805", control.getID() );
         assertFalse( control.isCritical() );
     }
+    
 
     @Test
-    public void testLdifParserRFC2849Sample7NoCritical() throws NamingException, Exception
+    public void testLdifParserRFC2849Sample7NoCritical() throws Exception, Exception
     {
         String ldif = 
             "version: 1\n" + 
@@ -1439,10 +1506,11 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         LdifEntry entry = (LdifEntry) entries.get( 0 );
 
-        assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn().getUpName() );
+        assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn().getName() );
         assertTrue( entry.isChangeDelete() );
 
         // Check the control
@@ -1453,6 +1521,7 @@
         assertEquals( "control-value", StringTools.utf8ToString( control.getEncodedValue() ) );
     }
 
+    
     @Test
     public void testLdifParserRFC2849Sample7NoOid() throws Exception
     {
@@ -1473,11 +1542,16 @@
             reader.parseLdif( ldif );
             fail();
         }
-        catch (NamingException ne)
+        catch (Exception ne)
         {
             assertTrue( true );
         }
+        finally
+        {
+            reader.close();
+        }
     }
+    
 
     @Test
     public void testLdifParserRFC2849Sample7BadOid() throws Exception
@@ -1499,15 +1573,19 @@
             reader.parseLdif( ldif );
             fail();
         }
-        catch (NamingException ne)
+        catch (Exception ne)
         {
             assertTrue( true );
         }
+        finally
+        {
+            reader.close();
+        }
     }
 
     
     @Test
-    public void testLdifReaderDirServer() throws NamingException, Exception
+    public void testLdifReaderDirServer() throws Exception, Exception
     {
         String ldif = 
             "# -------------------------------------------------------------------\n" +
@@ -1544,9 +1622,11 @@
         LdifReader reader = new LdifReader();
 
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
+
         LdifEntry entry = (LdifEntry) entries.get( 0 );
 
-        assertEquals( "ou=Users, dc=example, dc=com", entry.getDn().getUpName() );
+        assertEquals( "ou=Users, dc=example, dc=com", entry.getDn().getName() );
 
         EntryAttribute attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
@@ -1558,7 +1638,7 @@
 
     
     @Test
-    public void testLdifParserCommentsEmptyLines() throws NamingException, Exception
+    public void testLdifParserCommentsEmptyLines() throws Exception, Exception
     {
         String ldif = 
             "#\n" +
@@ -1602,10 +1682,11 @@
 
         LdifReader reader = new LdifReader();
         List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
 
         LdifEntry entry = (LdifEntry) entries.get( 0 );
 
-        assertEquals( "cn=browseRootAci,dc=example,dc=com", entry.getDn().getUpName() );
+        assertEquals( "cn=browseRootAci,dc=example,dc=com", entry.getDn().getName() );
         EntryAttribute attr = entry.get( "objectClass" );
         assertTrue( attr.contains( "top" ) );
         assertTrue( attr.contains( SchemaConstants.SUBENTRY_OC ) );



Mime
View raw message