Skip to content

Commit

Permalink
Merge pull request #263 from hvesalai/jetty9
Browse files Browse the repository at this point in the history
Migrated scalatra-scalatest to jetty9
  • Loading branch information
casualjim committed Mar 28, 2013
2 parents e449289 + 39993c4 commit a5fab65
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions project/build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ object ScalatraBuild extends Build {
lazy val jerkson = "io.backchat.jerkson" %% "jerkson" % "0.7.0"
lazy val jettyServer = "org.eclipse.jetty" % "jetty-server" % jettyVersion
lazy val jettyServlet = "org.eclipse.jetty" % "jetty-servlet" % jettyVersion
lazy val jettyWebsocket = "org.eclipse.jetty" % "jetty-websocket" % jettyVersion
lazy val jettyWebsocket = "org.eclipse.jetty.websocket" % "websocket-server" % jettyVersion
lazy val jettyWebapp = "org.eclipse.jetty" % "jetty-webapp" % jettyVersion
lazy val jodaConvert = "org.joda" % "joda-convert" % "1.2"
lazy val jodaTime = "joda-time" % "joda-time" % "2.1"
Expand Down Expand Up @@ -309,7 +309,7 @@ object ScalatraBuild extends Build {

private val httpcomponentsVersion = "4.2.3"

private val jettyVersion = "8.1.8.v20121106"
private val jettyVersion = "9.0.0.v20130308"

private val json4sVersion = "3.1.0"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.scalatra.test

import org.eclipse.jetty.server.Server
import org.eclipse.jetty.server.ServerConnector
import org.eclipse.jetty.servlet.ServletContextHandler

trait EmbeddedJettyContainer extends JettyContainer {
Expand All @@ -11,10 +12,13 @@ trait EmbeddedJettyContainer extends JettyContainer {

/**
* The port of the currently running Jetty. May differ from port if port is 0.
*
*
* @return Some port if Jetty is currently listening, or None if it is not.
*/
def localPort: Option[Int] = server.getConnectors.headOption map { _.getLocalPort }
def localPort: Option[Int] = server.getConnectors.headOption map {
case conn: ServerConnector => conn.getLocalPort
case _ => sys.error("can't get local port")
}

def contextPath = "/"

Expand All @@ -36,11 +40,11 @@ trait EmbeddedJettyContainer extends JettyContainer {

def baseUrl: String =
server.getConnectors.headOption match {
case Some(conn) =>
case Some(conn: ServerConnector) =>
val host = Option(conn.getHost) getOrElse "localhost"
val port = conn.getLocalPort
"http://%s:%d".format(host, port)
case None =>
case _ =>
sys.error("can't calculate base URL: no connector")
}
}
Expand Down

0 comments on commit a5fab65

Please sign in to comment.