blob: ec9cdc594e9292a2ec13d09109cc604ec6decc64 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
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 {
ServerSocket socket = new ServerSocket(0);
socket.setReuseAddress(true);
int port = socket.getLocalPort();
socket.close();
return port;
}
}
|