directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <elecha...@apache.org>
Subject Re: Need to control what port is used with unit testing setup
Date Wed, 16 Sep 2009 22:57:05 GMT
And if you want to launch the server within the Unit tests, you can 
define your own DirectoryServer factory where you define the port to use.

For instance, have a look at the MiscBindIT test (in the server-integ 
project, operations.bind package). It defines a LdapServerFactory where 
the port is selected by this line :

...
            int port = AvailablePortFinder.getNextAvailable( 1024 );
...

Just replace this line by what you want the port to be, it should work.

Paul Edwards wrote:
> Gary,
>
> I'm using apacheDS for unit testing. I do the following to control what port the service
is started on:
>
> TcpTransport transport = new TcpTransport(port, numberOfThreads);
> 		transport.enableSSL(useSsl);
>         LdapServer serv = new LdapServer();
>         serv.setTransports(transport);
>         serv.setDirectoryService(directoryService);
>                 
>         log.debug("Server is ssl enabled: " + transport.isSSLEnabled());
>         log.debug("Server enabled: " + serv.isEnabled());
>         serv.start();
>
> Hope that helps.
>
> --
> Paul Edwards
> Solutions Engineer
> Identity Solutions Practice
> ---------------------------------------------------------
> hyro
> W www.hyro.com
>
> ________________________________________
> From: Gary Horton [gary.horton@comcast.net]
> Sent: Thursday, 17 September 2009 7:31 a.m.
> To: users@directory.apache.org
> Subject: Need to control what port is used with unit testing setup
>
> Hi Apache DS team -
>
>     As per your invitation to ask for help at the bottom of
> http://directory.apache.org/apacheds/1.5/42-using-apacheds-for-unit-tests.html,
> I do have a question for you.
>
>     I've succeeded starting up and connecting to the standalone server,
> and in setting up the embedded server. Next I started looking at the
> unit testing instructions on your website, but have come to a dilemma.
> In the section "Creating a Blank Test", it is stated that "...let's
> declare the framework for a simple unit test, using a server which will
> be used through socket (the first free port above 1023 will be used)..."
> - and I see from looking at the LdapServerFactory source that indeed
> this is how it is done. I wonder however if there are any hidden hooks
> you might have that would allow us to control what port is used - or to
> at least find out at runtime what port has been selected.
>
>     We'd need this information because we are using iBatis, connecting
> to a JDBC-LDAP bridge driver (http://myvd.sourceforge.net/bridge.html).
> To make the iBatis connection, we need a database URL, something like
> jdbc:ldap://localhost:10389/ou=system (which works out of the box with
> the standalone service for Apache DS). So one way or the other, we'd
> need to at a minimum know what port is in use, or better yet be able to
> set that port explicitly.
>
>     Any ideas? Thanks mucho for any help here -
>   

> Best,
> Gary Horton
>
>
>   


-- 
--
cordialement, regards,
Emmanuel L├ęcharny
www.iktek.com
directory.apache.org



Mime
View raw message