You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2008/08/05 05:22:32 UTC

svn commit: r682572 - in /directory/apacheds/branches/bigbang: protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/ server-integ/src/test/java/org/apache/directory/server/operations/add/ server-integ/src/test/java/org/apache/dir...

Author: akarasulu
Date: Mon Aug  4 20:22:31 2008
New Revision: 682572

URL: http://svn.apache.org/viewvc?rev=682572&view=rev
Log:
adding referral handling code for add operation in newldap protocol handler

 o added referral handling code and gutted old code - hooked into base class 
 o fixed a few special issues that arrise with add due to missing entry handling
   logic in the SingleReplyRequestHandler
 o removed bogus test that chases referrals in CompareIT: this test tests JNDI
   more than our referral handling code and is messed up because we cannot 
   predict which referral the JNDI provider picks to use nor can we set the 
   port properly on this to hit the server again without bending over backwards
   so decided to remove the test
 o moved AddITest to server-integ as AddIT and cleaned up adapting it to new 
   test framework
 o moved AddingEntriesWithSpecialCharactersInRDNITest to server-integ as 
   AddingEntriesWithSpecialCharactersInRDNIT , cleaned up and adpated it to 
   new test framework
 o quieted down tests a little bit but for now still showing logging info 
   at debug level in server-integ until done with work here
  

Added:
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/add/
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java
Removed:
    directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/AddITest.java
    directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/AddingEntriesWithSpecialCharactersInRDNTest.java
Modified:
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewAddHandler.java
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewCompareHandler.java
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/SingleReplyRequestHandler.java
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java
    directory/apacheds/branches/bigbang/server-integ/src/test/resources/log4j.properties

Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewAddHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewAddHandler.java?rev=682572&r1=682571&r2=682572&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewAddHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewAddHandler.java Mon Aug  4 20:22:31 2008
@@ -20,17 +20,12 @@
 package org.apache.directory.server.newldap.handlers;
 
 
-import javax.naming.NamingException;
-import javax.naming.ReferralException;
-
+import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.newldap.LdapSession;
-import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.message.AddRequest;
 import org.apache.directory.shared.ldap.message.LdapResult;
-import org.apache.directory.shared.ldap.message.ReferralImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.util.ExceptionUtils;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -42,105 +37,36 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class NewAddHandler extends LdapRequestHandler<AddRequest>
+public class NewAddHandler extends SingleReplyRequestHandler<AddRequest>
 {
 	/** The logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( NewAddHandler.class );
     
     
     /**
-     * (non-Javadoc)
-     * @see org.apache.directory.server.newldap.handlers.LdapRequestHandler#
-     * handle(org.apache.directory.server.newldap.LdapSession, org.apache.directory.shared.ldap.message.Request)
+     * @see SingleReplyRequestHandler#handleIgnoringReferrals(LdapSession, LdapDN, ClonedServerEntry, 
+     * org.apache.directory.shared.ldap.message.SingleReplyRequest)
      */
-    public void handle( LdapSession session, AddRequest request ) throws Exception
+    public void handleIgnoringReferrals( LdapSession session, LdapDN reqTargetDn, 
+        ClonedServerEntry entry, AddRequest req ) 
     {
-        LdapResult result = request.getResultResponse().getLdapResult();
+        LOG.debug( "Handling add request while ignoring referrals: {}", req );
+        LdapResult result = req.getResultResponse().getLdapResult();
 
         try
         {
         	// Call the underlying layer to inject the new entry 
-            session.getCoreSession().add( request );
+            session.getCoreSession().add( req );
 
-            // If it succeeded, we should be here now, otherwise, we would have
-            // got an exception.
+            // If success, here now, otherwise, we would have an exception.
             result.setResultCode( ResultCodeEnum.SUCCESS );
             
-            // TODO : inject the responseControls here...
-            //request.getResultResponse().addAll( session.request.getControls().ResponseControls() );
-            
             // Write the AddResponse message
-            session.getIoSession().write( request.getResultResponse() );
-        }
-        catch( ReferralException e )
-        {
-        	// We tried to add an entry into a referral. 
-            ReferralImpl refs = new ReferralImpl();
-            result.setReferral( refs );
-            result.setResultCode( ResultCodeEnum.REFERRAL );
-            result.setErrorMessage( "Encountered referral attempting to handle add request." );
-            
-            if ( e.getResolvedName() != null )
-            {
-                result.setMatchedDn( new LdapDN( e.getResolvedName() ) );
-            }
-            
-            do
-            {
-                refs.addLdapUrl( ( String ) e.getReferralInfo() );
-            }
-            while ( e.skipReferral() );
-            
-            // Write back the response
-            session.getIoSession().write( request.getResultResponse() );
+            session.getIoSession().write( req.getResultResponse() );
         }
-        catch ( Throwable t )
+        catch ( Exception e )
         {
-        	// We got an error. Get the resultCode.
-            ResultCodeEnum resultCode = ResultCodeEnum.OTHER;
-            
-            if ( t instanceof LdapException )
-            {
-                resultCode = ( ( LdapException ) t ).getResultCode();
-            }
-            else
-            {
-                resultCode = ResultCodeEnum.getBestEstimate( t, request.getType() );
-            }
-            
-            result.setResultCode( resultCode );
-            
-            String msg = session + "failed to add entry " + request.getEntry() + ": " + t.getMessage();
-            
-            if ( LOG.isDebugEnabled() )
-            {
-                msg += ":\n" + ExceptionUtils.getStackTrace( t );
-            }
-
-            result.setErrorMessage( msg );
-
-            // Add the matchedDN if necessary
-            boolean setMatchedDn = 
-                resultCode == ResultCodeEnum.NO_SUCH_OBJECT             || 
-                resultCode == ResultCodeEnum.ALIAS_PROBLEM              ||
-                resultCode == ResultCodeEnum.INVALID_DN_SYNTAX          || 
-                resultCode == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM;
-            
-            if ( setMatchedDn )
-            {
-                if ( t instanceof NamingException )
-                {
-                    NamingException ne = ( NamingException ) t;
-                    
-                    if ( ne.getResolvedName() != null )
-                    {
-                        result.setMatchedDn( ( LdapDN ) ne.getResolvedName() );
-                    }
-                }
-            }
-
-            // Write back the error response
-            session.getIoSession().write( request.getResultResponse() );
+            handleException( session, req, e );
         }
     }
 }

Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewCompareHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewCompareHandler.java?rev=682572&r1=682571&r2=682572&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewCompareHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewCompareHandler.java Mon Aug  4 20:22:31 2008
@@ -51,7 +51,7 @@
     public void handleIgnoringReferrals( LdapSession session, LdapDN reqTargetDn, 
         ClonedServerEntry entry, CompareRequest req )
     {
-        LOG.debug( "Handling request while ignoring referrals: {}", req );
+        LOG.debug( "Handling compare request while ignoring referrals: {}", req );
         LdapResult result = req.getResultResponse().getLdapResult();
         
         try

Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/SingleReplyRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/SingleReplyRequestHandler.java?rev=682572&r1=682571&r2=682572&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/SingleReplyRequestHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/SingleReplyRequestHandler.java Mon Aug  4 20:22:31 2008
@@ -27,20 +27,20 @@
 import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.newldap.LdapSession;
-import org.apache.directory.shared.ldap.codec.add.AddRequest;
-import org.apache.directory.shared.ldap.codec.bind.BindRequest;
-import org.apache.directory.shared.ldap.codec.modify.ModifyRequest;
-import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNRequest;
 import org.apache.directory.shared.ldap.codec.util.LdapURL;
 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.message.AddRequest;
+import org.apache.directory.shared.ldap.message.BindRequest;
 import org.apache.directory.shared.ldap.message.CompareRequest;
 import org.apache.directory.shared.ldap.message.DeleteRequest;
 import org.apache.directory.shared.ldap.message.LdapResult;
 import org.apache.directory.shared.ldap.message.ManageDsaITControl;
+import org.apache.directory.shared.ldap.message.ModifyDnRequest;
+import org.apache.directory.shared.ldap.message.ModifyRequest;
 import org.apache.directory.shared.ldap.message.Referral;
 import org.apache.directory.shared.ldap.message.ReferralImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
@@ -99,10 +99,10 @@
                     " using this base class.  They have no target entry unlike the rest of" +
                     " the SingleReplyRequests" );
             case MOD_DN_RESPONSE:
-                reqTargetDn = ( ( ModifyDNRequest ) req ).getEntry();
+                reqTargetDn = ( ( ModifyDnRequest ) req ).getName();
                 break;
             case MODIFY_RESPONSE:
-                reqTargetDn = ( ( ModifyRequest ) req ).getObject();
+                reqTargetDn = ( ( ModifyRequest ) req ).getName();
                 break;
             default:
                 throw new IllegalStateException( 
@@ -139,21 +139,24 @@
         // referral - would rather attempt a lookup that fails then do check 
         // for existence than have to do another lookup to get entry info
 
-        try
-        {
-            entry = session.getCoreSession().lookup( reqTargetDn );
-            LOG.debug( "Entry for {} was found: ", reqTargetDn, entry );
-        }
-        catch ( NameNotFoundException e )
-        {
-            /* ignore */
-            LOG.debug( "Entry for {} not found.", reqTargetDn );
-        }
-        catch ( Exception e )
+        if ( ! ( req instanceof AddRequest ) )
         {
-            /* serious and needs handling */
-            handleException( session, req, e );
-            return;
+            try
+            {
+                entry = session.getCoreSession().lookup( reqTargetDn );
+                LOG.debug( "Entry for {} was found: ", reqTargetDn, entry );
+            }
+            catch ( NameNotFoundException e )
+            {
+                /* ignore */
+                LOG.debug( "Entry for {} not found.", reqTargetDn );
+            }
+            catch ( Exception e )
+            {
+                /* serious and needs handling */
+                handleException( session, req, e );
+                return;
+            }
         }
         
         // -------------------------------------------------------------------
@@ -197,6 +200,15 @@
             LdapDN lastMatchedDn = null;
             LdapDN dn = ( LdapDN ) reqTargetDn.clone();
             
+            try
+            {
+                dn.remove( dn.size() - 1 );
+            }
+            catch ( InvalidNameException e2 )
+            {
+                // never thrown
+            }
+            
             while ( ! dn.isEmpty() )
             {
                 LOG.debug( "Walking ancestors of {} to find referrals.", dn );
@@ -242,7 +254,7 @@
                 }
             }
 
-            if ( referralAncestor == null )
+            if ( referralAncestor == null && ! ( req instanceof AddRequest ) )
             {
                 result.setMatchedDn( lastMatchedDn );
                 result.setErrorMessage( "Entry not found." );
@@ -250,6 +262,11 @@
                 session.getIoSession().write( req.getResultResponse() );
                 return;
             }
+            else if ( ( req instanceof AddRequest ) && referralAncestor == null )
+            {
+                handleIgnoringReferrals( session, reqTargetDn, entry, req );
+                return;
+            }
               
             // if we get here then we have a valid referral ancestor
             handleReferralOnAncestor( session, reqTargetDn, req, referralAncestor, lastMatchedDn );
