package com.yahoo.document.restapi;

import com.yahoo.application.Application;
import com.yahoo.application.Networking;
import org.junit.Test;

/**
 * @author bratseth
 */
public class DocumentApiApplicationTest {

    /** Test that it is possible to instantiate an Application with a document-api */
    @Test
    public void application_with_document_api() {
        String services =
                "<container version='1.0'>" +
                "    <document-api/>" +
                "</container>";
        try (Application application = Application.fromServicesXml(services, Networking.enable)) {
        }
    }

}

package com.yahoo.document.restapi;

import com.yahoo.application.Application;
import com.yahoo.application.Networking;
import org.junit.Test;

import java.io.IOException;
import java.net.ServerSocket;

/**
 * @author bratseth
 */
public class DocumentApiApplicationTest {

    /** Test that it is possible to instantiate an Application with a document-api */
    @Test
    public void application_with_document_api() throws IOException {
        String services =
                "<jdisc version='1.0'>" +
                "    <http><server port=\"" + findRandomOpenPortOnAllLocalInterfaces() + "\" id=\"foobar\"/></http>" +
                "    <document-api/>" +
                "</jdisc>";
        try (Application application = Application.fromServicesXml(services, Networking.enable)) {
        }
    }

    private int findRandomOpenPortOnAllLocalInterfaces() throws IOException {
           return new ServerSocket(0).getLocalPort();
    }
}

Make test not require port 4080 to be available.
Make test not require port 4080 to be available.
