directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r725712 [7/9] - in /directory: apacheds/trunk/ apacheds/trunk/all/ apacheds/trunk/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/ apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltr...
Date Thu, 11 Dec 2008 15:32:12 GMT
Modified: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java (original)
+++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java Thu Dec 11 07:32:04 2008
@@ -20,6 +20,8 @@
 
 
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.mina.transport.socket.DatagramAcceptor;
+import org.apache.mina.transport.socket.SocketAcceptor;
 
 import java.util.Collections;
 import java.util.HashSet;
@@ -39,11 +41,51 @@
     private boolean enabled;
     private String serviceId;
     private String serviceName;
+    
+    /** The server IP address */
     private String ipAddress;
+    
+    /** The service's port, if there is only one (TCP or UDP) */
     private int ipPort = -1;
+    
+    /** The TCP port, if defined. */
+    private int tcpPort = -1;
+    
+    /** The UDP port, if defined. */
+    private int udpPort = -1;
+    
     private Set<TransportProtocol> transportProtocols;
+    
+    /** The IoAcceptor used to accept UDP requests */
     private DatagramAcceptor datagramAcceptor;
+    
+    /** The IoAcceptor used to accept TCP requests */
     private SocketAcceptor socketAcceptor;
+    
+    /** The number of threads to use for the IoAcceptor executor */
+    private int nbThreads;
+    
+    /** 
+     * The number of threads to use for the TCP transport
+     * protocol based IoAcceptor executor 
+     **/
+    private int nbTcpThreads;
+    
+    /** 
+     * The number of threads to use for the UDP transport
+     * protocol based IoAcceptor executor 
+     **/
+    private int nbUdpThreads;
+    
+    /** The backlog for all the transport services */
+    private int ipBacklog;
+    
+    /** The backlog for the TCP transport services */
+    private int tcpBacklog;
+    
+    /** The backlog for the UDP transport services */
+    private int udpBacklog;
+    
     /** directory service core where protocol data is backed */
     private DirectoryService directoryService;
 
