atom feed10 messages in org.apache.tomcat.devRe: Embeded Tomcat using a Connector ...
FromSent OnAttachments
Olivier LamyOct 9, 2011 7:08 am 
Mark ThomasOct 9, 2011 9:39 am 
Olivier LamyOct 9, 2011 10:37 am 
Konstantin KolinkoOct 9, 2011 3:58 pm 
Olivier LamyOct 14, 2011 1:27 am 
Henri GomezOct 14, 2011 1:34 am 
Konstantin KolinkoOct 14, 2011 4:33 am 
Mark ThomasOct 14, 2011 4:35 am 
Olivier LamyOct 14, 2011 5:40 am 
Konstantin KolinkoOct 14, 2011 5:57 am 
Subject:Re: Embeded Tomcat using a Connector with a random port (port 0)
From:Mark Thomas (mar@apache.org)
Date:Oct 9, 2011 9:39:05 am
List:org.apache.tomcat.dev

On 09/10/2011 15:08, Olivier Lamy wrote:

Hello, I'd like to be able to use a random port when using embedded Tomcat in unit tests to test servlets. Currently it's "locked" by a test in Connector#startInternal. Is it intentional ?

svn blame would have answered that for you.

I'd like to be able to do simply something like :

Tomcat tomcat = new Tomcat(); tomcat.setBaseDir(System.getProperty("java.io.tmpdir")); tomcat.getConnector().setPort( 0 );

If you want a random port, why not just set a random port at this point?

Makes sense for to add getLocalPort on Connector class and remove the test if (getPort() < 1) ?

No.

If yes I can start on providing a patch for review.

I'd be against adding that patch to the code base.

Mark