Bad tests take too long

This commit is contained in:
Joakim Erdfelt 2017-02-02 19:28:16 -07:00
parent 35b94fffd3
commit 25a95b83f9
2 changed files with 43 additions and 1 deletions

View File

@ -92,7 +92,8 @@ public abstract class AbstractHttpTest
writer.write("\r\n");
writer.flush();
HttpTester.Response response = HttpTester.parseResponse(socket.getInputStream());
HttpTester.Input input = HttpTester.from(socket.getInputStream());
HttpTester.Response response = HttpTester.parseResponse(input);
if ("HTTP/1.1".equals(httpVersion)
&& response.get("content-length") == null
&& response.get("transfer-encoding") == null

View File

@ -417,6 +417,47 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
}
}
@Test
public void testSetContentLengthFlushAndWriteInsufficientBytes() throws Exception
{
server.setHandler(new SetContentLengthAndWriteInsufficientBytesHandler(true));
server.start();
try
{
HttpTester.Response response = executeRequest();
char badChar = (char) -1;
String failed_body = "" + badChar + badChar + badChar;
assertThat("response code", response.getStatus(), is(200));
assertHeader(response, "content-length", "6");
assertThat(response.getContent(), endsWith(failed_body));
}
catch(EOFException e)
{
// possible good response
}
}
@Test
public void testSetContentLengthAndWriteInsufficientBytes() throws Exception
{
server.setHandler(new SetContentLengthAndWriteInsufficientBytesHandler(false));
server.start();
try
{
HttpTester.Response response = executeRequest();
char badChar = (char) -1;
String failed_body = "" + badChar + badChar + badChar;
assertThat("response code is 200", response.getStatus(), is(200));
assertHeader(response, "content-length", "6");
assertThat(response.getContent(), endsWith(failed_body));
}
catch(EOFException e)
{
// expected
}
}
@Test
public void testSetContentLengthAndWriteExactlyThatAmountOfBytes() throws Exception
{