@@ -120,23 +162,79 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public int getIpPort()
     {
         return ipPort;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
+    public int getTcpPort()
+    {
+        return tcpPort;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getUdpPort()
+    {
+        return udpPort;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
     public void setIpPort( int ipPort )
     {
-        if ( ipPort < 0 || ipPort > 65535 )
+        if ( ( ipPort < 0 ) || ( ipPort > 65535 ) )
         {
             throw new IllegalArgumentException( "Invalid port number: " + ipPort );
         }
 
         this.ipPort = ipPort;
+        
+        // Now, substitute the existing values by the new one
+         udpPort = ipPort;
+         tcpPort = ipPort;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
+    public void setTcpPort( int tcpPort )
+    {
+        if ( ( tcpPort < 0 ) || ( tcpPort > 65535 ) )
+        {
+            throw new IllegalArgumentException( "Invalid port number: " + tcpPort );
+        }
+
+        this.tcpPort = tcpPort;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void setUdpPort( int udpPort )
+    {
+        if ( ( udpPort < 0 ) || ( udpPort > 65535 ) )
+        {
+            throw new IllegalArgumentException( "Invalid port number: " + udpPort );
+        }
+
+        this.udpPort = udpPort;
+    }
+
+    
     public Set<TransportProtocol> getTransportProtocols()
     {
         return transportProtocols;
@@ -151,26 +249,160 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public DatagramAcceptor getDatagramAcceptor()
     {
         return datagramAcceptor;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setDatagramAcceptor( DatagramAcceptor datagramAcceptor )
     {
         this.datagramAcceptor = datagramAcceptor;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public SocketAcceptor getSocketAcceptor()
     {
         return socketAcceptor;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setSocketAcceptor( SocketAcceptor socketAcceptor )
     {
         this.socketAcceptor = socketAcceptor;
     }
+
+    
+    /**
+     * @return The number of thread used in the IoAcceptor executor. It is
+     * used if no specific transport protocol is defined, and will be
+     * overloaded by the specific NbUdpThreads or nbTcpThreads if those
+     * transport protocols are defined.
+     */
+    public int getNbThreads() 
+    {
+        return nbThreads;
+    }
+
+
+    /**
+     * @return The number of thread used in the IoAcceptor executor for
+     * a TCP transport protocol based Acceptor.
+     */
+    public int getNbTcpThreads() 
+    {
+        return nbTcpThreads;
+    }
+
+
+    /**
+     * @return The number of thread used in the IoAcceptor executor for
+     * a UDP transport protocol based Acceptor.
+     */
+    public int getNbUdpThreads() 
+    {
+        return nbUdpThreads;
+    }
+
+
+    /**
+     * @param nbThreads The number of thread to affect to the IoAcceptor
+     * executor. This number will be injected into the UDP and TCP
+     * nbThreads value.
+     */
+    public void setNbThreads(int nbThreads) 
+    {
+        this.nbThreads = nbThreads;
+        this.nbTcpThreads = nbThreads;
+        this.nbUdpThreads = nbThreads;
+    }
+
+
+    /**
+     * @param nbThreads The number of thread to affect to the 
+     * TCP transport protocol based IoAcceptor executor
+     */
+    public void setNbTcpThreads(int nbTcpThreads) 
+    {
+        this.nbTcpThreads = nbTcpThreads;
+    }
+
+
+    /**
+     * @param nbThreads The number of thread to affect to the 
+     * UDP transport protocol based IoAcceptor executor
+     */
+    public void setNbUdpThreads(int nbUdpThreads) 
+    {
+        this.nbUdpThreads = nbUdpThreads;
+    }
+
+
+    /**
+     * @return the ipBacklog
+     */
+    public int getIpBacklog() {
+        return ipBacklog;
+    }
+
+
+    /**
+     * @param ipBacklog the ipBacklog to set
+     */
+    public void setIpBacklog(int ipBacklog) {
+        if ( ipBacklog < 0  )
+        {
+            throw new IllegalArgumentException( "Invalid backlog number: " + ipBacklog );
+        }
+
+        this.ipBacklog = ipBacklog;
+        
+        // Now, substitute the existing values by the new one
+        tcpBacklog = ipBacklog;
+        udpBacklog = ipBacklog;
+    }
+
+
+    /**
+     * @return the tcpBacklog
+     */
+    public int getTcpBacklog() {
+        return tcpBacklog;
+    }
+
+
+    /**
+     * @param tcpBacklog the tcpBacklog to set
+     */
+    public void setTcpBacklog(int tcpBacklog) {
+        this.tcpBacklog = tcpBacklog;
+    }
+
+
+    /**
+     * @return the udpBacklog
+     */
+    public int getUdpBacklog() {
+        return udpBacklog;
+    }
+
+
+    /**
+     * @param udpBacklog the udpBacklog to set
+     */
+    public void setUdpBacklog(int udpBacklog) {
+        this.udpBacklog = udpBacklog;
+    }
 }

Modified: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ProtocolService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ProtocolService.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ProtocolService.java (original)
+++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ProtocolService.java Thu Dec 11 07:32:04 2008
@@ -20,6 +20,8 @@
 
 
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.mina.transport.socket.DatagramAcceptor;
+import org.apache.mina.transport.socket.SocketAcceptor;
 
 import java.util.Set;
 
@@ -66,15 +68,6 @@
 
 
     /**
-     * If this protocol service supports UDP transport then this sets the
-     * MINA DatagramAcceptor it uses.
-     *
-     * @param datagramAcceptor the MINA DatagramAcceptor used for UDP transport
-     */
-    void setDatagramAcceptor( DatagramAcceptor datagramAcceptor );
-
-
-    /**
      * If this protocol service support TCP transport then this gets the
      * MINA SocketAcceptor it uses.
      *
@@ -84,15 +77,6 @@
 
 
     /**
-     * If this protocol service support TCP transport then this sets the
-     * MINA SocketAcceptor it uses.
-     *
-     * @param socketAcceptor the MINA SocketAcceptor used for TCP transport
-     */
-    void setSocketAcceptor( SocketAcceptor socketAcceptor );
-
-
-    /**
      * Services can be enabled or disabled. If enabled they will be started, if
      * not they will not.
      *
@@ -160,7 +144,9 @@
 
 
     /**
-     * Gets the IP port for this service.
+     * Gets the IP port for this service. This is just a temporary
+     * storage for the service port, as we will move it to either
+     * TCP or UDP port.
      *
      * @return the IP port for this service
      */
@@ -168,6 +154,22 @@
 
 
     /**
+     * Gets the UDP port for this service.
+     *
+     * @return the UDP port for this service
+     */
+    int getUdpPort();
+
+
+    /**
+     * Gets the TCP port for this service.
+     *
+     * @return the TCP port for this service
+     */
+    int getTcpPort();
+
+
+    /**
      * Sets the IP port for this service.
      *
      * @param ipPort the ip port for this service
@@ -177,6 +179,24 @@
 
 
     /**
+     * Sets the UDP port for this service.
+     *
+     * @param ipPort the udp port for this service
+     * @throws IllegalArgumentException if the port number is not within a valid range
+     */
+    void setUdpPort( int udpPort );
+
+
+    /**
+     * Sets the TCP port for this service.
+     *
+     * @param tcpPort the tcp port for this service
+     * @throws IllegalArgumentException if the port number is not within a valid range
+     */
+    void setTcpPort( int tcpPort );
+
+
+    /**
      * Gets the transport protocols used by this service. At this point services
      * which support more than one transport are configured to bind to that transport
      * on the same port.

Modified: directory/apacheds/trunk/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java (original)
+++ directory/apacheds/trunk/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java Thu Dec 11 07:32:04 2008
@@ -78,8 +78,10 @@
 
     /** stores schemas of producers for callback access */
     private ThreadLocal<BootstrapSchema> schemas;
+    
     /** stores registries associated with producers for callback access */
     private ThreadLocal<Registries> registries;
+    
     /** the callback that just calls register() */
     private final ProducerCallback cb = new ProducerCallback()
     {
@@ -151,7 +153,8 @@
         notLoaded.remove( schema.getSchemaName() ); // Remove if user specified it.
         loaded.put( schema.getSchemaName(), schema );
 
-        Iterator list = notLoaded.values().iterator();
+        Iterator<Schema> list = notLoaded.values().iterator();
+        
         while ( list.hasNext() )
         {
             schema = ( BootstrapSchema ) list.next();
@@ -185,10 +188,19 @@
         this.registries.set( registries );
         this.schemas.set( ( BootstrapSchema ) schema );
 
-        for ( ProducerTypeEnum producerType:ProducerTypeEnum.getList() )
+        try
+        {
+            for ( ProducerTypeEnum producerType:ProducerTypeEnum.getList() )
+            {
+                BootstrapProducer producer = getProducer( ( BootstrapSchema ) schema, producerType.getName() );
+                producer.produce( registries, cb );
+            }
+        }
+        finally
         {
-            BootstrapProducer producer = getProducer( ( BootstrapSchema ) schema, producerType.getName() );
-            producer.produce( registries, cb );
+            // Don't forget to release the ThreadLocal variables when done !
+            this.registries.set( null );
+            this.schemas.set( null );
         }
 
         notifyListenerOrRegistries( schema, registries );

Modified: directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultRegistries.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultRegistries.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultRegistries.java (original)
+++ directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultRegistries.java Thu Dec 11 07:32:04 2008
@@ -542,7 +542,7 @@
     }
     
 
-    public SchemaLoader setSchemaLoader()
+    public SchemaLoader getSchemaLoader()
     {
         return schemaLoader;
     }

Modified: directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/Registries.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/Registries.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/Registries.java (original)
+++ directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/Registries.java Thu Dec 11 07:32:04 2008
@@ -45,7 +45,7 @@
 
     void unload( String schemaName ) throws Exception;
     
-    SchemaLoader setSchemaLoader();
+    SchemaLoader getSchemaLoader();
     
     AttributeTypeRegistry getAttributeTypeRegistry();
     

Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java (original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java Thu Dec 11 07:32:04 2008
@@ -34,8 +34,8 @@
 import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StartTlsHandler;
 import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
-import org.apache.directory.server.protocol.shared.SocketAcceptor;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.apache.mina.util.AvailablePortFinder;
 
 
@@ -69,8 +69,9 @@
 
             LdapService ldapService = new LdapService();
             ldapService.setDirectoryService( service );
-            ldapService.setSocketAcceptor( new SocketAcceptor( null ) );
+            ldapService.setSocketAcceptor( new NioSocketAcceptor() );
             ldapService.setIpPort( AvailablePortFinder.getNextAvailable( 1024 ) );
+            ldapService.setNbTcpThreads( 3 );
             ldapService.addExtendedOperationHandler( new StartTlsHandler() );
             ldapService.addExtendedOperationHandler( new StoredProcedureExtendedOperationHandler() );
 

Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/NonExistentState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/NonExistentState.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/NonExistentState.java (original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/NonExistentState.java Thu Dec 11 07:32:04 2008
@@ -83,6 +83,7 @@
         }
         catch ( Exception e )
         {
+            e.printStackTrace();
             throw new NamingException( e.getMessage() );
         }
     }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/KeyDerivationServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/KeyDerivationServiceIT.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/KeyDerivationServiceIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/KeyDerivationServiceIT.java Thu Dec 11 07:32:04 2008
@@ -49,8 +49,8 @@
 import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmMechanismHandler;
 import org.apache.directory.server.ldap.handlers.bind.plain.PlainMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
-import org.apache.directory.server.protocol.shared.SocketAcceptor;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.apache.mina.util.AvailablePortFinder;
 import org.junit.Before;
 import org.junit.Test;
@@ -142,10 +142,11 @@
 
              LdapService ldapService = new LdapService();
              ldapService.setDirectoryService( service );
-             ldapService.setSocketAcceptor( new SocketAcceptor( null ) );
+             ldapService.setSocketAcceptor( new NioSocketAcceptor() );
              ldapService.setIpPort( AvailablePortFinder.getNextAvailable( 1024 ) );
              ldapService.setAllowAnonymousAccess( false );
              ldapService.addExtendedOperationHandler( new StoredProcedureExtendedOperationHandler() );
+             ldapService.setNbTcpThreads( 3 );
 
              // Setup SASL Mechanisms
              

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/PasswordPolicyServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/PasswordPolicyServiceIT.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/PasswordPolicyServiceIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/PasswordPolicyServiceIT.java Thu Dec 11 07:32:04 2008
@@ -44,8 +44,8 @@
 import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmMechanismHandler;
 import org.apache.directory.server.ldap.handlers.bind.plain.PlainMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
-import org.apache.directory.server.protocol.shared.SocketAcceptor;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.apache.mina.util.AvailablePortFinder;
 import org.junit.After;
 import org.junit.Before;
@@ -131,8 +131,9 @@
 
             LdapService ldapService = new LdapService();
             ldapService.setDirectoryService( service );
-            ldapService.setSocketAcceptor( new SocketAcceptor( null ) );
+            ldapService.setSocketAcceptor( new NioSocketAcceptor() );
             ldapService.setIpPort( AvailablePortFinder.getNextAvailable( 1024 ) );
+            ldapService.setNbTcpThreads( 3 );
             ldapService.setAllowAnonymousAccess( false );
             ldapService.addExtendedOperationHandler( new StoredProcedureExtendedOperationHandler() );
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java Thu Dec 11 07:32:04 2008
@@ -763,14 +763,14 @@
     public void testDIRSERVER_1183() throws Exception
     {
         LdapContext ctx = ( LdapContext ) getWiredContext( ldapService ).lookup( BASE );
-    	Attributes attrs = new BasicAttributes( "objectClass", "inetOrgPerson", true );
-    	attrs.get( "objectClass" ).add( "organizationalPerson" );
-    	attrs.get( "objectClass" ).add( "person" );
-    	attrs.put( "givenName", "Jim" );
-    	attrs.put( "sn", "Bean" );
-    	attrs.put( "cn", "\"Jim, Bean\"" );
-    	
-    	ctx.createSubcontext( "cn=\"Jim, Bean\"", attrs );
+        Attributes attrs = new BasicAttributes( "objectClass", "inetOrgPerson", true );
+        attrs.get( "objectClass" ).add( "organizationalPerson" );
+        attrs.get( "objectClass" ).add( "person" );
+        attrs.put( "givenName", "Jim" );
+        attrs.put( "sn", "Bean" );
+        attrs.put( "cn", "\"Jim, Bean\"" );
+        
+        ctx.createSubcontext( "cn=\"Jim, Bean\"", attrs );
     }
 
 
@@ -942,4 +942,73 @@
         assertTrue( cn.contains( "Jackson" ) );
         assertTrue( cn.contains( "Michael" ) );
     }
+
+
+    /**
+     * Test that if we inject a PDU above the max allowed size,
+     * the connection is closed. 
+     * 
+     * @throws NamingException 
+     */
+    @Test
+    public void testAddPDUExceedingMaxSize() throws Exception
+    {
+        // Limit the PDU size to 1024
+        ldapService.getDirectoryService().setMaxPDUSize( 1024 );
+        DirContext ctx = ( DirContext ) getWiredContext( ldapService ).lookup( BASE );
+
+        // modify object classes, add two more
+        Attributes attributes = new BasicAttributes( true );
+        Attribute ocls = new BasicAttribute( "description" );
+        
+        // Inject a 1024 bytes long description
+        StringBuilder sb = new StringBuilder();
+        
+        for ( int i = 0; i < 128; i++ )
+        {
+            sb.append( "0123456789ABCDEF" );
+        }
+        
+        ocls.add( sb.toString() );
+        attributes.put( ocls );
+
+        DirContext person = ( DirContext ) ctx.lookup( RDN );
+        
+        try
+        {
+            person.modifyAttributes( "", DirContext.ADD_ATTRIBUTE, attributes );
+            fail();
+        }
+        catch ( Exception e )
+        {
+            // We are expecting the session to be close here.
+        }
+        
+        // Test again with a bigger size
+        // Limit the PDU size to 1024
+        ldapService.getDirectoryService().setMaxPDUSize( 4096 );
+        
+        ctx = ( DirContext ) getWiredContext( ldapService ).lookup( BASE );
+        person = ( DirContext ) ctx.lookup( RDN );
+        
+        try
+        {
+            person.modifyAttributes( "", DirContext.ADD_ATTRIBUTE, attributes );
+        }
+        catch ( Exception e )
+        {
+            // We should not go there
+            fail();
+        }
+
+        // Read again from directory
+        ctx = ( DirContext ) getWiredContext( ldapService ).lookup( BASE );
+        person = ( DirContext ) ctx.lookup( RDN );
+        
+        assertNotNull( person );
+        attributes = person.getAttributes( "" );
+        Attribute newOcls = attributes.get( "objectClass" );
+
+        assertNotNull( newOcls );
+    }
 }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java Thu Dec 11 07:32:04 2008
@@ -56,12 +56,12 @@
 import org.apache.directory.server.ldap.handlers.bind.gssapi.GssapiMechanismHandler;
 import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
-import org.apache.directory.server.protocol.shared.SocketAcceptor;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
 import org.apache.directory.shared.asn1.util.Asn1StringUtils;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
 import org.apache.directory.shared.ldap.message.MutableControl;
 import org.apache.directory.shared.ldap.util.ArrayUtils;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.apache.mina.util.AvailablePortFinder;
 import org.junit.After;
 import org.junit.Before;
@@ -122,8 +122,9 @@
 
             LdapService ldapService = new LdapService();
             ldapService.setDirectoryService( service );
-            ldapService.setSocketAcceptor( new SocketAcceptor( null ) );
+            ldapService.setSocketAcceptor( new NioSocketAcceptor() );
             ldapService.setIpPort( AvailablePortFinder.getNextAvailable( 1024 ) );
+            ldapService.setNbTcpThreads( 3 );
             ldapService.setAllowAnonymousAccess( true );
             ldapService.addExtendedOperationHandler( new StoredProcedureExtendedOperationHandler() );
 
@@ -201,8 +202,8 @@
             }
             catch ( Exception e )
             {
-            	// We should not get here
-            	fail();
+                // We should not get here
+                fail();
             }
         }
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java Thu Dec 11 07:32:04 2008
@@ -59,7 +59,6 @@
 import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmProvider;
 import org.apache.directory.server.ldap.handlers.bind.plain.PlainMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
-import org.apache.directory.server.protocol.shared.SocketAcceptor;
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
 import org.apache.directory.shared.ldap.message.BindRequestImpl;
@@ -70,7 +69,8 @@
 import org.apache.directory.shared.ldap.message.spi.BinaryAttributeDetector;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ArrayUtils;
-import org.apache.mina.common.IoSession;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.apache.mina.util.AvailablePortFinder;
 import org.junit.Before;
 import org.junit.Test;
@@ -152,8 +152,9 @@
 
              LdapService ldapService = new LdapService();
              ldapService.setDirectoryService( service );
-             ldapService.setSocketAcceptor( new SocketAcceptor( null ) );
+             ldapService.setSocketAcceptor( new NioSocketAcceptor() );
              ldapService.setIpPort( AvailablePortFinder.getNextAvailable( 1024 ) );
+             ldapService.setNbTcpThreads( 3 );
              ldapService.setAllowAnonymousAccess( false );
              ldapService.addExtendedOperationHandler( new StoredProcedureExtendedOperationHandler() );
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java Thu Dec 11 07:32:04 2008
@@ -170,7 +170,7 @@
         }
         catch ( AuthenticationException ae )
         {
-    		// Error code 49 : LDAP_INVALID_CREDENTIALS
+            // Error code 49 : LDAP_INVALID_CREDENTIALS
             assertTrue( ae.getMessage().contains( "error code 49" ) );
         }
         catch ( NamingException e )
@@ -200,8 +200,8 @@
         }
         catch ( InvalidNameException ine )
         {
-    		// Error code 34 : LDAP_INVALID_DN_SYNTAX
-        	assertTrue( ine.getMessage().startsWith( "[LDAP: error code 34 - Incorrect DN given" ) );
+            // Error code 34 : LDAP_INVALID_DN_SYNTAX
+            assertTrue( ine.getMessage().startsWith( "[LDAP: error code 34 - Incorrect DN given" ) );
         }
         catch ( NamingException e )
         {
@@ -256,47 +256,47 @@
         env.put( Context.SECURITY_CREDENTIALS, "" );
 
         String[] attrIDs = { "*", "+" };
-    	DirContext ctx = null;
-    	
-    	// Create the initial context
-    	try
-    	{
-    		ctx = new InitialDirContext(env);
-    	}
-    	catch ( NamingException ne )
-    	{
-    		fail();
-    	}
-    	
-    	// We should be anonymous here. 
-    	// Check that we can read the rootDSE
-    	try
-    	{
+        DirContext ctx = null;
+        
+        // Create the initial context
+        try
+        {
+            ctx = new InitialDirContext(env);
+        }
+        catch ( NamingException ne )
+        {
+            fail();
+        }
+        
+        // We should be anonymous here. 
+        // Check that we can read the rootDSE
+        try
+        {
             Attributes attrs = ctx.getAttributes( "", attrIDs );
-    		
-    		assertNotNull( attrs );
-    		assertEquals( "Apache Software Foundation", attrs.get( "vendorName" ).get() );
-    	}
-    	catch ( NamingException ne )
-    	{
-    		fail();
-    	}
-
-    	// Check that we cannot read another entry being anonymous
-    	try
-    	{
+            
+            assertNotNull( attrs );
+            assertEquals( "Apache Software Foundation", attrs.get( "vendorName" ).get() );
+        }
+        catch ( NamingException ne )
+        {
+            fail();
+        }
+
+        // Check that we cannot read another entry being anonymous
+        try
+        {
             Attributes attrs = ctx.getAttributes( "uid=admin,ou=system", attrIDs );
-    		
-    		assertNotNull( attrs );
-    		assertEquals( 0, attrs.size() );
+            
+            assertNotNull( attrs );
+            assertEquals( 0, attrs.size() );
             fail( "Should not be able to read the root DSE" );
-    	}
-    	catch ( NamingException ne )
-    	{
-    	}
-    	
-    	ldapService.getDirectoryService().setAllowAnonymousAccess( oldValue );
-    	ldapService.setAllowAnonymousAccess( oldValue );
+        }
+        catch ( NamingException ne )
+        {
+        }
+        
+        ldapService.getDirectoryService().setAllowAnonymousAccess( oldValue );
+        ldapService.setAllowAnonymousAccess( oldValue );
     }
     
     
@@ -314,19 +314,19 @@
         env.put( Context.SECURITY_CREDENTIALS, "" );
 
         // Create the initial context
-    	try
-    	{
-    		new InitialDirContext(env);
-    	}
-    	catch ( OperationNotSupportedException onse )
-    	{
-    		// Error code 53 : LDAP_UNWILLING_TO_PERFORM
-    		assertTrue( onse.getMessage().contains( "error code 53" ) );
-    	}
-    	catch ( NamingException ne )
-    	{
-    		fail();
-    	}
+        try
+        {
+            new InitialDirContext(env);
+        }
+        catch ( OperationNotSupportedException onse )
+        {
+            // Error code 53 : LDAP_UNWILLING_TO_PERFORM
+            assertTrue( onse.getMessage().contains( "error code 53" ) );
+        }
+        catch ( NamingException ne )
+        {
+            fail();
+        }
     }    
     
     
@@ -345,17 +345,17 @@
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
 
         // Create the initial context
-    	try
-    	{
-    		new InitialDirContext(env);
-    	}
-    	catch ( AuthenticationException ae )
-    	{
-    	}
-    	catch ( NamingException ne )
-    	{
-    		fail( "Expected AuthenticationException but instead got: " + ne.getMessage() );
-    	}
+        try
+        {
+            new InitialDirContext(env);
+        }
+        catch ( AuthenticationException ae )
+        {
+        }
+        catch ( NamingException ne )
+        {
+            fail( "Expected AuthenticationException but instead got: " + ne.getMessage() );
+        }
     }    
 
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/StoredProcedureIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/StoredProcedureIT.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/StoredProcedureIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/StoredProcedureIT.java Thu Dec 11 07:32:04 2008
@@ -37,11 +37,11 @@
 import org.apache.directory.server.ldap.handlers.bind.gssapi.GssapiMechanismHandler;
 import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
-import org.apache.directory.server.protocol.shared.SocketAcceptor;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
 import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.schema.OidNormalizer;
 import org.apache.directory.shared.ldap.sp.JavaStoredProcUtils;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.apache.mina.util.AvailablePortFinder;
 import org.junit.Before;
 import org.junit.Test;
@@ -94,8 +94,9 @@
 
             LdapService ldapService = new LdapService();
             ldapService.setDirectoryService( service );
-            ldapService.setSocketAcceptor( new SocketAcceptor( null ) );
+            ldapService.setSocketAcceptor( new NioSocketAcceptor() );
             ldapService.setIpPort( AvailablePortFinder.getNextAvailable( 1024 ) );
+            ldapService.setNbTcpThreads( 3 );
             ldapService.setEnabled( true );
             ldapService.addExtendedOperationHandler( new StoredProcedureExtendedOperationHandler() );
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java Thu Dec 11 07:32:04 2008
@@ -326,7 +326,7 @@
         }
         catch ( NoSuchAttributeException e )
         {
-        	assertTrue( true );
+            assertTrue( true );
             // expected behaviour
         }
     }
