directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r730170 - in /directory: apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/ apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ apacheds/trunk/protocol-kerberos/src/test/java/org/...
Date Tue, 30 Dec 2008 16:34:07 GMT
Author: elecharny
Date: Tue Dec 30 08:34:06 2008
New Revision: 730170

URL: http://svn.apache.org/viewvc?rev=730170&view=rev
Log:
o Fixed the way the Transport acceptor is created : if the constructor does not create it, it is created when setting the Transport(). This is mandatory to avoid using a constructor injection in Spring
o Switch Kerberos tests to Junit 4.4
o Disposing acceptors when done with the transport, otherwise we get some 'Too many open files' exceptions

Modified:
    directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/Main.java
    directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java
    directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java
    directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AbstractTicketGrantingServiceTest.java
    directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationEncryptionTypeTest.java
    directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationPolicyTest.java
    directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationServiceTest.java
    directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/EncTktInSkeyTest.java
    directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/PreAuthenticationTest.java
    directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingEncryptionTypeTest.java
    directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingPolicyTest.java
    directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingServiceTest.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java
    directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java
    directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpITest.java
    directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java
    directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java
    directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java
    directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/Transport.java
    directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/UdpTransport.java
    directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
    directory/installers/trunk/apacheds-noarch/src/main/java/org/apache/directory/server/Service.java

Modified: directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/Main.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/Main.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/Main.java (original)
+++ directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/Main.java Tue Dec 30 08:34:06 2008
@@ -21,7 +21,6 @@
 
 
 import java.io.IOException;
-import java.net.InetSocketAddress;
 
 import javax.naming.NamingException;
 
