Skip to content

Commit

Permalink
Migrate JSP to Facelets in Faces TCK
Browse files Browse the repository at this point in the history
Basically a find & replace of following things:
- *.jsp to *.xhtml
- <% taglib %> to <html xmlns>
- ${jsp.dir} to ${facelets.dir}

And removal of:
- removed irrelevant JSP/Facelets context params from web.xml
- removed JSP from TestServlets for VDL
- removed encodetest.jsp which already has encodetest_facelet.xhtml
- removed decodetest.jsp which already has decodetest_facelet.xhtml

TODO:
- <managed-bean> still needs to be migrated to @nAmed, 146 occurrences
  • Loading branch information
BalusC committed Mar 1, 2022
1 parent 83283a9 commit a241487
Show file tree
Hide file tree
Showing 234 changed files with 461 additions and 3,386 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -19,3 +19,4 @@ target/
/user_guides/**/toc.adoc
/nbproject
*.iml
.project
Expand Up @@ -59,7 +59,7 @@ public Status run(String args[], PrintWriter out, PrintWriter err) {
*/
public void applicationAddELResolverISETest() throws Fault {
// Make Client Call before running the test.
String clientside = "/faces/applicationtest.jsp";
String clientside = "/faces/applicationtest.xhtml";
this.getPage(new WebClient(),
"http://" + _hostname + ":" + _port + CONTEXT_ROOT + clientside);

Expand All @@ -78,7 +78,7 @@ public void applicationAddELResolverISETest() throws Fault {
*/
public void applicationSetResourceHandlerISETest() throws Fault {
// Make Client Call before running the test.
String clientside = "/faces/applicationtest.jsp";
String clientside = "/faces/applicationtest.xhtml";
this.getPage(new WebClient(),
"http://" + _hostname + ":" + _port + CONTEXT_ROOT + clientside);

Expand All @@ -97,7 +97,7 @@ public void applicationSetResourceHandlerISETest() throws Fault {
*/
public void applicationSetStateManagerISETest() throws Fault {
// Make Client Call before running the test.
String clientside = "/faces/applicationtest.jsp";
String clientside = "/faces/applicationtest.xhtml";
this.getPage(new WebClient(),
"http://" + _hostname + ":" + _port + CONTEXT_ROOT + clientside);

Expand All @@ -116,7 +116,7 @@ public void applicationSetStateManagerISETest() throws Fault {
*/
public void applicationSetViewHandlerISETest() throws Fault {
// Make Client Call before running the test.
String clientside = "/faces/applicationtest.jsp";
String clientside = "/faces/applicationtest.xhtml";
this.getPage(new WebClient(),
"http://" + _hostname + ":" + _port + CONTEXT_ROOT + clientside);

Expand Down
Expand Up @@ -22,7 +22,7 @@
<import file="../../../../common/common.xml"/>

<property name="app.name" value="jsf_appl_applicationISE"/>
<property name="jsp.dir"
<property name="facelets.dir"
value="${src.dir}/web/jsf/api/jakarta_faces/application/applicationISE"/>

<target name="package">
Expand All @@ -38,7 +38,7 @@
prefix="WEB-INF/classes"/>
<zipfileset dir="${ts.home}/weblib" includes="*.jar"
prefix="WEB-INF/lib"/>
<fileset dir="${jsp.dir}" includes="*.jsp"/>
<fileset dir="${facelets.dir}" includes="*.xhtml"/>
</ts.war>
</target>

Expand Down
Expand Up @@ -59,7 +59,7 @@ public Status run(String args[], PrintWriter out, PrintWriter err) {
*/
public void applicationWrapperAddELResolverISETest() throws Fault {
// Make Client Call before running the test.
String clientside = "/faces/applicationtest.jsp";
String clientside = "/faces/applicationtest.xhtml";
this.getPage(new WebClient(),
"http://" + _hostname + ":" + _port + CONTEXT_ROOT + clientside);

Expand All @@ -78,7 +78,7 @@ public void applicationWrapperAddELResolverISETest() throws Fault {
*/
public void applicationWrapperSetResourceHandlerISETest() throws Fault {
// Make Client Call before running the test.
String clientside = "/faces/applicationtest.jsp";
String clientside = "/faces/applicationtest.xhtml";
this.getPage(new WebClient(),
"http://" + _hostname + ":" + _port + CONTEXT_ROOT + clientside);

Expand All @@ -98,7 +98,7 @@ public void applicationWrapperSetResourceHandlerISETest() throws Fault {
*/
public void applicationWrapperSetStateManagerISETest() throws Fault {
// Make Client Call before running the test.
String clientside = "/faces/applicationtest.jsp";
String clientside = "/faces/applicationtest.xhtml";
this.getPage(new WebClient(),
"http://" + _hostname + ":" + _port + CONTEXT_ROOT + clientside);

Expand All @@ -117,7 +117,7 @@ public void applicationWrapperSetStateManagerISETest() throws Fault {
*/
public void applicationWrapperSetViewHandlerISETest() throws Fault {
// Make Client Call before running the test.
String clientside = "/faces/applicationtest.jsp";
String clientside = "/faces/applicationtest.xhtml";
this.getPage(new WebClient(),
"http://" + _hostname + ":" + _port + CONTEXT_ROOT + clientside);

Expand Down
Expand Up @@ -22,7 +22,7 @@
<import file="../../../../common/common.xml"/>

<property name="app.name" value="jsf_appl_applicationWrapperISE"/>
<property name="jsp.dir"
<property name="facelets.dir"
value="${src.dir}/web/jsf/api/jakarta_faces/application/applicationISE"/>

<target name="package">
Expand All @@ -38,7 +38,7 @@
prefix="WEB-INF/classes"/>
<zipfileset dir="${ts.home}/weblib" includes="*.jar"
prefix="WEB-INF/lib"/>
<fileset dir="${jsp.dir}" includes="*.jsp"/>
<fileset dir="${facelets.dir}" includes="*.xhtml"/>
</ts.war>
</target>

Expand Down
Expand Up @@ -61,7 +61,7 @@ public Status run(String[] args, PrintWriter out, PrintWriter err) {
*/
public void resourceHandlerExcludePropertiesTest() throws Fault {
HtmlPage page = getPage(
CONTEXT_ROOT + "/faces/resourceHandlerExcludeTest.jsp");
CONTEXT_ROOT + "/faces/resourceHandlerExcludeTest.xhtml");
HtmlAnchor outputLink = (HtmlAnchor) getElementOfTypeIncludingId(page, "a",
"properties");
this.testLink(outputLink);
Expand All @@ -78,7 +78,7 @@ public void resourceHandlerExcludePropertiesTest() throws Fault {
*/
public void resourceHandlerExcludeClassTest() throws Fault {
HtmlPage page = getPage(
CONTEXT_ROOT + "/faces/resourceHandlerExcludeTest.jsp");
CONTEXT_ROOT + "/faces/resourceHandlerExcludeTest.xhtml");
HtmlAnchor outputLink = (HtmlAnchor) getElementOfTypeIncludingId(page, "a",
"class");
this.testLink(outputLink);
Expand All @@ -95,7 +95,7 @@ public void resourceHandlerExcludeClassTest() throws Fault {
*/
public void resourceHandlerExcludeJSPXTest() throws Fault {
HtmlPage page = getPage(
CONTEXT_ROOT + "/faces/resourceHandlerExcludeTest.jsp");
CONTEXT_ROOT + "/faces/resourceHandlerExcludeTest.xhtml");
HtmlAnchor outputLink = (HtmlAnchor) getElementOfTypeIncludingId(page, "a",
"jspx");
this.testLink(outputLink);
Expand All @@ -112,7 +112,7 @@ public void resourceHandlerExcludeJSPXTest() throws Fault {
*/
public void resourceHandlerExcludeJSPTest() throws Fault {
HtmlPage page = getPage(
CONTEXT_ROOT + "/faces/resourceHandlerExcludeTest.jsp");
CONTEXT_ROOT + "/faces/resourceHandlerExcludeTest.xhtml");
HtmlAnchor outputLink = (HtmlAnchor) getElementOfTypeIncludingId(page, "a",
"jsp");
this.testLink(outputLink);
Expand All @@ -129,7 +129,7 @@ public void resourceHandlerExcludeJSPTest() throws Fault {
*/
public void resourceHandlerExcludeXHTMLTest() throws Fault {
HtmlPage page = getPage(
CONTEXT_ROOT + "/faces/resourceHandlerExcludeTest.jsp");
CONTEXT_ROOT + "/faces/resourceHandlerExcludeTest.xhtml");
HtmlAnchor outputLink = (HtmlAnchor) getElementOfTypeIncludingId(page, "a",
"xhtml");
this.testLink(outputLink);
Expand Down
Expand Up @@ -22,7 +22,7 @@
<import file="../../../../common/common.xml"/>

<property name="app.name" value="jsf_appl_resourcehandlerEx"/>
<property name="jsp.dir"
<property name="facelets.dir"
value="${src.dir}/web/jsf/api/jakarta_faces/application/resourcehandlerEx"/>

<target name="package">
Expand All @@ -36,7 +36,7 @@
<zipfileset dir="${class.dir}/com/sun/ts/tests/jsf/api/jakarta_faces/application/resourcehandlerEx"
includes="neg_class_test.class"
prefix="resources"/>
<fileset dir="${jsp.dir}" includes="*.jsp"/>
<fileset dir="${facelets.dir}" includes="*.xhtml"/>
</ts.war>
</target>
</project>
Expand Up @@ -204,14 +204,14 @@ public void viewHandlerRenderViewNPETest(HttpServletRequest request,
// if ("prefix".equals(request.getParameter("mapping"))) {
// // Simulate an incoming prefix path mapped request
// wrapper.setServletPath("/mapping");
// wrapper.setPathInfo("/myapp/test.jsp");
// wrapper.setPathInfo("/myapp/test.xhtml");
//
// result = handler.getViewIdPath(context, "/view.jsp");
// result = handler.getViewIdPath(context, "/view.xhtml");
//
// if (!"/mapping/view.jsp".equals(result)) {
// if (!"/mapping/view.xhtml".equals(result)) {
// out.println(FAIL + " Unexpected result returned when using" +
// " a simulated prefix path mapped request.");
// out.println("Expected: /mapping/view.jsp");
// out.println("Expected: /mapping/view.xhtml");
// out.println("Received: " + result);
// return;
// }
Expand All @@ -225,7 +225,7 @@ public void viewHandlerRenderViewNPETest(HttpServletRequest request,
// wrapper.setServletPath("/myapp/view.faces");
// wrapper.setPathInfo(null);
//
// result = handler.getViewIdPath(context, "/view.jsp");
// result = handler.getViewIdPath(context, "/view.xhtml");
//
// if (!"/view.faces".equals(result)) {
// out.println("Test FAILED[1]. Unexpected result returned when using" +
Expand Down
Expand Up @@ -235,14 +235,14 @@ public void viewHandlerRenderViewNPETest(HttpServletRequest request,
// if ("prefix".equals(request.getParameter("mapping"))) {
// // Simulate an incoming prefix path mapped request
// wrapper.setServletPath("/mapping");
// wrapper.setPathInfo("/myapp/test.jsp");
// wrapper.setPathInfo("/myapp/test.xhtml");
//
// result = handler.getViewIdPath(context, "/view.jsp");
// result = handler.getViewIdPath(context, "/view.xhtml");
//
// if (!"/mapping/view.jsp".equals(result)) {
// if (!"/mapping/view.xhtml".equals(result)) {
// out.println(FAIL + " Unexpected result returned when using" +
// " a simulated prefix path mapped request.");
// out.println("Expected: /mapping/view.jsp");
// out.println("Expected: /mapping/view.xhtml");
// out.println("Received: " + result);
// return;
// }
Expand All @@ -256,7 +256,7 @@ public void viewHandlerRenderViewNPETest(HttpServletRequest request,
// wrapper.setServletPath("/myapp/view.faces");
// wrapper.setPathInfo(null);
//
// result = handler.getViewIdPath(context, "/view.jsp");
// result = handler.getViewIdPath(context, "/view.xhtml");
//
// if (!"/view.faces".equals(result)) {
// out.println("Test FAILED[1]. Unexpected result returned when using" +
Expand Down
Expand Up @@ -33,7 +33,6 @@
import jakarta.servlet.http.HttpServletResponse;

public class TestServlet extends HttpTCKServlet {
private static final String JSP_VIEWID = "/root.jsp";

private static final String FACELETS_VIEWID = "/root.xhtml";

Expand Down Expand Up @@ -67,23 +66,6 @@ public void stateMgmtStrategyNonNullTest(HttpServletRequest request,

}// End stateMgmtStrategyNonNullTest

public void stateMgmtStratNullForJSPTest(HttpServletRequest request,
HttpServletResponse response) throws IOException {
PrintWriter out = response.getWriter();
FacesContext context = getFacesContext();
StateManagementStrategy statestrategy = this.getStateMgtmStrat(context,
JSP_VIEWID);

if (statestrategy == null) {
out.println(JSFTestUtil.PASS);

} else {
out.println(JSFTestUtil.FAIL + JSFTestUtil.NL
+ "StateManagementStrategy Must be null for JSP Views!");
}

}// End stateMgmtStratNullForJSPTest

// --------------------------------------------- private methods

private StateManagementStrategy getStateMgtmStrat(FacesContext context,
Expand Down
Expand Up @@ -43,8 +43,6 @@

public class TestServlet extends HttpTCKServlet {

private static final String JSP_VIEWID = "/root.jsp";

private static final String FACELETS_VIEWID = "/root.xhtml";

/**
Expand All @@ -57,67 +55,6 @@ public void init(ServletConfig config) throws ServletException {
super.init(config);
}

public void vdlGetComponentMetadataUSOETest(HttpServletRequest request,
HttpServletResponse response) throws IOException {
PrintWriter out = response.getWriter();
FacesContext context = getFacesContext();

Resource resource = this.getResource(context);
ViewDeclarationLanguage vdl = this.getVDL(context, JSP_VIEWID);

String methName = "getComponentMetadata";

try {
vdl.getComponentMetadata(context, resource);
out.println(JSFTestUtil.FAIL + " " + JSFTestUtil.NL
+ "No Exception thrown when calling '" + vdl.getClass().getName()
+ "." + methName + "()'" + JSFTestUtil.NL
+ "Expected: UnsupportedOperationException to be thrown!");

} catch (UnsupportedOperationException uoe) {
out.println(JSFTestUtil.PASS);
} catch (Exception e) {
out.println(JSFTestUtil.FAIL + " Unexpected Exception thrown for "
+ vdl.getClass().getName() + "." + methName + "("
+ context.getClass().getSimpleName() + ", "
+ resource.getClass().getSimpleName() + ")" + JSFTestUtil.NL
+ "Expected: UnsupportedOperationException" + JSFTestUtil.NL
+ "Received: " + e.getClass().getName());
}

}// End vdlGetComponentMetadataUSOETest

public void vdlGetScriptComponentResourceUSOETest(HttpServletRequest request,
HttpServletResponse response) throws IOException {
PrintWriter out = response.getWriter();
FacesContext context = getFacesContext();

ResourceHandler handler = context.getApplication().getResourceHandler();
Resource resource = handler.createResource("myComp.xhtml");

String methName = "getScriptComponentResource";
ViewDeclarationLanguage vdl = this.getVDL(context, JSP_VIEWID);

try {
vdl.getScriptComponentResource(context, resource);
out.println(JSFTestUtil.FAIL + " " + JSFTestUtil.NL
+ "No Exception thrown when calling '" + vdl.getClass().getName()
+ "." + methName + "()'" + JSFTestUtil.NL
+ "Expected: UnsupportedOperationException to be thrown!");

} catch (UnsupportedOperationException uoe) {
out.println(JSFTestUtil.PASS);
} catch (Exception e) {
out.println(JSFTestUtil.FAIL + " Unexpected Exception thrown for "
+ vdl.getClass().getName() + "." + methName + "("
+ context.getClass().getSimpleName() + ", "
+ resource.getClass().getSimpleName() + ")" + JSFTestUtil.NL
+ "Expected: UnsupportedOperationException" + JSFTestUtil.NL
+ "Received: " + e.getClass().getName());
}

}// End vdlGetScriptComponentResourceUSOETest

public void vdlGetComponentMetadataNPETest(HttpServletRequest request,
HttpServletResponse response) throws IOException {
PrintWriter pw = response.getWriter();
Expand Down
Expand Up @@ -27,18 +27,6 @@
<param-value>true</param-value>
</context-param>

<!-- Use .xhtml for Facelets -->
<context-param>
<param-name>jakarta.faces.FACELETS_VIEW_MAPPINGS</param-name>
<param-value>*.xhtml</param-value>
</context-param>

<!-- Default to JSP! -->
<context-param>
<param-name>jakarta.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsp</param-value>
</context-param>

<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>com.sun.ts.tests.jsf.api.jakarta_faces.view.viewdeclarationlang.TestServlet</servlet-class>
Expand Down

0 comments on commit a241487

Please sign in to comment.