Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetty 12.1.x ee9 ee10 ee11 default servlet test resource servlet test #12534

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 @@ -74,7 +74,6 @@
import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -1971,47 +1970,6 @@ public void testWelcomeExactServlet(Scenario scenario) throws Exception
scenario.extraAsserts.accept(response);
}

@Disabled("Disabled until fix for HttpContent merged")
@Test
public void testDirectFromResourceHttpContent() throws Exception
{
FS.ensureDirExists(docRoot);
Path index = docRoot.resolve("index.html");
Files.writeString(index, "<h1>Hello World</h1>", UTF_8);

ServletHolder defholder = context.addServlet(DefaultServlet.class, "/");
defholder.setInitParameter("dirAllowed", "true");
defholder.setInitParameter("redirectWelcome", "false");
defholder.setInitParameter("useFileMappedBuffer", "true");
defholder.setInitParameter("welcomeServlets", "exact");
defholder.setInitParameter("gzip", "false");
defholder.setInitParameter("resourceCache", "resourceCache");

String rawResponse;
HttpTester.Response response;

rawResponse = connector.getResponse("""
GET /context/index.html HTTP/1.1\r
Host: local\r
Connection: close\r
\r
""");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.OK_200));
assertThat(response.getContent(), containsString("<h1>Hello World</h1>"));

/*
TODO: fix after HttpContent changes.
ResourceHttpContentFactory factory = (ResourceHttpContentFactory)context.getServletContext().getAttribute("resourceCache");
HttpContent content = factory.getContent("/index.html", 200);
ByteBuffer buffer = content.getDirectBuffer();
assertThat("Buffer is direct", buffer.isDirect(), is(true));
content = factory.getContent("/index.html", 5);
buffer = content.getDirectBuffer();
assertThat("Direct buffer", buffer, is(nullValue()));
*/
}

@SuppressWarnings("Duplicates")
public static Stream<Arguments> rangeScenarios()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import org.eclipse.jetty.http.HttpTester;
import org.eclipse.jetty.http.UriCompliance;
import org.eclipse.jetty.http.content.ResourceHttpContent;
import org.eclipse.jetty.http.content.ResourceHttpContentFactory;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.logging.StacklessLogging;
import org.eclipse.jetty.server.AllowedResourceAliasChecker;
Expand Down Expand Up @@ -2035,47 +2034,6 @@ public void testWelcomeExactServlet(Scenario scenario) throws Exception
scenario.extraAsserts.accept(response);
}

@Test
public void testDirectFromResourceHttpContent() throws Exception
{
FS.ensureDirExists(docRoot);
Path index = docRoot.resolve("index.html");
Files.writeString(index, "<h1>Hello World</h1>", UTF_8);

ServletHolder holder = context.addServlet(ResourceServlet.class, "/");
holder.setInitParameter("dirAllowed", "true");
holder.setInitParameter("redirectWelcome", "false");
holder.setInitParameter("useFileMappedBuffer", "true");
holder.setInitParameter("welcomeServlets", "exact");
holder.setInitParameter("gzip", "false");
holder.setInitParameter("resourceCache", "resourceCache");

String rawResponse;
HttpTester.Response response;

rawResponse = connector.getResponse("""
GET /context/index.html HTTP/1.1\r
Host: local\r
Connection: close\r
\r
""");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.OK_200));
assertThat(response.getContent(), containsString("<h1>Hello World</h1>"));

ResourceHttpContentFactory factory = (ResourceHttpContentFactory)context.getServletContext().getAttribute("resourceCache");

/*
TODO: fix after HttpContent changes.
HttpContent content = factory.getContent("/index.html", 200);
ByteBuffer buffer = content.getDirectBuffer();
assertThat("Buffer is direct", buffer.isDirect(), is(true));
content = factory.getContent("/index.html", 5);
buffer = content.getDirectBuffer();
assertThat("Direct buffer", buffer, is(nullValue()));
*/
}

@SuppressWarnings("Duplicates")
public static Stream<Arguments> rangeScenarios()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -1971,47 +1970,6 @@ public void testWelcomeExactServlet(Scenario scenario) throws Exception
scenario.extraAsserts.accept(response);
}

