-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #56 - Add a Playwright with Jakarta Faces guide
- Loading branch information
Automated workflow
committed
Oct 13, 2023
1 parent
bd3dc58
commit ca707a8
Showing
8 changed files
with
207 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,6 @@ | ||
|
||
# Piranha Web Profile HelloFaces application | ||
|
||
See [Create a Jakarta Faces application](https://piranha.cloud/web-profile/guides/faces) | ||
for the step by step guide. This repository contains the resulting project for | ||
your reference. |
This file contains 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,115 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>cloud.piranha.guides.webprofile</groupId> | ||
<artifactId>playwright</artifactId> | ||
<version>1-SNAPSHOT</version> | ||
<packaging>war</packaging> | ||
<name>Testing with JUnit 5 and Playwright</name> | ||
<properties> | ||
<jakartaee.version>10.0.0</jakartaee.version> | ||
<java.version>21</java.version> | ||
<junit.version>5.10.0</junit.version> | ||
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version> | ||
<maven-failsafe-plugin.version>3.1.2</maven-failsafe-plugin.version> | ||
<maven-war-plugin.version>3.4.0</maven-war-plugin.version> | ||
<piranha.distribution>webprofile</piranha.distribution> | ||
<piranha.version>23.9.0</piranha.version> | ||
<playwright.version>1.38.0</playwright.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>jakarta.platform</groupId> | ||
<artifactId>jakarta.jakartaee-web-api</artifactId> | ||
<version>${jakartaee.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>${junit.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<version>${junit.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<version>${junit.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.microsoft.playwright</groupId> | ||
<artifactId>playwright</artifactId> | ||
<version>${playwright.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<finalName>playwright</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>cloud.piranha.maven.plugins</groupId> | ||
<artifactId>piranha-maven-plugin</artifactId> | ||
<version>${piranha.version}</version> | ||
<executions> | ||
<execution> | ||
<id>pre-integration-test</id> | ||
<phase>pre-integration-test</phase> | ||
<goals> | ||
<goal>start</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>post-integration-test</id> | ||
<phase>post-integration-test</phase> | ||
<goals> | ||
<goal>stop</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<distribution>${piranha.distribution}</distribution> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${maven-compiler-plugin.version}</version> | ||
<configuration> | ||
<release>${java.version}</release> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>${maven-failsafe-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<version>${maven-war-plugin.version}</version> | ||
<configuration> | ||
<failOnMissingWebXml>false</failOnMissingWebXml> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains 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,19 @@ | ||
package hello; | ||
|
||
import jakarta.enterprise.context.RequestScoped; | ||
import jakarta.inject.Named; | ||
|
||
@Named(value = "helloBean") | ||
@RequestScoped | ||
public class HelloBean { | ||
|
||
private String hello = "Hello Playwright!"; | ||
|
||
public String getHello() { | ||
return hello; | ||
} | ||
|
||
public void setHello(String hello) { | ||
this.hello = hello; | ||
} | ||
} |
This file contains 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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd" | ||
bean-discovery-mode="all"> | ||
</beans> |
This file contains 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,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> | ||
<servlet> | ||
<servlet-name>Faces Servlet</servlet-name> | ||
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
<servlet-mapping> | ||
<servlet-name>Faces Servlet</servlet-name> | ||
<url-pattern>*.xhtml</url-pattern> | ||
</servlet-mapping> | ||
</web-app> |
21 changes: 21 additions & 0 deletions
21
webprofile/playwright/src/main/webapp/helloplaywright.xhtml
This file contains 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,21 @@ | ||
<?xml version='1.0' encoding='UTF-8' ?> | ||
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
|
||
<html lang="en" | ||
xmlns="http://www.w3.org/1999/xhtml" | ||
xmlns:f="jakarta.faces.core" | ||
xmlns:h="jakarta.faces.html" | ||
xmlns:pt="jakarta.faces.passthrough"> | ||
<h:head> | ||
<title>Jakarta Faces application</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | ||
</h:head> | ||
<h:body> | ||
<div>Jakarta Faces application</div> | ||
<h:form> | ||
<h:outputText value="#{helloBean.hello}"/> | ||
<br/> | ||
</h:form> | ||
</h:body> | ||
</html> |
This file contains 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,23 @@ | ||
package hello; | ||
|
||
import com.microsoft.playwright.Browser; | ||
import com.microsoft.playwright.BrowserType; | ||
import com.microsoft.playwright.Page; | ||
import com.microsoft.playwright.Playwright; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class HelloIT { | ||
|
||
@Test | ||
public void testHelloPlaywrightXhtml() throws Exception { | ||
try (Playwright playwright = Playwright.create()) { | ||
BrowserType chromium = playwright.chromium(); | ||
try (Browser browser = chromium.launch()) { | ||
Page page = browser.newPage(); | ||
page.navigate("http://localhost:8080/playwright/helloplaywright.xhtml"); | ||
assertTrue(page.content().contains("Hello Playwright!")); | ||
} | ||
} | ||
} | ||
} |
This file contains 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