commit
ed35df0a44
7 changed files with 20 additions and 32 deletions
|
|
@ -10,10 +10,8 @@ import akka.stream.testkit.{ TestSubscriber, TestPublisher, AkkaSpec, TestUtils,
|
|||
import akka.http.scaladsl.model.headers
|
||||
|
||||
class ClientCancellationSpec extends AkkaSpec("""
|
||||
#akka.loggers = []
|
||||
akka.loglevel = DEBUG
|
||||
#akka.io.tcp.trace-logging = off
|
||||
akka.io.tcp.windows-connection-abort-workaround-enabled=auto""") {
|
||||
akka.io.tcp.trace-logging = off""") {
|
||||
|
||||
implicit val materializer = ActorMaterializer()
|
||||
val noncheckedMaterializer = ActorMaterializer()
|
||||
|
|
|
|||
|
|
@ -26,8 +26,7 @@ import akka.http.scaladsl.model._
|
|||
class ConnectionPoolSpec extends AkkaSpec("""
|
||||
akka.loggers = []
|
||||
akka.loglevel = OFF
|
||||
akka.io.tcp.trace-logging = off
|
||||
akka.io.tcp.windows-connection-abort-workaround-enabled=auto""") {
|
||||
akka.io.tcp.trace-logging = off""") {
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
// FIXME: Extract into proper util class to be reusable
|
||||
|
|
|
|||
|
|
@ -20,10 +20,8 @@ import akka.testkit.EventFilter
|
|||
import javax.net.ssl.SSLException
|
||||
|
||||
class TlsEndpointVerificationSpec extends AkkaSpec("""
|
||||
#akka.loggers = []
|
||||
akka.loglevel = DEBUG
|
||||
akka.io.tcp.trace-logging = off
|
||||
akka.io.tcp.windows-connection-abort-workaround-enabled=auto""") with ScalaFutures {
|
||||
akka.io.tcp.trace-logging = off""") with ScalaFutures {
|
||||
implicit val materializer = ActorMaterializer()
|
||||
val timeout = Timeout(Span(3, Seconds))
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ class ClientServerSpec extends WordSpec with Matchers with BeforeAndAfterAll {
|
|||
akka.loglevel = ERROR
|
||||
akka.stdout-loglevel = ERROR
|
||||
akka.log-dead-letters = OFF
|
||||
akka.io.tcp.windows-connection-abort-workaround-enabled = auto
|
||||
""")
|
||||
implicit val system = ActorSystem(getClass.getSimpleName, testConf)
|
||||
import system.dispatcher
|
||||
|
|
|
|||
|
|
@ -41,21 +41,21 @@ class FormFieldDirectivesSpec extends RoutingSpec {
|
|||
"The 'formFields' extraction directive" should {
|
||||
"properly extract the value of www-urlencoded form fields" in {
|
||||
Post("/", urlEncodedForm) ~> {
|
||||
formFields('firstName, "age".as[Int], 'sex?, "VIP" ? false) { (firstName, age, sex, vip) ⇒
|
||||
formFields('firstName, "age".as[Int], 'sex.?, "VIP" ? false) { (firstName, age, sex, vip) ⇒
|
||||
complete(firstName + age + sex + vip)
|
||||
}
|
||||
} ~> check { responseAs[String] shouldEqual "Mike42Nonefalse" }
|
||||
}
|
||||
"properly extract the value of www-urlencoded form fields when an explicit unmarshaller is given" in {
|
||||
Post("/", urlEncodedForm) ~> {
|
||||
formFields('firstName, "age".as(HexInt), 'sex?, "VIP" ? false) { (firstName, age, sex, vip) ⇒
|
||||
formFields('firstName, "age".as(HexInt), 'sex.?, "VIP" ? false) { (firstName, age, sex, vip) ⇒
|
||||
complete(firstName + age + sex + vip)
|
||||
}
|
||||
} ~> check { responseAs[String] shouldEqual "Mike66Nonefalse" }
|
||||
}
|
||||
"properly extract the value of multipart form fields" in {
|
||||
Post("/", multipartForm) ~> {
|
||||
formFields('firstName, "age", 'sex?, "VIP" ? nodeSeq) { (firstName, age, sex, vip) ⇒
|
||||
formFields('firstName, "age", 'sex.?, "VIP" ? nodeSeq) { (firstName, age, sex, vip) ⇒
|
||||
complete(firstName + age + sex + vip)
|
||||
}
|
||||
} ~> check { responseAs[String] shouldEqual "Mike<int>42</int>None<b>yes</b>" }
|
||||
|
|
@ -78,7 +78,7 @@ class FormFieldDirectivesSpec extends RoutingSpec {
|
|||
"properly extract the value if only a urlencoded deserializer is available for a multipart field that comes without a" +
|
||||
"Content-Type (or text/plain)" in {
|
||||
Post("/", multipartForm) ~> {
|
||||
formFields('firstName, "age", 'sex?, "VIPBoolean" ? false) { (firstName, age, sex, vip) ⇒
|
||||
formFields('firstName, "age", 'sex.?, "VIPBoolean" ? false) { (firstName, age, sex, vip) ⇒
|
||||
complete(firstName + age + sex + vip)
|
||||
}
|
||||
} ~> check {
|
||||
|
|
@ -96,7 +96,7 @@ class FormFieldDirectivesSpec extends RoutingSpec {
|
|||
}
|
||||
"work even if only a FromEntityUnmarshaller is available for a www-urlencoded field" in {
|
||||
Post("/", urlEncodedFormWithVip) ~> {
|
||||
formFields('firstName, "age", 'sex?, "super" ? nodeSeq) { (firstName, age, sex, vip) ⇒
|
||||
formFields('firstName, "age", 'sex.?, "super" ? nodeSeq) { (firstName, age, sex, vip) ⇒
|
||||
complete(firstName + age + sex + vip)
|
||||
}
|
||||
} ~> check {
|
||||
|
|
@ -107,17 +107,17 @@ class FormFieldDirectivesSpec extends RoutingSpec {
|
|||
"The 'formField' requirement directive" should {
|
||||
"block requests that do not contain the required formField" in {
|
||||
Post("/", urlEncodedForm) ~> {
|
||||
formFields('name ! "Mr. Mike") { completeOk }
|
||||
formField('name ! "Mr. Mike") { completeOk }
|
||||
} ~> check { handled shouldEqual false }
|
||||
}
|
||||
"block requests that contain the required parameter but with an unmatching value" in {
|
||||
Post("/", urlEncodedForm) ~> {
|
||||
formFields('firstName ! "Pete") { completeOk }
|
||||
formField('firstName ! "Pete") { completeOk }
|
||||
} ~> check { handled shouldEqual false }
|
||||
}
|
||||
"let requests pass that contain the required parameter with its required value" in {
|
||||
Post("/", urlEncodedForm) ~> {
|
||||
formFields('firstName ! "Mike") { completeOk }
|
||||
formField('firstName ! "Mike") { completeOk }
|
||||
} ~> check { response shouldEqual Ok }
|
||||
}
|
||||
}
|
||||
|
|
@ -125,17 +125,17 @@ class FormFieldDirectivesSpec extends RoutingSpec {
|
|||
"The 'formField' requirement with explicit unmarshaller directive" should {
|
||||
"block requests that do not contain the required formField" in {
|
||||
Post("/", urlEncodedForm) ~> {
|
||||
formFields('oldAge.as(HexInt) ! 78) { completeOk }
|
||||
formField('oldAge.as(HexInt) ! 78) { completeOk }
|
||||
} ~> check { handled shouldEqual false }
|
||||
}
|
||||
"block requests that contain the required parameter but with an unmatching value" in {
|
||||
Post("/", urlEncodedForm) ~> {
|
||||
formFields('age.as(HexInt) ! 78) { completeOk }
|
||||
formField('age.as(HexInt) ! 78) { completeOk }
|
||||
} ~> check { handled shouldEqual false }
|
||||
}
|
||||
"let requests pass that contain the required parameter with its required value" in {
|
||||
Post("/", urlEncodedForm) ~> {
|
||||
formFields('age.as(HexInt) ! 66 /* hex! */ ) { completeOk }
|
||||
formField('age.as(HexInt) ! 66 /* hex! */ ) { completeOk }
|
||||
} ~> check { response shouldEqual Ok }
|
||||
}
|
||||
}
|
||||
|
|
@ -143,22 +143,22 @@ class FormFieldDirectivesSpec extends RoutingSpec {
|
|||
"The 'formField' repeated directive" should {
|
||||
"extract an empty Iterable when the parameter is absent" in {
|
||||
Post("/", FormData("age" -> "42")) ~> {
|
||||
formFields('hobby.*) { echoComplete }
|
||||
formField('hobby.*) { echoComplete }
|
||||
} ~> check { responseAs[String] === "List()" }
|
||||
}
|
||||
"extract all occurrences into an Iterable when parameter is present" in {
|
||||
Post("/", FormData("age" -> "42", "hobby" -> "cooking", "hobby" -> "reading")) ~> {
|
||||
formFields('hobby.*) { echoComplete }
|
||||
formField('hobby.*) { echoComplete }
|
||||
} ~> check { responseAs[String] === "List(cooking, reading)" }
|
||||
}
|
||||
"extract as Iterable[Int]" in {
|
||||
Post("/", FormData("age" -> "42", "number" -> "3", "number" -> "5")) ~> {
|
||||
formFields('number.as[Int]*) { echoComplete }
|
||||
formField('number.as[Int].*) { echoComplete }
|
||||
} ~> check { responseAs[String] === "List(3, 5)" }
|
||||
}
|
||||
"extract as Iterable[Int] with an explicit deserializer" in {
|
||||
Post("/", FormData("age" -> "42", "number" -> "3", "number" -> "A")) ~> {
|
||||
formFields('number.as(HexInt)*) { echoComplete }
|
||||
formField('number.as(HexInt).*) { echoComplete }
|
||||
} ~> check { responseAs[String] === "List(3, 10)" }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,14 +8,11 @@ import akka.http.javadsl.server.RequestVal
|
|||
import akka.http.javadsl.server.values.FormField
|
||||
import akka.http.scaladsl.common.{ StrictForm, NameUnmarshallerReceptacle, NameReceptacle }
|
||||
import akka.http.scaladsl.unmarshalling._
|
||||
import akka.http.scaladsl.util.FastFuture
|
||||
import akka.japi.{ Option ⇒ JOption }
|
||||
|
||||
import scala.concurrent.{ Future, ExecutionContext }
|
||||
import scala.reflect.ClassTag
|
||||
import akka.http.scaladsl.server.directives.FormFieldDirectives
|
||||
import akka.http.scaladsl.server.directives.FormFieldDirectives._
|
||||
import akka.http.scaladsl.server.{ Directives, Directive1 }
|
||||
import FormFieldDirectives._
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
|
|
|
|||
|
|
@ -19,10 +19,7 @@ import scala.concurrent.duration._
|
|||
import java.net.BindException
|
||||
import akka.testkit.EventFilter
|
||||
|
||||
class TcpSpec extends AkkaSpec(
|
||||
"""
|
||||
|akka.io.tcp.windows-connection-abort-workaround-enabled=auto
|
||||
|akka.stream.materializer.subscription-timeout.timeout = 2s""".stripMargin) with TcpHelper {
|
||||
class TcpSpec extends AkkaSpec("akka.stream.materializer.subscription-timeout.timeout = 2s") with TcpHelper {
|
||||
var demand = 0L
|
||||
|
||||
"Outgoing TCP stream" must {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue