Skip to content

Commit cc234aa

Browse files
committed
Merge pull request #211 from jhuska/addingGraphene
adding graphene tests for jsf/simple-facelet
2 parents 9f2a67f + 159c547 commit cc234aa

File tree

7 files changed

+206
-7
lines changed

7 files changed

+206
-7
lines changed

README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,64 @@ Some samples/tests have documentataion otherwise read the code. The [Java EE 7 E
88

99
Samples are tested on Wildfly and GlassFish using the Arquillian ecosystem.
1010

11-
Only one profile can be active at a given time otherwise there will be dependency conflicts.
11+
Only one container profile and one profile for browser can be active at a given time otherwise there will be dependency conflicts.
1212

13-
There are 4 available profiles:
13+
There are 4 available container profiles:
1414

1515
* ``wildfly-managed-arquillian``
16+
1617
The default profile and it will install a Wildfly server and start up the server per sample.
1718
Useful for CI servers.
1819

1920
* ``wildfly-remote-arquillian``
21+
2022
This profile requires you to start up a Wildfly server outside of the build. Each sample will then
2123
reuse this instance to run the tests.
2224
Useful for development to avoid the server start up cost per sample.
2325

2426
* ``glassfish-embedded-arquillian``
27+
2528
This profile uses the GlassFish embedded server and runs in the same JVM as the TestClass.
2629
Useful for development, but has the downside of server startup per sample.
2730

2831
* ``glassfish-remote-arquillian``
32+
2933
This profile requires you to start up a GlassFish server outside of the build. Each sample will then
3034
reuse this instance to run the tests.
3135
Useful for development to avoid the server start up cost per sample.
3236

37+
Similarly, there are 6 profiles to choose a browser to test on:
38+
39+
* ``browser-firefox``
40+
41+
To run tests on Mozilla Firefox. If its binary is installed in the usual place, no additional information is required.
42+
43+
* ``browser-chrome``
44+
45+
To run tests on Google Chrome. Need to pass a ``-Darq.extension.webdriver.chromeDriverBinary`` property
46+
pointing to a ``chromedriver`` binary.
47+
48+
* ``browser-ie``
49+
50+
To run tests on Internet Explorer. Need to pass a ``-Darq.extension.webdriver.ieDriverBinary`` property
51+
pointing to a ``IEDriverServer.exe``.
52+
53+
* ``browser-safari``
54+
55+
To run tests on Safari. If its binary is installed in the usual place, no additional information is required.
56+
57+
* ``browser-opera``
58+
59+
To run tests on Opera. Need to pass a ``-Darq.extension.webdriver.opera.binary`` property pointing to a Opera executable.
60+
61+
* ``browser-phantomjs``
62+
63+
To run tests on headless browser PhantomJS. If you do not specify the path of phantomjs binary via
64+
``-Dphantomjs.binary.path`` property, it will be downloaded automatically.
65+
3366
To run them in the console do:
3467

35-
1. In the terminal, ``mvn -Pwildfly-managed-arquillian test`` at the top-level directory to start the tests
68+
1. In the terminal, ``mvn -Pwildfly-managed-arquillian,browser-firefox test`` at the top-level directory to start the tests
3669

3770
When developing and runing them from IDE, remember to activate the profile before running the test.
3871

jsf/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,14 @@
3636
<module>server-extension</module>
3737
<module>viewscoped</module>
3838
</modules>
39+
40+
<dependencies>
41+
<dependency>
42+
<groupId>org.jboss.arquillian.graphene</groupId>
43+
<artifactId>graphene-webdriver</artifactId>
44+
<type>pom</type>
45+
<scope>test</scope>
46+
</dependency>
47+
</dependencies>
3948

4049
</project>

jsf/simple-facelet/pom.xml

Lines changed: 3 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,7 @@
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+
1515
</project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.javaee7.jsf.simple.facelets.test;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import org.jboss.arquillian.graphene.page.Location;
6+
import org.openqa.selenium.WebElement;
7+
import org.openqa.selenium.support.FindBy;
8+
9+
/**
10+
*
11+
* @author Juraj Huska
12+
*/
13+
@Location("")
14+
public class SimpleFaceletPage {
15+
16+
@FindBy(tagName = "td")
17+
private List<WebElement> names;
18+
19+
public List<String> getNames() {
20+
List<String> result = new ArrayList<String>();
21+
for(WebElement nameElement : names) {
22+
result.add(nameElement.getText());
23+
}
24+
return result;
25+
}
26+
}
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}</property>
9+
</extension>
10+
11+
</arquillian>