@@ -402,10 +419,10 @@
      */
     public void handleException( LdapSession session, T req, Exception e )
     {
-        LdapResult result = req.getResultResponse().getLdapResult();
-
         String msg = "failed for " + req + ": " + e.getMessage();
         LOG.error( msg, e );
+        LdapResult result = req.getResultResponse().getLdapResult();
+
 
         if ( IS_DEBUG )
         {
@@ -430,11 +447,16 @@
         {
             NamingException ne = ( NamingException ) e;
 
-            if ( ( ne.getResolvedName() != null )
-                && ( ( code == ResultCodeEnum.NO_SUCH_OBJECT ) || ( code == ResultCodeEnum.ALIAS_PROBLEM )
-                    || ( code == ResultCodeEnum.INVALID_DN_SYNTAX ) || ( code == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM ) ) )
+            // Add the matchedDN if necessary
+            boolean setMatchedDn = 
+                code == ResultCodeEnum.NO_SUCH_OBJECT             || 
+                code == ResultCodeEnum.ALIAS_PROBLEM              ||
+                code == ResultCodeEnum.INVALID_DN_SYNTAX          || 
+                code == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM;
+            
+            if ( ( ne.getResolvedName() != null ) && setMatchedDn )
             {
-                result.setMatchedDn( (LdapDN)ne.getResolvedName() );
+                result.setMatchedDn( ( LdapDN ) ne.getResolvedName() );
             }
         }
 

Added: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java?rev=682572&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java (added)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java Mon Aug  4 20:22:31 2008
@@ -0,0 +1,512 @@
+/*
+ *  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.operations.add;
+
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InvalidAttributeValueException;
+import javax.naming.directory.SchemaViolationException;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+
+import netscape.ldap.LDAPAttribute;
+import netscape.ldap.LDAPAttributeSet;
+import netscape.ldap.LDAPConnection;
+import netscape.ldap.LDAPEntry;
+import netscape.ldap.LDAPException;
+
+import org.apache.directory.server.core.integ.Level;
+import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
+import org.apache.directory.server.core.integ.annotations.CleanupLevel;
+
+import org.apache.directory.server.integ.SiRunner;
+import org.apache.directory.server.integ.ServerIntegrationUtils;
+import org.apache.directory.server.newldap.LdapServer;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+
+/**
+ * Various add scenario tests.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 674593 $
+ */
+@RunWith ( SiRunner.class ) 
+@CleanupLevel ( Level.SUITE )
+@ApplyLdifs( {
+    // Entry # 1
+    "dn: cn=The Person,ou=system\n" +
+    "objectClass: person\n" +
+    "objectClass: top\n" +
+    "cn: The Person\n" +
+    "description: this is a person\n" +
+    "sn: Person\n\n" 
+    }
+)
+public class AddIT
+{
+    private static final String RDN = "cn=The Person";
+
+    static final String HOST = "localhost";
+    static final String USER = "uid=admin,ou=system";
+    static final String PASSWORD = "secret";
+    static final String BASE = "ou=system";
+
+
+
+    public static LdapServer ldapServer;
+
+
+    /**
+     * This is the original defect as in JIRA DIREVE-216.
+     * 
+     * @throws NamingException if we cannot connect and perform add operations
+     */
+    @Test
+    public void testAddObjectClasses() throws Exception
+    {
+        DirContext ctx = ( DirContext ) ServerIntegrationUtils.getWiredContext( ldapServer ).lookup( "ou=system" );
+
+        // modify object classes, add two more
+        Attributes attributes = new AttributesImpl( true );
+        Attribute ocls = new AttributeImpl( "objectClass" );
+        ocls.add( "organizationalPerson" );
+        ocls.add( "inetOrgPerson" );
+        attributes.put( ocls );
+
+        DirContext person = ( DirContext ) ctx.lookup( RDN );
+        person.modifyAttributes( "", DirContext.ADD_ATTRIBUTE, attributes );
+
+        // Read again from directory
+        person = ( DirContext ) ctx.lookup( RDN );
+        attributes = person.getAttributes( "" );
+        Attribute newOcls = attributes.get( "objectClass" );
+
+        String[] expectedOcls = { "top", "person", "organizationalPerson", "inetOrgPerson" };
+        for ( String name : expectedOcls )
+        {
+            assertTrue( "object class " + name + " is present", newOcls.contains( name ) );
+        }
+    }
+
+
+    /**
+     * This changes a single attribute value. Just as a reference.
+     * 
+     * @throws NamingException if we cannot connect and modify the description
+     */
+    @Test
+    public void testModifyDescription() throws Exception
+    {
+        DirContext ctx = ( DirContext ) ServerIntegrationUtils.getWiredContext( ldapServer ).lookup( "ou=system" );
+
+        String newDescription = "More info on the user ...";
+
+        // modify object classes, add two more
+        Attributes attributes = new AttributesImpl( true );
+        Attribute desc = new AttributeImpl( "description", newDescription );
+        attributes.put( desc );
+
+        DirContext person = ( DirContext ) ctx.lookup( RDN );
+        person.modifyAttributes( "", DirContext.REPLACE_ATTRIBUTE, attributes );
+
+        // Read again from directory
+        person = ( DirContext ) ctx.lookup( RDN );
+        attributes = person.getAttributes( "" );
+        Attribute newDesc = attributes.get( "description" );
+
+        assertTrue( "new Description", newDesc.contains( newDescription ) );
+    }
+
+
+    /**
+     * Try to add entry with required attribute missing.
+     * 
+     * @throws NamingException if we fail to connect
+     */
+    @Test
+    public void testAddWithMissingRequiredAttributes() throws Exception
+    {
+        DirContext ctx = ( DirContext ) ServerIntegrationUtils.getWiredContext( ldapServer ).lookup( "ou=system" );
+
+        // person without sn
+        Attributes attrs = new AttributesImpl();
+        Attribute ocls = new AttributeImpl( "objectClass" );
+        ocls.add( "top" );
+        ocls.add( "person" );
+        attrs.put( ocls );
+        attrs.put( "cn", "Fiona Apple" );
+
+        try
+        {
+            ctx.createSubcontext( "cn=Fiona Apple", attrs );
+            fail( "creation of entry should fail" );
+        }
+        catch ( SchemaViolationException e )
+        {
+            // expected
+        }
+    }
+    
+    
+    /**
+     * Test case to demonstrate DIRSERVER-643 ("Netscape SDK: Adding an entry with
+     * two description attributes does not combine values."). Uses Sun ONE Directory
+     * SDK for Java 4.1 , or comparable (Netscape, Mozilla).
+     * 
+     * @throws LDAPException if we fail to connect and add entries
+     */
+    @Test
+    public void testAddEntryWithTwoDescriptions() throws Exception
+    {
+        LDAPConnection con = ServerIntegrationUtils.getWiredConnection( ldapServer );
+        LDAPAttributeSet attrs = new LDAPAttributeSet();
+        LDAPAttribute ocls = new LDAPAttribute( "objectclass", new String[]
+            { "top", "person" } );
+        attrs.add( ocls );
+        attrs.add( new LDAPAttribute( "sn", "Bush" ) );
+        attrs.add( new LDAPAttribute( "cn", "Kate Bush" ) );
+
+        String descr[] =
+            { "a British singer-songwriter with an expressive four-octave voice",
+                "one of the most influential female artists of the twentieth century" };
+
+        attrs.add( new LDAPAttribute( "description", descr ) );
+
+        String dn = "cn=Kate Bush," + BASE;
+        LDAPEntry kate = new LDAPEntry( dn, attrs );
+
+        con.add( kate );
+
+        // Analyze entry and description attribute
+        LDAPEntry kateReloaded = con.read( dn );
+        assertNotNull( kateReloaded );
+        LDAPAttribute attr = kateReloaded.getAttribute( "description" );
+        assertNotNull( attr );
+        assertEquals( 2, attr.getStringValueArray().length );
+
+        // Remove entry
+        con.delete( dn );
+        con.disconnect();
+    }
+
+
+    /**
+     * Testcase to demonstrate DIRSERVER-643 ("Netscape SDK: Adding an entry with
+     * two description attributes does not combine values."). Uses Sun ONE Directory
+     * SDK for Java 4.1 , or comparable (Netscape, Mozilla).
+     * 
+     * @throws LDAPException if we fail to connect and add entries
+     */
+    @Test
+    public void testAddEntryWithTwoDescriptionsVariant() throws Exception
+    {
+        LDAPConnection con = ServerIntegrationUtils.getWiredConnection( ldapServer );
+        LDAPAttributeSet attrs = new LDAPAttributeSet();
+        LDAPAttribute ocls = new LDAPAttribute( "objectclass", new String[]
+            { "top", "person" } );
+        attrs.add( ocls );
+        attrs.add( new LDAPAttribute( "sn", "Bush" ) );
+        attrs.add( new LDAPAttribute( "cn", "Kate Bush" ) );
+
+        String descr[] =
+            { "a British singer-songwriter with an expressive four-octave voice",
+                "one of the most influential female artists of the twentieth century" };
+
+        attrs.add( new LDAPAttribute( "description", descr[0] ) );
+        attrs.add( new LDAPAttribute( "description", descr[1] ) );
+
+        String dn = "cn=Kate Bush," + BASE;
+        LDAPEntry kate = new LDAPEntry( dn, attrs );
+
+        con.add( kate );
+
+        // Analyze entry and description attribute
+        LDAPEntry kateReloaded = con.read( dn );
+        assertNotNull( kateReloaded );
+        LDAPAttribute attr = kateReloaded.getAttribute( "description" );
+        assertNotNull( attr );
+        assertEquals( 2, attr.getStringValueArray().length );
+
+        // Remove entry
+        con.delete( dn );
+        con.disconnect();
+    }
+
+
+    /**
+     * Testcase to demonstrate DIRSERVER-643 ("Netscape SDK: Adding an entry with
+     * two description attributes does not combine values."). Uses Sun ONE Directory
+     * SDK for Java 4.1 , or comparable (Netscape, Mozilla).
+     * 
+     * @throws LDAPException if we fail to connect and add entries
+     */
+    @Test
+    public void testAddEntryWithTwoDescriptionsSecondVariant() throws Exception
+    {
+        LDAPConnection con = ServerIntegrationUtils.getWiredConnection( ldapServer );
+        LDAPAttributeSet attrs = new LDAPAttributeSet();
+        LDAPAttribute ocls = new LDAPAttribute( "objectclass", new String[]
+            { "top", "person" } );
+        attrs.add( ocls );
+        attrs.add( new LDAPAttribute( "sn", "Bush" ) );
+
+        String descr[] =
+            { "a British singer-songwriter with an expressive four-octave voice",
+                "one of the most influential female artists of the twentieth century" };
+
+        attrs.add( new LDAPAttribute( "description", descr[0] ) );
+        attrs.add( new LDAPAttribute( "cn", "Kate Bush" ) );
+        attrs.add( new LDAPAttribute( "description", descr[1] ) );
+
+        String dn = "cn=Kate Bush," + BASE;
+        LDAPEntry kate = new LDAPEntry( dn, attrs );
+
+        con.add( kate );
+
+        // Analyze entry and description attribute
+        LDAPEntry kateReloaded = con.read( dn );
+        assertNotNull( kateReloaded );
+        LDAPAttribute attr = kateReloaded.getAttribute( "description" );
+        assertNotNull( attr );
+        assertEquals( 2, attr.getStringValueArray().length );
+
+        // Remove entry
+        con.delete( dn );
+        con.disconnect();
+    }
+
+    
+    /**
+     * Try to add entry with invalid number of values for a single-valued atribute
+     * 
+     * @throws NamingException if we fail to connect and add entries
+     * @see <a href="http://issues.apache.org/jira/browse/DIRSERVER-614">DIRSERVER-614</a>
+     */
+    @Test
+    public void testAddWithInvalidNumberOfAttributeValues() throws Exception
+    {
+        DirContext ctx = ( DirContext ) ServerIntegrationUtils.getWiredContext( ldapServer ).lookup( "ou=system" );
+        
+        // add inetOrgPerson with two displayNames
+        Attributes attrs = new AttributesImpl();
+        Attribute ocls = new AttributeImpl( "objectClass" );
+        ocls.add( "top" );
+        ocls.add( "inetOrgPerson" );
+        attrs.put( ocls );
+        attrs.put( "cn", "Fiona Apple" );
+        attrs.put( "sn", "Apple" );
+        Attribute displayName = new AttributeImpl( "displayName" );
+        displayName.add( "Fiona" );
+        displayName.add( "Fiona A." );
+        attrs.put( displayName );
+
+        try
+        {
+            ctx.createSubcontext( "cn=Fiona Apple", attrs );
+            fail( "creation of entry should fail" );
+        }
+        catch ( InvalidAttributeValueException e )
+        {
+        }
+    }
+
+
+    /**
+     * Try to add entry and an alias to it. Afterwards, remove it.
+     * 
+     * @throws NamingException if we fail to connect and add entries
+     */
+    @Test
+    public void testAddAlias() throws Exception
+    {
+        DirContext ctx = ( DirContext ) ServerIntegrationUtils.getWiredContext( ldapServer ).lookup( "ou=system" );
+
+        // Create entry
+        Attributes entry = new AttributesImpl();
+        Attribute entryOcls = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
+        entryOcls.add( SchemaConstants.TOP_OC );
+        entryOcls.add( SchemaConstants.ORGANIZATIONAL_UNIT_OC );
+        entry.put( entryOcls );
+        entry.put( SchemaConstants.OU_AT, "favorite" );
+        String entryRdn = "ou=favorite";
+        ctx.createSubcontext( entryRdn, entry );
+
+        // Create Alias
+        String aliasedObjectName = entryRdn + "," + ctx.getNameInNamespace();
+        Attributes alias = new AttributesImpl();
+        Attribute aliasOcls = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
+        aliasOcls.add( SchemaConstants.TOP_OC );
+        aliasOcls.add( SchemaConstants.EXTENSIBLE_OBJECT_OC );
+        aliasOcls.add( SchemaConstants.ALIAS_OC );
+        alias.put( aliasOcls );
+        alias.put( SchemaConstants.OU_AT, "bestFruit" );
+        alias.put( SchemaConstants.ALIASED_OBJECT_NAME_AT, aliasedObjectName );
+        String rdnAlias = "ou=bestFruit";
+        ctx.createSubcontext( rdnAlias, alias );
+
+        // Remove alias and entry
+        ctx.destroySubcontext( rdnAlias );
+        ctx.destroySubcontext( entryRdn );
+    }
+
+
+    /**
+     * Try to add entry and an alias to it. Afterwards, remove it. This version
+     * cretes a container entry before the operations.
+     * 
+     * @throws NamingException if we fail to connect and add entries
+     */
+    @Test
+    public void testAddAliasInContainer() throws Exception
+    {
+        DirContext ctx = ( DirContext ) ServerIntegrationUtils.getWiredContext( ldapServer ).lookup( "ou=system" );
+
+        // Create container
+        Attributes container = new AttributesImpl();
+        Attribute containerOcls = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
+        containerOcls.add( SchemaConstants.TOP_OC );
+        containerOcls.add( SchemaConstants.ORGANIZATIONAL_UNIT_OC );
+        container.put( containerOcls );
+        container.put( SchemaConstants.OU_AT, "Fruits" );
+        String containerRdn = "ou=Fruits";
+        DirContext containerCtx = ctx.createSubcontext( containerRdn, container );
+
+        // Create entry
+        Attributes entry = new AttributesImpl();
+        Attribute entryOcls = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
+        entryOcls.add( SchemaConstants.TOP_OC );
+        entryOcls.add( SchemaConstants.ORGANIZATIONAL_UNIT_OC );
+        entry.put( entryOcls );
+        entry.put( SchemaConstants.OU_AT, "favorite" );
+        String entryRdn = "ou=favorite";
+        containerCtx.createSubcontext( entryRdn, entry );
+
+        // Create alias ou=bestFruit,ou=Fruits to entry ou=favorite,ou=Fruits
+        String aliasedObjectName = entryRdn + "," + containerCtx.getNameInNamespace();
+        Attributes alias = new AttributesImpl();
+        Attribute aliasOcls = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
+        aliasOcls.add( SchemaConstants.TOP_OC );
+        aliasOcls.add( SchemaConstants.EXTENSIBLE_OBJECT_OC );
+        aliasOcls.add( SchemaConstants.ALIAS_OC );
+        alias.put( aliasOcls );
+        alias.put( SchemaConstants.OU_AT, "bestFruit" );
+        alias.put( SchemaConstants.ALIASED_OBJECT_NAME_AT, aliasedObjectName );
+        String rdnAlias = "ou=bestFruit";
+        containerCtx.createSubcontext( rdnAlias, alias );
+
+        // search one level scope for alias 
+        SearchControls controls = new SearchControls();
+        controls.setDerefLinkFlag( true );
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        containerCtx.addToEnvironment( "java.naming.ldap.derefAliases", "never" );
+        NamingEnumeration<SearchResult> ne = containerCtx.search( "", "(objectClass=*)", controls );
+        assertTrue( ne.hasMore() );
+        SearchResult sr = ne.next();
+        assertEquals( "ou=favorite", sr.getName() );
+        assertTrue( ne.hasMore() );
+        sr = ne.next();
+        assertEquals( "ou=bestFruit", sr.getName() );
+        
+        // search one level with dereferencing turned on
+        controls = new SearchControls();
+        controls.setDerefLinkFlag( true );
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        containerCtx.addToEnvironment( "java.naming.ldap.derefAliases", "always" );
+        ne = containerCtx.search( "", "(objectClass=*)", controls );
+        assertTrue( ne.hasMore() );
+        sr = ne.next();
+        assertEquals( "ou=favorite", sr.getName() );
+        assertFalse( ne.hasMore() );
+        
+        // search with base set to alias and dereferencing turned on
+        controls = new SearchControls();
+        controls.setDerefLinkFlag( false );
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        containerCtx.addToEnvironment( "java.naming.ldap.derefAliases", "always" );
+        ne = containerCtx.search( "ou=bestFruit", "(objectClass=*)", controls );
+        assertTrue( ne.hasMore() );
+        sr = ne.next();
+        assertEquals( "ldap://localhost:"+ ldapServer.getIpPort() +"/ou=favorite,ou=Fruits,ou=system", sr.getName() );
+        assertFalse( ne.hasMore() );
+        
+        // Remove alias and entry
+        containerCtx.destroySubcontext( rdnAlias );
+        containerCtx.destroySubcontext( entryRdn );
+
+        // Remove container
+        ctx.destroySubcontext( containerRdn );
+    }
+    
+    
+    /**
+     * Try to add entry and an alias to it. Afterwards, remove it.  Taken from
+     * DIRSERVER-1157 test contribution.
+     * 
+     * @see https://issues.apache.org/jira/browse/DIRSERVER-1157
+     * @throws Exception
+     */
+    @Test
+    public void testAddDeleteAlias() throws Exception
+    {
+        DirContext ctx = ( DirContext ) ServerIntegrationUtils.getWiredContext( ldapServer ).lookup( "ou=system" );
+
+        // Create entry ou=favorite,dc=example,dc=com
+        Attributes entry = new AttributesImpl();
+        Attribute entryOcls = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
+        entryOcls.add( SchemaConstants.TOP_OC );
+        entryOcls.add( SchemaConstants.ORGANIZATIONAL_UNIT_OC );
+        entry.put( entryOcls );
+        entry.put( SchemaConstants.OU_AT, "favorite" );
+        String entryRdn = "ou=favorite";
+        ctx.createSubcontext( entryRdn, entry );
+
+        // Create Alias ou=bestFruit,dc=example,dc=com to ou=favorite
+        String aliasedObjectName = entryRdn + "," + ctx.getNameInNamespace();
+        Attributes alias = new AttributesImpl();
+        Attribute aliasOcls = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
+        aliasOcls.add( SchemaConstants.TOP_OC );
+        aliasOcls.add( SchemaConstants.EXTENSIBLE_OBJECT_OC );
+        aliasOcls.add( SchemaConstants.ALIAS_OC );
+        alias.put( aliasOcls );
+        alias.put( SchemaConstants.OU_AT, "bestFruit" );
+        alias.put( SchemaConstants.ALIASED_OBJECT_NAME_AT, aliasedObjectName );
+        String rdnAlias = "ou=bestFruit";
+        ctx.createSubcontext( rdnAlias, alias );
+
+        // Remove alias and entry
+        ctx.destroySubcontext( rdnAlias ); //Waiting for Connection.reply()
+        ctx.destroySubcontext( entryRdn );
+    }
+}

Added: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java?rev=682572&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java (added)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java Mon Aug  4 20:22:31 2008
@@ -0,0 +1,336 @@
+/*
+ *  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.operations.add;
+
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+
+import org.apache.directory.server.core.integ.Level;
+import org.apache.directory.server.core.integ.annotations.CleanupLevel;
+import org.apache.directory.server.integ.SiRunner;
+import org.apache.directory.server.integ.ServerIntegrationUtils;
+import org.apache.directory.server.newldap.LdapServer;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+
+/**
+ * Test case to demonstrate DIRSERVER-631 ("Creation of entry with special (and
+ * escaped) character in RDN leads to wrong attribute value").
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith( SiRunner.class )
+@CleanupLevel( Level.SUITE )
+public class AddingEntriesWithSpecialCharactersInRDNIT
+{
+    public static LdapServer ldapServer;
+
+
+    protected Attributes getPersonAttributes( String sn, String cn )
+    {
+        Attributes attrs = new AttributesImpl();
+        Attribute ocls = new AttributeImpl( "objectClass" );
+        ocls.add( "top" );
+        ocls.add( "person" );
+        attrs.put( ocls );
+        attrs.put( "cn", cn );
+        attrs.put( "sn", sn );
+
+        return attrs;
+    }
+
+
+    protected Attributes getOrgUnitAttributes( String ou )
+    {
+        Attributes attrs = new AttributesImpl();
+        Attribute ocls = new AttributeImpl( "objectClass" );
+        ocls.add( "top" );
+        ocls.add( "organizationalUnit" );
+        attrs.put( ocls );
+        attrs.put( "ou", ou );
+
+        return attrs;
+    }
+
+
+    /**
+     * adding an entry with hash sign (#) in RDN.
+     * 
+     * @throws NamingException 
+     */
+    @Test
+    public void testAddingWithHashRdn() throws Exception
+    {
+        DirContext ctx = ( DirContext ) ServerIntegrationUtils.getWiredContext( ldapServer ).lookup( "ou=system" );
+
+        Attributes attrs = getPersonAttributes( "Bush", "Kate#Bush" );
+        String rdn = "cn=Kate\\#Bush";
+        ctx.createSubcontext( rdn, attrs );
+
+        SearchControls sctls = new SearchControls();
+        sctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+
+        NamingEnumeration<SearchResult> enm = ctx.search( "", "(cn=Kate\\#Bush)", sctls );
+        assertEquals( "entry found", true, enm.hasMore() );
+
+        while ( enm.hasMore() )
+        {
+            SearchResult sr = enm.next();
+            attrs = sr.getAttributes();
+            Attribute cn = sr.getAttributes().get( "cn" );
+            assertNotNull( cn );
+            assertTrue( cn.contains( "Kate#Bush" ) );
+        }
+
+        ctx.destroySubcontext( rdn );
+    }
+
+
+    /**
+     * adding an entry with comma sign (,) in RDN.
+     *    
+     * @throws NamingException 
+     */
+    @Test
+    public void testAddingWithCommaInRdn() throws Exception
+    {
+        DirContext ctx = ( DirContext ) ServerIntegrationUtils.getWiredContext( ldapServer ).lookup( "ou=system" );
+
+        Attributes attrs = getPersonAttributes( "Bush", "Bush, Kate" );
+        String rdn = "cn=Bush\\, Kate";
+        ctx.createSubcontext( rdn, attrs );
+
+        SearchControls sctls = new SearchControls();
+        sctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+
+        NamingEnumeration<SearchResult> enm = ctx.search( "", "(cn=Bush, Kate)", sctls );
+        assertEquals( "entry found", true, enm.hasMore() );
+
+        while ( enm.hasMore() )
+        {
+            SearchResult sr = enm.next();
+            attrs = sr.getAttributes();
+            Attribute cn = sr.getAttributes().get( "cn" );
+            assertNotNull( cn );
+            assertTrue( cn.contains( "Bush, Kate" ) );
+            assertEquals( "cn=Bush\\, Kate", sr.getName() );
+        }
+
+        ctx.destroySubcontext( rdn );
+    }
+
+
+    /**
+     * adding an entry with quotes (") in RDN.
+     */
+    /*   public void testAddingWithQuotesInRdn() throws NamingException {
+
+           Attributes attrs = getPersonAttributes("Messer",
+                   "Mackie \\\\\\\"The Knife\" Messer");
+           String rdn = "cn=Mackie \\\"The Knife\" Messer";
+           ctx.createSubcontext(rdn, attrs);
+
+           SearchControls sctls = new SearchControls();
+           sctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
+
+           NamingEnumeration enm = ctx.search("",
+                   "(cn=Mackie \"The Knife\" Messer)", sctls);
+           assertEquals("entry found", true, enm.hasMore());
+           while (enm.hasMore()) {
+               SearchResult sr = (SearchResult) enm.next();
+               attrs = sr.getObject();
+               Attribute cn = sr.getObject().get("cn");
+               assertNotNull(cn);
+               assertTrue(cn.contains("Mackie \"The Knife\" Messer"));
+           }
+
+           ctx.destroySubcontext(rdn);
+       }
+    */
+    /**
+     * adding an entry with backslash (\) in RDN.
+     */
+    /*   public void testAddingWithBackslashInRdn() throws NamingException {
+
+           Attributes attrs = getOrgUnitAttributes("AC\\DC");
+           String rdn = "ou=AC\\\\DC";
+           ctx.createSubcontext(rdn, attrs);
+
+           SearchControls sctls = new SearchControls();
+           sctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
+
+           NamingEnumeration enm = ctx.search("", "(ou=AC\\DC)", sctls);
+           assertEquals("entry found", true, enm.hasMore());
+           while (enm.hasMore()) {
+               SearchResult sr = (SearchResult) enm.next();
+               attrs = sr.getObject();
+               Attribute ou = sr.getObject().get("ou");
+               assertNotNull(ou);
+               assertTrue(ou.contains("AC\\DC"));
+           }
+
+           ctx.destroySubcontext(rdn);
+       }
+    */
+
+    /**
+     * adding an entry with greater sign (>) in RDN.
+     * 
+     * @throws NamingException 
+     */
+    @Test
+    public void testAddingWithGreaterSignInRdn() throws Exception
+    {
+        DirContext ctx = ( DirContext ) ServerIntegrationUtils.getWiredContext( ldapServer ).lookup( "ou=system" );
+
+        Attributes attrs = getOrgUnitAttributes( "East -> West" );
+        String rdn = "ou=East -\\> West";
+        ctx.createSubcontext( rdn, attrs );
+
+        SearchControls sctls = new SearchControls();
+        sctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+
+        NamingEnumeration<SearchResult> enm = ctx.search( "", "(ou=East -> West)", sctls );
+        assertEquals( "entry found", true, enm.hasMore() );
+
+        while ( enm.hasMore() )
+        {
+            SearchResult sr = enm.next();
+            attrs = sr.getAttributes();
+            Attribute ou = sr.getAttributes().get( "ou" );
+            assertNotNull( ou );
+            assertTrue( ou.contains( "East -> West" ) );
+        }
+
+        ctx.destroySubcontext( rdn );
+    }
+
+
+    /**
+     * adding an entry with less sign (<) in RDN.
+     * 
+     * @throws NamingException 
+     */
+    @Test
+    public void testAddingWithLessSignInRdn() throws Exception
+    {
+        DirContext ctx = ( DirContext ) ServerIntegrationUtils.getWiredContext( ldapServer ).lookup( "ou=system" );
+
+        Attributes attrs = getOrgUnitAttributes( "Scissors 8<" );
+        String rdn = "ou=Scissors 8\\<";
+        ctx.createSubcontext( rdn, attrs );
+
+        SearchControls sctls = new SearchControls();
+        sctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+
+        NamingEnumeration<SearchResult> enm = ctx.search( "", "(ou=Scissors 8<)", sctls );
+        assertEquals( "entry found", true, enm.hasMore() );
+
+        while ( enm.hasMore() )
+        {
+            SearchResult sr = enm.next();
+            attrs = sr.getAttributes();
+            Attribute ou = sr.getAttributes().get( "ou" );
+            assertNotNull( ou );
+            assertTrue( ou.contains( "Scissors 8<" ) );
+        }
+
+        ctx.destroySubcontext( rdn );
+    }
+
+
+    /**
+     * adding an entry with semicolon (;) in RDN.
+     * 
+     * @throws NamingException 
+     */
+    @Test
+    public void testAddingWithSemicolonInRdn() throws Exception
+    {
+        DirContext ctx = ( DirContext ) ServerIntegrationUtils.getWiredContext( ldapServer ).lookup( "ou=system" );
+
+        Attributes attrs = getOrgUnitAttributes( "semicolon group;" );
+        String rdn = "ou=semicolon group\\;";
+        ctx.createSubcontext( rdn, attrs );
+
+        SearchControls sctls = new SearchControls();
+        sctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+
+        NamingEnumeration<SearchResult> enm = ctx.search( "", "(ou=semicolon group;)", sctls );
+        assertEquals( "entry found", true, enm.hasMore() );
+
+        while ( enm.hasMore() )
+        {
+            SearchResult sr = enm.next();
+            attrs = sr.getAttributes();
+            Attribute ou = sr.getAttributes().get( "ou" );
+            assertNotNull( ou );
+            assertTrue( ou.contains( "semicolon group;" ) );
+        }
+
+        ctx.destroySubcontext( rdn );
+    }
+
+
+    /**
+     * adding an entry with equals sign (=) in RDN.
+     * 
+     * @throws NamingException 
+     */
+    @Test
+    public void testAddingWithEqualsInRdn() throws Exception
+    {
+        DirContext ctx = ( DirContext ) ServerIntegrationUtils.getWiredContext( ldapServer ).lookup( "ou=system" );
+
+        Attributes attrs = getOrgUnitAttributes( "nomen=omen" );
+        String rdn = "ou=nomen\\=omen";
+        ctx.createSubcontext( rdn, attrs );
+
+        SearchControls sctls = new SearchControls();
+        sctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+
+        NamingEnumeration<SearchResult> enm = ctx.search( "", "(ou=nomen=omen)", sctls );
+        assertEquals( "entry found", true, enm.hasMore() );
+
+        while ( enm.hasMore() )
+        {
+            SearchResult sr = enm.next();
+            attrs = sr.getAttributes();
+            Attribute ou = sr.getAttributes().get( "ou" );
+            assertNotNull( ou );
+            assertTrue( ou.contains( "nomen=omen" ) );
+        }
+
+        ctx.destroySubcontext( rdn );
+    }
+}
\ No newline at end of file

Modified: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java?rev=682572&r1=682571&r2=682572&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java Mon Aug  4 20:22:31 2008
@@ -47,7 +47,6 @@
 
 import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredConnection;
 import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContextThrowOnRefferal;
-import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContextFollowOnRefferal;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -86,7 +85,7 @@
     "uid: akarasuluref\n" +
     "ref: ldap://localhost:10389/uid=akarasulu,ou=users,ou=system\n" + 
     "ref: ldap://foo:10389/uid=akarasulu,ou=users,ou=system\n" +
-    "ref: ldap://bar:10389/uid=akarasulu,ou=users,ou=system\n\n" 
+    "ref: ldap://bar:10389/uid=akarasulu,ou=users,ou=system\n\n"
     }
 )
 public class CompareIT
