Good suggestion. I opened OAK-5483 to track this.

2017-01-19 5:26 GMT+01:00 Chetan Mehrotra <[email protected]>:
> Hi Francesco,
>
> On Wed, Jan 18, 2017 at 7:01 PM,  <[email protected]> wrote:
>> +package org.apache.jackrabbit.oak.segment.test;
>> +
>> +import java.net.ServerSocket;
>> +
>> +import org.junit.rules.ExternalResource;
>> +
>> +public class TemporaryPort extends ExternalResource {
>> +
>> +    private int port;
>> +
>> +    @Override
>> +    protected void before() throws Throwable {
>> +        try (ServerSocket socket = new ServerSocket(0)) {
>> +            port = socket.getLocalPort();
>> +        }
>> +    }
>> +
>> +    public int getPort() {
>> +        return port;
>> +    }
>> +
>> +}
>
> This looks useful and can be used in other places also like in [1].
> Would be good if we can move it to oak-commons in
> org.apache.jackrabbit.oak.commons.junit package.
>
> Chetan Mehrotra
> [1] 
> https://issues.apache.org/jira/browse/OAK-5441?focusedCommentId=15823491&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15823491

Reply via email to