Skip to content

Commit 10da618

Browse files
committed
Merge branch 'master' of github.com:javaee-samples/javaee7-samples
2 parents f6e9368 + 5a1918b commit 10da618

File tree

8 files changed

+208
-31
lines changed

8 files changed

+208
-31
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

ejb/stateless/src/test/java/org/javaee7/ejb/stateless/AccountSessionStatelessnessTest.java

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.jboss.arquillian.container.test.api.Deployment;
44
import org.jboss.arquillian.junit.Arquillian;
5-
import org.jboss.arquillian.junit.InSequence;
65
import org.jboss.shrinkwrap.api.Archive;
76
import org.jboss.shrinkwrap.api.ShrinkWrap;
87
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
@@ -12,18 +11,15 @@
1211

1312
import javax.ejb.EJB;
1413

15-
import static org.hamcrest.MatcherAssert.assertThat;
16-
import static org.hamcrest.Matchers.equalTo;
17-
import static org.hamcrest.Matchers.is;
14+
import static org.hamcrest.MatcherAssert.*;
15+
import static org.hamcrest.Matchers.*;
1816

1917
/**
2018
* @author Jakub Marchwicki
2119
*/
2220
@RunWith(Arquillian.class)
2321
public class AccountSessionStatelessnessTest {
2422

25-
final private float deposit_amount = 10f;
26-
2723
@EJB
2824
AccountSessionBean account1;
2925

@@ -47,25 +43,7 @@ public static Archive<?> deployment() {
4743
* stateless session bean have the same object identity.
4844
*/
4945
@Test
50-
@InSequence(1)
5146
public void should_be_identical_beans() {
5247
assertThat("Expect same instances", account1, is(account2));
5348
}
54-
55-
@Test
56-
@InSequence(2)
57-
public void should_deposit_amount_on_first_account() {
58-
assertThat(account1.getAmount(), equalTo(0f));
59-
60-
String actual = account1.deposit(deposit_amount);
61-
62-
assertThat(actual, is(equalTo("Deposited: " + deposit_amount)));
63-
assertThat(account1.getAmount(), equalTo(0f));
64-
}
65-
66-
@Test
67-
@InSequence(3)
68-
public void should_contain_already_deposited_amount_on_second_account() {
69-
assertThat(account2.getAmount(), equalTo(account1.getAmount()));
70-
}
7149
}

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)