#6327 improve test

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2021-08-04 10:16:57 +02:00
parent 56eed8211e
commit 8766bddb50
1 changed files with 13 additions and 11 deletions

View File

@ -60,11 +60,13 @@ import org.eclipse.jetty.http2.HTTP2Session;
import org.eclipse.jetty.http2.api.Session; import org.eclipse.jetty.http2.api.Session;
import org.eclipse.jetty.http2.client.http.HttpConnectionOverHTTP2; import org.eclipse.jetty.http2.client.http.HttpConnectionOverHTTP2;
import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EofException;
import org.eclipse.jetty.logging.StacklessLogging; import org.eclipse.jetty.logging.StacklessLogging;
import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpChannel; import org.eclipse.jetty.server.HttpChannel;
import org.eclipse.jetty.server.HttpInput; import org.eclipse.jetty.server.HttpInput;
import org.eclipse.jetty.server.HttpInput.Content; import org.eclipse.jetty.server.HttpInput.Content;
import org.eclipse.jetty.server.HttpOutput;
import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandler.Context; import org.eclipse.jetty.server.handler.ContextHandler.Context;
@ -401,12 +403,7 @@ public class AsyncIOServletTest extends AbstractTest<AsyncIOServletTest.AsyncTra
{ {
init(transport); init(transport);
String text = "Now is the winter of our discontent. How Now Brown Cow. The quick brown fox jumped over the lazy dog.\n"; byte[] data = new byte[1024];
for (int i = 0; i < 10; i++)
{
text = text + text;
}
byte[] data = text.getBytes(StandardCharsets.UTF_8);
CountDownLatch errorLatch = new CountDownLatch(1); CountDownLatch errorLatch = new CountDownLatch(1);
scenario.start(new HttpServlet() scenario.start(new HttpServlet()
@ -432,17 +429,22 @@ public class AsyncIOServletTest extends AbstractTest<AsyncIOServletTest.AsyncTra
{ {
await().atMost(5, TimeUnit.SECONDS).until(() -> await().atMost(5, TimeUnit.SECONDS).until(() ->
{ {
out.write(new byte[0]); try
// Extract HttpOutput._apiState value from toString. {
return !out.toString().split(",")[1].split("=")[1].equals("READY"); if (out.isReady())
((HttpOutput)out).write(ByteBuffer.wrap(data));
return false;
}
catch (EofException e)
{
return true;
}
}); });
} }
catch (Exception e) catch (Exception e)
{ {
throw new AssertionError(e); throw new AssertionError(e);
} }
out.write(data);
} }
@Override @Override