+doc #19429 initial merge of docs-dev and docs
This commit is contained in:
parent
be0c8af4c0
commit
5a18d43435
501 changed files with 9876 additions and 3681 deletions
24
akka-docs/rst/scala/code/docs/utils/TestUtils.scala
Normal file
24
akka-docs/rst/scala/code/docs/utils/TestUtils.scala
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
|
||||
*/
|
||||
|
||||
package docs.utils
|
||||
|
||||
import java.net.InetSocketAddress
|
||||
import java.nio.channels.ServerSocketChannel
|
||||
|
||||
object TestUtils {
|
||||
def temporaryServerAddress(interface: String = "127.0.0.1"): InetSocketAddress = {
|
||||
val serverSocket = ServerSocketChannel.open()
|
||||
try {
|
||||
serverSocket.socket.bind(new InetSocketAddress(interface, 0))
|
||||
val port = serverSocket.socket.getLocalPort
|
||||
new InetSocketAddress(interface, port)
|
||||
} finally serverSocket.close()
|
||||
}
|
||||
|
||||
def temporaryServerHostnameAndPort(interface: String = "127.0.0.1"): (String, Int) = {
|
||||
val socketAddress = temporaryServerAddress(interface)
|
||||
socketAddress.getHostName -> socketAddress.getPort // TODO getHostString in Java7
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue