Skip to content

Commit ec9d5f2

Browse files
author
Juraj Huska
committed
Tests for jsf/simple-facelet added
1 parent fcb607a commit ec9d5f2

File tree

4 files changed

+108
-3
lines changed

4 files changed

+108
-3
lines changed

jsf/simple-facelet/pom.xml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<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">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45
<parent>
56
<groupId>org.javaee7.jsf</groupId>
@@ -8,8 +9,15 @@
89
<relativePath>../pom.xml</relativePath>
910
</parent>
1011

11-
<groupId>org.javaee7.jsf</groupId>
1212
<artifactId>simple-facelet</artifactId>
13-
<version>1.0-SNAPSHOT</version>
1413
<packaging>war</packaging>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>org.jboss.arquillian.graphene</groupId>
18+
<artifactId>graphene-webdriver</artifactId>
19+
<type>pom</type>
20+
<scope>test</scope>
21+
</dependency>
22+
</dependencies>
1523
</project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
7+
package org.javaee7.jsf.simple.facelets.test;
8+
9+
import java.util.ArrayList;
10+
import java.util.List;
11+
import org.jboss.arquillian.graphene.page.Location;
12+
import org.openqa.selenium.WebElement;
13+
import org.openqa.selenium.support.FindBy;
14+
15+
/**
16+
*
17+
* @author Juraj Huska
18+
*/
19+
@Location("")
20+
public class SimpleFaceletPage {
21+
22+
@FindBy(tagName = "td")
23+
private List<WebElement> names;
24+
25+
public List<String> getNames() {
26+
List<String> result = new ArrayList<String>();
27+
for(WebElement nameElement : names) {
28+
result.add(nameElement.getText());
29+
}
30+
return result;
31+
}
32+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package org.javaee7.jsf.simple.facelets.test;
2+
3+
import java.io.File;
4+
import java.util.Arrays;
5+
import java.util.List;
6+
import org.javaee7.jsf.simple.facelets.CustomerSessionBean;
7+
import org.javaee7.jsf.simple.facelets.Name;
8+
import org.jboss.arquillian.container.test.api.Deployment;
9+
import org.jboss.arquillian.container.test.api.RunAsClient;
10+
import org.jboss.arquillian.drone.api.annotation.Drone;
11+
import org.jboss.arquillian.graphene.page.InitialPage;
12+
import org.jboss.arquillian.junit.Arquillian;
13+
import org.jboss.shrinkwrap.api.ShrinkWrap;
14+
import org.jboss.shrinkwrap.api.spec.WebArchive;
15+
import org.junit.Assert;
16+
import org.junit.Test;
17+
import org.junit.runner.RunWith;
18+
import org.openqa.selenium.WebDriver;
19+
20+
/**
21+
*
22+
* @author Juraj Huska
23+
*/
24+
@RunWith(Arquillian.class)
25+
@RunAsClient
26+
public class SimpleFaceletTest {
27+
28+
private static final String WEBAPP_SRC = "src/main/webapp/";
29+
30+
private static final List<String> EXPECTED_TABLE_NAMES = Arrays.asList("Penny", "Sheldon",
31+
"Amy", "Leonard", "Bernadette", "Raj", "Priya", "Howard");
32+
33+
@Drone
34+
private WebDriver browser;
35+
36+
@Deployment
37+
public static WebArchive createDeployment() {
38+
return ShrinkWrap.create(WebArchive.class)
39+
.addClass(CustomerSessionBean.class)
40+
.addClass(Name.class)
41+
.addAsWebResource(new File(WEBAPP_SRC, "index.xhtml"))
42+
.addAsWebResource(new File(WEBAPP_SRC + "resources/css/cssLayout.css"), "resources/css/cssLayout.css")
43+
.addAsWebResource(new File(WEBAPP_SRC + "resources/css/default.css"), "resources/css/default.css")
44+
.addAsWebInfResource(new File(WEBAPP_SRC, "/WEB-INF/template.xhtml"))
45+
.addAsWebInfResource(new File(WEBAPP_SRC + "/WEB-INF", "web.xml"));
46+
}
47+
48+
@Test
49+
public void testDataTableRendered(@InitialPage SimpleFaceletPage simpleFaceletPage) {
50+
Assert.assertEquals(
51+
"The simple facelet was not rendered correctly!",
52+
EXPECTED_TABLE_NAMES, simpleFaceletPage.getNames());
53+
}
54+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<arquillian>
2+
3+
<engine>
4+
<property name="deploymentExportPath">target/</property>
5+
</engine>
6+
7+
<extension qualifier="webdriver">
8+
<property name="browser">${browser:firefox}</property>
9+
</extension>
10+
11+
</arquillian>

0 commit comments

Comments
 (0)