From 58e78757debb4c9ba16dff368d4e74b2d705fee3 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Wed, 15 Jul 2015 12:42:59 +0200 Subject: [PATCH] =htp a few small things that got lost in the #17988 merge --- .../http/javadsl/server/PathDirectiveExampleTest.java | 8 -------- akka-docs-dev/rst/java/http/routing-dsl/handlers.rst | 11 +++++------ akka-http-tests-java8/src/test/java/AllJavaTests.java | 4 +++- .../http/javadsl/server/HandlerExampleDocTest.java | 8 ++++---- .../javadsl/server/directives/BasicDirectives.scala | 3 +-- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/akka-docs-dev/rst/java/code/docs/http/javadsl/server/PathDirectiveExampleTest.java b/akka-docs-dev/rst/java/code/docs/http/javadsl/server/PathDirectiveExampleTest.java index d77cafaa1c..ff4224957f 100644 --- a/akka-docs-dev/rst/java/code/docs/http/javadsl/server/PathDirectiveExampleTest.java +++ b/akka-docs-dev/rst/java/code/docs/http/javadsl/server/PathDirectiveExampleTest.java @@ -4,14 +4,11 @@ package docs.http.javadsl.server; -import akka.http.javadsl.model.HttpRequest; import akka.http.javadsl.model.StatusCodes; import akka.http.javadsl.server.*; -import akka.http.javadsl.server.values.Parameters; import akka.http.javadsl.server.values.PathMatcher; import akka.http.javadsl.server.values.PathMatchers; import akka.http.javadsl.testkit.JUnitRouteTest; -import akka.http.javadsl.testkit.TestRoute; import org.junit.Test; public class PathDirectiveExampleTest extends JUnitRouteTest { @@ -82,9 +79,4 @@ public class PathDirectiveExampleTest extends JUnitRouteTest { ); //#path-examples } - - // FIXME: remove once #17988 is merged - public static Route handleWith1(RequestVal val, Object o) { - return null; - } } \ No newline at end of file diff --git a/akka-docs-dev/rst/java/http/routing-dsl/handlers.rst b/akka-docs-dev/rst/java/http/routing-dsl/handlers.rst index 2a89011d82..0d51a44ba8 100644 --- a/akka-docs-dev/rst/java/http/routing-dsl/handlers.rst +++ b/akka-docs-dev/rst/java/http/routing-dsl/handlers.rst @@ -64,7 +64,8 @@ about the number of handled arguments easier. For example, a :class:`Handler1[St ``Function2[RequestContext, String, RouteResult]``. You can think of handlers as hot-dogs, where each ``T`` type represents a sausage, put between the "buns" which are ``RequestContext`` and ``RouteResult``. -In Java 8 handlers can be provided as function literals or method references. The example from before then looks like this: +In Java 8 handlers can be provided as function literals or method references. The previous example can then be written +like this: .. includecode:: /../../akka-http-tests-java8/src/test/java/docs/http/javadsl/server/HandlerExampleDocTest.java :include: handler2-java8-example-full @@ -76,11 +77,9 @@ In Java 8 handlers can be provided as function literals or method references. Th if one type of a handler does not match the given values, *all* possible candidates would be printed in the error message (22 of them), instead of just the one arity-matching method, pointing out that the type does not match. - We opted for better error messages as we feel this is more helpful when developing applications, - instead of having one overloaded method which looks nice when everything works, but procudes hard to read error - messages if something does not match up. - - + We opted for better error messages as we feel this is more helpful when developing applications, + instead of having one overloaded method which looks nice when everything works, but procudes hard to read error + messages if something does not match up. Providing Handlers by Reflection -------------------------------- diff --git a/akka-http-tests-java8/src/test/java/AllJavaTests.java b/akka-http-tests-java8/src/test/java/AllJavaTests.java index 3736e171a2..1965a8fce1 100644 --- a/akka-http-tests-java8/src/test/java/AllJavaTests.java +++ b/akka-http-tests-java8/src/test/java/AllJavaTests.java @@ -3,12 +3,14 @@ */ import akka.http.javadsl.server.HandlerBindingTest; +import docs.http.javadsl.server.HandlerExampleDocTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ - HandlerBindingTest.class + HandlerBindingTest.class, + HandlerExampleDocTest.class }) public class AllJavaTests { } diff --git a/akka-http-tests-java8/src/test/java/docs/http/javadsl/server/HandlerExampleDocTest.java b/akka-http-tests-java8/src/test/java/docs/http/javadsl/server/HandlerExampleDocTest.java index 57ad1f807b..fdcb15e02d 100644 --- a/akka-http-tests-java8/src/test/java/docs/http/javadsl/server/HandlerExampleDocTest.java +++ b/akka-http-tests-java8/src/test/java/docs/http/javadsl/server/HandlerExampleDocTest.java @@ -66,11 +66,11 @@ public class HandlerExampleDocTest extends JUnitRouteTest { public void testCalculator() { //#handler2-example-full class TestHandler extends akka.http.javadsl.server.AllDirectives { - RequestVal xParam = Parameters.intValue("x"); - RequestVal yParam = Parameters.intValue("y"); + final RequestVal xParam = Parameters.intValue("x"); + final RequestVal yParam = Parameters.intValue("y"); - RequestVal xSegment = PathMatchers.intValue(); - RequestVal ySegment = PathMatchers.intValue(); + final RequestVal xSegment = PathMatchers.intValue(); + final RequestVal ySegment = PathMatchers.intValue(); //#handler2 final Handler2 multiply = diff --git a/akka-http/src/main/scala/akka/http/javadsl/server/directives/BasicDirectives.scala b/akka-http/src/main/scala/akka/http/javadsl/server/directives/BasicDirectives.scala index 929cbdece4..e4ea1868c5 100644 --- a/akka-http/src/main/scala/akka/http/javadsl/server/directives/BasicDirectives.scala +++ b/akka-http/src/main/scala/akka/http/javadsl/server/directives/BasicDirectives.scala @@ -6,10 +6,9 @@ package akka.http.javadsl.server.directives import java.lang.reflect.{ Method, ParameterizedType } -import akka.http.javadsl.model.{ Uri, ContentType, StatusCode, HttpResponse } import akka.http.impl.server.RouteStructure._ import akka.http.impl.server._ -import akka.http.javadsl.model.{ ContentType, HttpResponse, StatusCode } +import akka.http.javadsl.model.{ ContentType, HttpResponse, StatusCode, Uri } import akka.http.javadsl.server._ import scala.annotation.varargs