From 474fb870e9a27c9c9ec2e86b727ba18ba0201c58 Mon Sep 17 00:00:00 2001 From: 2beaucoup Date: Mon, 7 Dec 2015 16:24:57 +0100 Subject: [PATCH 1/2] =htc: minor cleanups --- .../client/ClientCancellationSpec.scala | 4 +-- .../client/TlsEndpointVerificationSpec.scala | 1 - .../directives/FormFieldDirectivesSpec.scala | 30 +++++++++---------- .../akka/http/impl/server/FormFieldImpl.scala | 5 +--- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/client/ClientCancellationSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/client/ClientCancellationSpec.scala index 52c7b40653..0d02eb6aca 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/client/ClientCancellationSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/client/ClientCancellationSpec.scala @@ -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() diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/client/TlsEndpointVerificationSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/client/TlsEndpointVerificationSpec.scala index 71ccc11977..1d54b00141 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/client/TlsEndpointVerificationSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/client/TlsEndpointVerificationSpec.scala @@ -20,7 +20,6 @@ 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 { diff --git a/akka-http-tests/src/test/scala/akka/http/scaladsl/server/directives/FormFieldDirectivesSpec.scala b/akka-http-tests/src/test/scala/akka/http/scaladsl/server/directives/FormFieldDirectivesSpec.scala index cbf19f1b03..f92f634066 100644 --- a/akka-http-tests/src/test/scala/akka/http/scaladsl/server/directives/FormFieldDirectivesSpec.scala +++ b/akka-http-tests/src/test/scala/akka/http/scaladsl/server/directives/FormFieldDirectivesSpec.scala @@ -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 "Mike42Noneyes" } @@ -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)" } } } diff --git a/akka-http/src/main/scala/akka/http/impl/server/FormFieldImpl.scala b/akka-http/src/main/scala/akka/http/impl/server/FormFieldImpl.scala index 9d8c3a31f3..03e1c204f5 100644 --- a/akka-http/src/main/scala/akka/http/impl/server/FormFieldImpl.scala +++ b/akka-http/src/main/scala/akka/http/impl/server/FormFieldImpl.scala @@ -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 From a39aed086eb8aa4cff645dd151eee8fe5aaaf87e Mon Sep 17 00:00:00 2001 From: 2beaucoup Date: Fri, 11 Dec 2015 15:59:37 +0100 Subject: [PATCH 2/2] =htc, str remove references to 'akka.io.tcp.windows-connection-abort-workaround-enabled' setting --- .../akka/http/impl/engine/client/ConnectionPoolSpec.scala | 3 +-- .../impl/engine/client/TlsEndpointVerificationSpec.scala | 3 +-- .../src/test/scala/akka/http/scaladsl/ClientServerSpec.scala | 1 - .../src/test/scala/akka/stream/io/TcpSpec.scala | 5 +---- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/client/ConnectionPoolSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/client/ConnectionPoolSpec.scala index e287b92add..02ba7a5d94 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/client/ConnectionPoolSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/client/ConnectionPoolSpec.scala @@ -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 diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/client/TlsEndpointVerificationSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/client/TlsEndpointVerificationSpec.scala index 1d54b00141..dd875a3ca4 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/client/TlsEndpointVerificationSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/client/TlsEndpointVerificationSpec.scala @@ -21,8 +21,7 @@ import javax.net.ssl.SSLException class TlsEndpointVerificationSpec extends AkkaSpec(""" 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)) diff --git a/akka-http-core/src/test/scala/akka/http/scaladsl/ClientServerSpec.scala b/akka-http-core/src/test/scala/akka/http/scaladsl/ClientServerSpec.scala index eca0ed7e50..aa954bbcba 100644 --- a/akka-http-core/src/test/scala/akka/http/scaladsl/ClientServerSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/scaladsl/ClientServerSpec.scala @@ -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 diff --git a/akka-stream-tests/src/test/scala/akka/stream/io/TcpSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/io/TcpSpec.scala index 2ed5dbc48e..0bf1e8f879 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/io/TcpSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/io/TcpSpec.scala @@ -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 {