@@ -354,7 +354,7 @@
         Attribute attr2 = new BasicAttribute( "telephoneNumber", "7890" );
         Attributes attrs2 = new BasicAttributes( true );
         attrs2.put( attr2 );
-    	
+    
         ctx.modifyAttributes( RDN, DirContext.REMOVE_ATTRIBUTE, attrs2 );
         
         // We shopuld not get an exception

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java Thu Dec 11 07:32:04 2008
@@ -58,10 +58,10 @@
 import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StartTlsHandler;
 import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
-import org.apache.directory.server.protocol.shared.SocketAcceptor;
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.apache.mina.util.AvailablePortFinder;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -135,8 +135,9 @@
 
             LdapService ldapService = new LdapService();
             ldapService.setDirectoryService( service );
-            ldapService.setSocketAcceptor( new SocketAcceptor( null ) );
+            ldapService.setSocketAcceptor( new NioSocketAcceptor() );
             ldapService.setIpPort( AvailablePortFinder.getNextAvailable( 1024 ) );
+            ldapService.setNbTcpThreads( 3 );
             ldapService.addExtendedOperationHandler( new StartTlsHandler() );
             ldapService.addExtendedOperationHandler( new StoredProcedureExtendedOperationHandler() );
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/IndexedNegationSearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/IndexedNegationSearchIT.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/IndexedNegationSearchIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/IndexedNegationSearchIT.java Thu Dec 11 07:32:04 2008
@@ -44,9 +44,9 @@
 import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StartTlsHandler;
 import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
-import org.apache.directory.server.protocol.shared.SocketAcceptor;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.apache.mina.util.AvailablePortFinder;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -182,8 +182,9 @@
 
             LdapService ldapService = new LdapService();
             ldapService.setDirectoryService( service );
-            ldapService.setSocketAcceptor( new SocketAcceptor( null ) );
+            ldapService.setSocketAcceptor( new NioSocketAcceptor() );
             ldapService.setIpPort( AvailablePortFinder.getNextAvailable( 1024 ) );
+            ldapService.setNbTcpThreads( 3 );
             ldapService.addExtendedOperationHandler( new StartTlsHandler() );
             ldapService.addExtendedOperationHandler( new StoredProcedureExtendedOperationHandler() );
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java Thu Dec 11 07:32:04 2008
@@ -30,6 +30,9 @@
 import javax.naming.directory.DirContext;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
+import javax.naming.ldap.Control;
+import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.ManageReferralControl;
 
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
@@ -345,6 +348,159 @@
 
     
     /**
+     * Test of an search operation with a referral after the entry
+     * has been renamed.
+     *
+     * search for "cn=alex karasulu" on "c=usa, ou=system"
+     * we should get a referral URL thrown, which point to
+     * "c=usa, ou=system", and ask for a subtree search
+     */
+    @Test
+    public void testSearchBaseWithReferralThrowAfterRename() throws Exception
+    {
+        DirContext ctx = getWiredContextThrowOnRefferal( ldapService );
+
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+        try
+        {
+            ctx.search( "c=america,ou=Countries,ou=system", "(cn=alex karasulu)", controls );
+            fail( "Should fail here throwing a ReferralException" );
+        }
+        catch ( ReferralException re )
+        {
+            String referral = (String)re.getReferralInfo();
+            assertEquals( "ldap://localhost:" + ldapService.getIpPort() + "/c=usa,ou=system??base", referral );
+        }
+        
+        Control manageDsaItControl = new ManageReferralControl();
+        ((LdapContext)ctx).setRequestControls( new Control[]{manageDsaItControl} );
+
+        // Now let's move the entry
+        ctx.rename( "c=america,ou=Countries,ou=system", "c=USA,ou=Countries,ou=system" );
+
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+        ((LdapContext)ctx).setRequestControls( new Control[]{} );
+
+        try
+        {
+            ctx.search( "c=usa,ou=Countries,ou=system", "(cn=alex karasulu)", controls );
+            fail( "Should fail here throwing a ReferralException" );
+        }
+        catch ( ReferralException re )
+        {
+            String referral = (String)re.getReferralInfo();
+            assertEquals( "ldap://localhost:" + ldapService.getIpPort() + "/c=usa,ou=system??base", referral );
+        }
+        
+    }
+
+    
+    /**
+     * Test of an search operation with a referral after the entry
+     * has been moved.
+     *
+     * search for "cn=alex karasulu" on "c=america, ou=system"
+     * we should get a referral URL thrown, which point to
+     * "c=usa, ou=system", and ask for a subtree search
+     */
+    @Test
+    public void testSearchBaseWithReferralThrowAfterMove() throws Exception
+    {
+        DirContext ctx = getWiredContextThrowOnRefferal( ldapService );
+
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+        try
+        {
+            ctx.search( "c=america,ou=Countries,ou=system", "(cn=alex karasulu)", controls );
+            fail( "Should fail here throwing a ReferralException" );
+        }
+        catch ( ReferralException re )
+        {
+            String referral = (String)re.getReferralInfo();
+            assertEquals( "ldap://localhost:" + ldapService.getIpPort() + "/c=usa,ou=system??base", referral );
+        }
+        
+        Control manageDsaItControl = new ManageReferralControl();
+        ((LdapContext)ctx).setRequestControls( new Control[]{manageDsaItControl} );
+
+        // Now let's move the entry
+        ctx.rename( "c=america,ou=Countries,ou=system", "c=america,ou=system" );
+
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+        ((LdapContext)ctx).setRequestControls( new Control[]{} );
+
+        try
+        {
+            ctx.search( "c=america,ou=system", "(cn=alex karasulu)", controls );
+            fail( "Should fail here throwing a ReferralException" );
+        }
+        catch ( ReferralException re )
+        {
+            String referral = (String)re.getReferralInfo();
+            assertEquals( "ldap://localhost:" + ldapService.getIpPort() + "/c=usa,ou=system??base", referral );
+        }
+        
+    }
+
+    
+    /**
+     * Test of an search operation with a referral after the entry
+     * has been moved.
+     *
+     * search for "cn=alex karasulu" on "c=usa, ou=system"
+     * we should get a referral URL thrown, which point to
+     * "c=usa, ou=system", and ask for a subtree search
+     */
+    @Test
+    public void testSearchBaseWithReferralThrowAfterMoveAndRename() throws Exception
+    {
+        DirContext ctx = getWiredContextThrowOnRefferal( ldapService );
+
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+        try
+        {
+            ctx.search( "c=america,ou=Countries,ou=system", "(cn=alex karasulu)", controls );
+            fail( "Should fail here throwing a ReferralException" );
+        }
+        catch ( ReferralException re )
+        {
+            String referral = (String)re.getReferralInfo();
+            assertEquals( "ldap://localhost:" + ldapService.getIpPort() + "/c=usa,ou=system??base", referral );
+        }
+        
+        Control manageDsaItControl = new ManageReferralControl();
+        ((LdapContext)ctx).setRequestControls( new Control[]{manageDsaItControl} );
+
+        // Now let's move the entry
+        ctx.rename( "c=america,ou=Countries,ou=system", "c=us,ou=system" );
+
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+        ((LdapContext)ctx).setRequestControls( new Control[]{} );
+
+        try
+        {
+            ctx.search( "c=us,ou=system", "(cn=alex karasulu)", controls );
+            fail( "Should fail here throwing a ReferralException" );
+        }
+        catch ( ReferralException re )
+        {
+            String referral = (String)re.getReferralInfo();
+            assertEquals( "ldap://localhost:" + ldapService.getIpPort() + "/c=usa,ou=system??base", referral );
+        }
+        
+    }
+
+    
+    /**
      * Test of an search operation with a referral
      *
      * search for "cn=alex karasulu" on "c=america, ou=system"

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java Thu Dec 11 07:32:04 2008
@@ -1377,8 +1377,8 @@
 
         result.close();
     }
-
-
+   
+    
     @Test
     public void testSubstringSearchWithEscapedCharsInFilter() throws Exception
     {
@@ -1447,7 +1447,7 @@
         }
     }
 
-
+    
     @Test
     public void testSubstringSearchWithEscapedAsterisksInFilter_DIRSERVER_1181() throws Exception
     {
@@ -1479,5 +1479,4 @@
         assertEquals( "x*y*z*", res.next().getAttributes().get( "cn" ).get() );
         assertFalse( res.hasMore() );
     }
-
 }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java Thu Dec 11 07:32:04 2008
@@ -33,7 +33,10 @@
 import org.apache.directory.server.core.interceptor.context.SearchingOperationContext;
 import org.apache.directory.server.integ.SiRunner;
 import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContext;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 
 import org.apache.directory.server.ldap.LdapService;
 import org.junit.After;
@@ -200,7 +203,7 @@
         ldapService.setMaxTimeLimit( LdapService.NO_TIME_LIMIT );
         delayInterceptor.setDelayMillis( 500 );
         
-        getActorsWithLimit( "(objectClass=*)", 499, 0 );
+        getActorsWithLimit( "(objectClass=*)", 499, LdapService.NO_SIZE_LIMIT );
     }
     
 
@@ -215,7 +218,7 @@
         ldapService.setMaxTimeLimit( 10000 ); // this is in seconds
         delayInterceptor.setDelayMillis( 500 );
         
-        getActorsWithLimit( "(objectClass=*)", 499, 0 );
+        getActorsWithLimit( "(objectClass=*)", 499, LdapService.NO_SIZE_LIMIT );
     }
 
     
@@ -230,7 +233,7 @@
         ldapService.setMaxTimeLimit( 1 ); // this is in seconds
         delayInterceptor.setDelayMillis( 1100 );
         
-        getActorsWithLimit( "(objectClass=*)", 100000, 0 );
+        getActorsWithLimit( "(objectClass=*)", 100000, LdapService.NO_SIZE_LIMIT );
     }
 
     
@@ -244,7 +247,8 @@
         ldapService.setMaxTimeLimit( 1 ); // this is in seconds
         delayInterceptor.setDelayMillis( 500 );
         
-        getActorsWithLimit( "(objectClass=*)", 0, 0 );
+        getActorsWithLimit( "(objectClass=*)", 
+            LdapService.NO_TIME_LIMIT, LdapService.NO_SIZE_LIMIT );
     }
 
     
@@ -258,7 +262,8 @@
         ldapService.setMaxTimeLimit( 1 ); // this is in seconds
         delayInterceptor.setDelayMillis( 500 );
         
-        getActorsWithLimitNonAdmin( "(objectClass=*)", 0, 0 );
+        getActorsWithLimitNonAdmin( "(objectClass=*)", 
+            LdapService.NO_TIME_LIMIT, LdapService.NO_SIZE_LIMIT );
     }
     
     
@@ -272,11 +277,20 @@
      * by request size limit value to cause a size limit exceeded exception on
      * the client.
      */
