fix tests in AsyncServletTest

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2022-07-26 15:04:45 +10:00
parent d56a4e0dd3
commit ce8048c4bd
2 changed files with 25 additions and 3 deletions

View File

@ -419,7 +419,7 @@ public class ServletChannel implements Runnable
} }
Dispatcher dispatcher = new Dispatcher(getContextHandler(), uri, pathInContext); Dispatcher dispatcher = new Dispatcher(getContextHandler(), uri, pathInContext);
dispatcher.async(_request.getHttpServletRequest(), getResponse().getHttpServletResponse()); dispatcher.async(asyncContextEvent.getSuppliedRequest(), asyncContextEvent.getSuppliedResponse());
}); });
break; break;
} }

View File

@ -51,7 +51,6 @@ import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
@ -60,7 +59,6 @@ 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.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
@Disabled("A lot of the test expectations are now broken because of the request wrapping done by Jetty 12 implementation.")
public class AsyncServletTest public class AsyncServletTest
{ {
protected AsyncServlet _servlet = new AsyncServlet(); protected AsyncServlet _servlet = new AsyncServlet();
@ -244,6 +242,7 @@ public class AsyncServletTest
"onTimeout", "onTimeout",
"dispatch", "dispatch",
"ASYNC /ctx/path/info?start=200&timeout=dispatch", "ASYNC /ctx/path/info?start=200&timeout=dispatch",
"wrapped REQ",
"!initial", "!initial",
"onComplete")); "onComplete"));
@ -263,6 +262,7 @@ public class AsyncServletTest
"onTimeout", "onTimeout",
"error", "error",
"ERROR /ctx/error/custom?start=200&timeout=error", "ERROR /ctx/error/custom?start=200&timeout=error",
"wrapped REQ",
"!initial", "!initial",
"onComplete")); "onComplete"));
@ -296,6 +296,7 @@ public class AsyncServletTest
"start", "start",
"dispatch", "dispatch",
"ASYNC /ctx/path/info?start=200&dispatch=10", "ASYNC /ctx/path/info?start=200&dispatch=10",
"wrapped REQ",
"!initial", "!initial",
"onComplete")); "onComplete"));
assertFalse(__history.contains("onTimeout")); assertFalse(__history.contains("onTimeout"));
@ -312,6 +313,7 @@ public class AsyncServletTest
"start", "start",
"dispatch", "dispatch",
"ASYNC /ctx/path/info?start=200&dispatch=0", "ASYNC /ctx/path/info?start=200&dispatch=0",
"wrapped REQ",
"!initial", "!initial",
"onComplete")); "onComplete"));
} }
@ -328,6 +330,7 @@ public class AsyncServletTest
"start", "start",
"onError", "onError",
"ERROR /ctx/error/custom?start=200&throw=1", "ERROR /ctx/error/custom?start=200&throw=1",
"wrapped REQ",
"!initial", "!initial",
"onComplete")); "onComplete"));
assertContains("ERROR DISPATCH: /ctx/error/custom", response); assertContains("ERROR DISPATCH: /ctx/error/custom", response);
@ -376,11 +379,13 @@ public class AsyncServletTest
"start", "start",
"dispatch", "dispatch",
"ASYNC /ctx/path/info?start=1000&dispatch=10&start2=1000&dispatch2=10", "ASYNC /ctx/path/info?start=1000&dispatch=10&start2=1000&dispatch2=10",
"wrapped REQ",
"!initial", "!initial",
"onStartAsync", "onStartAsync",
"start", "start",
"dispatch", "dispatch",
"ASYNC /ctx/path/info?start=1000&dispatch=10&start2=1000&dispatch2=10", "ASYNC /ctx/path/info?start=1000&dispatch=10&start2=1000&dispatch2=10",
"wrapped REQ",
"!initial", "!initial",
"onComplete")); "onComplete"));
assertContains("DISPATCHED", response); assertContains("DISPATCHED", response);
@ -397,6 +402,7 @@ public class AsyncServletTest
"start", "start",
"dispatch", "dispatch",
"ASYNC /ctx/path/info?start=1000&dispatch=10&start2=1000&complete2=10", "ASYNC /ctx/path/info?start=1000&dispatch=10&start2=1000&complete2=10",
"wrapped REQ",
"!initial", "!initial",
"onStartAsync", "onStartAsync",
"start", "start",
@ -417,11 +423,13 @@ public class AsyncServletTest
"start", "start",
"dispatch", "dispatch",
"ASYNC /ctx/path/info?start=1000&dispatch=10&start2=10", "ASYNC /ctx/path/info?start=1000&dispatch=10&start2=10",
"wrapped REQ",
"!initial", "!initial",
"onStartAsync", "onStartAsync",
"start", "start",
"onTimeout", "onTimeout",
"ERROR /ctx/error/custom?start=1000&dispatch=10&start2=10", "ERROR /ctx/error/custom?start=1000&dispatch=10&start2=10",
"wrapped REQ",
"!initial", "!initial",
"onComplete")); "onComplete"));
assertContains("ERROR DISPATCH: /ctx/error/custom", response); assertContains("ERROR DISPATCH: /ctx/error/custom", response);
@ -438,11 +446,13 @@ public class AsyncServletTest
"start", "start",
"onTimeout", "onTimeout",
"ERROR /ctx/error/custom?start=10&start2=1000&dispatch2=10", "ERROR /ctx/error/custom?start=10&start2=1000&dispatch2=10",
"wrapped REQ",
"!initial", "!initial",
"onStartAsync", "onStartAsync",
"start", "start",
"dispatch", "dispatch",
"ASYNC /ctx/path/info?start=10&start2=1000&dispatch2=10", "ASYNC /ctx/path/info?start=10&start2=1000&dispatch2=10",
"wrapped REQ",
"!initial", "!initial",
"onComplete")); "onComplete"));
assertContains("DISPATCHED", response); assertContains("DISPATCHED", response);
@ -459,6 +469,7 @@ public class AsyncServletTest
"start", "start",
"onTimeout", "onTimeout",
"ERROR /ctx/error/custom?start=10&start2=1000&complete2=10", "ERROR /ctx/error/custom?start=10&start2=1000&complete2=10",
"wrapped REQ",
"!initial", "!initial",
"onStartAsync", "onStartAsync",
"start", "start",
@ -480,11 +491,13 @@ public class AsyncServletTest
"start", "start",
"onTimeout", "onTimeout",
"ERROR /ctx/path/error?start=10&start2=10", "ERROR /ctx/path/error?start=10&start2=10",
"wrapped REQ",
"!initial", "!initial",
"onStartAsync", "onStartAsync",
"start", "start",
"onTimeout", "onTimeout",
"ERROR /ctx/path/error?start=10&start2=10", "ERROR /ctx/path/error?start=10&start2=10",
"wrapped REQ",
"!initial", "!initial",
"onComplete")); // Error Page Loop! "onComplete")); // Error Page Loop!
assertContains("AsyncContext timeout", response); assertContains("AsyncContext timeout", response);
@ -518,6 +531,7 @@ public class AsyncServletTest
"start", "start",
"dispatch", "dispatch",
"ASYNC /ctx/p%20th3?start=200&dispatch=20&path=/p%20th3", "ASYNC /ctx/p%20th3?start=200&dispatch=20&path=/p%20th3",
"wrapped REQ",
"!initial", "!initial",
"onComplete")); "onComplete"));
assertContains("DISPATCHED", response); assertContains("DISPATCHED", response);
@ -531,11 +545,14 @@ public class AsyncServletTest
assertThat(__history, contains( assertThat(__history, contains(
"FWD REQUEST /ctx/fwd/info?start=200&dispatch=20", "FWD REQUEST /ctx/fwd/info?start=200&dispatch=20",
"FORWARD /ctx/path1?forward=true", "FORWARD /ctx/path1?forward=true",
"wrapped REQ",
"initial", "initial",
"start", "start",
"dispatch", "dispatch",
"FWD ASYNC /ctx/fwd/info?start=200&dispatch=20", "FWD ASYNC /ctx/fwd/info?start=200&dispatch=20",
"wrapped REQ",
"FORWARD /ctx/path1?forward=true", "FORWARD /ctx/path1?forward=true",
"wrapped REQ",
"!initial", "!initial",
"onComplete")); "onComplete"));
assertContains("DISPATCHED", response); assertContains("DISPATCHED", response);
@ -549,10 +566,12 @@ public class AsyncServletTest
assertThat(__history, contains( assertThat(__history, contains(
"FWD REQUEST /ctx/fwd/info?start=200&dispatch=20&path=/path2", "FWD REQUEST /ctx/fwd/info?start=200&dispatch=20&path=/path2",
"FORWARD /ctx/path1?forward=true", "FORWARD /ctx/path1?forward=true",
"wrapped REQ",
"initial", "initial",
"start", "start",
"dispatch", "dispatch",
"ASYNC /ctx/path2?start=200&dispatch=20&path=/path2", "ASYNC /ctx/path2?start=200&dispatch=20&path=/path2",
"wrapped REQ",
"!initial", "!initial",
"onComplete")); "onComplete"));
assertContains("DISPATCHED", response); assertContains("DISPATCHED", response);
@ -566,6 +585,7 @@ public class AsyncServletTest
assertThat(__history, contains( assertThat(__history, contains(
"FWD REQUEST /ctx/fwd/info?wrap=true&start=200&dispatch=20", "FWD REQUEST /ctx/fwd/info?wrap=true&start=200&dispatch=20",
"FORWARD /ctx/path1?forward=true", "FORWARD /ctx/path1?forward=true",
"wrapped REQ",
"initial", "initial",
"start", "start",
"dispatch", "dispatch",
@ -584,6 +604,7 @@ public class AsyncServletTest
assertThat(__history, contains( assertThat(__history, contains(
"FWD REQUEST /ctx/fwd/info?wrap=true&start=200&dispatch=20&path=/path2", "FWD REQUEST /ctx/fwd/info?wrap=true&start=200&dispatch=20&path=/path2",
"FORWARD /ctx/path1?forward=true", "FORWARD /ctx/path1?forward=true",
"wrapped REQ",
"initial", "initial",
"start", "start",
"dispatch", "dispatch",
@ -622,6 +643,7 @@ public class AsyncServletTest
"async-read=10", "async-read=10",
"dispatch", "dispatch",
"ASYNC /ctx/path/info?start=2000&dispatch=1500", "ASYNC /ctx/path/info?start=2000&dispatch=1500",
"wrapped REQ",
"!initial", "!initial",
"onComplete")); "onComplete"));
} }