Skip to content
This repository was archived by the owner on Apr 7, 2025. It is now read-only.

Commit ca707a8

Browse files
author
Automated workflow
committed
Fixes #56 - Add a Playwright with Jakarta Faces guide
1 parent bd3dc58 commit ca707a8

File tree

8 files changed

+207
-0
lines changed

8 files changed

+207
-0
lines changed

webprofile/playwright/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
# Piranha Web Profile HelloFaces application
3+
4+
See [Create a Jakarta Faces application](https://piranha.cloud/web-profile/guides/faces)
5+
for the step by step guide. This repository contains the resulting project for
6+
your reference.

webprofile/playwright/pom.xml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project
4+
xmlns="http://maven.apache.org/POM/4.0.0"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
7+
<modelVersion>4.0.0</modelVersion>
8+
<groupId>cloud.piranha.guides.webprofile</groupId>
9+
<artifactId>playwright</artifactId>
10+
<version>1-SNAPSHOT</version>
11+
<packaging>war</packaging>
12+
<name>Testing with JUnit 5 and Playwright</name>
13+
<properties>
14+
<jakartaee.version>10.0.0</jakartaee.version>
15+
<java.version>21</java.version>
16+
<junit.version>5.10.0</junit.version>
17+
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
18+
<maven-failsafe-plugin.version>3.1.2</maven-failsafe-plugin.version>
19+
<maven-war-plugin.version>3.4.0</maven-war-plugin.version>
20+
<piranha.distribution>webprofile</piranha.distribution>
21+
<piranha.version>23.9.0</piranha.version>
22+
<playwright.version>1.38.0</playwright.version>
23+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
24+
</properties>
25+
<dependencies>
26+
<dependency>
27+
<groupId>jakarta.platform</groupId>
28+
<artifactId>jakarta.jakartaee-web-api</artifactId>
29+
<version>${jakartaee.version}</version>
30+
<scope>provided</scope>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.junit.jupiter</groupId>
34+
<artifactId>junit-jupiter-api</artifactId>
35+
<version>${junit.version}</version>
36+
<scope>test</scope>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.junit.jupiter</groupId>
40+
<artifactId>junit-jupiter-engine</artifactId>
41+
<version>${junit.version}</version>
42+
<scope>test</scope>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.junit.jupiter</groupId>
46+
<artifactId>junit-jupiter-params</artifactId>
47+
<version>${junit.version}</version>
48+
<scope>test</scope>
49+
</dependency>
50+
<dependency>
51+
<groupId>com.microsoft.playwright</groupId>
52+
<artifactId>playwright</artifactId>
53+
<version>${playwright.version}</version>
54+
<scope>test</scope>
55+
</dependency>
56+
</dependencies>
57+
<build>
58+
<finalName>playwright</finalName>
59+
<plugins>
60+
<plugin>
61+
<groupId>cloud.piranha.maven.plugins</groupId>
62+
<artifactId>piranha-maven-plugin</artifactId>
63+
<version>${piranha.version}</version>
64+
<executions>
65+
<execution>
66+
<id>pre-integration-test</id>
67+
<phase>pre-integration-test</phase>
68+
<goals>
69+
<goal>start</goal>
70+
</goals>
71+
</execution>
72+
<execution>
73+
<id>post-integration-test</id>
74+
<phase>post-integration-test</phase>
75+
<goals>
76+
<goal>stop</goal>
77+
</goals>
78+
</execution>
79+
</executions>
80+
<configuration>
81+
<distribution>${piranha.distribution}</distribution>
82+
</configuration>
83+
</plugin>
84+
<plugin>
85+
<groupId>org.apache.maven.plugins</groupId>
86+
<artifactId>maven-compiler-plugin</artifactId>
87+
<version>${maven-compiler-plugin.version}</version>
88+
<configuration>
89+
<release>${java.version}</release>
90+
</configuration>
91+
</plugin>
92+
<plugin>
93+
<groupId>org.apache.maven.plugins</groupId>
94+
<artifactId>maven-failsafe-plugin</artifactId>
95+
<version>${maven-failsafe-plugin.version}</version>
96+
<executions>
97+
<execution>
98+
<goals>
99+
<goal>integration-test</goal>
100+
<goal>verify</goal>
101+
</goals>
102+
</execution>
103+
</executions>
104+
</plugin>
105+
<plugin>
106+
<groupId>org.apache.maven.plugins</groupId>
107+
<artifactId>maven-war-plugin</artifactId>
108+
<version>${maven-war-plugin.version}</version>
109+
<configuration>
110+
<failOnMissingWebXml>false</failOnMissingWebXml>
111+
</configuration>
112+
</plugin>
113+
</plugins>
114+
</build>
115+
</project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package hello;
2+
3+
import jakarta.enterprise.context.RequestScoped;
4+
import jakarta.inject.Named;
5+
6+
@Named(value = "helloBean")
7+
@RequestScoped
8+
public class HelloBean {
9+
10+
private String hello = "Hello Playwright!";
11+
12+
public String getHello() {
13+
return hello;
14+
}
15+
16+
public void setHello(String hello) {
17+
this.hello = hello;
18+
}
19+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
6+
bean-discovery-mode="all">
7+
</beans>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
6+
<servlet>
7+
<servlet-name>Faces Servlet</servlet-name>
8+
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
9+
<load-on-startup>1</load-on-startup>
10+
</servlet>
11+
<servlet-mapping>
12+
<servlet-name>Faces Servlet</servlet-name>
13+
<url-pattern>*.xhtml</url-pattern>
14+
</servlet-mapping>
15+
</web-app>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version='1.0' encoding='UTF-8' ?>
2+
3+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4+
5+
<html lang="en"
6+
xmlns="http://www.w3.org/1999/xhtml"
7+
xmlns:f="jakarta.faces.core"
8+
xmlns:h="jakarta.faces.html"
9+
xmlns:pt="jakarta.faces.passthrough">
10+
<h:head>
11+
<title>Jakarta Faces application</title>
12+
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
13+
</h:head>
14+
<h:body>
15+
<div>Jakarta Faces application</div>
16+
<h:form>
17+
<h:outputText value="#{helloBean.hello}"/>
18+
<br/>
19+
</h:form>
20+
</h:body>
21+
</html>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package hello;
2+
3+
import com.microsoft.playwright.Browser;
4+
import com.microsoft.playwright.BrowserType;
5+
import com.microsoft.playwright.Page;
6+
import com.microsoft.playwright.Playwright;
7+
import static org.junit.jupiter.api.Assertions.assertTrue;
8+
import org.junit.jupiter.api.Test;
9+
10+
public class HelloIT {
11+
12+
@Test
13+
public void testHelloPlaywrightXhtml() throws Exception {
14+
try (Playwright playwright = Playwright.create()) {
15+
BrowserType chromium = playwright.chromium();
16+
try (Browser browser = chromium.launch()) {
17+
Page page = browser.newPage();
18+
page.navigate("http://localhost:8080/playwright/helloplaywright.xhtml");
19+
assertTrue(page.content().contains("Hello Playwright!"));
20+
}
21+
}
22+
}
23+
}

webprofile/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<modules>
1111
<module>faces</module>
1212
<module>helloworld</module>
13+
<module>playwright</module>
1314
<module>rest</module>
1415
</modules>
1516
</project>

0 commit comments

Comments
 (0)