diff --git a/akka-http-tests-java8/src/main/resources/web/calculator.html b/akka-http-tests-java8/src/main/resources/web/calculator.html
deleted file mode 100644
index a32b0542877..00000000000
--- a/akka-http-tests-java8/src/main/resources/web/calculator.html
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-Calculator
-
-Add
-
-
-Subtract
-
-
-Multiply
-/multiply/42/23
-
-
-
\ No newline at end of file
diff --git a/akka-http-tests-java8/src/test/java/akka/http/javadsl/server/HandlerBindingTest.java b/akka-http-tests-java8/src/test/java/akka/http/javadsl/server/HandlerBindingTest.java
deleted file mode 100644
index cad4872238e..00000000000
--- a/akka-http-tests-java8/src/test/java/akka/http/javadsl/server/HandlerBindingTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2009-2014 Typesafe Inc.
- */
-
-package akka.http.javadsl.server;
-
-import akka.http.scaladsl.model.HttpRequest;
-import org.junit.Test;
-import akka.http.javadsl.testkit.*;
-import akka.http.javadsl.server.values.*;
-
-public class HandlerBindingTest extends JUnitRouteTest {
- Parameter aParam = Parameters.intValue("a");
- Parameter bParam = Parameters.intValue("b");
- Parameter cParam = Parameters.intValue("c");
- Parameter dParam = Parameters.intValue("d");
-
- @Test
- public void testHandlerWithoutExtractions() {
- Route route = handleWith(ctx -> ctx.complete("Ok"));
- TestResponse response = runRoute(route, HttpRequest.GET("/"));
- response.assertEntity("Ok");
- }
- @Test
- public void testHandler1() {
- Route route = handleWith1(aParam, (ctx, a) -> ctx.complete("Ok " + a));
- TestResponse response = runRoute(route, HttpRequest.GET("?a=23"));
- response.assertStatusCode(200);
- response.assertEntity("Ok 23");
- }
- @Test
- public void testHandler2() {
- Route route =
- handleWith2(
- aParam,
- bParam,
- (ctx, a, b) -> ctx.complete("Sum: " + (a + b)));
- TestResponse response = runRoute(route, HttpRequest.GET("?a=23&b=42"));
- response.assertStatusCode(200);
- response.assertEntity("Sum: 65");
- }
- @Test
- public void testHandler3() {
- Route route =
- handleWith3(
- aParam,
- bParam,
- cParam,
- (ctx, a, b, c) -> ctx.complete("Sum: " + (a + b + c)));
- TestResponse response = runRoute(route, HttpRequest.GET("?a=23&b=42&c=30"));
- response.assertStatusCode(200);
- response.assertEntity("Sum: 95");
- }
- @Test
- public void testHandler4() {
- Route route =
- handleWith4(
- aParam,
- bParam,
- cParam,
- dParam,
- (ctx, a, b, c, d) -> ctx.complete("Sum: " + (a + b + c + d)));
- TestResponse response = runRoute(route, HttpRequest.GET("?a=23&b=42&c=30&d=45"));
- response.assertStatusCode(200);
- response.assertEntity("Sum: 140");
- }
- public RouteResult sum(RequestContext ctx, int a, int b, int c, int d) {
- return ctx.complete("Sum: "+(a + b + c + d));
- }
- @Test
- public void testHandler4MethodRef() {
- Route route =
- handleWith4(
- aParam,
- bParam,
- cParam,
- dParam,
- this::sum);
- TestResponse response = runRoute(route, HttpRequest.GET("?a=23&b=42&c=30&d=45"));
- response.assertStatusCode(200);
- response.assertEntity("Sum: 140");
- }
-}
diff --git a/akka-http-tests-java8/src/test/resources/reference.conf b/akka-http-tests-java8/src/test/resources/reference.conf
deleted file mode 100644
index ab48718a519..00000000000
--- a/akka-http-tests-java8/src/test/resources/reference.conf
+++ /dev/null
@@ -1,6 +0,0 @@
-akka {
- actor {
- serialize-creators = on
- serialize-messages = on
- }
-}
\ No newline at end of file
diff --git a/akka-http-tests-java8/src/main/java/akka/http/javadsl/server/examples/simple/SimpleServerApp8.java b/akka-http-tests/src/main/java/akka/http/javadsl/server/examples/simple/SimpleServerApp8.java
similarity index 100%
rename from akka-http-tests-java8/src/main/java/akka/http/javadsl/server/examples/simple/SimpleServerApp8.java
rename to akka-http-tests/src/main/java/akka/http/javadsl/server/examples/simple/SimpleServerApp8.java
diff --git a/akka-http-tests-java8/src/test/java/AllJavaTests.java b/akka-http-tests/src/test/java/AllJavaTests.java
similarity index 100%
rename from akka-http-tests-java8/src/test/java/AllJavaTests.java
rename to akka-http-tests/src/test/java/AllJavaTests.java
diff --git a/akka-http-tests/src/test/java/akka/http/javadsl/server/HandlerBindingTest.java b/akka-http-tests/src/test/java/akka/http/javadsl/server/HandlerBindingTest.java
index 20b51c50e43..cad4872238e 100644
--- a/akka-http-tests/src/test/java/akka/http/javadsl/server/HandlerBindingTest.java
+++ b/akka-http-tests/src/test/java/akka/http/javadsl/server/HandlerBindingTest.java
@@ -4,146 +4,80 @@
package akka.http.javadsl.server;
-import org.junit.Test;
-
import akka.http.scaladsl.model.HttpRequest;
+import org.junit.Test;
import akka.http.javadsl.testkit.*;
import akka.http.javadsl.server.values.*;
public class HandlerBindingTest extends JUnitRouteTest {
+ Parameter aParam = Parameters.intValue("a");
+ Parameter bParam = Parameters.intValue("b");
+ Parameter cParam = Parameters.intValue("c");
+ Parameter dParam = Parameters.intValue("d");
+
@Test
public void testHandlerWithoutExtractions() {
- Route route = handleWith(
- new Handler() {
- @Override
- public RouteResult apply(RequestContext ctx) {
- return ctx.complete("Ok");
- }
- }
- );
- runRoute(route, HttpRequest.GET("/"))
- .assertEntity("Ok");
- }
- @Test
- public void testHandlerWithSomeExtractions() {
- final Parameter a = Parameters.intValue("a");
- final Parameter b = Parameters.intValue("b");
-
- Route route = handleWith(
- new Handler() {
- @Override
- public RouteResult apply(RequestContext ctx) {
- return ctx.complete("Ok a:" + a.get(ctx) + " b:" + b.get(ctx));
- }
- }, a, b
- );
- runRoute(route, HttpRequest.GET("?a=23&b=42"))
- .assertEntity("Ok a:23 b:42");
- }
- @Test
- public void testHandlerIfExtractionFails() {
- final Parameter a = Parameters.intValue("a");
-
- Route route = handleWith(
- new Handler() {
- @Override
- public RouteResult apply(RequestContext ctx) {
- return ctx.complete("Ok " + a.get(ctx));
- }
- }, a
- );
- runRoute(route, HttpRequest.GET("/"))
- .assertStatusCode(404)
- .assertEntity("Request is missing required query parameter 'a'");
+ Route route = handleWith(ctx -> ctx.complete("Ok"));
+ TestResponse response = runRoute(route, HttpRequest.GET("/"));
+ response.assertEntity("Ok");
}
@Test
public void testHandler1() {
- final Parameter a = Parameters.intValue("a");
-
- Route route = handleWith1(a,
- new Handler1() {
- @Override
- public RouteResult apply(RequestContext ctx, Integer a) {
- return ctx.complete("Ok " + a);
- }
- }
- );
- runRoute(route, HttpRequest.GET("?a=23"))
- .assertStatusCode(200)
- .assertEntity("Ok 23");
+ Route route = handleWith1(aParam, (ctx, a) -> ctx.complete("Ok " + a));
+ TestResponse response = runRoute(route, HttpRequest.GET("?a=23"));
+ response.assertStatusCode(200);
+ response.assertEntity("Ok 23");
}
@Test
public void testHandler2() {
- Route route = handleWith2(
- Parameters.intValue("a"),
- Parameters.intValue("b"),
- new Handler2() {
- @Override
- public RouteResult apply(RequestContext ctx, Integer a, Integer b) {
- return ctx.complete("Sum: " + (a + b));
- }
- }
- );
- runRoute(route, HttpRequest.GET("?a=23&b=42"))
- .assertStatusCode(200)
- .assertEntity("Sum: 65");
+ Route route =
+ handleWith2(
+ aParam,
+ bParam,
+ (ctx, a, b) -> ctx.complete("Sum: " + (a + b)));
+ TestResponse response = runRoute(route, HttpRequest.GET("?a=23&b=42"));
+ response.assertStatusCode(200);
+ response.assertEntity("Sum: 65");
}
@Test
public void testHandler3() {
- Route route = handleWith3(
- Parameters.intValue("a"),
- Parameters.intValue("b"),
- Parameters.intValue("c"),
- new Handler3() {
- @Override
- public RouteResult apply(RequestContext ctx, Integer a, Integer b, Integer c) {
- return ctx.complete("Sum: " + (a + b + c));
- }
- }
- );
+ Route route =
+ handleWith3(
+ aParam,
+ bParam,
+ cParam,
+ (ctx, a, b, c) -> ctx.complete("Sum: " + (a + b + c)));
TestResponse response = runRoute(route, HttpRequest.GET("?a=23&b=42&c=30"));
response.assertStatusCode(200);
response.assertEntity("Sum: 95");
}
@Test
public void testHandler4() {
- Route route = handleWith4(
- Parameters.intValue("a"),
- Parameters.intValue("b"),
- Parameters.intValue("c"),
- Parameters.intValue("d"),
- new Handler4() {
- @Override
- public RouteResult apply(RequestContext ctx, Integer a, Integer b, Integer c, Integer d) {
- return ctx.complete("Sum: " + (a + b + c + d));
- }
- }
- );
- runRoute(route, HttpRequest.GET("?a=23&b=42&c=30&d=45"))
- .assertStatusCode(200)
- .assertEntity("Sum: 140");
- }
- @Test
- public void testReflectiveInstanceHandler() {
- class Test {
- public RouteResult negate(RequestContext ctx, int a) {
- return ctx.complete("Negated: " + (- a));
- }
- }
- Route route = handleReflectively(new Test(), "negate", Parameters.intValue("a"));
- runRoute(route, HttpRequest.GET("?a=23"))
- .assertStatusCode(200)
- .assertEntity("Negated: -23");
+ Route route =
+ handleWith4(
+ aParam,
+ bParam,
+ cParam,
+ dParam,
+ (ctx, a, b, c, d) -> ctx.complete("Sum: " + (a + b + c + d)));
+ TestResponse response = runRoute(route, HttpRequest.GET("?a=23&b=42&c=30&d=45"));
+ response.assertStatusCode(200);
+ response.assertEntity("Sum: 140");
}
-
- public static RouteResult squared(RequestContext ctx, int a) {
- return ctx.complete("Squared: " + (a * a));
+ public RouteResult sum(RequestContext ctx, int a, int b, int c, int d) {
+ return ctx.complete("Sum: "+(a + b + c + d));
}
@Test
- public void testStaticReflectiveHandler() {
- Route route = handleReflectively(HandlerBindingTest.class, "squared", Parameters.intValue("a"));
- runRoute(route, HttpRequest.GET("?a=23"))
- .assertStatusCode(200)
- .assertEntity("Squared: 529");
+ public void testHandler4MethodRef() {
+ Route route =
+ handleWith4(
+ aParam,
+ bParam,
+ cParam,
+ dParam,
+ this::sum);
+ TestResponse response = runRoute(route, HttpRequest.GET("?a=23&b=42&c=30&d=45"));
+ response.assertStatusCode(200);
+ response.assertEntity("Sum: 140");
}
}
diff --git a/akka-http-tests-java8/src/test/java/docs/http/javadsl/server/HandlerExampleDocTest.java b/akka-http-tests/src/test/java/docs/http/javadsl/server/HandlerExampleDocTest.java
similarity index 100%
rename from akka-http-tests-java8/src/test/java/docs/http/javadsl/server/HandlerExampleDocTest.java
rename to akka-http-tests/src/test/java/docs/http/javadsl/server/HandlerExampleDocTest.java