-
Notifications
You must be signed in to change notification settings - Fork 98
Fix #20 - add support for <welcome-servlet> #881
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
Open
markt-asf
wants to merge
3
commits into
jakartaee:master
Choose a base branch
from
markt-asf:fix-issue-20
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
tck/tck-runtime/src/main/java/servlet/tck/spec/welcomefiles/IndexServletDo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2025 Contributors to the Eclipse Foundation | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
package servlet.tck.spec.welcomefiles; | ||
|
||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
|
||
import jakarta.servlet.GenericServlet; | ||
import jakarta.servlet.ServletException; | ||
import jakarta.servlet.ServletRequest; | ||
import jakarta.servlet.ServletResponse; | ||
|
||
/** | ||
* Simple servlet used for the welcome servlet tests. | ||
*/ | ||
public class IndexServletDo extends GenericServlet { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException { | ||
PrintWriter pw = response.getWriter(); | ||
// Test looks for this string to confirm the welcome servlet was used. | ||
pw.println("INDEX from *.do"); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
tck/tck-runtime/src/main/java/servlet/tck/spec/welcomefiles/WelcomeFilesFileTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2025 Contributors to the Eclipse Foundation | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
package servlet.tck.spec.welcomefiles; | ||
|
||
import servlet.tck.common.client.AbstractTckTest; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Arrays; | ||
|
||
public class WelcomeFilesFileTests extends AbstractTckTest { | ||
|
||
/** | ||
* Deployment for the test. | ||
* | ||
* @return The web archive to test. | ||
* | ||
* @throws Exception If an error occurs creating the archive. | ||
*/ | ||
@Deployment(testable = false) | ||
public static WebArchive getTestArchive() throws Exception { | ||
WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "servlet_spec_welcomefiles_file_web.war") | ||
.addClasses(IndexServletDo.class) | ||
.setWebXML(WelcomeFilesFileTests.class.getResource("servlet_spec_welcomefiles_file_web.xml")); | ||
Arrays.asList("legacy/index.html") | ||
.forEach(s -> webArchive.addAsWebResource("spec/welcomefiles/" +s, s)); | ||
return webArchive; | ||
} | ||
|
||
|
||
/* | ||
* Test should trigger a 404 since index.do is configured as a welcome file and no such file exists. | ||
*/ | ||
@Test | ||
public void partialfoundLegacy() throws Exception { | ||
TEST_PROPS.get().setProperty(FOLLOW_REDIRECT, "follow_redirect"); | ||
TEST_PROPS.get().setProperty(STATUS_CODE, NOT_FOUND); | ||
TEST_PROPS.get().setProperty(SEARCH_STRING, "<html"); | ||
TEST_PROPS.get().setProperty(APITEST, "legacy"); | ||
invoke(); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
tck/tck-runtime/src/main/java/servlet/tck/spec/welcomefiles/WelcomeFilesLegacyTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2025 Contributors to the Eclipse Foundation | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
package servlet.tck.spec.welcomefiles; | ||
|
||
import servlet.tck.common.client.AbstractTckTest; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Arrays; | ||
|
||
public class WelcomeFilesLegacyTests extends AbstractTckTest { | ||
|
||
/** | ||
* Deployment for the test. | ||
* | ||
* @return The web archive to test. | ||
* | ||
* @throws Exception If an error occurs creating the archive. | ||
*/ | ||
@Deployment(testable = false) | ||
public static WebArchive getTestArchive() throws Exception { | ||
WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "servlet_spec_welcomefiles_legacy_web.war") | ||
.addClasses(IndexServletDo.class) | ||
.setWebXML(WelcomeFilesLegacyTests.class.getResource("servlet_spec_welcomefiles_legacy_web.xml")); | ||
Arrays.asList("legacy/index.html") | ||
.forEach(s -> webArchive.addAsWebResource("spec/welcomefiles/" +s, s)); | ||
return webArchive; | ||
} | ||
|
||
|
||
/* | ||
* Test should trigger a 404 since default.jsp is a valid welcome file but does not exist. | ||
*/ | ||
@Test | ||
public void partialfoundLegacy() throws Exception { | ||
TEST_PROPS.get().setProperty(FOLLOW_REDIRECT, "follow_redirect"); | ||
TEST_PROPS.get().setProperty(STATUS_CODE, NOT_FOUND); | ||
TEST_PROPS.get().setProperty(SEARCH_STRING, "<html"); | ||
TEST_PROPS.get().setProperty(APITEST, "legacy"); | ||
invoke(); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
tck/tck-runtime/src/main/java/servlet/tck/spec/welcomefiles/WelcomeFilesServletTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2025 Contributors to the Eclipse Foundation | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
package servlet.tck.spec.welcomefiles; | ||
|
||
import servlet.tck.common.client.AbstractTckTest; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Arrays; | ||
|
||
public class WelcomeFilesServletTests extends AbstractTckTest { | ||
|
||
/** | ||
* Deployment for the test. | ||
* | ||
* @return The web archive to test. | ||
* | ||
* @throws Exception If an error occurs creating the archive. | ||
*/ | ||
@Deployment(testable = false) | ||
public static WebArchive getTestArchive() throws Exception { | ||
WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "servlet_spec_welcomefiles_servlet_web.war") | ||
.addClasses(IndexServletDo.class) | ||
.setWebXML(WelcomeFilesServletTests.class.getResource("servlet_spec_welcomefiles_servlet_web.xml")); | ||
Arrays.asList("legacy/index.html") | ||
.forEach(s -> webArchive.addAsWebResource("spec/welcomefiles/" +s, s)); | ||
return webArchive; | ||
} | ||
|
||
|
||
/* | ||
* Test should use the index.do mapping since it is configured as a welcome-servlet. | ||
*/ | ||
@Test | ||
public void partialfoundServlet() throws Exception { | ||
TEST_PROPS.get().setProperty(FOLLOW_REDIRECT, "follow_redirect"); | ||
TEST_PROPS.get().setProperty(SEARCH_STRING, "INDEX from *.do"); | ||
TEST_PROPS.get().setProperty(APITEST, "legacy"); | ||
invoke(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we mapping welcome-file elements in 6.2 descriptors to servlets? Surely these mappings should only be for
welcome-servlet
resources and perhaps legacy welcome files?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second bullet (exact matching) is to handle pre-compiled JSPs.
The third bullet (prefix mapping) is probably unnecessary. There might be some backwards compatibility edge cases but I don't have a concrete argument for keeping it.
I see the point re *.jsp. I think that is a wording issue. How about this instead of the last bullet for the first iteration:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think that for all
welcome-file
resources, then the file must exist. This would work for precompiled JSPs because the index.jsp file should still be there. Then only forwelcome-servlet
resources do we look for a match regardless of the files existence?I'm AFK until Monday, so can this wait until then for some more considered discussion?