Skip to content

Commit

Permalink
Remove inapplicable test cases; removed unused DefaultServlet initpar…
Browse files Browse the repository at this point in the history
…ams (#12534)
  • Loading branch information
janbartel authored Nov 21, 2024
1 parent 1eaceae commit 1c1dfc9
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 172 deletions.
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

0 comments on commit 1c1dfc9

Please sign in to comment.