!htj move RequestVal classes to javadsl.server.values

This commit is contained in:
Johannes Rudolph 2015-05-07 17:00:45 +02:00 committed by Mathias
parent 45a410b02a
commit 10ea40b2f8
23 changed files with 142 additions and 38 deletions

View file

@ -7,6 +7,8 @@ package akka.http.javadsl.server.examples.petstore;
import akka.actor.ActorSystem;
import akka.http.javadsl.marshallers.jackson.Jackson;
import akka.http.javadsl.server.*;
import akka.http.javadsl.server.values.PathMatcher;
import akka.http.javadsl.server.values.PathMatchers;
import java.io.IOException;
import java.util.Map;

View file

@ -6,6 +6,10 @@ package akka.http.javadsl.server.examples.simple;
import akka.actor.ActorSystem;
import akka.http.javadsl.server.*;
import akka.http.javadsl.server.values.Parameter;
import akka.http.javadsl.server.values.Parameters;
import akka.http.javadsl.server.values.PathMatcher;
import akka.http.javadsl.server.values.PathMatchers;
import java.io.IOException;

View file

@ -4,15 +4,16 @@
package akka.http.javadsl.server;
import org.junit.Test;
import java.util.concurrent.Callable;
import akka.dispatch.Futures;
import akka.http.javadsl.testkit.*;
import akka.http.javadsl.marshallers.jackson.Jackson;
import akka.http.javadsl.model.HttpRequest;
import akka.http.javadsl.model.MediaTypes;
import org.junit.Test;
import akka.http.javadsl.testkit.*;
import java.util.concurrent.Callable;
import static akka.http.javadsl.server.Directives.*;
import akka.http.javadsl.server.values.*;
public class CompleteTest extends JUnitRouteTest {
@Test

View file

@ -4,10 +4,11 @@
package akka.http.javadsl.server;
import akka.http.scaladsl.model.HttpRequest;
import org.junit.Test;
import akka.http.scaladsl.model.HttpRequest;
import akka.http.javadsl.testkit.*;
import static akka.http.javadsl.server.Directives.*;
import akka.http.javadsl.server.values.*;
public class HandlerBindingTest extends JUnitRouteTest {
@Test

View file

@ -4,8 +4,6 @@
package akka.http.javadsl.server.directives;
import static akka.http.javadsl.server.Directives.*;
import akka.actor.ActorSystem;
import akka.http.javadsl.model.HttpRequest;
import akka.http.javadsl.model.headers.AcceptEncoding;

View file

@ -0,0 +1,59 @@
/*
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.http.javadsl.server.directives;
import org.junit.Test;
import akka.http.javadsl.model.*;
import akka.http.javadsl.server.*;
import akka.http.javadsl.server.values.*;
import akka.http.javadsl.testkit.*;
public class ExecutionDirectivesTest extends JUnitRouteTest {
@Test
public void testCatchExceptionThrownFromHandler() {
Parameter<Integer> a = Parameters.integer("a");
Parameter<Integer> b = Parameters.integer("b");
Handler2<Integer, Integer> divide =
new Handler2<Integer, Integer>() {
@Override
public RouteResult handle(RequestContext ctx, Integer a, Integer b) {
int result = a / b;
return ctx.complete("The result is: " + result);
}
};
ExceptionHandler handleDivByZero =
new ExceptionHandler() {
@Override
public Route handle(RuntimeException exception) {
try {
throw exception;
} catch(ArithmeticException t) {
return complete(
HttpResponse.create()
.withStatus(400)
.withEntity("Congratulations you provoked a division by zero!"));
}
}
};
TestRoute route =
testRoute(
handleExceptions(handleDivByZero,
path("divide").route(
handleWith(a, b, divide)
)
)
);
route.run(HttpRequest.GET("/divide?a=10&b=5"))
.assertEntity("The result is: 2");
route.run(HttpRequest.GET("/divide?a=10&b=0"))
.assertStatusCode(400)
.assertEntity("Congratulations you provoked a division by zero!");
}
}

View file

@ -4,17 +4,17 @@
package akka.http.javadsl.server.directives;
import akka.http.javadsl.server.values.PathMatcher;
import org.junit.Test;
import java.util.List;
import java.util.UUID;
import akka.http.javadsl.server.*;
import akka.http.javadsl.server.values.*;
import akka.http.javadsl.testkit.*;
import akka.http.scaladsl.model.HttpRequest;
import static akka.http.javadsl.server.Directives.*;
public class PathDirectivesTest extends JUnitRouteTest {
@Test
public void testPathPrefixAndPath() {
@ -87,7 +87,7 @@ public class PathDirectivesTest extends JUnitRouteTest {
public void testSingleSlash() {
TestRoute route =
testRoute(
pathSingleSlash().route(complete("Ok"))
pathSingleSlash().route(complete("Ok"))
);
route.run(HttpRequest.GET("/"))

View file

@ -2,7 +2,7 @@
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.http.javadsl.server.directives;
package akka.http.javadsl.server.values;
import org.junit.Test;
import scala.Option;
@ -12,10 +12,8 @@ import akka.http.javadsl.server.*;
import akka.http.javadsl.model.HttpRequest;
import akka.http.javadsl.model.headers.Authorization;
import akka.http.javadsl.testkit.*;
import akka.http.javadsl.server.*;
import static akka.http.javadsl.server.Directives.*;
public class AuthenticationDirectivesTest extends JUnitRouteTest {
public class HttpBasicAuthenticationTest extends JUnitRouteTest {
HttpBasicAuthenticator<String> authenticatedUser =
new HttpBasicAuthenticator<String>("test-realm") {
@Override