Skip to content

Commit

Permalink
Refactor TestProxiedErrorResponses
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavr12 committed Oct 2, 2024
1 parent 4ed6436 commit b5347b5
Showing 1 changed file with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@
package io.trino.aws.proxy.server.rest;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.inject.BindingAnnotation;
import com.google.inject.Inject;
import com.google.inject.Key;
import io.airlift.http.client.HttpStatus;
import io.airlift.http.server.HttpServerConfig;
import io.airlift.http.server.HttpServerInfo;
import io.airlift.http.server.testing.TestingHttpServer;
import io.airlift.node.NodeInfo;
import io.trino.aws.proxy.server.remote.PathStyleRemoteS3Facade;
import io.trino.aws.proxy.server.testing.TestingRemoteS3Facade;
import io.trino.aws.proxy.server.testing.TestingTrinoAwsProxyServer.Builder;
Expand All @@ -43,6 +39,7 @@
import java.util.Optional;

import static com.google.common.collect.ImmutableMap.toImmutableMap;
import static io.trino.aws.proxy.server.testing.TestingUtil.createTestingHttpServer;
import static io.trino.aws.proxy.server.testing.TestingUtil.getFileFromStorage;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
Expand Down Expand Up @@ -87,7 +84,7 @@ public Builder filter(Builder builder)
{
TestingHttpServer httpErrorResponseServer;
try {
httpErrorResponseServer = createTestingHttpErrorResponseServer();
httpErrorResponseServer = createTestingHttpServer(new HttpErrorResponseServlet());
httpErrorResponseServer.start();
}
catch (Exception e) {
Expand Down Expand Up @@ -120,15 +117,6 @@ private void assertThrownAwsError(HttpStatus status)
exception -> assertThat(exception.awsErrorDetails().errorCode()).isEqualTo(status.reason()));
}

private static TestingHttpServer createTestingHttpErrorResponseServer()
throws IOException
{
NodeInfo nodeInfo = new NodeInfo("test");
HttpServerConfig config = new HttpServerConfig().setHttpPort(0);
HttpServerInfo httpServerInfo = new HttpServerInfo(config, nodeInfo);
return new TestingHttpServer(httpServerInfo, nodeInfo, config, new HttpErrorResponseServlet(), ImmutableMap.of());
}

private static class HttpErrorResponseServlet
extends HttpServlet
{
Expand Down

0 comments on commit b5347b5

Please sign in to comment.