From 5f665e7bd430d82bc1ce2803000b1dfd3d1f6766 Mon Sep 17 00:00:00 2001 From: Manfred Riem Date: Mon, 25 Nov 2024 17:42:18 -0600 Subject: [PATCH] Fixes #4275 - Remove Create a Faces application guide from dist/servlet (#4276) --- .../markdown/create_a_faces_application.md | 336 ------------------ dist/servlet/src/site/markdown/index.md | 1 - dist/servlet/src/site/site.xml | 1 - test/servlet/faces/pom.xml | 141 -------- .../faces/src/main/java/hello/HelloBean.java | 59 --- .../faces/src/main/webapp/WEB-INF/beans.xml | 7 - .../faces/src/main/webapp/WEB-INF/web.xml | 15 - .../faces/src/main/webapp/hellofaces.xhtml | 21 -- .../faces/src/test/java/hello/HelloIT.java | 32 -- test/servlet/pom.xml | 10 +- 10 files changed, 4 insertions(+), 619 deletions(-) delete mode 100644 dist/servlet/src/site/markdown/create_a_faces_application.md delete mode 100644 test/servlet/faces/pom.xml delete mode 100644 test/servlet/faces/src/main/java/hello/HelloBean.java delete mode 100644 test/servlet/faces/src/main/webapp/WEB-INF/beans.xml delete mode 100644 test/servlet/faces/src/main/webapp/WEB-INF/web.xml delete mode 100644 test/servlet/faces/src/main/webapp/hellofaces.xhtml delete mode 100644 test/servlet/faces/src/test/java/hello/HelloIT.java diff --git a/dist/servlet/src/site/markdown/create_a_faces_application.md b/dist/servlet/src/site/markdown/create_a_faces_application.md deleted file mode 100644 index 3f0029767a..0000000000 --- a/dist/servlet/src/site/markdown/create_a_faces_application.md +++ /dev/null @@ -1,336 +0,0 @@ -# Create a Faces application - -If you are looking to use Piranha Servlet with Jakarta Faces then look no -further! - -In 8 steps you will learn how to use Jakarta Faces on Piranha Servlet. They are: - -1. Create the Maven POM file -1. Add the hellofaces.xhtml page -1. Add the HelloBean.java file -1. Add the web.xml file -1. Add the beans.xml file -1. Add an integration test -1. Test the application -1. Deploy the application - -## Create the Maven POM file - -Create an empty directory to store your Maven project. Inside of that directory -create the ```pom.xml``` file with the content as below. - -```xml - - - - 4.0.0 - cloud.piranha.test.servlet - faces - 24.11.0-SNAPSHOT - war - Create a Jakarta Faces application - - - 5.11.0 - 4.1.1 - 6.0.0.Beta4 - - 21 - servlet - 24.9.0 - UTF-8 - - 3.6.0 - 3.13.0 - 3.5.0 - 3.4.0 - - - - org.glassfish - jakarta.faces - ${mojarra.version} - compile - - - org.jboss.weld.servlet - weld-servlet-shaded - ${weld.version} - compile - - - cloud.piranha.extension - piranha-extension-weld - ${piranha.version} - runtime - - - org.junit.jupiter - junit-jupiter-api - ${junit.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit.version} - test - - - org.junit.jupiter - junit-jupiter-params - ${junit.version} - test - - - - faces - - - cloud.piranha.maven - piranha-maven-plugin - ${piranha.version} - - - pre-integration-test - pre-integration-test - - start - - - - post-integration-test - post-integration-test - - stop - - - - - servlet - ${httpPort} - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${java.version} - - - - org.apache.maven.plugins - maven-failsafe-plugin - ${maven-failsafe-plugin.version} - - - - integration-test - verify - - - - - 1 - - ${httpPort} - - - - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - false - - - - org.codehaus.mojo - build-helper-maven-plugin - ${build-helper-maven-plugin.version} - - - reserve-network-port - - reserve-network-port - - package - - - httpPort - - - - - - - - -``` - -## Add the Hello Faces XHTML file - -Add the helloworld.xhtml file in the `src/main/webapp` directory. - -```html - - - - - - - Jakarta Faces application - - - -
Jakarta Faces application
- - -
-
-
- -``` - -## Add the HelloBean.java file - -Add the HelloBean.java file in the `src/main/java/hello` directory. - -```java -package hello; - -import jakarta.enterprise.context.RequestScoped; -import jakarta.inject.Named; - -@Named(value = "helloBean") -@RequestScoped -public class HelloBean { - - private String hello = "Hello from Jakarta Faces!"; - - public String getHello() { - return hello; - } - - public void setHello(String hello) { - this.hello = hello; - } -} -``` - -## Add the web.xml file - -Add the web.xml file in the `src/main/webapp/WEB-INF` directory. - -```xml - - - - - Faces Servlet - jakarta.faces.webapp.FacesServlet - 1 - - - Faces Servlet - *.xhtml - - -``` - -## Add the beans.xml file - -Add the beans.xml file in the `src/main/webapp/WEB-INF` directory. - -```xml - - - - -``` - -## Add an integration test - -As we want to make sure the application gets tested before we release an -integration test is added which will be executed as part of the build. - -We'll add the integration test to the `src/test/java` directory. - -```java -package hello; - -import java.net.URI; -import java.net.http.HttpClient; -import static java.net.http.HttpClient.Redirect.ALWAYS; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.net.http.HttpResponse.BodyHandlers; -import java.time.Duration; -import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.jupiter.api.Test; - -public class HelloIT { - - private String portNumber = System.getProperty("httpPort"); - - @Test - public void testHelloFacesXhtml() throws Exception { - HttpClient client = HttpClient - .newBuilder() - .connectTimeout(Duration.ofSeconds(60)) - .followRedirects(ALWAYS) - .build(); - HttpRequest request = HttpRequest - .newBuilder(new URI("http://localhost:" + portNumber + "/faces/hellofaces.xhtml")) - .build(); - HttpResponse response = client.send(request, BodyHandlers.ofString()); - assertTrue(response.body().contains("Hello from Jakarta Faces!")); - } -} -``` - -## Test the application - -The application is setup to use JUnit to do integration testing using the -Piranha Maven plugin so when you are building the application it will also -execute an integration test validating the web application works. - -To build and test the application execute the following command: - -```bash - mvn install -``` - -## Deploy the application - -To deploy your application you will need 2 pieces. - -1. The Piranha Servlet runtime JAR. -2. The WAR file you just produced. - -For the WAR file see the `target` directory. For the Piranha Servlet -distribution go to Maven Central. And then the following command line will -deploy your application: - -```bash - java -jar piranha-dist-servlet.jar --war-file faces.war -``` - -## Conclusion - -As you can integrating Jakarta Faces with Piranha Servlet can be done quickly! - diff --git a/dist/servlet/src/site/markdown/index.md b/dist/servlet/src/site/markdown/index.md index 0fc59319c2..1b76443142 100644 --- a/dist/servlet/src/site/markdown/index.md +++ b/dist/servlet/src/site/markdown/index.md @@ -15,7 +15,6 @@ The following components are available in the Piranha Servlet distribution: ## Documentation -1. [Create a Faces application](create_a_faces_application.html) 1. [Create a Hello World web application](create_a_hello_world_web_application.html) 1. [Create a Jakarta Pages application](create_a_jakarta_pages_application.html) 1. [Create a WebSocket application](create_a_websocket_application.html) diff --git a/dist/servlet/src/site/site.xml b/dist/servlet/src/site/site.xml index d464d06f68..4e0cfc45ed 100644 --- a/dist/servlet/src/site/site.xml +++ b/dist/servlet/src/site/site.xml @@ -9,7 +9,6 @@ - diff --git a/test/servlet/faces/pom.xml b/test/servlet/faces/pom.xml deleted file mode 100644 index 9042867b68..0000000000 --- a/test/servlet/faces/pom.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - - 4.0.0 - - cloud.piranha.test.servlet - project - 24.12.0-SNAPSHOT - - cloud.piranha.test.servlet - faces - 24.12.0-SNAPSHOT - war - Piranha - Test - Servlet - Jakarta Faces application - - - 21 - servlet - ${project.version} - UTF-8 - - - - org.glassfish - jakarta.faces - compile - - - org.jboss.weld.servlet - weld-servlet-shaded - 6.0.0.Beta4 - compile - - - cloud.piranha.extension - piranha-extension-weld - ${piranha.version} - runtime - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - org.junit.jupiter - junit-jupiter-params - test - - - - faces - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - - integration-test - verify - - - - - 1 - - ${httpPort} - - - - - org.apache.maven.plugins - maven-war-plugin - - false - - - - org.codehaus.mojo - build-helper-maven-plugin - - - reserve-network-port - - reserve-network-port - - package - - - httpPort - - - - - - - - diff --git a/test/servlet/faces/src/main/java/hello/HelloBean.java b/test/servlet/faces/src/main/java/hello/HelloBean.java deleted file mode 100644 index cac1b4408b..0000000000 --- a/test/servlet/faces/src/main/java/hello/HelloBean.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2002-2024 Manorrock.com. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package hello; - -import jakarta.enterprise.context.RequestScoped; -import jakarta.inject.Named; - -@Named(value = "helloBean") -@RequestScoped -public class HelloBean { - - /** - * Stores the hello string. - */ - private String hello = "Hello from Jakarta Faces!"; - - /** - * Get the hello string. - * - * @return the hello string. - */ - public String getHello() { - return hello; - } - - /** - * Set the hello string. - * - * @param hello the hello string. - */ - public void setHello(String hello) { - this.hello = hello; - } -} diff --git a/test/servlet/faces/src/main/webapp/WEB-INF/beans.xml b/test/servlet/faces/src/main/webapp/WEB-INF/beans.xml deleted file mode 100644 index 05298c86da..0000000000 --- a/test/servlet/faces/src/main/webapp/WEB-INF/beans.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/test/servlet/faces/src/main/webapp/WEB-INF/web.xml b/test/servlet/faces/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 8de5ccd77a..0000000000 --- a/test/servlet/faces/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - Faces Servlet - jakarta.faces.webapp.FacesServlet - 1 - - - Faces Servlet - *.xhtml - - diff --git a/test/servlet/faces/src/main/webapp/hellofaces.xhtml b/test/servlet/faces/src/main/webapp/hellofaces.xhtml deleted file mode 100644 index 0dd605ba4a..0000000000 --- a/test/servlet/faces/src/main/webapp/hellofaces.xhtml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - Jakarta Faces application - - - -
Jakarta Faces application
- - -
-
-
- diff --git a/test/servlet/faces/src/test/java/hello/HelloIT.java b/test/servlet/faces/src/test/java/hello/HelloIT.java deleted file mode 100644 index 71aeef69b7..0000000000 --- a/test/servlet/faces/src/test/java/hello/HelloIT.java +++ /dev/null @@ -1,32 +0,0 @@ -package hello; - -import java.net.URI; -import java.net.http.HttpClient; -import static java.net.http.HttpClient.Redirect.ALWAYS; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.net.http.HttpResponse.BodyHandlers; -import java.time.Duration; -import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -public class HelloIT { - - private String portNumber = System.getProperty("httpPort"); - - @Disabled - @Test - public void testHelloFacesXhtml() throws Exception { - HttpClient client = HttpClient - .newBuilder() - .connectTimeout(Duration.ofSeconds(60)) - .followRedirects(ALWAYS) - .build(); - HttpRequest request = HttpRequest - .newBuilder(new URI("http://localhost:" + portNumber + "/faces/hellofaces.xhtml")) - .build(); - HttpResponse response = client.send(request, BodyHandlers.ofString()); - assertTrue(response.body().contains("Hello from Jakarta Faces!")); - } -} diff --git a/test/servlet/pom.xml b/test/servlet/pom.xml index 2a8dd81000..5f3265ed2c 100644 --- a/test/servlet/pom.xml +++ b/test/servlet/pom.xml @@ -1,20 +1,19 @@ - + 4.0.0 - cloud.piranha.test project 24.12.0-SNAPSHOT - cloud.piranha.test.servlet project pom - Piranha - Test - Servlet - Project -