Skip to content
Browse files

moved random socket into util

  • Loading branch information...
1 parent 2427f24 commit 950bfa2bd2ded7ba506c906257774bb98264d15e Nick Kallen committed Jan 6, 2011
View
31 finagle-core/src/test/scala/com/twitter/finagle/Common.scala
@@ -1,31 +0,0 @@
-package com.twitter.finagle
-
-import java.net.{InetAddress, InetSocketAddress, Socket}
-import java.util.Random
-
-object RandomSocket {
- private[this] val rng = new Random
- private[this] def localSocketOnPort(port: Int) =
- new InetSocketAddress(port)
- private[this] val ephemeralSocketAddress = localSocketOnPort(0)
-
- def apply() = nextAddress()
-
- def nextAddress(): InetSocketAddress =
- localSocketOnPort(nextPort())
-
- def nextPort(): Int = {
- val s = new Socket
- s.setReuseAddress(true)
- try {
- s.bind(ephemeralSocketAddress)
- s.getLocalPort
- } catch {
- case e: Throwable =>
- throw new Exception("Couldn't find an open port: %s".format(e.getMessage))
- } finally {
- s.close()
- }
- }
-}
-
View
2 finagle-thrift/src/test/scala/com/twitter/finagle/thrift/EndToEnd.scala
@@ -26,7 +26,7 @@ import org.jboss.netty.channel.socket.nio.{
import com.twitter.util.{Promise, Return, Throw}
import com.twitter.util.TimeConversions._
import com.twitter.silly.Silly
-import com.twitter.finagle.RandomSocket
+import com.twitter.util.RandomSocket
import com.twitter.finagle.util.Conversions._
object EndToEndSpec extends Specification {
View
2 finagle-thrift/src/test/scala/com/twitter/finagle/thrift/ServiceEndToEnd.scala
@@ -9,7 +9,7 @@ import org.apache.thrift.TBase
import org.jboss.netty.channel._
import org.jboss.netty.channel.local._
-import com.twitter.finagle.RandomSocket
+import com.twitter.util.RandomSocket
import com.twitter.finagle.builder._
import com.twitter.finagle.service._

0 comments on commit 950bfa2

Please sign in to comment.
Something went wrong with that request. Please try again.