-    @Test ( expected = SizeLimitExceededException.class )
+    @Test
     public void testRequestConstrainedUnlimitByConfigurationSize() throws Exception
     {
         ldapService.setMaxSizeLimit( LdapService.NO_SIZE_LIMIT );
-        getActorsWithLimit( "(objectClass=*)", 0,  1 );
+        
+        try
+        {
+            getActorsWithLimit( "(objectClass=*)", LdapService.NO_TIME_LIMIT, 1 );
+            assertTrue( true );
+        }
+        catch ( SizeLimitExceededException slee )
+        {
+            fail();
+        }
     }
     
 
@@ -285,11 +299,19 @@
      * which constrains size by request size limit value to cause a size limit 
      * exceeded exception on the client.
      */
-    @Test ( expected = SizeLimitExceededException.class )
+    @Test
     public void testRequestConstrainedLessThanConfigurationSize() throws Exception
     {
         ldapService.setMaxSizeLimit( 10000 ); 
-        getActorsWithLimit( "(objectClass=*)", 0, 1 );
+
+        try
+        {
+            getActorsWithLimit( "(objectClass=*)", LdapService.NO_TIME_LIMIT, 1 );
+        }
+        catch ( SizeLimitExceededException slee )
+        {
+            fail();
+        }
     }
 
 
@@ -302,7 +324,7 @@
     public void testRequestConstrainedGreaterThanConfigurationSize() throws Exception
     {
         ldapService.setMaxSizeLimit( 1 ); 
-        Set<String> set = getActorsWithLimit( "(objectClass=*)", 0, 100000 );
+        Set<String> set = getActorsWithLimit( "(objectClass=*)", LdapService.NO_TIME_LIMIT, 100000 );
         assertEquals( 4, set.size() );
     }
 
@@ -312,11 +334,13 @@
      * which constrains size by using server max limit value to cause a size 
      * limit exceeded exception on the client.
      */
-    @Test ( expected = SizeLimitExceededException.class )
+    @Test (expected = SizeLimitExceededException.class ) 
     public void testNonAdminRequestConstrainedGreaterThanConfigurationSize() throws Exception
     {
         ldapService.setMaxSizeLimit( 1 ); 
-        getActorsWithLimitNonAdmin( "(objectClass=*)", 0, 100000 );
+        
+        // We are not using the admin : it should fail
+        getActorsWithLimitNonAdmin( "(objectClass=*)", LdapService.NO_TIME_LIMIT, 100000 );
     }
 
     
@@ -328,7 +352,9 @@
     public void testRequestUnlimitedConfigurationLimitedSize() throws Exception
     {
         ldapService.setMaxSizeLimit( 1 ); 
-        Set<String> set = getActorsWithLimit( "(objectClass=*)", 0, 0 );
+        Set<String> set = getActorsWithLimit( "(objectClass=*)", 
+            LdapService.NO_TIME_LIMIT, LdapService.NO_SIZE_LIMIT );
+        
         assertEquals( 4, set.size() );
     }
 
@@ -340,8 +366,9 @@
     @Test ( expected = SizeLimitExceededException.class ) 
     public void testNonAdminRequestUnlimitedConfigurationLimitedSize() throws Exception
     {
-        ldapService.setMaxSizeLimit( 1 ); // this is in seconds
-        getActorsWithLimitNonAdmin( "(objectClass=*)", 0, 0 );
+        ldapService.setMaxSizeLimit( 1 );
+        getActorsWithLimitNonAdmin( "(objectClass=*)", 
+            LdapService.NO_TIME_LIMIT, LdapService.NO_SIZE_LIMIT );
     }
 
 
@@ -350,12 +377,18 @@
      * Sets up the server with unlimited search size limit but constrains size
      * by request size limit value. The request size limit is less than the
      * expected number of result entries, so exception expected.
+     * 
+     * cf RFC 4511 :
+     *  "sizeLimitExceeded (4)
+     *   Indicates that the size limit specified by the client was
+     *   exceeded before the operation could be completed."
      */
-    @Test(expected = SizeLimitExceededException.class)
+    @Test ( expected = SizeLimitExceededException.class )
     public void testRequestConstraintedLessThanExpectedSize() throws Exception
     {
         ldapService.setMaxSizeLimit( LdapService.NO_SIZE_LIMIT );
-        getActorsWithLimit( "(objectClass=*)", 0, 3 );
+        
+        getActorsWithLimit( "(objectClass=*)", LdapService.NO_TIME_LIMIT, 3 );
     }
 
 
@@ -369,7 +402,7 @@
     public void testRequestConstraintedEqualToExpectedSize() throws Exception
     {
         ldapService.setMaxSizeLimit( LdapService.NO_SIZE_LIMIT );
-        Set<String> set = getActorsWithLimit( "(objectClass=*)", 0, 4 );
+        Set<String> set = getActorsWithLimit( "(objectClass=*)", LdapService.NO_TIME_LIMIT, 4 );
         assertEquals( 4, set.size() );
     }
 
@@ -384,7 +417,7 @@
     public void testRequestConstraintedGreaterThanExpectedSize() throws Exception
     {
         ldapService.setMaxSizeLimit( LdapService.NO_SIZE_LIMIT );
-        Set<String> set = getActorsWithLimit( "(objectClass=*)", 0, 5 );
+        Set<String> set = getActorsWithLimit( "(objectClass=*)", LdapService.NO_TIME_LIMIT, 5 );
         assertEquals( 4, set.size() );
     }
 
@@ -406,7 +439,8 @@
         controls.setCountLimit( 1 );
         controls.setSearchScope( SearchControls.OBJECT_SCOPE );
 
-        NamingEnumeration<SearchResult> namingEnumeration = ctx.search( "ou=actors,ou=system", filter, controls );
+        NamingEnumeration<SearchResult> namingEnumeration = 
+            ctx.search( "ou=actors,ou=system", filter, controls );
         assertTrue( namingEnumeration.hasMore() );
         namingEnumeration.next();
         assertFalse( namingEnumeration.hasMore() );