@@ -269,44 +268,6 @@
             assertEquals( "no permission exception", 50, e.getLDAPResultCode() );
         }
     }
-
-
-    /**
-     * Tests compare operation on normal and referral entries without the 
-     * ManageDsaIT control using JNDI while chasing referrals instead of 
-     * the Netscape API. Referrals are sent back to the client with a 
-     * non-success result code.
-     */
-    @Test
-    public void testFollowOnReferralWithJndi() throws Exception
-    {
-        LdapContext ctx = getWiredContextFollowOnRefferal( ldapServer );
-        SearchControls controls = new SearchControls();
-        controls.setReturningAttributes( new String[0] );
-        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
-        
-        // comparison success
-        NamingEnumeration<SearchResult> answer = ctx.search( "uid=akarasulu,ou=users,ou=system", 
-            "(uid=akarasulu)", controls );
-        assertTrue( answer.hasMore() );
-        SearchResult result = answer.next();
-        assertEquals( "", result.getName() );
-        assertEquals( 0, result.getAttributes().size() );
-        assertFalse( answer.hasMore() );
-        answer.close();
-
-        // referrals follow
-        answer = ctx.search( "uid=akarasuluref,ou=users,ou=system", 
-            "(uid=akarasulu)", controls );
-
-        assertTrue( answer.hasMore() );
-        result = answer.next();
-        assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", result.getName() );
-        assertEquals( 0, result.getAttributes().size() );
-        assertFalse( answer.hasMore() );
-        answer.close();
-        ctx.close();
-    }
     
     
     /**

Modified: directory/apacheds/branches/bigbang/server-integ/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/resources/log4j.properties?rev=682572&r1=682571&r2=682572&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/resources/log4j.properties (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/resources/log4j.properties Mon Aug  4 20:22:31 2008
@@ -28,3 +28,5 @@
 log4j.logger.org.apache.directory.server.schema=ERROR
 log4j.logger.org.apache.directory.server.referral.ReferralIT=DEBUG
 log4j.logger.org.apache.directory.server.operations=DEBUG
+log4j.logger.org.apache.directory.shared.asn1.ber=WARN
+log4j.logger.org.apache.directory.shared.ldap.codec=WARN