Skip to content

Commit

Permalink
Merge pull request akka#447 from jonas/scala-2.12.0-RC2
Browse files Browse the repository at this point in the history
Cross compile to Scala 2.12.0-RC2 (akka#437)
  • Loading branch information
jrudolph authored Nov 1, 2016
2 parents a9cfe58 + 1fc56c4 commit 4bfd320
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class DebuggingDirectivesSpec extends RoutingSpec {

def resetDebugMsg(): Unit = { debugMsg = "" }

// Gracefully handle prefix difference for `ByteString.ByteString1C`
// in Scala 2.12 due to https://issues.scala-lang.org/browse/SI-9019.
def normalizedDebugMsg(): String =
debugMsg.replace("ByteString.ByteString1C(", "ByteString(")

val log = new LoggingAdapter {
def isErrorEnabled = true
def isWarningEnabled = true
Expand All @@ -36,7 +41,7 @@ class DebuggingDirectivesSpec extends RoutingSpec {
resetDebugMsg()
Get("/hello") ~> route ~> check {
response shouldEqual Ok
debugMsg shouldEqual "1: HttpRequest(HttpMethod(GET),http://example.com/hello,List(),HttpEntity.Strict(none/none,ByteString()),HttpProtocol(HTTP/1.1))\n"
normalizedDebugMsg shouldEqual "1: HttpRequest(HttpMethod(GET),http://example.com/hello,List(),HttpEntity.Strict(none/none,ByteString()),HttpProtocol(HTTP/1.1))\n"
}
}
}
Expand All @@ -51,7 +56,7 @@ class DebuggingDirectivesSpec extends RoutingSpec {
resetDebugMsg()
Get("/hello") ~> route ~> check {
response shouldEqual Ok
debugMsg shouldEqual "2: Complete(HttpResponse(200 OK,List(),HttpEntity.Strict(none/none,ByteString()),HttpProtocol(HTTP/1.1)))\n"
normalizedDebugMsg shouldEqual "2: Complete(HttpResponse(200 OK,List(),HttpEntity.Strict(none/none,ByteString()),HttpProtocol(HTTP/1.1)))\n"
}
}
}
Expand All @@ -66,12 +71,13 @@ class DebuggingDirectivesSpec extends RoutingSpec {
resetDebugMsg()
Get("/hello") ~> route ~> check {
response shouldEqual Ok
debugMsg shouldEqual """|3: Response for
| Request : HttpRequest(HttpMethod(GET),http://example.com/hello,List(),HttpEntity.Strict(none/none,ByteString()),HttpProtocol(HTTP/1.1))
| Response: Complete(HttpResponse(200 OK,List(),HttpEntity.Strict(none/none,ByteString()),HttpProtocol(HTTP/1.1)))
|""".stripMarginWithNewline("\n")
normalizedDebugMsg shouldEqual
"""|3: Response for
| Request : HttpRequest(HttpMethod(GET),http://example.com/hello,List(),HttpEntity.Strict(none/none,ByteString()),HttpProtocol(HTTP/1.1))
| Response: Complete(HttpResponse(200 OK,List(),HttpEntity.Strict(none/none,ByteString()),HttpProtocol(HTTP/1.1)))
|""".stripMarginWithNewline("\n")
}
}
}

}
}
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ inThisBuild(Def.settings(
startYear := Some(2014),
// test in assembly := {},
licenses := Seq("Apache License 2.0" -> url("https://opensource.org/licenses/Apache-2.0")),
scalaVersion := "2.11.8",
scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8", // yes, this is 2 args
Expand Down
6 changes: 1 addition & 5 deletions docs/src/main/paradox/scala/http/common/json-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ To enable automatic support for (un)marshalling from and to JSON with [spray-jso

Next, provide a `RootJsonFormat[T]` for your type and bring it into scope. Check out the [spray-json] documentation for more info on how to do this.

Finally, mix in the `akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport` trait as shown in the example below or import the `FromEntityUnmarshaller[T]` and `ToEntityMarshaller[T]` implicits directly from `SprayJsonSupport`

```scala
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
```
Finally, import the `FromEntityUnmarshaller[T]` and `ToEntityMarshaller[T]` implicits directly from `SprayJsonSupport` as shown in the example below or mix the `akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport` trait into your JSON support module.

Once you have done this (un)marshalling between JSON and your type `T` should work nicely and transparently.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,28 @@
*/
package docs.http.scaladsl

import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.server.Directives
import org.scalatest.{ Matchers, WordSpec }

class SprayJsonPrettyMarshalSpec extends server.RoutingSpec {

"spray-json example" in {
//#example
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import spray.json._

// domain model
final case class PrettyPrintedItem(name: String, id: Long)

trait PrettyJsonFormatSupport extends DefaultJsonProtocol with SprayJsonSupport {
object PrettyJsonFormatSupport {
import DefaultJsonProtocol._
implicit val printer = PrettyPrinter
implicit val prettyPrintedItemFormat = jsonFormat2(PrettyPrintedItem)
}

// use it wherever json (un)marshalling is needed
class MyJsonService extends Directives with PrettyJsonFormatSupport {
class MyJsonService extends Directives {
import PrettyJsonFormatSupport._

// format: OFF
val route =
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object Dependencies {
lazy val java8CompatVersion = settingKey[String]("The version of scala-java8-compat to use.")

val Versions = Seq(
crossScalaVersions := Seq("2.11.8"), // "2.12.0-RC1"
crossScalaVersions := Seq("2.11.8", "2.12.0-RC2"),
scalaVersion := crossScalaVersions.value.head,
scalaCheckVersion := sys.props.get("akka.build.scalaCheckVersion").getOrElse("1.13.2"),
scalaTestVersion := {
Expand Down

0 comments on commit 4bfd320

Please sign in to comment.