@@ -29,8 +28,6 @@
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.directory.server.protocol.shared.transport.UdpTransport;
-import org.apache.mina.transport.socket.nio.NioDatagramAcceptor;
-import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -65,12 +62,8 @@
     {
         LOG.debug( "Starting the DNS server" );
         
-        NioDatagramAcceptor datagramAcceptor = new NioDatagramAcceptor( null );
-        NioSocketAcceptor socketAcceptor = new NioSocketAcceptor();
         DirectoryService directoryService = new DefaultDirectoryService();
         dnsConfiguration = new DnsServer();
-        dnsConfiguration.setDatagramAcceptor( datagramAcceptor );
-        dnsConfiguration.setSocketAcceptor( socketAcceptor );
         dnsConfiguration.setDirectoryService( directoryService );
         dnsConfiguration.setEnabled( true );
         dnsConfiguration.setTcpTransport( new TcpTransport( 10053 ) );

Modified: directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java Tue Dec 30 08:34:06 2008
@@ -21,7 +21,6 @@
 
 
 import java.io.IOException;
-import java.net.InetSocketAddress;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -40,10 +39,8 @@
 import org.apache.directory.server.protocol.shared.transport.UdpTransport;
 import org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder;
 import org.apache.mina.core.filterchain.IoFilterChainBuilder;
+import org.apache.mina.core.service.IoAcceptor;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
-import org.apache.mina.transport.socket.DatagramAcceptor;
-import org.apache.mina.transport.socket.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.NioDatagramAcceptor;
 import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -442,22 +439,15 @@
     {
         PrincipalStore store;
 
-        // TODO - for now ignoring this catelog crap
+        // TODO - for now ignoring this catalog crap
         store = new DirectoryPrincipalStore( getDirectoryService() );
         
-        Transport udpTransport = getTcpTransport();
+        Transport udpTransport = getUdpTransport();
 
         // Kerberos can use UDP or TCP
         if ( udpTransport != null )
         {
-            // Actually, this is not used for Datagram. But it should !
-            //int nbUdpThreads = getNbUdpThreads();
-            
-            // Create the acceptor
-            DatagramAcceptor udpAcceptor = new NioDatagramAcceptor();
-            
-            // Stores it
-            setDatagramAcceptor( udpAcceptor );
+            IoAcceptor udpAcceptor = udpTransport.getAcceptor();
             
             // Now, configure the acceptor
             // Inject the chain
@@ -473,28 +463,16 @@
             udpAcceptor.setHandler( new KerberosProtocolHandler( this, store ) );
             
             // Bind to the configured address
-            udpAcceptor.bind( new InetSocketAddress( udpTransport.getPort() ) );
+            udpAcceptor.bind();
+            System.out.println( "Bound UDP <" + udpAcceptor.getDefaultLocalAddress() + ">" );
         }
 
         Transport tcpTransport = getTcpTransport();
 
         if ( tcpTransport != null )
         {
-            // First, create the acceptor with the configured number of threads (if defined)
-            int nbTcpThreads = tcpTransport.getNbThreads();
-            SocketAcceptor tcpAcceptor;
-            
-            if ( nbTcpThreads > 0 )
-            {
-                tcpAcceptor = new NioSocketAcceptor( nbTcpThreads );
-            }
-            else
-            {
-                tcpAcceptor = new NioSocketAcceptor();
-            }
-                
-            setSocketAcceptor( tcpAcceptor );
-            
+            NioSocketAcceptor tcpAcceptor = (NioSocketAcceptor)tcpTransport.getAcceptor();
+
             // Now, configure the acceptor
             // Disable the disconnection of the clients on unbind
             tcpAcceptor.setCloseOnDeactivation( false );
@@ -518,7 +496,8 @@
             tcpAcceptor.setHandler( new KerberosProtocolHandler( this, store ) );
             
             // Bind to the configured address
-            tcpAcceptor.bind( new InetSocketAddress( tcpTransport.getPort() ) );
+            tcpAcceptor.bind();
+            System.out.println( "Bound TCP <" + tcpAcceptor.getDefaultLocalAddress() + ">" );
         }
         
         LOG.info( "Kerberos service started." );
@@ -530,11 +509,13 @@
     {
         if ( getDatagramAcceptor() != null )
         {
-            getDatagramAcceptor().unbind( new InetSocketAddress( getUdpTransport().getPort() ));
+            System.out.println( "Unbinding UDP <" + getDatagramAcceptor().getDefaultLocalAddress() + ">" );
+            getDatagramAcceptor().dispose();
         }
         if ( getSocketAcceptor() != null )
         {
-            getSocketAcceptor().unbind( new InetSocketAddress( getTcpTransport().getPort() ));
+            System.out.println( "Unbinding TCP <" + getSocketAcceptor().getDefaultLocalAddress() + ">" );
+            getSocketAcceptor().dispose();
         }
         
         LOG.info( "Kerberos service stopped." );

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java Tue Dec 30 08:34:06 2008
@@ -32,6 +32,9 @@
 import org.apache.directory.server.unit.AbstractServerTest;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 import javax.naming.Context;
 import javax.naming.NamingException;
@@ -79,6 +82,7 @@
      * Set up a partition for EXAMPLE.COM and add user and service principals to
      * test authentication with.
      */
+    @Before
     public void setUp() throws Exception
     {
         super.setUp();
@@ -87,7 +91,6 @@
         ldapService.setSaslPrincipal( "ldap/localhost@EXAMPLE.COM" );
 
         KdcServer kdcConfig = new KdcServer();
-        kdcConfig.setSocketAcceptor( socketAcceptor );
         kdcConfig.setDirectoryService( directoryService );
         kdcConfig.setEnabled( true );
         kdcConfig.setSearchBaseDn( "ou=users,dc=example,dc=com" );
@@ -226,6 +229,7 @@
     /**
      * Tests to make sure GSSAPI binds below the RootDSE work.
      */
+    @Test
     public void testSaslGssapiBind()
     {
         assertTrue( true );
@@ -235,6 +239,7 @@
     /**
      * Tear down.
      */
+    @After
     public void tearDown() throws Exception
     {
         ctx.close();

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AbstractTicketGrantingServiceTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AbstractTicketGrantingServiceTest.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AbstractTicketGrantingServiceTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AbstractTicketGrantingServiceTest.java Tue Dec 30 08:34:06 2008
@@ -26,8 +26,6 @@
 import javax.security.auth.kerberos.KerberosKey;
 import javax.security.auth.kerberos.KerberosPrincipal;
 
-import junit.framework.TestCase;
-
 import org.apache.directory.server.kerberos.shared.KerberosConstants;
 import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 import org.apache.directory.server.kerberos.shared.crypto.checksum.ChecksumHandler;
@@ -70,7 +68,7 @@
 
 
  */
-public abstract class AbstractTicketGrantingServiceTest extends TestCase
+public abstract class AbstractTicketGrantingServiceTest
 {
     protected CipherTextHandler lockBox;
     protected static final SecureRandom random = new SecureRandom();

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationEncryptionTypeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationEncryptionTypeTest.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationEncryptionTypeTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationEncryptionTypeTest.java Tue Dec 30 08:34:06 2008
@@ -47,6 +47,7 @@
 import org.apache.directory.server.kerberos.shared.messages.value.types.PaDataType;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import static org.junit.Assert.assertEquals;
@@ -82,6 +83,16 @@
 
 
     /**
+     * Shutdown the Kerberos server
+     */
+    @After
+    public void shutDown()
+    {
+        config.stop();
+    }
+    
+    
+    /**
      * Tests a basic request using DES-CBC-MD5.
      * 
      * @throws Exception

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationPolicyTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationPolicyTest.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationPolicyTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationPolicyTest.java Tue Dec 30 08:34:06 2008
@@ -30,6 +30,7 @@
 import org.apache.directory.server.kerberos.shared.messages.value.RequestBodyModifier;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import static org.junit.Assert.assertEquals;
@@ -60,8 +61,18 @@
         handler = new KerberosProtocolHandler( config, store );
         session = new KrbDummySession();
     }
-
-
+    
+    
+    /**
+     * Shutdown the Kerberos server
+     */
+    @After
+    public void shutDown()
+    {
+        config.stop();
+    }
+    
+    
     /**
      * Tests when forwardable tickets are disallowed that requests for
      * forwardable tickets fail with the correct error message.

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationServiceTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationServiceTest.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationServiceTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationServiceTest.java Tue Dec 30 08:34:06 2008
@@ -38,6 +38,7 @@
 import org.apache.directory.server.kerberos.shared.messages.value.RequestBodyModifier;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import static org.junit.Assert.assertEquals;
@@ -74,6 +75,16 @@
 
 
     /**
+     * Shutdown the Kerberos server
+     */
+    @After
+    public void shutDown()
+    {
+        config.stop();
+    }
+    
+    
+    /**
      * Tests the default minimum request, which consists of as little as the
      * client name, realm, till time, nonce, and encryption types.
      * 

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/EncTktInSkeyTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/EncTktInSkeyTest.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/EncTktInSkeyTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/EncTktInSkeyTest.java Tue Dec 30 08:34:06 2008
@@ -35,6 +35,10 @@
 import org.apache.directory.server.kerberos.shared.messages.value.RequestBody;
 import org.apache.directory.server.kerberos.shared.messages.value.RequestBodyModifier;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
 
 
 /**
@@ -55,7 +59,8 @@
     /**
      * Creates a new instance of {@link EncTktInSkeyTest}.
      */
-    public EncTktInSkeyTest()
+    @Before
+    public void setUp()
     {
         config = new KdcServer();
 
@@ -73,6 +78,16 @@
 
 
     /**
+     * Shutdown the Kerberos server
+     */
+    @After
+    public void shutDown()
+    {
+        config.stop();
+    }
+    
+    
+    /**
      * If the ENC-TKT-IN-SKEY option has been specified and an additional ticket
      * has been included in the request, it indicates that the client is using
      * user-to-user authentication to prove its identity to a server that does
@@ -91,6 +106,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testEncTktInSkey() throws Exception
     {
         // Get the mutable ticket part.

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/PreAuthenticationTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/PreAuthenticationTest.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/PreAuthenticationTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/PreAuthenticationTest.java Tue Dec 30 08:34:06 2008
@@ -38,6 +38,7 @@
 import org.apache.directory.server.kerberos.shared.messages.value.RequestBodyModifier;
 import org.apache.directory.server.kerberos.shared.messages.value.types.PaDataType;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import static org.junit.Assert.assertEquals;
@@ -73,6 +74,16 @@
 
 
     /**
+     * Shutdown the Kerberos server
+     */
+    @After
+    public void shutDown()
+    {
+        config.stop();
+    }
+    
+    
+    /**
      * Tests when the KDC configuration requires pre-authentication by encrypted
      * timestamp that an AS_REQ without pre-authentication is rejected with the
      * correct error message.

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingEncryptionTypeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingEncryptionTypeTest.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingEncryptionTypeTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingEncryptionTypeTest.java Tue Dec 30 08:34:06 2008
@@ -42,6 +42,10 @@
 import org.apache.directory.server.kerberos.shared.messages.value.RequestBody;
 import org.apache.directory.server.kerberos.shared.messages.value.RequestBodyModifier;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
 
 
 /**
@@ -61,7 +65,8 @@
     /**
      * Creates a new instance of {@link TicketGrantingEncryptionTypeTest}.
      */
-    public TicketGrantingEncryptionTypeTest()
+    @Before
+    public void setUp()
     {
         config = new KdcServer();
 
@@ -79,10 +84,21 @@
 
 
     /**
+     * Shutdown the Kerberos server
+     */
+    @After
+    public void shutDown()
+    {
+        config.stop();
+    }
+    
+    
+    /**
      * Tests a basic request using DES-CBC-MD5.
      *
      * @throws Exception
      */
+    @Test
     public void testRequestDesCbcMd5() throws Exception
     {
         // Get the mutable ticket part.
@@ -130,6 +146,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testRequestAes128() throws Exception
     {
         EncryptionType[] configuredEncryptionTypes =
@@ -183,6 +200,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testRequestAes128TgtAndRequested() throws Exception
     {
         EncryptionType[] configuredEncryptionTypes =
@@ -246,6 +264,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testNonce() throws Exception
     {
         EncryptionType[] configuredEncryptionTypes =
@@ -312,6 +331,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testDecryptWithSessionKey() throws Exception
     {
         EncryptionType[] configuredEncryptionTypes =
@@ -376,6 +396,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testDecryptWithSubSessionKey() throws Exception
     {
         EncryptionType[] configuredEncryptionTypes =

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingPolicyTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingPolicyTest.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingPolicyTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingPolicyTest.java Tue Dec 30 08:34:06 2008
@@ -20,6 +20,7 @@
 package org.apache.directory.server.kerberos.protocol;
 
 
+import java.io.IOException;
 import java.net.InetAddress;
 
 import javax.security.auth.kerberos.KerberosPrincipal;
@@ -40,6 +41,10 @@
 import org.apache.directory.server.kerberos.shared.messages.value.RequestBodyModifier;
 import org.apache.directory.server.kerberos.shared.messages.value.flags.TicketFlag;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
 
 
 /**
@@ -59,7 +64,8 @@
     /**
      * Creates a new instance of {@link TicketGrantingPolicyTest}.
      */
-    public TicketGrantingPolicyTest()
+    @Before
+    public void setUp() throws IOException
     {
         config = new KdcServer();
 
@@ -77,11 +83,22 @@
 
 
     /**
+     * Shutdown the Kerberos server
+     */
+    @After
+    public void shutDown()
+    {
+        config.stop();
+    }
+    
+    
+    /**
      * Tests when forwardable tickets are disallowed that requests for
      * forwardable tickets fail with the correct error message.
      *
      * @throws Exception
      */
+    @Test
     public void testForwardableTicket() throws Exception
     {
         // Deny FORWARDABLE tickets in policy.
@@ -131,6 +148,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testForwardedTicket() throws Exception
     {
         // Deny FORWARDABLE tickets in policy.
@@ -180,6 +198,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testForwardedNoAddressesTicket() throws Exception
     {
         // Deny empty addresses tickets in policy.
@@ -234,6 +253,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testProxiableTicket() throws Exception
     {
         // Deny PROXIABLE tickets in policy.
@@ -283,6 +303,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testProxyTicket() throws Exception
     {
         // Deny PROXIABLE tickets in policy.
@@ -337,6 +358,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testProxyNoAddressesTicket() throws Exception
     {
         // Deny empty addresses tickets in policy.
@@ -391,6 +413,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testAllowPostdate() throws Exception
     {
         // Deny ALLOW_POSTDATE tickets in policy.
@@ -440,6 +463,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testPostdated() throws Exception
     {
         // Deny POSTDATED tickets in policy.
@@ -489,6 +513,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testValidateInvalidTicket() throws Exception
     {
         // Deny VALIDATE tickets in policy.
@@ -539,6 +564,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testRenewTicket() throws Exception
     {
         // Deny RENEWABLE tickets in policy.
@@ -582,6 +608,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testRenewableOk() throws Exception
     {
         // Deny RENEWABLE tickets in policy.
@@ -631,6 +658,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testRenewableTicket() throws Exception
     {
         // Deny RENEWABLE tickets in policy.

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingServiceTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingServiceTest.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingServiceTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingServiceTest.java Tue Dec 30 08:34:06 2008
@@ -48,6 +48,13 @@
 import org.apache.directory.server.kerberos.shared.messages.value.RequestBodyModifier;
 import org.apache.directory.server.kerberos.shared.messages.value.flags.TicketFlag;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 
 
 /**
@@ -67,7 +74,8 @@
     /**
      * Creates a new instance of {@link TicketGrantingServiceTest}.
      */
-    public TicketGrantingServiceTest()
+    @Before
+    public void setUp()
     {
         config = new KdcServer();
 
@@ -85,6 +93,16 @@
 
 
     /**
+     * Shutdown the Kerberos server
+     */
+    @After
+    public void shutDown()
+    {
+        config.stop();
+    }
+    
+    
+    /**
      * Tests the default minimum request, which consists of as little as the
      * client name, service name, realm, till time, nonce, and encryption types.
      * 
@@ -101,6 +119,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testRequestArchetype() throws Exception
     {
         KerberosPrincipal clientPrincipal = new KerberosPrincipal( "hnelson@EXAMPLE.COM" );
@@ -134,6 +153,7 @@
     /**
      * Tests the protocol version number, which must be '5'.
      */
+    @Test
     public void testProtocolVersionNumber()
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -155,6 +175,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testServerNotFound() throws Exception
     {
         KerberosPrincipal clientPrincipal = new KerberosPrincipal( "hnelson@EXAMPLE.COM" );
@@ -197,6 +218,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testNoTicketFound() throws Exception
     {
         KerberosPrincipal clientPrincipal = new KerberosPrincipal( "hnelson@EXAMPLE.COM" );
@@ -242,6 +264,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testInappropriateChecksum() throws Exception
     {
         config.setBodyChecksumVerified( true );
@@ -282,6 +305,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testChecksumTypeNoSupport() throws Exception
     {
         config.setBodyChecksumVerified( true );
@@ -325,6 +349,7 @@
      * 
      * @throws Exception
      */
+    @Test
     public void testIntegrityCheckedFailed() throws Exception
     {
         KerberosPrincipal clientPrincipal = new KerberosPrincipal( "hnelson@EXAMPLE.COM" );
@@ -363,6 +388,7 @@
      * 
      * @throws Exception
      */
+    @Test
     public void testNotUs() throws Exception
     {
         KerberosPrincipal clientPrincipal = new KerberosPrincipal( "hnelson@EXAMPLE.COM" );
@@ -402,6 +428,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testRenewTicket() throws Exception
     {
         KerberosPrincipal clientPrincipal = new KerberosPrincipal( "hnelson@EXAMPLE.COM" );
@@ -445,6 +472,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testValidateTicket() throws Exception
     {
         // Get the mutable ticket part.
@@ -495,6 +523,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testProxyTicket() throws Exception
     {
         // Get the mutable ticket part.
@@ -553,6 +582,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testForwardedTicket() throws Exception
     {
         // Get the mutable ticket part.
@@ -612,6 +642,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testExpiredTgt() throws Exception
     {
         // Get the mutable ticket part.
@@ -658,6 +689,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testExpiredRenewableTicket() throws Exception
     {
         // Get the mutable ticket part.
@@ -706,6 +738,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testRenewableTicketNoRenew() throws Exception
     {
         long now = System.currentTimeMillis();
@@ -756,6 +789,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testRenewableTicketRenewal() throws Exception
     {
         long now = System.currentTimeMillis();
@@ -810,6 +844,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testEncryptionTypeNoSupport() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -843,6 +878,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testServerNullKey() throws Exception
     {
         KerberosPrincipal clientPrincipal = new KerberosPrincipal( "hnelson@EXAMPLE.COM" );
@@ -888,6 +924,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testStartTimeAbsentNoPostdate() throws Exception
     {
         // Get the mutable ticket part.
@@ -941,6 +978,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testStartTimeInThePastNoPostdate() throws Exception
     {
         // Get the mutable ticket part.
@@ -997,6 +1035,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testStartTimeAcceptableClockSkewNoPostdate() throws Exception
     {
         // Get the mutable ticket part.
@@ -1051,6 +1090,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testStartTimeOrderNeverValid() throws Exception
     {
         // Get the mutable ticket part.
@@ -1105,6 +1145,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testStartTimeMinimumNeverValid() throws Exception
     {
         // Get the mutable ticket part.
@@ -1157,6 +1198,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testStartTimeNoPostdated() throws Exception
     {
         // Get the mutable ticket part.
@@ -1218,6 +1260,7 @@
      * 
      * @throws Exception
      */
+    @Test
     public void testSpecificStartTime() throws Exception
     {
         long now = System.currentTimeMillis();
@@ -1278,6 +1321,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testPreAuthenticationFlag() throws Exception
     {
         // Get the mutable ticket part.
@@ -1328,6 +1372,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testSpecificEndTime() throws Exception
     {
         // Get the mutable ticket part.
@@ -1378,6 +1423,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testEndTimeExceedsMaximumAllowable() throws Exception
     {
         // Get the mutable ticket part.
@@ -1426,6 +1472,7 @@
      * 
      * @throws Exception
      */
+    @Test
     public void testEpochEndTime() throws Exception
     {
         // Get the mutable ticket part.
@@ -1480,6 +1527,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testRenewableOk() throws Exception
     {
         // Get the mutable ticket part.
@@ -1539,6 +1587,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testForwardableTicket() throws Exception
     {
         // Get the mutable ticket part.
@@ -1593,6 +1642,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testAllowPostdate() throws Exception
     {
         // Get the mutable ticket part.
@@ -1647,6 +1697,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testProxiableTicket() throws Exception
     {
         // Get the mutable ticket part.
@@ -1704,6 +1755,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testRenewableTicket() throws Exception
     {
         // Get the mutable ticket part.
@@ -1767,6 +1819,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testRenewableTicketExceedsMaximumAllowable() throws Exception
     {
         // Get the mutable ticket part.
@@ -1826,6 +1879,7 @@
      *     
      * @throws Exception 
      */
+    @Test
     public void testAuthenticatorSubKey() throws Exception
     {
         // Get the mutable ticket part.
@@ -1874,6 +1928,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testBadOptionReserved() throws Exception
     {
         KerberosPrincipal clientPrincipal = new KerberosPrincipal( "hnelson@EXAMPLE.COM" );

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java Tue Dec 30 08:34:06 2008
@@ -22,7 +22,6 @@
 
 import java.io.FileInputStream;
 import java.io.IOException;
-import java.net.InetSocketAddress;
 import java.security.KeyStore;
 import java.security.Provider;
 import java.security.Security;
@@ -85,7 +84,6 @@
 import org.apache.mina.filter.executor.OrderedThreadPoolExecutor;
 import org.apache.mina.handler.demux.MessageHandler;
 import org.apache.mina.transport.socket.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -409,7 +407,7 @@
                 return;
             }
 
-            getSocketAcceptor().unbind( new InetSocketAddress( getPort() ) );
+            getSocketAcceptor().unbind();
 
             if ( LOG.isInfoEnabled() )
             {
@@ -475,24 +473,8 @@
 
         try
         {
-            // First, create the acceptor with the configured number of threads (if defined)
-            int nbTcpThreads = getTcpTransport().getNbThreads();
-            SocketAcceptor acceptor;
+            SocketAcceptor acceptor = getSocketAcceptor();
             
-            if ( nbTcpThreads > 0 )
-            {
-                acceptor = new NioSocketAcceptor( nbTcpThreads );
-            }
-            else
-            {
-                acceptor = new NioSocketAcceptor();
-            }
-            
-            setSocketAcceptor( acceptor );
-            
-            // Set the service backlog
-            acceptor.setBacklog( backlog );
-                
             // Now, configure the acceptor
             // Disable the disconnection of the clients on unbind
             acceptor.setCloseOnDeactivation( false );
@@ -510,14 +492,7 @@
             acceptor.setHandler( getHandler() );
             
             // Bind to the configured address
-            if ( StringTools.isEmpty( hostname ) )
-            {
-                acceptor.bind( new InetSocketAddress( port ) );
-            }
-            else
-            {
-                acceptor.bind( new InetSocketAddress( hostname, port ) );
-            }
+            acceptor.bind();
             
             // We are done !
             started = true;

Modified: directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java (original)
+++ directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java Tue Dec 30 08:34:06 2008
@@ -23,17 +23,13 @@
 import org.apache.directory.server.ntp.protocol.NtpProtocolCodecFactory;
 import org.apache.directory.server.ntp.protocol.NtpProtocolHandler;
 import org.apache.directory.server.protocol.shared.AbstractProtocolService;
-import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.directory.server.protocol.shared.transport.Transport;
-import org.apache.directory.server.protocol.shared.transport.UdpTransport;
 import org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder;
 import org.apache.mina.core.service.IoHandler;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.apache.mina.transport.socket.DatagramAcceptor;
 import org.apache.mina.transport.socket.DatagramSessionConfig;
 import org.apache.mina.transport.socket.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.NioDatagramAcceptor;
-import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
@@ -89,14 +85,13 @@
         DefaultIoFilterChainBuilder ntpChain = new DefaultIoFilterChainBuilder();
         ntpChain.addLast( "codec", new ProtocolCodecFilter( NtpProtocolCodecFactory.getInstance() ) );
         
-        Transport udpTransport = getTcpTransport();
+        Transport udpTransport = getUdpTransport();
         
         if ( udpTransport != null )
         {
             // We have to create a DatagramAcceptor
-            DatagramAcceptor acceptor = new NioDatagramAcceptor();
-            setDatagramAcceptor( (NioDatagramAcceptor)acceptor );
-        
+            DatagramAcceptor acceptor = (DatagramAcceptor)udpTransport.getAcceptor();
+
             // Set the handler
             acceptor.setHandler( ntpProtocolHandler );
     
@@ -107,7 +102,7 @@
             acceptor.setFilterChainBuilder( ntpChain );
             
             // Start the listener
-            acceptor.bind( new InetSocketAddress( udpTransport.getAddress(), udpTransport.getPort() ) );
+            acceptor.bind();
         }
 
         Transport tcpTransport = getTcpTransport();
@@ -115,7 +110,7 @@
         if ( tcpTransport != null )
         {
             // It's a SocketAcceptor
-            SocketAcceptor acceptor = new NioSocketAcceptor();
+            SocketAcceptor acceptor = (SocketAcceptor)tcpTransport.getAcceptor();
             
             // Set the handler
             acceptor.setHandler( ntpProtocolHandler );
@@ -132,13 +127,8 @@
             // Inject the chain
             acceptor.setFilterChainBuilder( ntpChain );
 
-            setSocketAcceptor( acceptor );
-
-            // Set the backlog size
-            acceptor.setBacklog( tcpTransport.getBackLog() );
-
             // Start the listener
-            acceptor.bind( new InetSocketAddress( tcpTransport.getAddress(), tcpTransport.getPort() ) );
+            acceptor.bind();
         }
     }
 

Modified: directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpITest.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpITest.java (original)
+++ directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpITest.java Tue Dec 30 08:34:06 2008
@@ -34,6 +34,9 @@
 import org.apache.mina.filter.executor.ExecutorFilter;
 import org.apache.mina.transport.socket.nio.NioDatagramAcceptor;
 import org.apache.mina.util.AvailablePortFinder;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 
 /**
@@ -51,15 +54,15 @@
     /**
      * Set up a partition for EXAMPLE.COM and enable the NTP service.  The LDAP service is disabled.
      */
+    @Before
     public void setUp() throws Exception
     {
-        NioDatagramAcceptor datagramAcceptor = new NioDatagramAcceptor( null );
-        datagramAcceptor.getFilterChain().addLast( "executor", new ExecutorFilter( Executors.newCachedThreadPool() ) );
-        ntpConfig = new NtpServer();
+        ntpConfig = new NtpServer( );
         port = AvailablePortFinder.getNextAvailable( 10123 );
         ntpConfig.setTcpTransport( new TcpTransport( port ) );
         ntpConfig.setUdpTransport( new UdpTransport( port ) );
-        ntpConfig.setDatagramAcceptor( datagramAcceptor );
+        ntpConfig.getDatagramAcceptor().getFilterChain().addLast( "executor", new ExecutorFilter( Executors.newCachedThreadPool() ) );
+        ntpConfig.getSocketAcceptor().getFilterChain().addLast( "executor", new ExecutorFilter( Executors.newCachedThreadPool() ) );
         ntpConfig.setEnabled( true );
         ntpConfig.start();
 
@@ -70,6 +73,7 @@
      *
      * @throws Exception if there are errors
      */
+    @Test
     public void testNtp() throws Exception
     {
         long currentTime = System.currentTimeMillis();
@@ -93,6 +97,7 @@
     /**
      * Tear down.
      */
+    @After
     public void tearDown() throws Exception
     {
         ntpConfig.stop();

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=730170&r1=730169&r2=730170&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 Tue Dec 30 08:34:06 2008
@@ -292,6 +292,12 @@
     public void setTcpTransport( TcpTransport transport )
     {
         tcpTransport = transport;
+
+        if ( ( transport != null ) && ( transport.getAcceptor() == null ) )
+        {
+            transport.init();
+        }
+        
     }
     
     
@@ -302,6 +308,12 @@
     public void setUdpTransport( UdpTransport transport )
     {
         udpTransport = transport;
+
+        if ( ( transport != null ) && ( transport.getAcceptor() == null ) )
+        {
+            transport.init();
+        }
+        
     }
     
     
@@ -337,7 +349,7 @@
     /**
      * {@inheritDoc}
      * @org.apache.xbean.Property hidden="true"
-     */
+     *
     public void setDatagramAcceptor( DatagramAcceptor datagramAcceptor )
     {
         udpTransport.setAcceptor( datagramAcceptor );
@@ -356,7 +368,7 @@
     /**
      * {@inheritDoc}
      * @org.apache.xbean.Property hidden="true"
-     */
+     *
     public void setSocketAcceptor( SocketAcceptor socketAcceptor )
     {
         tcpTransport.setAcceptor( socketAcceptor );

Modified: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java (original)
+++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java Tue Dec 30 08:34:06 2008
@@ -37,13 +37,22 @@
     
     /** The IoAcceptor used to accept requests */
     protected IoAcceptor acceptor;
+    
+    protected static final int DEFAULT_BACKLOG_NB = 50;
+    
+    protected static final String LOCAL_HOST = "localhost";
+    
+    protected static final int DEFAULT_NB_THREADS = 3;
 
     /**
      * Creates an instance of an Abstract Transport class.
      */
     public AbstractTransport()
     {
-        address = "localHost";
+        address = LOCAL_HOST;
+        nbThreads = DEFAULT_NB_THREADS;
+        port = -1;
+        backlog = DEFAULT_BACKLOG_NB;
     }
     
     
@@ -61,6 +70,21 @@
     
     
     /**
+     * Creates an instance of an Abstract Transport class, using localhost
+     * and port.
+     * 
+     * @param port The port
+     * @param nbThreads The number of threads to create in the acceptor
+     */
+    public AbstractTransport( int port, int nbThreads )
+    {
+       this.address = "localhost";
+       this.port = port;
+       this.nbThreads = nbThreads;
+    }
+    
+    
+    /**
      * Creates an instance of an Abstract Transport class, using the given address
      * and port.
      * 
@@ -108,6 +132,12 @@
     
     
     /**
+     * Initialize the Acceptor if needed
+     */
+    public abstract void init();
+
+    
+    /**
      * {@inheritDoc}
      */
     public int getPort()
@@ -157,7 +187,7 @@
     /**
      * Set the IoAcceptor
      * @param acceptor The IoAcceptor to set
-     */
+     *
     public void setAcceptor ( IoAcceptor acceptor )
     {
         this.acceptor = acceptor;

Modified: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java (original)
+++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java Tue Dec 30 08:34:06 2008
@@ -18,7 +18,11 @@
  */
 package org.apache.directory.server.protocol.shared.transport;
 
+import java.net.InetSocketAddress;
+
+import org.apache.mina.core.service.IoAcceptor;
 import org.apache.mina.transport.socket.SocketAcceptor;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 
 /**
  * @org.apache.xbean.XBean
@@ -39,11 +43,26 @@
     
     /**
      * Creates an instance of the TcpTransport class on localhost
-     * @param port The port
+     * @param tcpPort The port
+     */
+    public TcpTransport( int tcpPort )
+    {
+        super( LOCAL_HOST, tcpPort, DEFAULT_NB_THREADS, DEFAULT_BACKLOG_NB );
+        
+        this.acceptor = createAcceptor( LOCAL_HOST, tcpPort, DEFAULT_NB_THREADS, DEFAULT_BACKLOG_NB );
+    }
+    
+    
+    /**
+     * Creates an instance of the TcpTransport class on localhost
+     * @param tcpPort The port
+     * @param nbThreads The number of threads to create in the acceptor
      */
-    public TcpTransport( int port )
+    public TcpTransport( int tcpPort, int nbThreads )
     {
-        super( port );
+        super( LOCAL_HOST, tcpPort, nbThreads, DEFAULT_BACKLOG_NB );
+        
+        this.acceptor = createAcceptor( LOCAL_HOST, tcpPort, nbThreads, DEFAULT_BACKLOG_NB );
     }
     
     
@@ -54,7 +73,8 @@
      */
     public TcpTransport( String address, int port )
     {
-        super( address, port );
+        super( address, port, DEFAULT_NB_THREADS, DEFAULT_BACKLOG_NB );
+        this.acceptor = createAcceptor( address, port, DEFAULT_NB_THREADS, DEFAULT_BACKLOG_NB );
     }
     
     
@@ -67,7 +87,8 @@
      */
     public TcpTransport( int tcpPort, int nbThreads, int backLog )
     {
-        super( tcpPort, nbThreads, backLog );
+        super( LOCAL_HOST, tcpPort, nbThreads, backLog );
+        this.acceptor = createAcceptor( LOCAL_HOST, tcpPort, nbThreads, backLog );
     }
     
     
@@ -82,6 +103,30 @@
     public TcpTransport( String address, int tcpPort, int nbThreads, int backLog )
     {
         super( address, tcpPort, nbThreads, backLog );
+        this.acceptor = createAcceptor( address, tcpPort, nbThreads, backLog );
+    }
+    
+    
+    /**
+     * Initialize the Acceptor if needed
+     */
+    public void init()
+    {
+        acceptor = createAcceptor( this.getAddress(), this.getPort(), this.getNbThreads(), this.getBackLog() );
+    }
+    
+    
+    /**
+     * Helper method to create an IoAcceptor
+     */
+    private IoAcceptor createAcceptor( String address, int port, int nbThreads, int backLog )
+    {
+        NioSocketAcceptor acceptor = new NioSocketAcceptor( nbThreads );
+        acceptor.setBacklog( backLog );
+        InetSocketAddress socketAddress = new InetSocketAddress( address, port ); 
+        acceptor.setDefaultLocalAddress( socketAddress );
+        
+        return acceptor;
     }
     
     

Modified: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/Transport.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/Transport.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/Transport.java (original)
+++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/Transport.java Tue Dec 30 08:34:06 2008
@@ -23,6 +23,11 @@
 public interface Transport
 {
     /**
+     * Initialize the Acceptor if needed
+     */
+    void init();
+
+    /**
      * @return The associated Address
      */
     String getAddress();
@@ -61,7 +66,7 @@
     /**
      * Set the IoAcceptor
      * @param acceptor The IoAcceptor to set
-     */
+     *
     void setAcceptor ( IoAcceptor acceptor );
 
 

Modified: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/UdpTransport.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/UdpTransport.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/UdpTransport.java (original)
+++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/UdpTransport.java Tue Dec 30 08:34:06 2008
@@ -18,7 +18,11 @@
  */
 package org.apache.directory.server.protocol.shared.transport;
 
+import java.net.InetSocketAddress;
+
+import org.apache.mina.core.service.IoAcceptor;
 import org.apache.mina.transport.socket.DatagramAcceptor;
+import org.apache.mina.transport.socket.nio.NioDatagramAcceptor;
 
 /**
  * @org.apache.xbean.XBean
@@ -39,38 +43,39 @@
     
     /**
      * Creates an instance of the UdpTransport class on localhost
-     * @param port The port
+     * @param udpPort The port
      */
-    public UdpTransport( int port )
+    public UdpTransport( int udpPort )
     {
-        super( port );
+        super( udpPort );
+        
+        this.acceptor = createAcceptor( LOCAL_HOST, udpPort );
+        
+        System.out.println( "UDP Transport created : <localhost:" + udpPort + ", 3>" );
     }
     
     
     /**
      * Creates an instance of the UdpTransport class 
      * @param address The address
-     * @param port The port
+     * @param udpPort The port
      */
-    public UdpTransport( String address, int port )
+    public UdpTransport( String address, int udpPort )
     {
-        super( address, port );
+        super( address, udpPort );
+        
+        this.acceptor = createAcceptor( LOCAL_HOST, udpPort );
     }
     
     
     /**
-     * Creates an instance of the UdpTransport class 
-     * @param address The address
-     * @param udpPort The port
-     * @param nbThreads The number of threads to create in the acceptor
-     * @param backlog The queue size for incoming messages, waiting for the
-     * acceptor to be ready
+     * Initialize the Acceptor if needed
      */
-    UdpTransport( String address, int udpPort, int nbThreads, int backLog )
+    public void init()
     {
-        super( address, udpPort, nbThreads, backLog );
+        acceptor = createAcceptor( this.getAddress(), this.getPort() );
     }
-    
+
     
     /**
      * @return The associated DatagramAcceptor
@@ -79,4 +84,17 @@
     {
         return acceptor == null ? null : (DatagramAcceptor)acceptor;
     }
+    
+    
+    /**
+     * Helper method to create an IoAcceptor
+     */
+    private IoAcceptor createAcceptor( String address, int port )
+    {
+        NioDatagramAcceptor acceptor = new NioDatagramAcceptor();
+        InetSocketAddress socketAddress = new InetSocketAddress( address, port ); 
+        acceptor.setDefaultLocalAddress( socketAddress );
+        
+        return acceptor;
+    }
 }

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=730170&r1=730169&r2=730170&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 Tue Dec 30 08:34:06 2008
@@ -256,9 +256,6 @@
         port = AvailablePortFinder.getNextAvailable( 1024 );
         ldapService = new LdapService();
         ldapService.setTcpTransport( new TcpTransport( port ) );
-        ldapService.getTcpTransport().setNbThreads( 3 );
-        socketAcceptor = new NioSocketAcceptor();
-        ldapService.setSocketAcceptor( socketAcceptor );
         ldapService.setDirectoryService( directoryService );
 
         setupSaslMechanisms( ldapService );

Modified: directory/installers/trunk/apacheds-noarch/src/main/java/org/apache/directory/server/Service.java
URL: http://svn.apache.org/viewvc/directory/installers/trunk/apacheds-noarch/src/main/java/org/apache/directory/server/Service.java?rev=730170&r1=730169&r2=730170&view=diff
==============================================================================
--- directory/installers/trunk/apacheds-noarch/src/main/java/org/apache/directory/server/Service.java (original)
+++ directory/installers/trunk/apacheds-noarch/src/main/java/org/apache/directory/server/Service.java Tue Dec 30 08:34:06 2008
@@ -31,8 +31,7 @@
 import org.apache.directory.server.kerberos.kdc.KdcServer;
 import org.apache.directory.server.ldap.LdapService;
 import org.apache.directory.server.ntp.NtpServer;
-import org.apache.mina.transport.socket.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.xbean.spring.context.FileSystemXmlApplicationContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -109,17 +108,16 @@
             LOG.info( "server: using default settings ..." );
             DirectoryService directoryService = new DefaultDirectoryService();
             directoryService.startup();
-            SocketAcceptor socketAcceptor = new NioSocketAcceptor();
             LdapService ldapService = new LdapService();
-            ldapService.setSocketAcceptor( socketAcceptor );
             ldapService.setDirectoryService( directoryService );
+            ldapService.setTcpTransport( new TcpTransport( 10389 ) );
             ldapService.start();
-            LdapService ldapsServer = new LdapService();
-            ldapsServer.setEnableLdaps( true );
-            ldapsServer.setSocketAcceptor( socketAcceptor );
-            ldapsServer.setDirectoryService( directoryService );
-            ldapsServer.start();
-            apacheDS = new ApacheDS( directoryService, ldapService, ldapsServer );
+            LdapService ldapsService = new LdapService();
+            ldapService.setTcpTransport( new TcpTransport( 10686 ) );
+            ldapsService.setEnableLdaps( true );
+            ldapsService.setDirectoryService( directoryService );
+            ldapsService.start();
+            apacheDS = new ApacheDS( directoryService, ldapService, ldapsService );
         }
 
         if ( install != null )



Mime
View raw message