Skip to content

Commit

Permalink
Issue #12680 - Fixing testcase to use real connector.
Browse files Browse the repository at this point in the history
  • Loading branch information
joakime committed Jan 8, 2025
1 parent b620df7 commit eba500a
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.channels.SeekableByteChannel;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -59,6 +61,7 @@
import org.eclipse.jetty.server.LocalConnector;
import org.eclipse.jetty.server.ResourceService;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.TrailingSlashAliasChecker;
import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.toolchain.test.MavenPaths;
Expand Down Expand Up @@ -772,22 +775,23 @@ public void testBigger() throws Exception
@Test
public void testOver2GBFile() throws Exception
{
_server.stop();
ServerConnector connector = new ServerConnector(_server);
connector.setPort(0);
_server.addConnector(connector);
_server.start();

long hugeLength = (long)Integer.MAX_VALUE + 10L;

generateFile(docRoot.resolve("huge.mkv"), hugeLength);

HttpTester.Response response = HttpTester.parseResponse(
_local.getResponse("""
GET /context/huge.mkv HTTP/1.1\r
Host: local\r
Connection: close\r
\r
"""));
URI uri = URI.create("http://localhost:%d/context/huge.mkv".formatted(connector.getLocalPort()));

System.err.println(response);
HttpURLConnection http = (HttpURLConnection)uri.toURL().openConnection();
http.setRequestProperty("Connection", "close");

assertThat(response.getStatus(), is(HttpStatus.OK_200));
long responseContentLength = response.getLongField(CONTENT_LENGTH);
assertThat(http.getResponseCode(), is(HttpStatus.OK_200));
long responseContentLength = http.getContentLengthLong();
assertThat(responseContentLength, is(hugeLength));
}

Expand Down

0 comments on commit eba500a

Please sign in to comment.