Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<Message, Message, NotUsed> greeterFlow = greeter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,7 +75,7 @@ public void testOnComplete() {
.matchAny(
ex ->
complete(
StatusCodes.InternalServerError(),
StatusCodes.INTERNAL_SERVER_ERROR,
"An error occurred: " + ex.getMessage()))
.build())
.get()));
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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()));
Expand All @@ -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
Expand All @@ -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;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -31,8 +31,7 @@ public void testRetrieveAttributeByKey() {
// keys with the same type but different names should be considered different
AttributeKey<String> otherStringKey = AttributeKey.create("other", String.class);

// it should be possible to use 'Scala attribute keys' in the Java API's
AttributeKey<Integer> intKey = AttributeKey$.MODULE$.apply("int", Integer.class);
AttributeKey<Integer> intKey = AttributeKey.create("int", Integer.class);
// keys with the same name but different types should be considered different
AttributeKey<Integer> otherIntKey = AttributeKey.create("other", Integer.class);

Expand Down Expand Up @@ -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
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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);
}
}
}
Loading