diff --git a/docs/src/test/java/docs/http/javadsl/HttpClientDecodingExampleTest.java b/docs/src/test/java/docs/http/javadsl/HttpClientDecodingExampleTest.java index 7137f5987b..208f6aba88 100644 --- a/docs/src/test/java/docs/http/javadsl/HttpClientDecodingExampleTest.java +++ b/docs/src/test/java/docs/http/javadsl/HttpClientDecodingExampleTest.java @@ -19,7 +19,7 @@ import org.apache.pekko.http.javadsl.coding.Coder; import org.apache.pekko.http.javadsl.model.HttpRequest; import org.apache.pekko.http.javadsl.model.HttpResponse; -import org.apache.pekko.http.scaladsl.model.headers.HttpEncodings; +import org.apache.pekko.http.javadsl.model.headers.HttpEncodings; import java.util.Arrays; import java.util.List; @@ -48,9 +48,9 @@ public static void main(String[] args) throws Exception { response -> { // Pick the right coder final Coder coder; - if (HttpEncodings.gzip().equals(response.encoding())) { + if (HttpEncodings.GZIP.equals(response.encoding())) { coder = Coder.Gzip; - } else if (HttpEncodings.deflate().equals(response.encoding())) { + } else if (HttpEncodings.DEFLATE.equals(response.encoding())) { coder = Coder.Deflate; } else { coder = Coder.NoCoding; diff --git a/docs/src/test/java/docs/http/javadsl/server/HttpBasicAuthenticatorExample.java b/docs/src/test/java/docs/http/javadsl/server/HttpBasicAuthenticatorExample.java index cb125596f9..2f4ab7589b 100644 --- a/docs/src/test/java/docs/http/javadsl/server/HttpBasicAuthenticatorExample.java +++ b/docs/src/test/java/docs/http/javadsl/server/HttpBasicAuthenticatorExample.java @@ -18,11 +18,11 @@ import org.junit.Test; import org.apache.pekko.http.javadsl.model.HttpRequest; +import org.apache.pekko.http.javadsl.model.headers.Authorization; import org.apache.pekko.http.javadsl.model.headers.Host; import org.apache.pekko.http.javadsl.server.Route; import org.apache.pekko.http.javadsl.server.directives.SecurityDirectives.ProvidedCredentials; import org.apache.pekko.http.javadsl.testkit.JUnitRouteTest; -import org.apache.pekko.http.scaladsl.model.headers.Authorization; // #basic-authenticator-java import static org.apache.pekko.http.javadsl.server.Directives.authenticateBasic; diff --git a/docs/src/test/java/docs/http/javadsl/server/OAuth2AuthenticatorExample.java b/docs/src/test/java/docs/http/javadsl/server/OAuth2AuthenticatorExample.java index eb651155b7..967c29d0b2 100644 --- a/docs/src/test/java/docs/http/javadsl/server/OAuth2AuthenticatorExample.java +++ b/docs/src/test/java/docs/http/javadsl/server/OAuth2AuthenticatorExample.java @@ -14,10 +14,10 @@ package docs.http.javadsl.server; import org.apache.pekko.http.javadsl.model.HttpRequest; +import org.apache.pekko.http.javadsl.model.headers.Authorization; import org.apache.pekko.http.javadsl.model.headers.Host; import org.apache.pekko.http.javadsl.server.directives.SecurityDirectives.ProvidedCredentials; import org.apache.pekko.http.javadsl.testkit.JUnitRouteTest; -import org.apache.pekko.http.scaladsl.model.headers.Authorization; import java.util.Optional; diff --git a/docs/src/test/java/docs/http/javadsl/server/WebSocketCoreExample.java b/docs/src/test/java/docs/http/javadsl/server/WebSocketCoreExample.java index 5455fa1c61..2e63858784 100644 --- a/docs/src/test/java/docs/http/javadsl/server/WebSocketCoreExample.java +++ b/docs/src/test/java/docs/http/javadsl/server/WebSocketCoreExample.java @@ -26,12 +26,12 @@ import org.apache.pekko.http.impl.util.JavaMapping; import org.apache.pekko.http.javadsl.ConnectHttp; import org.apache.pekko.http.javadsl.ConnectionContext; +import org.apache.pekko.http.javadsl.model.AttributeKeys; import org.apache.pekko.http.javadsl.model.StatusCodes; import org.apache.pekko.http.javadsl.model.ws.WebSocketRequest; import org.apache.pekko.http.javadsl.settings.ClientConnectionSettings; import org.apache.pekko.http.javadsl.settings.ServerSettings; import org.apache.pekko.http.javadsl.settings.WebSocketSettings; -import org.apache.pekko.http.scaladsl.model.AttributeKeys; import org.apache.pekko.japi.JavaPartialFunction; import org.apache.pekko.japi.function.Function; @@ -58,7 +58,7 @@ public static HttpResponse handleRequest(HttpRequest request) { if (request.getUri().path().equals("/greeter")) { return request - .getAttribute(AttributeKeys.webSocketUpgrade()) + .getAttribute(AttributeKeys.webSocketUpgrade) .map( upgrade -> { Flow greeterFlow = greeter(); diff --git a/docs/src/test/java/docs/http/javadsl/server/directives/FutureDirectivesExamplesTest.java b/docs/src/test/java/docs/http/javadsl/server/directives/FutureDirectivesExamplesTest.java index 65af9b1f03..6b79ea13cd 100644 --- a/docs/src/test/java/docs/http/javadsl/server/directives/FutureDirectivesExamplesTest.java +++ b/docs/src/test/java/docs/http/javadsl/server/directives/FutureDirectivesExamplesTest.java @@ -18,10 +18,10 @@ import java.util.concurrent.TimeUnit; import org.apache.pekko.http.javadsl.model.HttpRequest; +import org.apache.pekko.http.javadsl.model.StatusCodes; import org.apache.pekko.http.javadsl.marshalling.Marshaller; import org.apache.pekko.http.javadsl.server.Route; import org.apache.pekko.http.javadsl.testkit.JUnitRouteTest; -import org.apache.pekko.http.scaladsl.model.StatusCodes; import org.apache.pekko.japi.pf.PFBuilder; import org.apache.pekko.pattern.CircuitBreaker; import org.apache.pekko.testkit.javadsl.TestKit; @@ -75,7 +75,7 @@ public void testOnComplete() { .matchAny( ex -> complete( - StatusCodes.InternalServerError(), + StatusCodes.INTERNAL_SERVER_ERROR, "An error occurred: " + ex.getMessage())) .build()) .get())); @@ -84,7 +84,7 @@ public void testOnComplete() { testRoute(route) .run(HttpRequest.GET("/divide/10/0")) - .assertStatusCode(StatusCodes.InternalServerError()) + .assertStatusCode(StatusCodes.INTERNAL_SERVER_ERROR) .assertEntity("An error occurred: / by zero"); // #onComplete } @@ -114,7 +114,7 @@ public void testOnSuccess() { testRoute(route) .run(HttpRequest.GET("/failure")) - .assertStatusCode(StatusCodes.InternalServerError()) + .assertStatusCode(StatusCodes.INTERNAL_SERVER_ERROR) .assertEntity("There was an internal server error."); // #onSuccess } @@ -148,7 +148,7 @@ public void testCompleteOrRecoverWith() { testRoute(route) .run(HttpRequest.GET("/failure")) - .assertStatusCode(StatusCodes.InternalServerError()) + .assertStatusCode(StatusCodes.INTERNAL_SERVER_ERROR) .assertEntity("There was an internal server error."); // #completeOrRecoverWith } @@ -185,7 +185,7 @@ public void testOnCompleteWithBreaker() throws InterruptedException { .matchAny( ex -> complete( - StatusCodes.InternalServerError(), + StatusCodes.INTERNAL_SERVER_ERROR, "An error occurred: " + ex.toString())) .build()) .get())); @@ -194,7 +194,7 @@ public void testOnCompleteWithBreaker() throws InterruptedException { testRoute(route) .run(HttpRequest.GET("/divide/10/0")) - .assertStatusCode(StatusCodes.InternalServerError()) + .assertStatusCode(StatusCodes.INTERNAL_SERVER_ERROR) .assertEntity("An error occurred: java.lang.ArithmeticException: / by zero"); // The circuit-breaker will eventually be opened @@ -207,7 +207,7 @@ public void testOnCompleteWithBreaker() throws InterruptedException { .run(HttpRequest.GET("/divide/10/0")) .assertEntity( "The server is currently unavailable (because it is overloaded or down for maintenance).") - .assertStatusCode(StatusCodes.ServiceUnavailable()); + .assertStatusCode(StatusCodes.SERVICE_UNAVAILABLE); return null; }); diff --git a/http-core/src/test/java/org/apache/pekko/http/javadsl/model/HttpMessageTest.java b/http-core/src/test/java/org/apache/pekko/http/javadsl/model/HttpMessageTest.java index 56df3a7e87..8afca552cd 100644 --- a/http-core/src/test/java/org/apache/pekko/http/javadsl/model/HttpMessageTest.java +++ b/http-core/src/test/java/org/apache/pekko/http/javadsl/model/HttpMessageTest.java @@ -13,7 +13,6 @@ package org.apache.pekko.http.javadsl.model; -import org.apache.pekko.http.scaladsl.model.AttributeKey$; import org.apache.pekko.stream.scaladsl.TLSPlacebo; import org.junit.Test; import org.scalatestplus.junit.JUnitSuite; @@ -23,6 +22,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class HttpMessageTest extends JUnitSuite { @Test @@ -31,8 +31,7 @@ public void testRetrieveAttributeByKey() { // keys with the same type but different names should be considered different AttributeKey otherStringKey = AttributeKey.create("other", String.class); - // it should be possible to use 'Scala attribute keys' in the Java API's - AttributeKey intKey = AttributeKey$.MODULE$.apply("int", Integer.class); + AttributeKey intKey = AttributeKey.create("int", Integer.class); // keys with the same name but different types should be considered different AttributeKey otherIntKey = AttributeKey.create("other", Integer.class); @@ -64,7 +63,7 @@ public void testAttributeKeys() { RemoteAddress remoteAddress = RemoteAddress.create(new byte[] {10, 0, 0, 1}); HttpRequest newRequest = request.addAttribute(AttributeKeys.remoteAddress, remoteAddress); - assert (newRequest.getAttribute(AttributeKeys.remoteAddress).get().equals(remoteAddress)); + assertTrue(newRequest.getAttribute(AttributeKeys.remoteAddress).get().equals(remoteAddress)); } @Test @@ -73,6 +72,6 @@ public void testSslAttribute() throws Exception { HttpRequest request = HttpRequest.create().addAttribute(AttributeKeys.sslSession, SslSessionInfo.create(session)); - assert (request.getAttribute(AttributeKeys.sslSession).get().getSession() == session); + assertTrue(request.getAttribute(AttributeKeys.sslSession).get().getSession() == session); } } diff --git a/http-tests/src/test/java/org/apache/pekko/http/javadsl/HttpAPIsTest.java b/http-tests/src/test/java/org/apache/pekko/http/javadsl/HttpAPIsTest.java index 3382afa525..fddc5f223f 100644 --- a/http-tests/src/test/java/org/apache/pekko/http/javadsl/HttpAPIsTest.java +++ b/http-tests/src/test/java/org/apache/pekko/http/javadsl/HttpAPIsTest.java @@ -17,8 +17,8 @@ import org.apache.pekko.http.javadsl.model.HttpRequest; import org.apache.pekko.http.javadsl.model.HttpResponse; import org.apache.pekko.http.javadsl.settings.ClientConnectionSettings; +import org.apache.pekko.http.javadsl.settings.ConnectionPoolSettings; import org.apache.pekko.http.javadsl.testkit.JUnitRouteTest; -import org.apache.pekko.http.scaladsl.settings.ConnectionPoolSettings; import org.apache.pekko.japi.function.Function; import org.apache.pekko.stream.javadsl.Flow; import com.typesafe.config.ConfigFactory; diff --git a/http-tests/src/test/java/org/apache/pekko/http/javadsl/server/HandlerBindingTest.java b/http-tests/src/test/java/org/apache/pekko/http/javadsl/server/HandlerBindingTest.java index bc3e54ca7e..81510e2202 100644 --- a/http-tests/src/test/java/org/apache/pekko/http/javadsl/server/HandlerBindingTest.java +++ b/http-tests/src/test/java/org/apache/pekko/http/javadsl/server/HandlerBindingTest.java @@ -17,9 +17,9 @@ import org.junit.Test; +import org.apache.pekko.http.javadsl.model.HttpRequest; import org.apache.pekko.http.javadsl.testkit.JUnitRouteTest; import org.apache.pekko.http.javadsl.testkit.TestRouteResult; -import org.apache.pekko.http.scaladsl.model.HttpRequest; import static org.apache.pekko.http.javadsl.server.Directives.*; diff --git a/http-tests/src/test/java/org/apache/pekko/http/javadsl/server/directives/PathDirectivesTest.java b/http-tests/src/test/java/org/apache/pekko/http/javadsl/server/directives/PathDirectivesTest.java index 191d3af5f3..9b580a490c 100644 --- a/http-tests/src/test/java/org/apache/pekko/http/javadsl/server/directives/PathDirectivesTest.java +++ b/http-tests/src/test/java/org/apache/pekko/http/javadsl/server/directives/PathDirectivesTest.java @@ -17,12 +17,12 @@ import org.junit.Test; +import org.apache.pekko.http.javadsl.model.HttpRequest; import org.apache.pekko.http.javadsl.model.StatusCodes; import org.apache.pekko.http.javadsl.model.headers.Host; import org.apache.pekko.http.javadsl.server.PathMatchers; import org.apache.pekko.http.javadsl.testkit.JUnitRouteTest; import org.apache.pekko.http.javadsl.testkit.TestRoute; -import org.apache.pekko.http.scaladsl.model.HttpRequest; public class PathDirectivesTest extends JUnitRouteTest { @Test diff --git a/http-tests/src/test/java/org/apache/pekko/http/javadsl/unmarshalling/sse/EventStreamUnmarshallingTest.java b/http-tests/src/test/java/org/apache/pekko/http/javadsl/unmarshalling/sse/EventStreamUnmarshallingTest.java index eb91d3970b..64e269fdd6 100644 --- a/http-tests/src/test/java/org/apache/pekko/http/javadsl/unmarshalling/sse/EventStreamUnmarshallingTest.java +++ b/http-tests/src/test/java/org/apache/pekko/http/javadsl/unmarshalling/sse/EventStreamUnmarshallingTest.java @@ -26,7 +26,6 @@ import org.junit.Assert; import org.junit.Test; import org.scalatestplus.junit.JUnitSuite; -import static org.apache.pekko.util.FutureConverters.asJava; public class EventStreamUnmarshallingTest extends JUnitSuite { @@ -48,7 +47,8 @@ public void testFromEventsStream() throws Exception { Assert.assertEquals(events, unmarshalledEvents); } finally { - asJava(system.terminate()).toCompletableFuture().get(42, TimeUnit.SECONDS); + system.terminate(); + system.getWhenTerminated().toCompletableFuture().get(42, TimeUnit.SECONDS); } } }