com.landoop.kafka.testing.PortProvider.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kafka-testing_2.11 Show documentation
Show all versions of kafka-testing_2.11 Show documentation
Kafka Unit Testing: Embeded broker, ZK, SR, Connect services
The newest version!
package com.landoop.kafka.testing
import java.net.{InetAddress, ServerSocket}
object PortProvider {
def appy(count: Int): Vector[Int] = {
(1 to count).map { _ =>
val serverSocket = new ServerSocket(0, 0, InetAddress.getLocalHost)
val port = serverSocket.getLocalPort
serverSocket.close()
port
}.toVector
}
def one: Int = appy(1).head
}