@@ -418,6 +452,10 @@
     // -----------------------------------------------------------------------
     
     
+    /**
+     * Do a search request from the ou=actors,ou=system base, with a principal
+     * which is the administrator.
+     */
     private Set<String> getActorsWithLimit( String filter, int timeLimitMillis, int sizeLimit ) throws Exception
     {
         DirContext ctx = getWiredContext( ldapService );
@@ -427,7 +465,9 @@
         controls.setCountLimit( sizeLimit );
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         
-        NamingEnumeration<SearchResult> namingEnumeration = ctx.search( "ou=actors,ou=system", filter, controls );
+        NamingEnumeration<SearchResult> namingEnumeration = 
+            ctx.search( "ou=actors,ou=system", filter, controls );
+        
         while( namingEnumeration.hasMore() )
         {
             results.add( namingEnumeration.next().getNameInNamespace() );
@@ -436,7 +476,10 @@
         return results;
     }
 
-    
+    /**
+     * Do a search request from the ou=actors,ou=system base, with a principal
+     * which is not the administrator.
+     */
     private Set<String> getActorsWithLimitNonAdmin( String filter, int timeLimitMillis, int sizeLimit ) 
         throws Exception
     {
@@ -447,7 +490,9 @@
         controls.setCountLimit( sizeLimit );
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         
-        NamingEnumeration<SearchResult> namingEnumeration = ctx.search( "ou=actors,ou=system", filter, controls );
+        NamingEnumeration<SearchResult> namingEnumeration = 
+            ctx.search( "ou=actors,ou=system", filter, controls );
+        
         while( namingEnumeration.hasMore() )
         {
             results.add( namingEnumeration.next().getNameInNamespace() );

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsIT.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsIT.java Thu Dec 11 07:32:04 2008
@@ -36,9 +36,9 @@
 import org.apache.directory.server.ldap.handlers.bind.gssapi.GssapiMechanismHandler;
 import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
-import org.apache.directory.server.protocol.shared.SocketAcceptor;
 import org.apache.directory.server.ssl.SSLSocketFactory;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.apache.mina.util.AvailablePortFinder;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -90,8 +90,9 @@
 
             LdapService ldapService = new LdapService();
             ldapService.setDirectoryService( service );
-            ldapService.setSocketAcceptor( new SocketAcceptor( null ) );
+            ldapService.setSocketAcceptor( new NioSocketAcceptor() );
             ldapService.setIpPort( AvailablePortFinder.getNextAvailable( 1024 ) );
+            ldapService.setNbTcpThreads( 3 );
             ldapService.setEnabled( true );
             ldapService.setEnableLdaps( true );
             ldapService.setConfidentialityRequired( true );

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsIT.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsIT.java Thu Dec 11 07:32:04 2008
@@ -111,27 +111,27 @@
     @Before
     public void installKeyStoreWithCertificate() throws Exception
     {
-    	if ( ksFile != null && ksFile.exists() )
-    	{
-    		ksFile.delete();
-    	}
-    	
-    	ksFile = File.createTempFile( "testStore", "ks" );
-    	
-    	CoreSession session = ldapService.getDirectoryService().getAdminSession();
-    	ClonedServerEntry entry = session.lookup( new LdapDN( "uid=admin,ou=system" ), CERT_IDS );
-    	byte[] userCertificate = entry.get( CERT_IDS[0] ).getBytes();
-    	assertNotNull( userCertificate );
-
-    	ByteArrayInputStream in = new ByteArrayInputStream( userCertificate );
-    	CertificateFactory factory = CertificateFactory.getInstance( "X.509" );
-    	Certificate cert = factory.generateCertificate( in );
-    	KeyStore ks = KeyStore.getInstance( KeyStore.getDefaultType() );
-    	ks.load( null, null );
-    	ks.setCertificateEntry( "apacheds", cert );
-    	ks.store( new FileOutputStream( ksFile ), "changeit".toCharArray() );
-    	LOG.debug( "Keystore file installed: {}", ksFile.getAbsolutePath() );
-    	
+        if ( ksFile != null && ksFile.exists() )
+        {
+            ksFile.delete();
+        }
+        
+        ksFile = File.createTempFile( "testStore", "ks" );
+        
+        CoreSession session = ldapService.getDirectoryService().getAdminSession();
+        ClonedServerEntry entry = session.lookup( new LdapDN( "uid=admin,ou=system" ), CERT_IDS );
+        byte[] userCertificate = entry.get( CERT_IDS[0] ).getBytes();
+        assertNotNull( userCertificate );
+
+        ByteArrayInputStream in = new ByteArrayInputStream( userCertificate );
+        CertificateFactory factory = CertificateFactory.getInstance( "X.509" );
+        Certificate cert = factory.generateCertificate( in );
+        KeyStore ks = KeyStore.getInstance( KeyStore.getDefaultType() );
+        ks.load( null, null );
+        ks.setCertificateEntry( "apacheds", cert );
+        ks.store( new FileOutputStream( ksFile ), "changeit".toCharArray() );
+        LOG.debug( "Keystore file installed: {}", ksFile.getAbsolutePath() );
+        
         oldConfidentialityRequiredValue = ldapService.isConfidentialityRequired();
     }
     
@@ -142,25 +142,25 @@
     @After
     public void deleteKeyStore() throws Exception
     {
-    	if ( ksFile != null && ksFile.exists() )
-    	{
-    		ksFile.delete();
-    	}
-    	
-    	LOG.debug( "Keystore file deleted: {}", ksFile.getAbsolutePath() );
-    	ldapService.setConfidentialityRequired( oldConfidentialityRequiredValue );
+        if ( ksFile != null && ksFile.exists() )
+        {
+            ksFile.delete();
+        }
+        
+        LOG.debug( "Keystore file deleted: {}", ksFile.getAbsolutePath() );
+        ldapService.setConfidentialityRequired( oldConfidentialityRequiredValue );
     }
     
 
     private LdapContext getSecuredContext() throws Exception
     {
-    	System.setProperty ( "javax.net.ssl.trustStore", ksFile.getAbsolutePath() );
-    	System.setProperty ( "javax.net.ssl.keyStore", ksFile.getAbsolutePath() );
-    	System.setProperty ( "javax.net.ssl.keyStorePassword", "changeit" );
-    	LOG.debug( "testStartTls() test starting ... " );
-    	
-    	// Set up environment for creating initial context
-    	Hashtable<String, Object> env = new Hashtable<String,Object>();
+        System.setProperty ( "javax.net.ssl.trustStore", ksFile.getAbsolutePath() );
+        System.setProperty ( "javax.net.ssl.keyStore", ksFile.getAbsolutePath() );
+        System.setProperty ( "javax.net.ssl.keyStorePassword", "changeit" );
+        LOG.debug( "testStartTls() test starting ... " );
+        
+        // Set up environment for creating initial context
+        Hashtable<String, Object> env = new Hashtable<String,Object>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
         
         // Must use the name of the server that is found in its certificate?
@@ -195,103 +195,103 @@
         ldapService.setConfidentialityRequired( true );
 
         // -------------------------------------------------------------------
-    	// Unsecured bind should fail
-    	// -------------------------------------------------------------------
+        // Unsecured bind should fail
+        // -------------------------------------------------------------------
 
-    	try
-    	{
-    		ServerIntegrationUtils.getWiredContext( ldapService );
-    		fail( "Should not get here due to violation of confidentiality requirements" );
-    	}
-    	catch( AuthenticationNotSupportedException e )
-    	{
-    	}
-    	
-    	// -------------------------------------------------------------------
-    	// get anonymous connection with StartTLS (no bind request sent)
-    	// -------------------------------------------------------------------
-
-    	LdapContext ctx = getSecuredContext();
-    	assertNotNull( ctx );
-    	
-    	// -------------------------------------------------------------------
-    	// upgrade connection via bind request (same physical connection - TLS)
-    	// -------------------------------------------------------------------
-
-    	ctx.addToEnvironment( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
-    	ctx.addToEnvironment( Context.SECURITY_CREDENTIALS, "secret" );
-    	ctx.addToEnvironment( Context.SECURITY_AUTHENTICATION, "simple" );
-    	ctx.reconnect( null );
-    	
-    	// -------------------------------------------------------------------
-    	// do a search and confirm
-    	// -------------------------------------------------------------------
-
-    	NamingEnumeration<SearchResult> results = ctx.search( "ou=system", "(objectClass=*)", new SearchControls() );
-    	Set<String> names = new HashSet<String>();
-    	while( results.hasMore() )
-    	{
-    		names.add( results.next().getName() );
-    	}
-    	results.close();
-    	assertTrue( names.contains( "prefNodeName=sysPrefRoot" ) );
-    	assertTrue( names.contains( "ou=users" ) );
-    	assertTrue( names.contains( "ou=configuration" ) );
-    	assertTrue( names.contains( "uid=admin" ) );
-    	assertTrue( names.contains( "ou=groups" ) );
-    	
-    	// -------------------------------------------------------------------
-    	// do add and confirm
-    	// -------------------------------------------------------------------
-
-    	Attributes attrs = new BasicAttributes( "objectClass", "person", true );
-    	attrs.put( "sn", "foo" );
-    	attrs.put( "cn", "foo bar" );
-    	ctx.createSubcontext( "cn=foo bar,ou=system", attrs );
-    	assertNotNull( ctx.lookup( "cn=foo bar,ou=system" ) );
-    	
-    	// -------------------------------------------------------------------
-    	// do modify and confirm
-    	// -------------------------------------------------------------------
-
-    	ModificationItem[] mods = new ModificationItem[] {
-    			new ModificationItem( DirContext.ADD_ATTRIBUTE, new BasicAttribute( "cn", "fbar" ) )
-    	};
-    	ctx.modifyAttributes( "cn=foo bar,ou=system", mods );
-    	Attributes reread = ( Attributes ) ctx.getAttributes( "cn=foo bar,ou=system" );
-    	assertTrue( reread.get( "cn" ).contains( "fbar" ) );
-    	
-    	// -------------------------------------------------------------------
-    	// do rename and confirm 
-    	// -------------------------------------------------------------------
-
-    	ctx.rename( "cn=foo bar,ou=system", "cn=fbar,ou=system" );
-    	try
-    	{
-    		ctx.getAttributes( "cn=foo bar,ou=system" );
-    		fail( "old name of renamed entry should not be found" );
-    	}
-    	catch ( NameNotFoundException e )
-    	{
-    	}
-    	reread = ( Attributes ) ctx.getAttributes( "cn=fbar,ou=system" );
-    	assertTrue( reread.get( "cn" ).contains( "fbar" ) );
-    	
-    	// -------------------------------------------------------------------
-    	// do delete and confirm
-    	// -------------------------------------------------------------------
-
-    	ctx.destroySubcontext( "cn=fbar,ou=system" );
-    	try
-    	{
-    		ctx.getAttributes( "cn=fbar,ou=system" );
-    		fail( "deleted entry should not be found" );
-    	}
-    	catch ( NameNotFoundException e )
-    	{
-    	}
-    	
-    	ctx.close();
+        try
+        {
+            ServerIntegrationUtils.getWiredContext( ldapService );
+            fail( "Should not get here due to violation of confidentiality requirements" );
+        }
+        catch( AuthenticationNotSupportedException e )
+        {
+        }
+        
+        // -------------------------------------------------------------------
+        // get anonymous connection with StartTLS (no bind request sent)
+        // -------------------------------------------------------------------
+
+        LdapContext ctx = getSecuredContext();
+        assertNotNull( ctx );
+        
+        // -------------------------------------------------------------------
+        // upgrade connection via bind request (same physical connection - TLS)
+        // -------------------------------------------------------------------
+
+        ctx.addToEnvironment( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
+        ctx.addToEnvironment( Context.SECURITY_CREDENTIALS, "secret" );
+        ctx.addToEnvironment( Context.SECURITY_AUTHENTICATION, "simple" );
+        ctx.reconnect( null );
+        
+        // -------------------------------------------------------------------
+        // do a search and confirm
+        // -------------------------------------------------------------------
+
+        NamingEnumeration<SearchResult> results = ctx.search( "ou=system", "(objectClass=*)", new SearchControls() );
+        Set<String> names = new HashSet<String>();
+        while( results.hasMore() )
+        {
+            names.add( results.next().getName() );
+        }
+        results.close();
+        assertTrue( names.contains( "prefNodeName=sysPrefRoot" ) );
+        assertTrue( names.contains( "ou=users" ) );
+        assertTrue( names.contains( "ou=configuration" ) );
+        assertTrue( names.contains( "uid=admin" ) );
+        assertTrue( names.contains( "ou=groups" ) );
+        
+        // -------------------------------------------------------------------
+        // do add and confirm
+        // -------------------------------------------------------------------
+
+        Attributes attrs = new BasicAttributes( "objectClass", "person", true );
+        attrs.put( "sn", "foo" );
+        attrs.put( "cn", "foo bar" );
+        ctx.createSubcontext( "cn=foo bar,ou=system", attrs );
+        assertNotNull( ctx.lookup( "cn=foo bar,ou=system" ) );
+        
+        // -------------------------------------------------------------------
+        // do modify and confirm
+        // -------------------------------------------------------------------
+
+        ModificationItem[] mods = new ModificationItem[] {
+                new ModificationItem( DirContext.ADD_ATTRIBUTE, new BasicAttribute( "cn", "fbar" ) )
+        };
+        ctx.modifyAttributes( "cn=foo bar,ou=system", mods );
+        Attributes reread = ( Attributes ) ctx.getAttributes( "cn=foo bar,ou=system" );
+        assertTrue( reread.get( "cn" ).contains( "fbar" ) );
+        
+        // -------------------------------------------------------------------
+        // do rename and confirm 
+        // -------------------------------------------------------------------
+
+        ctx.rename( "cn=foo bar,ou=system", "cn=fbar,ou=system" );
+        try
+        {
+            ctx.getAttributes( "cn=foo bar,ou=system" );
+            fail( "old name of renamed entry should not be found" );
+        }
+        catch ( NameNotFoundException e )
+        {
+        }
+        reread = ( Attributes ) ctx.getAttributes( "cn=fbar,ou=system" );
+        assertTrue( reread.get( "cn" ).contains( "fbar" ) );
+        
+        // -------------------------------------------------------------------
+        // do delete and confirm
+        // -------------------------------------------------------------------
+
+        ctx.destroySubcontext( "cn=fbar,ou=system" );
+        try
+        {
+            ctx.getAttributes( "cn=fbar,ou=system" );
+            fail( "deleted entry should not be found" );
+        }
+        catch ( NameNotFoundException e )
+        {
+        }
+        
+        ctx.close();
     }
 
 

Modified: directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java (original)
+++ directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java Thu Dec 11 07:32:04 2008
@@ -34,8 +34,8 @@
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.StringTools;
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.SimpleByteBufferAllocator;
+import org.apache.mina.core.buffer.IoBuffer;
+import org.apache.mina.core.buffer.SimpleBufferAllocator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -101,8 +101,8 @@
         
         this.ldapService = ldapService;
         this.ldapsService = ldapsService;
-        ByteBuffer.setAllocator( new SimpleByteBufferAllocator() );
-        ByteBuffer.setUseDirectBuffers( false );
+        IoBuffer.setAllocator( new SimpleBufferAllocator() );
+        IoBuffer.setUseDirectBuffer( false );
     }
 
 
@@ -267,7 +267,7 @@
         }
         catch( Exception e )
         {
-            LOG.warn( "Failure while looking up {}. The entry will be created now.", ServerDNConstants.LDIF_FILES_DN, e );
+            LOG.info( "Failure while looking up {}. The entry will be created now.", ServerDNConstants.LDIF_FILES_DN, e );
         }
 
         if ( entry == null )

Modified: directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java (original)
+++ directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java Thu Dec 11 07:32:04 2008
@@ -84,7 +84,7 @@
 {
     private Registries bootstrapRegistries = new DefaultRegistries( "bootstrap", new BootstrapSchemaLoader(),
         new DefaultOidRegistry() );
-    private Set exclusions = new HashSet();
+    private Set<String> exclusions = new HashSet<String>();
     private boolean includeOperational = false;
 
 
@@ -135,6 +135,7 @@
 
         // If not present then we need to abort 
         File schemaDirectory = new File( getLayout().getPartitionsDirectory(), "schema" );
+
         if ( !schemaDirectory.exists() )
         {
             throw new LdapConfigurationException( "The following schema directory from "
@@ -146,6 +147,7 @@
         schemaPartition.setCacheSize( 1000 );
 
         DbFileListing listing;
+        
         try
         {
             listing = new DbFileListing();
@@ -172,7 +174,6 @@
         // --------------------------------------------------------------------
         // Initialize schema subsystem and reset registries
         // --------------------------------------------------------------------
-
         PartitionSchemaLoader schemaLoader = new PartitionSchemaLoader( schemaPartition, registries );
         Registries globalRegistries = new DefaultRegistries( "global", schemaLoader, oidRegistry );
         schemaLoader.loadEnabled( globalRegistries );
@@ -192,12 +193,14 @@
         PrintWriter out = null;
 
         String[] excludedAttributes = cmdline.getOptionValues( 'e' );
+        
         if ( excludedAttributes != null )
         {
             AttributeTypeRegistry registry = bootstrapRegistries.getAttributeTypeRegistry();
-            for ( int ii = 0; ii < excludedAttributes.length; ii++ )
+            
+            for ( String attributeType:excludedAttributes)
             {
-                AttributeType type = registry.lookup( excludedAttributes[ii] );
+                AttributeType type = registry.lookup( attributeType );
                 exclusions.add( type.getName() );
             }
         }
@@ -211,9 +214,9 @@
             out = new PrintWriter( new FileWriter( outputFile ) );
         }
 
-        for ( int ii = 0; ii < partitions.length; ii++ )
+        for ( String partition:partitions )
         {
-            File partitionDirectory = new File( getLayout().getPartitionsDirectory(), partitions[ii] );
+            File partitionDirectory = new File( getLayout().getPartitionsDirectory(), partition );
             out.println( "\n\n" );
             dump( partitionDirectory, out );
         }
@@ -250,6 +253,7 @@
         out.println( "#---------------------" );
         Cursor<Tuple<Long,ServerEntry>> list = master.cursor();
         StringBuffer buf = new StringBuffer();
+        
         while ( list.next() )
         {
             Tuple<Long,ServerEntry> tuple = list.get();
@@ -260,6 +264,7 @@
             filterAttributes( dn, entry );
 
             buf.append( "# Entry: " ).append( id ).append( "\n#---------------------\n\n" );
+        
             if ( !LdifUtils.isLDIFSafe( dn ) )
             {
                 // If the DN isn't LdifSafe, it needs to be Base64 encoded.
@@ -270,11 +275,14 @@
             {
                 buf.append( "dn: " ).append( dn );
             }
+            
             buf.append( "\n" ).append( LdifUtils.convertToLdif( entry ) );
+
             if ( list.next() )
             {
                 buf.append( "\n\n#---------------------\n" );
             }
+            
             out.print( buf.toString() );
             out.flush();
             buf.setLength( 0 );
@@ -284,12 +292,14 @@
 
     private void filterAttributes( String dn, Attributes entry ) throws Exception
     {
-        List toRemove = new ArrayList();
+        List<String> toRemove = new ArrayList<String>();
         AttributeTypeRegistry registry = bootstrapRegistries.getAttributeTypeRegistry();
-        NamingEnumeration attrs = entry.getAll();
+        NamingEnumeration<? extends Attribute> attrs = entry.getAll();
+        
         while ( attrs.hasMore() )
         {
-            Attribute attr = ( Attribute ) attrs.next();
+            Attribute attr = attrs.next();
+            
             if ( !registry.hasAttributeType( attr.getID() ) )
             {
                 if ( !isQuietEnabled() )
@@ -302,15 +312,17 @@
 
             AttributeType type = registry.lookup( attr.getID() );
             boolean isOperational = type.getUsage() != UsageEnum.USER_APPLICATIONS;
+            
             if ( exclusions.contains( attr.getID() ) || ( isOperational && ( !includeOperational ) ) )
             {
                 toRemove.add( attr.getID() );
             }
         }
-        for ( int ii = 0; ii < toRemove.size(); ii++ )
+        
+        for ( String id:toRemove )
         {
-            String id = ( String ) toRemove.get( ii );
             entry.remove( id );
+            
             if ( isDebugEnabled() )
             {
                 System.out.println( "# Excluding attribute " + id + " in " + dn );

Modified: directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java (original)
+++ directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java Thu Dec 11 07:32:04 2008
@@ -54,7 +54,6 @@
 import org.apache.directory.server.ldap.handlers.bind.plain.PlainMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StartTlsHandler;
 import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
-import org.apache.directory.server.protocol.shared.SocketAcceptor;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
@@ -62,6 +61,7 @@
 import org.apache.directory.shared.ldap.exception.LdapConfigurationException;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.ldif.LdifReader;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.apache.mina.util.AvailablePortFinder;
 
 import org.slf4j.Logger;
@@ -92,15 +92,13 @@
     /** flag whether to delete database files for each test or not */
     protected boolean doDelete = true;
 
-//    protected ApacheDS apacheDS = new ApacheDS();
-
     protected int port = -1;
 
     private static int start;
     private static long t0;
     protected static int nbTests = 10000;
     protected DirectoryService directoryService;
-    protected SocketAcceptor socketAcceptor;
+    protected NioSocketAcceptor socketAcceptor;
     protected LdapService ldapService;
 
 
@@ -254,11 +252,12 @@
         start++;
         directoryService = new DefaultDirectoryService();
         directoryService.setShutdownHookEnabled( false );
-        socketAcceptor = new SocketAcceptor( null );
+        socketAcceptor = new NioSocketAcceptor();
         ldapService = new LdapService();
         ldapService.setSocketAcceptor( socketAcceptor );
         ldapService.setDirectoryService( directoryService );
         ldapService.setIpPort( port = AvailablePortFinder.getNextAvailable( 1024 ) );
+        ldapService.setNbTcpThreads( 3 );
 
         setupSaslMechanisms( ldapService );
 

Modified: directory/apacheds/trunk/server-xml/src/main/resources/server.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-xml/src/main/resources/server.xml?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/server-xml/src/main/resources/server.xml (original)
+++ directory/apacheds/trunk/server-xml/src/main/resources/server.xml Thu Dec 11 07:32:04 2008
@@ -21,14 +21,15 @@
 
 
 <spring:beans xmlns:spring="http://xbean.apache.org/schemas/spring/1.0" 
-			  xmlns:s="http://www.springframework.org/schema/beans"
-			  xmlns="http://apacheds.org/config/1.0">
+              xmlns:s="http://www.springframework.org/schema/beans"
+              xmlns="http://apacheds.org/config/1.0">
 
   <defaultDirectoryService id="directoryService" instanceId="default"
                            workingDirectory="example.com"
                            allowAnonymousAccess="true"
                            accessControlEnabled="false"
-                           denormalizeOpAttrsEnabled="false">
+                           denormalizeOpAttrsEnabled="false"
+                           maxPDUSize="2000000">
     <systemPartition>
       <!-- use the following partitionConfiguration to override defaults for -->
       <!-- the system partition                                              -->
@@ -105,56 +106,42 @@
     </interceptors>
   </defaultDirectoryService>
 
-  <standardThreadPool id="standardThreadPool" maxThreads="8"/>
-  <datagramAcceptor id="datagramAcceptor" logicExecutor="#standardThreadPool"/>
-  <socketAcceptor id="socketAcceptor" logicExecutor="#standardThreadPool"/>
-
 <!--  missing  atou=users,dc=example,dc=com
-  <changePasswordServer ipPort="60464">
+  <changePasswordServer ipPort="60464" nbThreads="8">
     <directoryService>#directoryService</directoryService>
-    <datagramAcceptor>#datagramAcceptor</datagramAcceptor>
-    <socketAcceptor>#socketAcceptor</socketAcceptor>
   </changePasswordServer>
 -->
 <!--  missing atou=users,dc=example,dc=com
-  <kdcServer ipPort="60088">
+  <kdcServer ipPort="60088" nbThreads="8">
     <directoryService>#directoryService</directoryService>
-    <datagramAcceptor>#datagramAcceptor</datagramAcceptor>
-    <socketAcceptor>#socketAcceptor</socketAcceptor>
   </kdcServer>
 -->
-  <ntpServer ipPort="60123">
-    <datagramAcceptor>#datagramAcceptor</datagramAcceptor>
-    <socketAcceptor>#socketAcceptor</socketAcceptor>
-  </ntpServer>
+  <ntpServer ipPort="60123" nbThreads="8"/>
 <!--  missing atou=users,dc=example,dc=com
-  <dnsServer ipPort="8053">
+  <dnsServer ipPort="8053" nbThreads="8">
     <directoryService>#directoryService</directoryService>
-    <datagramAcceptor>#datagramAcceptor</datagramAcceptor>
-    <socketAcceptor>#socketAcceptor</socketAcceptor>
   </dnsServer>
 -->
 
   <ldapService id="ldapsService"
               enabled="true"
-              ipPort="10636"
-              enableLdaps="true">
+              tcpPort="10636"
+              enableLdaps="true"
+              nbTcpThreads="8">
     <directoryService>#directoryService</directoryService>
-    <socketAcceptor>#socketAcceptor</socketAcceptor>
   </ldapService>
 
-
   <ldapService id="ldapService"
-              ipPort="10389"
+              tcpPort="10389"
               allowAnonymousAccess="false"
               saslHost="ldap.example.com"
               saslPrincipal="ldap/ldap.example.com@EXAMPLE.COM"
               searchBaseDn="ou=users,ou=system"
               maxTimeLimit="15000"
-              maxSizeLimit="1000">
+              maxSizeLimit="1000"
+              nbTcpThreads="8">
 
     <directoryService>#directoryService</directoryService>
-    <socketAcceptor>#socketAcceptor</socketAcceptor>
 
     <!-- The list of supported authentication mechanisms.                   -->
     <saslMechanismHandlers>



Mime
View raw message