Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tck challenges #590

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -695,12 +695,13 @@ public void doHeadTest() throws Exception {
// RFC 9110, section 9.32
.filter(name -> !name.toLowerCase(Locale.ENGLISH).equals("content-length"))
.filter(name -> !name.toLowerCase(Locale.ENGLISH).equals("vary"))
.filter(name -> !name.toLowerCase(Locale.ENGLISH).equals("transfer-encoding"))
.collect(Collectors.toSet());

List<Header> headersHead = responseHead.getResponseHeaders();
for (Header header : headersHead) {
if (header.getName().equalsIgnoreCase("date") || header.getName().equalsIgnoreCase("content-length") ||
header.getName().equalsIgnoreCase("vary")) {
header.getName().equalsIgnoreCase("vary") || header.getName().equalsIgnoreCase("transfer-encoding")) {
// Skip date, content-length and vary header to align with filtering just above
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static WebArchive getTestArchive() throws Exception {
return ShrinkWrap.create(WebArchive.class, "servlet_spec_requestdispatcher_web.war")
.addAsLibraries(CommonServlets.getCommonServletsArchive())
.addClasses(ForwardedServlet.class, HttpTestServlet.class, IncludedServlet.class,
MultiForwardedServlet.class, TestServlet.class, WrapServlet.class)
MultiForwardedServlet.class, TestServlet.class)
.setWebXML(RequestDispatcherTests.class.getResource("servlet_spec_requestdispatcher_web.xml"));
}

Expand Down Expand Up @@ -123,9 +123,9 @@ public void getRequestAttributes2() throws Exception {

/*
* @testName: requestDispatcherIncludeIOAndServletExceptionTest
*
*
* @assertion_ids: Servlet:SPEC:82; Servlet:JAVADOC:279; Servlet:JAVADOC:280;
*
*
* @test_Strategy: Validate an exception thrown during a
* RequestDispatcher.include() operation results in an IOException or
* ServletException being thrown, the Servlet or IOException will be
Expand All @@ -143,9 +143,9 @@ public void requestDispatcherIncludeIOAndServletExceptionTest() throws Exception

/*
* @testName: requestDispatcherIncludeRuntimeExceptionTest
*
*
* @assertion_ids: Servlet:SPEC:82
*
*
* @test_Strategy: Validate a RuntimeException thrown during a
* RequestDispacher.include() operation results in the RuntimeException being
* propagated back to the caller and will not be wrapped by a
Expand All @@ -162,9 +162,9 @@ public void requestDispatcherIncludeRuntimeExceptionTest() throws Exception {

/*
* @testName: requestDispatcherIncludeCheckedExceptionTest
*
*
* @assertion_ids: Servlet:SPEC:82
*
*
* @test_Strategy: Validate a checked exception that is thrown during a
* RequetDispatcher.include() operation and is not an instance of
* ServletException or IOException is returned to the caller wrapped by
Expand All @@ -181,9 +181,9 @@ public void requestDispatcherIncludeCheckedExceptionTest() throws Exception {

/*
* @testName: requestDispatcherForwardIOAndServletExceptionTest
*
*
* @assertion_ids: Servlet:SPEC:82; Servlet:JAVADOC:275; Servlet:JAVADOC:276;
*
*
* @test_Strategy: Validate an exception thrown during a
* RequestDispatcher.forward() operation results in an IOException or
* ServletException being thrown, the Servlet or IOException will be
Expand All @@ -201,9 +201,9 @@ public void requestDispatcherForwardIOAndServletExceptionTest() throws Exception

/*
* @testName: requestDispatcherForwardRuntimeExceptionTest
*
*
* @assertion_ids: Servlet:SPEC:82
*
*
* @test_Strategy: Validate a RuntimeException thrown during a
* RequestDispacher.forward() operation results in the RuntimeException being
* propagated back to the caller and will not be wrapped by a
Expand All @@ -220,9 +220,9 @@ public void requestDispatcherForwardRuntimeExceptionTest() throws Exception {

/*
* @testName: requestDispatcherForwardCheckedExceptionTest
*
*
* @assertion_ids: Servlet:SPEC:82
*
*
* @test_Strategy: Validate a checked exception that is thrown during a
* RequetDispatcher.forward() operation and is not an instance of
* ServletException or IOException is returned to the caller wrapped by
Expand Down Expand Up @@ -372,34 +372,11 @@ public void bufferContent() throws Exception {
invoke();
}

/*
* @testName: requestDispatcherNoWrappingTest
*
* @assertion_ids: Servlet:SPEC:50;
*
* @test_Strategy: Validate the container passes the same objects from a
* RequestDispatcher operation to the target entity. The container should not
* wrap the object at any point.
*/
@Test
public void requestDispatcherNoWrappingTest() throws Exception {
TEST_PROPS.get().setProperty(REQUEST,
"GET /servlet_spec_requestdispatcher_web/TestServlet?testname=rdNoWrappingTest&operation=0 HTTP/1.1");
TEST_PROPS.get().setProperty(SEARCH_STRING, "Test PASSED");
TEST_PROPS.get().setProperty(UNEXPECTED_RESPONSE_MATCH, "Test FAILED");
invoke();
TEST_PROPS.get().setProperty(REQUEST,
"GET /servlet_spec_requestdispatcher_web/TestServlet?testname=rdNoWrappingTest&operation=1 HTTP/1.1");
TEST_PROPS.get().setProperty(SEARCH_STRING, "Test PASSED");
TEST_PROPS.get().setProperty(UNEXPECTED_RESPONSE_MATCH, "Test FAILED");
invoke();
}

/*
* @testName: getRequestURIIncludeTest
*
*
* @assertion_ids: Servlet:SPEC:76; Servlet:JAVADOC:561;
*
*
* @test_Strategy: 1. Create servlets TestServlet and HttpTestServlet; 2. In
* TestServlet;, access HttpTestServlet using RequestDispatcher.include. 3.
* Verify in HttpTestServlet, that getRequestURI returns correct URI according
Expand All @@ -413,9 +390,9 @@ public void getRequestURIIncludeTest() throws Exception {

/*
* @testName: getRequestURLIncludeTest
*
*
* @assertion_ids: Servlet:SPEC:76; Servlet:JAVADOC:562;
*
*
* @test_Strategy: 1. Create servlets TestServlet and HttpTestServlet; 2. In
* TestServlet;, access HttpTestServlet using RequestDispatcher.include. 3.
* Verify in HttpTestServlet, that getRequestURL returns correct URI according
Expand All @@ -429,9 +406,9 @@ public void getRequestURLIncludeTest() throws Exception {

/*
* @testName: getRequestURIForwardTest
*
*
* @assertion_ids: Servlet:SPEC:78;; Servlet:JAVADOC:561;
*
*
* @test_Strategy: 1. Create servlets TestServlet and HttpTestServlet; 2. In
* TestServlet;, access HttpTestServlet using RequestDispatcher.forward. 3.
* Verify in HttpTestServlet, that getRequestURI returns correct URI according
Expand All @@ -445,9 +422,9 @@ public void getRequestURIForwardTest() throws Exception {

/*
* @testName: getRequestURLForwardTest
*
*
* @assertion_ids: Servlet:SPEC:78; Servlet:JAVADOC:562;
*
*
* @test_Strategy: 1. Create servlets TestServlet and HttpTestServlet; 2. In
* TestServlet;, access HttpTestServlet using RequestDispatcher.forward. 3.
* Verify in HttpTestServlet, that getRequestURL returns correct URL according
Expand All @@ -461,9 +438,9 @@ public void getRequestURLForwardTest() throws Exception {

/*
* @testName: getQueryStringIncludeTest
*
*
* @assertion_ids: Servlet:SPEC:192; Servlet:JAVADOC:552;
*
*
* @test_Strategy: 1. Create servlets TestServlet and HttpTestServlet; 2. Send
* request to TestServlet with ?testname=getQueryStringIncludeTest; 3. In
* TestServlet, access HttpTestServlet using RequestDispatcher.include, with
Expand All @@ -479,9 +456,9 @@ public void getQueryStringIncludeTest() throws Exception {

/*
* @testName: getQueryStringForwardTest
*
*
* @assertion_ids: Servlet:SPEC:78; Servlet:JAVADOC:552;
*
*
* @test_Strategy: 1. Create servlets TestServlet and HttpTestServlet; 2. Send
* request to TestServlet with ?testname=getQueryStringForwardTest; 3. In
* TestServlet, access HttpTestServlet using RequestDispatcher.forward, with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,39 +391,6 @@ public void bufferContent(HttpServletRequest request,
rd.forward(request, response);
}

public void rdNoWrappingTest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {

// when calling the request dispatcher, the objects passed to the included
// or forwarded servlet must be the same objects passed to the
// RequestDispatcher

int operation = Integer.parseInt(request.getParameter("operation"));
System.out.println("Operation: " + operation);
HttpServletRequestWrapper reqw = new HttpServletRequestWrapper(request);
HttpServletResponseWrapper resw = new HttpServletResponseWrapper(response);

ServletContext ctx = getServletConfig().getServletContext();
ctx.setAttribute("tck.request", reqw);
ctx.setAttribute("tck.response", resw);

RequestDispatcher rd = request.getRequestDispatcher("/WrapServlet");

if (rd != null) {
switch (operation) {
case 0:
System.out.println("PERFORMING RD.FORWARD....");
System.out.println("COMMITTED: " + response.isCommitted());
rd.forward(reqw, resw);
break;
case 1:
System.out.println("PERFORMING RD.INCLUDE...");
rd.include(reqw, resw);
break;
}
}
}

public void getRequestURIIncludeTest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
PrintWriter pw = response.getWriter();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
<servlet-name>ForwardedServlet</servlet-name>
<servlet-class>servlet.tck.spec.requestdispatcher.ForwardedServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>WrapServlet</servlet-name>
<servlet-class>servlet.tck.spec.requestdispatcher.WrapServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/TestServlet</url-pattern>
Expand All @@ -63,10 +59,6 @@
<servlet-name>MultiForwardedServlet</servlet-name>
<url-pattern>/forward/MultiForwardedServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>WrapServlet</servlet-name>
<url-pattern>/WrapServlet</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>54</session-timeout>
</session-config>
Expand Down
Loading