pom.xml

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<maven.min.version>3.0.0</maven.min.version>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
<org.jboss.arquillian.version>1.1.1.Final</org.jboss.arquillian.version>
16+
<org.jboss.arquillian.drone.version>1.3.0.Final</org.jboss.arquillian.drone.version>
17+
<org.jboss.arquillian.selenium.bom.version>2.40.0</org.jboss.arquillian.selenium.bom.version>
18+
<org.jboss.arquillian.graphene.version>2.0.2.Final</org.jboss.arquillian.graphene.version>
1619
<org.jboss.arquillian.spock>1.0.0.Beta2</org.jboss.arquillian.spock>
1720
<org.wildfly>8.0.0.Final</org.wildfly>
1821
<org.jboss.eap>7.2.0.Final</org.jboss.eap>
@@ -32,6 +35,27 @@
3235
<scope>import</scope>
3336
<type>pom</type>
3437
</dependency>
38+
<dependency>
39+
<groupId>org.jboss.arquillian.extension</groupId>
40+
<artifactId>arquillian-drone-bom</artifactId>
41+
<version>${org.jboss.arquillian.drone.version}</version>
42+
<type>pom</type>
43+
<scope>import</scope>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.jboss.arquillian.selenium</groupId>
47+
<artifactId>selenium-bom</artifactId>
48+
<version>${org.jboss.arquillian.selenium.bom.version}</version>
49+
<type>pom</type>
50+
<scope>import</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.jboss.arquillian.graphene</groupId>
54+
<artifactId>graphene-webdriver</artifactId>
55+
<version>${org.jboss.arquillian.graphene.version}</version>
56+
<type>pom</type>
57+
<scope>test</scope>
58+
</dependency>
3559
<dependency>
3660
<groupId>org.javaee7</groupId>
3761
<artifactId>util-samples</artifactId>
@@ -152,7 +176,7 @@
152176
<version>1.3.5</version>
153177
<scope>test</scope>
154178
</dependency>
155-
<!-- <dependency>
179+
<!-- <dependency>
156180
<groupId>org.apache.httpcomponents</groupId>
157181
<artifactId>httpclient</artifactId>
158182
<version>4.2.1</version>
@@ -189,6 +213,12 @@
189213

190214
<build>
191215
<finalName>${project.artifactId}</finalName>
216+
<testResources>
217+
<testResource>
218+
<directory>src/test/resources</directory>
219+
<filtering>true</filtering>
220+
</testResource>
221+
</testResources>
192222
<plugins>
193223
<plugin>
194224
<groupId>org.apache.maven.plugins</groupId>
@@ -643,6 +673,42 @@
643673
</dependency>
644674
</dependencies>
645675
</profile>
676+
<profile>
677+
<id>browser-firefox</id>
678+
<properties>
679+
<browser>firefox</browser>
680+
</properties>
681+
</profile>
682+
<profile>
683+
<id>browser-chrome</id>
684+
<properties>
685+
<browser>chrome</browser>
686+
</properties>
687+
</profile>
688+
<profile>
689+
<id>browser-ie</id>
690+
<properties>
691+
<browser>internetExplorer</browser>
692+
</properties>
693+
</profile>
694+
<profile>
695+
<id>browser-safari</id>
696+
<properties>
697+
<browser>safari</browser>
698+
</properties>
699+
</profile>
700+
<profile>
701+
<id>browser-opera</id>
702+
<properties>
703+
<browser>opera</browser>
704+
</properties>
705+
</profile>
706+
<profile>
707+
<id>browser-phantomjs</id>
708+
<properties>
709+
<browser>phantomjs</browser>
710+
</properties>
711+
</profile>
646712
<profile>
647713
<id>javadocs</id>
648714
<activation>

0 commit comments

Comments
 (0)