Author: mgencur(a)redhat.com
Date: 2009-09-23 02:53:25 -0400 (Wed, 23 Sep 2009)
New Revision: 11508
Modified:
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/examples/dvdstore/build.xml
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/examples/dvdstore/jboss.xml
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/examples/dvdstore/src/org/jboss/seam/example/dvd/test/selenium/ShoppingCartTest.java
Log:
JBPAPP-2829 Backported new version of functional test files
Modified: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/examples/dvdstore/build.xml
===================================================================
---
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/examples/dvdstore/build.xml 2009-09-22
13:53:09 UTC (rev 11507)
+++
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/examples/dvdstore/build.xml 2009-09-23
06:53:25 UTC (rev 11508)
@@ -22,7 +22,7 @@
-->
<project name="dvdstore.ftest.build" basedir="."
default="build">
<property name="example.name" value="dvdstore" />
- <property name="jboss.example.ready.check.url"
value="seam-dvd/search.seam" />
+ <property name="jboss.example.ready.check.url" value="seam-dvd"
/>
<import file="../build.xml" />
Modified: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/examples/dvdstore/jboss.xml
===================================================================
---
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/examples/dvdstore/jboss.xml 2009-09-22
13:53:09 UTC (rev 11507)
+++
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/examples/dvdstore/jboss.xml 2009-09-23
06:53:25 UTC (rev 11508)
@@ -28,11 +28,11 @@
<classes>
<class
name="org.jboss.seam.example.dvd.test.selenium.LoginTest" />
-<!-- <class
name="org.jboss.seam.example.dvd.test.selenium.RegistrationTest" />-->
+ <class
name="org.jboss.seam.example.dvd.test.selenium.RegistrationTest" />
<class
name="org.jboss.seam.example.dvd.test.selenium.SearchTest" />
<class
name="org.jboss.seam.example.dvd.test.selenium.ShoppingCartTest"
/>
</classes>
</test>
-</suite>
\ No newline at end of file
+</suite>
Modified:
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/examples/dvdstore/src/org/jboss/seam/example/dvd/test/selenium/ShoppingCartTest.java
===================================================================
---
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/examples/dvdstore/src/org/jboss/seam/example/dvd/test/selenium/ShoppingCartTest.java 2009-09-22
13:53:09 UTC (rev 11507)
+++
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/examples/dvdstore/src/org/jboss/seam/example/dvd/test/selenium/ShoppingCartTest.java 2009-09-23
06:53:25 UTC (rev 11508)
@@ -27,9 +27,6 @@
import java.text.MessageFormat;
import java.text.NumberFormat;
import java.text.ParseException;
-import java.util.Currency;
-import java.util.Locale;
-
import org.testng.annotations.Test;
/**
@@ -40,6 +37,8 @@
*
*/
public class ShoppingCartTest extends SeleniumDvdTest {
+
+ private NumberFormat nf = NumberFormat.getNumberInstance();
@Test(dependsOnGroups = { "search" })
public void simpleCartTest() {
@@ -60,8 +59,6 @@
@Test(dependsOnMethods = { "simpleCartTest" })
public void testCartCostCalculation() throws ParseException {
String[] dvds = new String[] { "Top Gun", "Pulp Fiction",
"Top Gun" };
- NumberFormat nf = NumberFormat.getCurrencyInstance();
- nf.setCurrency(Currency.getInstance(Locale.US));
BigDecimal expectedSum = BigDecimal.ZERO;
for (String dvd : dvds) {
addDVDToCart(dvd);
@@ -72,18 +69,14 @@
.intValue();
assertNotSame("Cart should not be empty.", 0, items);
for (int i = 0; i < items; i++) {
- BigDecimal quantity = BigDecimal.valueOf(Double.parseDouble(browser
- .getValue(MessageFormat.format(
- getProperty("CART_TABLE_QUANTITY_BY_ID"), i))));
- BigDecimal price = BigDecimal.valueOf(nf.parse(
- browser.getText(MessageFormat.format(
- getProperty("CART_TABLE_PRICE_BY_ID"), i)))
- .doubleValue());
+ BigDecimal quantity = parseBalance(browser.getValue(MessageFormat.format(
+ getProperty("CART_TABLE_QUANTITY_BY_ID"), i)));
+ BigDecimal price = parseBalance(browser.getText(MessageFormat.format(
+ getProperty("CART_TABLE_PRICE_BY_ID"), i)));
BigDecimal priceForCurrentRow = price.multiply(quantity);
expectedSum = expectedSum.add(priceForCurrentRow);
}
- BigDecimal actualSum = BigDecimal.valueOf((nf.parse(browser
- .getText(getProperty("CART_SUBTOTAL"))).doubleValue()));
+ BigDecimal actualSum =
parseBalance(browser.getText(getProperty("CART_SUBTOTAL")));
assertEquals("Price sum in cart is incorrect.", 0, expectedSum
.compareTo(actualSum));
}
@@ -144,4 +137,9 @@
browser.click(getProperty("SEARCH_RESULT_UPDATE_BUTTON"));
browser.waitForPageToLoad(TIMEOUT);
}
+
+ private BigDecimal parseBalance(String text) throws ParseException {
+ String number = text.replaceAll("\\$", "").trim();
+ return BigDecimal.valueOf(nf.parse(number).doubleValue());
+ }
}
Show replies by date