@Disabled("Disabled until fix for HttpContent merged")
@Test
public void testDirectFromResourceHttpContent() throws Exception
{
FS.ensureDirExists(docRoot);
Path index = docRoot.resolve("index.html");
Files.writeString(index, "<h1>Hello World</h1>", UTF_8);

ServletHolder defholder = context.addServlet(DefaultServlet.class, "/");
defholder.setInitParameter("dirAllowed", "true");
defholder.setInitParameter("redirectWelcome", "false");
defholder.setInitParameter("useFileMappedBuffer", "true");
defholder.setInitParameter("welcomeServlets", "exact");
defholder.setInitParameter("gzip", "false");
defholder.setInitParameter("resourceCache", "resourceCache");

String rawResponse;
HttpTester.Response response;

rawResponse = connector.getResponse("""
GET /context/index.html HTTP/1.1\r
Host: local\r
Connection: close\r
\r
""");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.OK_200));
assertThat(response.getContent(), containsString("<h1>Hello World</h1>"));

/*
TODO: fix after HttpContent changes.
ResourceHttpContentFactory factory = (ResourceHttpContentFactory)context.getServletContext().getAttribute("resourceCache");
HttpContent content = factory.getContent("/index.html", 200);
ByteBuffer buffer = content.getDirectBuffer();
assertThat("Buffer is direct", buffer.isDirect(), is(true));
content = factory.getContent("/index.html", 5);
buffer = content.getDirectBuffer();
assertThat("Direct buffer", buffer, is(nullValue()));
*/
}

@SuppressWarnings("Duplicates")
public static Stream<Arguments> rangeScenarios()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import org.eclipse.jetty.http.HttpTester;
import org.eclipse.jetty.http.UriCompliance;
import org.eclipse.jetty.http.content.ResourceHttpContent;
import org.eclipse.jetty.http.content.ResourceHttpContentFactory;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.logging.StacklessLogging;
import org.eclipse.jetty.server.AllowedResourceAliasChecker;
Expand Down Expand Up @@ -2033,47 +2032,6 @@ public void testWelcomeExactServlet(Scenario scenario) throws Exception
scenario.extraAsserts.accept(response);
}

@Test
public void testDirectFromResourceHttpContent() throws Exception
{
FS.ensureDirExists(docRoot);
Path index = docRoot.resolve("index.html");
Files.writeString(index, "<h1>Hello World</h1>", UTF_8);

ServletHolder holder = context.addServlet(ResourceServlet.class, "/");
holder.setInitParameter("dirAllowed", "true");
holder.setInitParameter("redirectWelcome", "false");
holder.setInitParameter("useFileMappedBuffer", "true");
holder.setInitParameter("welcomeServlets", "exact");
holder.setInitParameter("gzip", "false");
holder.setInitParameter("resourceCache", "resourceCache");

String rawResponse;
HttpTester.Response response;

rawResponse = connector.getResponse("""
GET /context/index.html HTTP/1.1\r
Host: local\r
Connection: close\r
\r
""");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.OK_200));
assertThat(response.getContent(), containsString("<h1>Hello World</h1>"));

ResourceHttpContentFactory factory = (ResourceHttpContentFactory)context.getServletContext().getAttribute("resourceCache");

/*
TODO: fix after HttpContent changes.
HttpContent content = factory.getContent("/index.html", 200);
ByteBuffer buffer = content.getDirectBuffer();
assertThat("Buffer is direct", buffer.isDirect(), is(true));
content = factory.getContent("/index.html", 5);
buffer = content.getDirectBuffer();
assertThat("Direct buffer", buffer, is(nullValue()));
*/
}

@SuppressWarnings("Duplicates")
public static Stream<Arguments> rangeScenarios()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@
*
* baseResource Set to replace the context resource base
*
* resourceCache If set, this is a context attribute name, which the servlet
* will use to look for a shared ResourceCache instance.
*
* relativeBaseResource
* Set with a pathname relative to the base of the
* servlet context root. Useful for only serving static content out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,6 @@ public void testDirectFromResourceHttpContent() throws Exception
defholder.setInitParameter("useFileMappedBuffer", "true");
defholder.setInitParameter("welcomeServlets", "exact");
defholder.setInitParameter("gzip", "false");
defholder.setInitParameter("resourceCache", "resourceCache");
});

String rawResponse;
Expand Down