Fixed merge
This commit is contained in:
parent
e8f09cb3e0
commit
8ecb4b8669
|
@ -18,8 +18,8 @@ import java.util.Arrays;
|
||||||
|
|
||||||
import org.eclipse.jetty.http.HttpHeader;
|
import org.eclipse.jetty.http.HttpHeader;
|
||||||
import org.eclipse.jetty.io.Content;
|
import org.eclipse.jetty.io.Content;
|
||||||
import org.eclipse.jetty.server.Handler;
|
|
||||||
import org.eclipse.jetty.io.NullByteBufferPool;
|
import org.eclipse.jetty.io.NullByteBufferPool;
|
||||||
|
import org.eclipse.jetty.server.Handler;
|
||||||
import org.eclipse.jetty.server.HttpConfiguration;
|
import org.eclipse.jetty.server.HttpConfiguration;
|
||||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||||
import org.eclipse.jetty.server.LocalConnector;
|
import org.eclipse.jetty.server.LocalConnector;
|
||||||
|
|
|
@ -32,6 +32,7 @@ import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.jetty.start.Props.Prop;
|
import org.eclipse.jetty.start.Props.Prop;
|
||||||
|
@ -335,7 +336,7 @@ public class Main
|
||||||
base.source);
|
base.source);
|
||||||
|
|
||||||
// 4) Active Module Resolution
|
// 4) Active Module Resolution
|
||||||
List<String> selectedModules = args.getSelectedModules();
|
Set<String> selectedModules = args.getSelectedModules();
|
||||||
List<String> sortedSelectedModules = modules.getSortedNames(selectedModules);
|
List<String> sortedSelectedModules = modules.getSortedNames(selectedModules);
|
||||||
List<String> unknownModules = new ArrayList<>(selectedModules);
|
List<String> unknownModules = new ArrayList<>(selectedModules);
|
||||||
unknownModules.removeAll(sortedSelectedModules);
|
unknownModules.removeAll(sortedSelectedModules);
|
||||||
|
|
|
@ -462,15 +462,6 @@ public class StartArgs
|
||||||
return allModules;
|
return allModules;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link #getSelectedModules()} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public List<String> getEnabledModules()
|
|
||||||
{
|
|
||||||
return getSelectedModules();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* The list of selected Modules to enable based on configuration
|
* The list of selected Modules to enable based on configuration
|
||||||
|
@ -484,7 +475,7 @@ public class StartArgs
|
||||||
* @return the list of selected modules (by name) that the configuration has.
|
* @return the list of selected modules (by name) that the configuration has.
|
||||||
* @see Modules#getEnabled()
|
* @see Modules#getEnabled()
|
||||||
*/
|
*/
|
||||||
public List<String> getSelectedModules()
|
public Set<String> getSelectedModules()
|
||||||
{
|
{
|
||||||
return this.modules;
|
return this.modules;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class HugeResourceTest
|
||||||
|
|
||||||
makeStaticFile(staticBase.resolve("test-1g.dat"), GB);
|
makeStaticFile(staticBase.resolve("test-1g.dat"), GB);
|
||||||
makeStaticFile(staticBase.resolve("test-4g.dat"), 4 * GB);
|
makeStaticFile(staticBase.resolve("test-4g.dat"), 4 * GB);
|
||||||
makeStaticFile(staticBase.resolve("test-10g.dat"), 10 * GB);
|
// makeStaticFile(staticBase.resolve("test-10g.dat"), 10 * GB);
|
||||||
|
|
||||||
outputDir = MavenTestingUtils.getTargetTestingPath(HugeResourceTest.class.getSimpleName() + "-outputdir");
|
outputDir = MavenTestingUtils.getTargetTestingPath(HugeResourceTest.class.getSimpleName() + "-outputdir");
|
||||||
FS.ensureEmpty(outputDir);
|
FS.ensureEmpty(outputDir);
|
||||||
|
@ -117,7 +117,7 @@ public class HugeResourceTest
|
||||||
|
|
||||||
ret.add(Arguments.of("test-1g.dat", GB));
|
ret.add(Arguments.of("test-1g.dat", GB));
|
||||||
ret.add(Arguments.of("test-4g.dat", 4 * GB));
|
ret.add(Arguments.of("test-4g.dat", 4 * GB));
|
||||||
ret.add(Arguments.of("test-10g.dat", 10 * GB));
|
// ret.add(Arguments.of("test-10g.dat", 10 * GB));
|
||||||
|
|
||||||
return ret.stream();
|
return ret.stream();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ import jakarta.servlet.ServletException;
|
||||||
import jakarta.servlet.WriteListener;
|
import jakarta.servlet.WriteListener;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.eclipse.jetty.io.NullByteBufferPool;
|
||||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||||
import org.eclipse.jetty.server.LocalConnector;
|
import org.eclipse.jetty.server.LocalConnector;
|
||||||
import org.eclipse.jetty.io.NullByteBufferPool;
|
|
||||||
import org.eclipse.jetty.server.LocalConnector.LocalEndPoint;
|
import org.eclipse.jetty.server.LocalConnector.LocalEndPoint;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.util.BufferUtil;
|
import org.eclipse.jetty.util.BufferUtil;
|
||||||
|
|
|
@ -18,6 +18,7 @@ import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.net.URL;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.channels.SeekableByteChannel;
|
import java.nio.channels.SeekableByteChannel;
|
||||||
import java.nio.file.FileStore;
|
import java.nio.file.FileStore;
|
||||||
|
@ -189,6 +190,7 @@ public class HugeResourceTest
|
||||||
context.setBaseResource(new PathResource(staticBase));
|
context.setBaseResource(new PathResource(staticBase));
|
||||||
|
|
||||||
context.addServlet(PostServlet.class, "/post");
|
context.addServlet(PostServlet.class, "/post");
|
||||||
|
context.addServlet(ChunkedServlet.class, "/chunked/*");
|
||||||
|
|
||||||
String location = multipartTempDir.toString();
|
String location = multipartTempDir.toString();
|
||||||
long maxFileSize = Long.MAX_VALUE;
|
long maxFileSize = Long.MAX_VALUE;
|
||||||
|
@ -224,7 +226,7 @@ public class HugeResourceTest
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("staticFiles")
|
@MethodSource("staticFiles")
|
||||||
public void testDownload(String filename, long expectedSize) throws Exception
|
public void testDownloadStatic(String filename, long expectedSize) throws Exception
|
||||||
{
|
{
|
||||||
URI destUri = server.getURI().resolve("/" + filename);
|
URI destUri = server.getURI().resolve("/" + filename);
|
||||||
InputStreamResponseListener responseListener = new InputStreamResponseListener();
|
InputStreamResponseListener responseListener = new InputStreamResponseListener();
|
||||||
|
@ -251,7 +253,33 @@ public class HugeResourceTest
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("staticFiles")
|
@MethodSource("staticFiles")
|
||||||
public void testHead(String filename, long expectedSize) throws Exception
|
public void testDownloadChunked(String filename, long expectedSize) throws Exception
|
||||||
|
{
|
||||||
|
URI destUri = server.getURI().resolve("/chunked/" + filename);
|
||||||
|
InputStreamResponseListener responseListener = new InputStreamResponseListener();
|
||||||
|
|
||||||
|
Request request = client.newRequest(destUri)
|
||||||
|
.method(HttpMethod.GET);
|
||||||
|
request.send(responseListener);
|
||||||
|
Response response = responseListener.get(5, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
assertThat("HTTP Response Code", response.getStatus(), is(200));
|
||||||
|
// dumpResponse(response);
|
||||||
|
|
||||||
|
String transferEncoding = response.getHeaders().get(HttpHeader.TRANSFER_ENCODING);
|
||||||
|
assertThat("Http Response Header: \"Transfer-Encoding\"", transferEncoding, is("chunked"));
|
||||||
|
|
||||||
|
try (ByteCountingOutputStream out = new ByteCountingOutputStream();
|
||||||
|
InputStream in = responseListener.getInputStream())
|
||||||
|
{
|
||||||
|
IO.copy(in, out);
|
||||||
|
assertThat("Downloaded Files Size: " + filename, out.getCount(), is(expectedSize));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@MethodSource("staticFiles")
|
||||||
|
public void testHeadStatic(String filename, long expectedSize) throws Exception
|
||||||
{
|
{
|
||||||
URI destUri = server.getURI().resolve("/" + filename);
|
URI destUri = server.getURI().resolve("/" + filename);
|
||||||
InputStreamResponseListener responseListener = new InputStreamResponseListener();
|
InputStreamResponseListener responseListener = new InputStreamResponseListener();
|
||||||
|
@ -274,6 +302,30 @@ public class HugeResourceTest
|
||||||
assertThat("Http Response Header: \"Content-Length: " + contentLength + "\"", contentLengthLong, is(expectedSize));
|
assertThat("Http Response Header: \"Content-Length: " + contentLength + "\"", contentLengthLong, is(expectedSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@MethodSource("staticFiles")
|
||||||
|
public void testHeadChunked(String filename, long expectedSize) throws Exception
|
||||||
|
{
|
||||||
|
URI destUri = server.getURI().resolve("/chunked/" + filename);
|
||||||
|
InputStreamResponseListener responseListener = new InputStreamResponseListener();
|
||||||
|
|
||||||
|
Request request = client.newRequest(destUri)
|
||||||
|
.method(HttpMethod.HEAD);
|
||||||
|
request.send(responseListener);
|
||||||
|
Response response = responseListener.get(5, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
try (InputStream in = responseListener.getInputStream())
|
||||||
|
{
|
||||||
|
assertThat(in.read(), is(-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
assertThat("HTTP Response Code", response.getStatus(), is(200));
|
||||||
|
// dumpResponse(response);
|
||||||
|
|
||||||
|
String transferEncoding = response.getHeaders().get(HttpHeader.TRANSFER_ENCODING);
|
||||||
|
assertThat("Http Response Header: \"Transfer-Encoding\"", transferEncoding, is("chunked"));
|
||||||
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("staticFiles")
|
@MethodSource("staticFiles")
|
||||||
public void testUpload(String filename, long expectedSize) throws Exception
|
public void testUpload(String filename, long expectedSize) throws Exception
|
||||||
|
@ -361,6 +413,22 @@ public class HugeResourceTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class ChunkedServlet extends HttpServlet
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException
|
||||||
|
{
|
||||||
|
URL resource = req.getServletContext().getResource(req.getPathInfo());
|
||||||
|
OutputStream output = resp.getOutputStream();
|
||||||
|
try (InputStream input = resource.openStream())
|
||||||
|
{
|
||||||
|
resp.setContentType("application/octet-stream");
|
||||||
|
resp.flushBuffer();
|
||||||
|
IO.copy(input, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class MultipartServlet extends HttpServlet
|
public static class MultipartServlet extends HttpServlet
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue