Skip to content

Commit 2f5992f

Browse files
author
Reza Rahman
committed
JSF test working
1 parent 99387f1 commit 2f5992f

4 files changed

Lines changed: 55 additions & 68 deletions

File tree

actionbazaar/pom.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<dependency>
1919
<groupId>org.jboss.arquillian</groupId>
2020
<artifactId>arquillian-bom</artifactId>
21-
<version>1.1.0.Final</version>
21+
<version>1.1.5.Final</version>
2222
<scope>import</scope>
2323
<type>pom</type>
2424
</dependency>
@@ -29,6 +29,13 @@
2929
<type>pom</type>
3030
<scope>import</scope>
3131
</dependency>
32+
<dependency>
33+
<groupId>org.jboss.arquillian.extension</groupId>
34+
<artifactId>arquillian-drone-bom</artifactId>
35+
<version>1.3.1.Final</version>
36+
<type>pom</type>
37+
<scope>import</scope>
38+
</dependency>
3239
</dependencies>
3340
</dependencyManagement>
3441
<dependencies>
@@ -74,17 +81,10 @@
7481
<version>1.0.0.Alpha2</version>
7582
<scope>test</scope>
7683
</dependency>
77-
<dependency>
78-
<groupId>org.jboss.arquillian.extension</groupId>
79-
<artifactId>arquillian-warp-jsf</artifactId>
80-
<version>1.0.0.Alpha7</version>
81-
<scope>test</scope>
82-
</dependency>
8384
<dependency>
8485
<groupId>org.jboss.arquillian.extension</groupId>
8586
<artifactId>arquillian-drone-webdriver-depchain</artifactId>
8687
<type>pom</type>
87-
<version>2.0.0.Alpha2</version>
8888
<scope>test</scope>
8989
</dependency>
9090
<dependency>
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<?xml version='1.0' encoding='UTF-8' ?>
22
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
33
<html xmlns="http://www.w3.org/1999/xhtml"
4-
xmlns:h="http://java.sun.com/jsf/html">
5-
<h:head>
6-
<title>Action Bazaar</title>
7-
</h:head>
8-
<h:body>
9-
<h:form id="bid">
10-
<h1>Add Bid</h1>
11-
<h:panelGrid columns="2">
12-
<h:outputLabel for="item">Item name:</h:outputLabel>
13-
<h:inputText id="item" value="#{bid.item}" />
14-
<h:outputLabel for="bidder">Bidder name:</h:outputLabel>
15-
<h:inputText id="bidder" value="#{bid.bidder}" />
16-
<h:outputLabel for="amount">Bid amount:</h:outputLabel>
17-
<h:inputText id="amount" value="#{bid.amount}" />
18-
</h:panelGrid>
19-
<h:commandButton id="add" value="Add Bid"
20-
action="#{addBid.addBid}" />
21-
</h:form>
22-
</h:body>
4+
xmlns:h="http://java.sun.com/jsf/html">
5+
<h:head>
6+
<title>Action Bazaar</title>
7+
</h:head>
8+
<h:body>
9+
<h:form id="bidForm">
10+
<h1>Add Bid</h1>
11+
<h:panelGrid columns="2">
12+
<h:outputLabel for="item">Item name:</h:outputLabel>
13+
<h:inputText id="itemTextField" value="#{bid.item}" />
14+
<h:outputLabel for="bidder">Bidder name:</h:outputLabel>
15+
<h:inputText id="bidderTextField" value="#{bid.bidder}" />
16+
<h:outputLabel for="amount">Bid amount:</h:outputLabel>
17+
<h:inputText id="amountTextField" value="#{bid.amount}" />
18+
</h:panelGrid>
19+
<h:commandButton id="addBidButton" value="Add Bid"
20+
action="#{addBid.addBid}" />
21+
</h:form>
22+
</h:body>
2323
</html>
Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
<?xml version='1.0' encoding='UTF-8' ?>
22
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
33
<html xmlns="http://www.w3.org/1999/xhtml"
4-
xmlns:h="http://java.sun.com/jsf/html">
5-
<h:head>
6-
<title>Action Bazaar</title>
7-
</h:head>
8-
<h:body>
9-
<h:form id="bid">
10-
<h1>Bid Added</h1>
11-
<h:panelGrid columns="2">
12-
<h:outputLabel for="item">Item name:</h:outputLabel>
13-
<h:outputText id="item" value="#{bid.item}" />
14-
<h:outputLabel for="bidder">Bidder name:</h:outputLabel>
15-
<h:outputText id="bidder" value="#{bid.bidder}" />
16-
<h:outputLabel for="amount">Bid amount:</h:outputLabel>
17-
<h:outputText id="amount" value="#{bid.amount}" />
18-
</h:panelGrid>
19-
</h:form>
20-
</h:body>
4+
xmlns:h="http://java.sun.com/jsf/html">
5+
<h:head>
6+
<title>Action Bazaar</title>
7+
</h:head>
8+
<h:body>
9+
<h1>Bid Added</h1>
10+
<h:panelGrid columns="2">
11+
<h:outputLabel for="item">Item name:</h:outputLabel>
12+
<h:outputText id="itemField" value="#{bid.item}" />
13+
<h:outputLabel for="bidder">Bidder name:</h:outputLabel>
14+
<h:outputText id="bidderField" value="#{bid.bidder}" />
15+
<h:outputLabel for="amount">Bid amount:</h:outputLabel>
16+
<h:outputText id="amountField" value="#{bid.amount}" />
17+
</h:panelGrid>
18+
</h:body>
2119
</html>

actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AddBidTest.java

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,17 @@
1010
import org.jboss.arquillian.drone.api.annotation.Drone;
1111
import org.jboss.arquillian.junit.Arquillian;
1212
import org.jboss.arquillian.test.api.ArquillianResource;
13-
import org.jboss.arquillian.warp.Activity;
14-
import org.jboss.arquillian.warp.Inspection;
15-
import org.jboss.arquillian.warp.Warp;
16-
import org.jboss.arquillian.warp.WarpTest;
1713
import org.jboss.shrinkwrap.api.Archive;
1814
import org.jboss.shrinkwrap.api.ShrinkWrap;
1915
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
2016
import org.jboss.shrinkwrap.api.spec.WebArchive;
21-
17+
import static org.junit.Assert.assertEquals;
2218
import org.junit.Test;
2319
import org.junit.runner.RunWith;
20+
import org.openqa.selenium.By;
2421
import org.openqa.selenium.WebDriver;
2522

2623
@RunWith(Arquillian.class)
27-
@WarpTest
2824
public class AddBidTest {
2925

3026
@Drone
@@ -36,7 +32,7 @@ public class AddBidTest {
3632
@Deployment(testable = false)
3733
public static Archive<?> createDeployment() {
3834
return ShrinkWrap
39-
.create(WebArchive.class, "test.war")
35+
.create(WebArchive.class, "actionbazaar-test.war")
4036
.addClasses(BidService.class, DefaultBidService.class,
4137
BidRepository.class, DefaultBidRepository.class, Bid.class,
4238
AddBid.class)
@@ -52,21 +48,16 @@ public static Archive<?> createDeployment() {
5248

5349
@Test
5450
public void testAddBid() {
55-
Warp.initiate(new Activity() {
56-
@Override
57-
public void perform() {
58-
browser.navigate().to(contextPath + "add_bid.jsf");
59-
}
60-
}).inspect(new Inspection() {
61-
// @Inject
62-
// CdiBean myBean;
63-
//
64-
// @AfterPhase(RENDER_RESPONSE)
65-
// public void initial_state_havent_changed_yet() {
66-
// assertEquals("John", myBean.getName());
67-
// }
68-
});
51+
browser.navigate().to(contextPath + "add_bid.jsf");
6952

53+
browser.findElement(By.id("bidForm:itemTextField")).sendKeys("Test item");
54+
browser.findElement(By.id("bidForm:bidderTextField")).sendKeys("rrahman");
55+
browser.findElement(By.id("bidForm:amountTextField")).sendKeys("50.25");
56+
browser.findElement(By.id("bidForm:addBidButton")).click();
57+
58+
assertEquals("Test item", browser.findElement(By.id("itemField")).getText());
59+
assertEquals("rrahman", browser.findElement(By.id("bidderField")).getText());
60+
assertEquals("50.25", browser.findElement(By.id("amountField")).getText());
7061
//
7162
// JSFServerSession server = session.getJSFServerSession();
7263
//
@@ -83,8 +74,6 @@ public void perform() {
8374
//
8475
// assertEquals("/confirm_bid.xhtml", server.getCurrentViewID());
8576
//
86-
// assertEquals("Test Item", server.getManagedBeanValue("#{bid.item}"));
87-
// assertEquals("Test Bidder", server.getManagedBeanValue("#{bid.bidder}"));
88-
// assertEquals(101.50, server.getManagedBeanValue("#{bid.amount}"));
77+
8978
}
9079
}

0 commit comments

Comments
 (0)