#9287 - catch error in ee9 maxRequestSize MultiPart test
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
341ac15061
commit
820fbb7331
|
@ -46,6 +46,7 @@ import org.eclipse.jetty.http.HttpScheme;
|
||||||
import org.eclipse.jetty.http.HttpStatus;
|
import org.eclipse.jetty.http.HttpStatus;
|
||||||
import org.eclipse.jetty.http.MimeTypes;
|
import org.eclipse.jetty.http.MimeTypes;
|
||||||
import org.eclipse.jetty.http.MultiPart;
|
import org.eclipse.jetty.http.MultiPart;
|
||||||
|
import org.eclipse.jetty.io.EofException;
|
||||||
import org.eclipse.jetty.logging.StacklessLogging;
|
import org.eclipse.jetty.logging.StacklessLogging;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.ServerConnector;
|
import org.eclipse.jetty.server.ServerConnector;
|
||||||
|
@ -58,10 +59,12 @@ import org.junit.jupiter.api.Test;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
import static org.hamcrest.Matchers.instanceOf;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.startsWith;
|
import static org.hamcrest.Matchers.startsWith;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
public class MultiPartServletTest
|
public class MultiPartServletTest
|
||||||
{
|
{
|
||||||
|
@ -251,20 +254,28 @@ public class MultiPartServletTest
|
||||||
.body(multiPart)
|
.body(multiPart)
|
||||||
.send(listener);
|
.send(listener);
|
||||||
|
|
||||||
// Write large amount of content to the part.
|
Throwable writeError = null;
|
||||||
byte[] byteArray = new byte[1024 * 1024];
|
try
|
||||||
Arrays.fill(byteArray, (byte)1);
|
|
||||||
for (int i = 0; i < 1024 * 2; i++)
|
|
||||||
{
|
{
|
||||||
content.getOutputStream().write(byteArray);
|
// Write large amount of content to the part.
|
||||||
|
byte[] byteArray = new byte[1024 * 1024];
|
||||||
|
Arrays.fill(byteArray, (byte)1);
|
||||||
|
for (int i = 0; i < 1024 * 1024; i++)
|
||||||
|
{
|
||||||
|
content.getOutputStream().write(byteArray);
|
||||||
|
}
|
||||||
|
fail("We should never be able to write all the content.");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
writeError = e;
|
||||||
}
|
}
|
||||||
content.close();
|
|
||||||
|
|
||||||
|
assertThat(writeError, instanceOf(EofException.class));
|
||||||
|
|
||||||
|
// We should get 400 response, for some reason reading the content throws EofException.
|
||||||
Response response = listener.get(30, TimeUnit.SECONDS);
|
Response response = listener.get(30, TimeUnit.SECONDS);
|
||||||
assertThat(response.getStatus(), equalTo(HttpStatus.BAD_REQUEST_400));
|
assertThat(response.getStatus(), equalTo(HttpStatus.BAD_REQUEST_400));
|
||||||
String responseContent = IO.toString(listener.getInputStream());
|
|
||||||
assertThat(responseContent, containsString("Unable to parse form content"));
|
|
||||||
assertThat(responseContent, containsString("Request exceeds maxRequestSize"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue