[seam-commits] Seam SVN: r9551 - in trunk: examples/seampay/view and 23 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Nov 11 04:41:43 EST 2008


Author: jharting
Date: 2008-11-11 04:41:43 -0500 (Tue, 11 Nov 2008)
New Revision: 9551

Added:
   trunk/src/test/ftest/examples/quartz/
   trunk/src/test/ftest/examples/quartz/build.xml
   trunk/src/test/ftest/examples/quartz/src/
   trunk/src/test/ftest/examples/quartz/src/org/
   trunk/src/test/ftest/examples/quartz/src/org/jboss/
   trunk/src/test/ftest/examples/quartz/src/org/jboss/seam/
   trunk/src/test/ftest/examples/quartz/src/org/jboss/seam/example/
   trunk/src/test/ftest/examples/quartz/src/org/jboss/seam/example/quartz/
   trunk/src/test/ftest/examples/quartz/src/org/jboss/seam/example/quartz/test/
   trunk/src/test/ftest/examples/quartz/src/org/jboss/seam/example/quartz/test/selenium/
   trunk/src/test/ftest/examples/quartz/src/org/jboss/seam/example/quartz/test/selenium/QuartzPaymentTest.java
   trunk/src/test/ftest/examples/quartz/src/org/jboss/seam/example/quartz/test/selenium/quartz.properties
   trunk/src/test/ftest/examples/quartz/testng.xml
   trunk/src/test/ftest/examples/seampay/
   trunk/src/test/ftest/examples/seampay/build.xml
   trunk/src/test/ftest/examples/seampay/src/
   trunk/src/test/ftest/examples/seampay/src/org/
   trunk/src/test/ftest/examples/seampay/src/org/jboss/
   trunk/src/test/ftest/examples/seampay/src/org/jboss/seam/
   trunk/src/test/ftest/examples/seampay/src/org/jboss/seam/example/
   trunk/src/test/ftest/examples/seampay/src/org/jboss/seam/example/seampay/
   trunk/src/test/ftest/examples/seampay/src/org/jboss/seam/example/seampay/test/
   trunk/src/test/ftest/examples/seampay/src/org/jboss/seam/example/seampay/test/selenium/
   trunk/src/test/ftest/examples/seampay/src/org/jboss/seam/example/seampay/test/selenium/seampay.properties
   trunk/src/test/ftest/examples/seampay/testng.xml
   trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/seampay/
   trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/seampay/selenium/
   trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/seampay/selenium/PaymentTest.java
Modified:
   trunk/examples/quartz/view/search.xhtml
   trunk/examples/seampay/view/search.xhtml
   trunk/src/test/ftest/build.xml
Log:
JBSEAM-3690 added tests for seampay and quartz

Modified: trunk/examples/quartz/view/search.xhtml
===================================================================
--- trunk/examples/quartz/view/search.xhtml	2008-11-11 09:41:19 UTC (rev 9550)
+++ trunk/examples/quartz/view/search.xhtml	2008-11-11 09:41:43 UTC (rev 9551)
@@ -30,16 +30,16 @@
                 <th>Account Number</th>
                 <th>Balance</th>
             </tr>
-            <ui:repeat value="#{accounts.resultList}" var="account">
+            <ui:repeat id="accountTable" value="#{accounts.resultList}" var="account">
                 <tr>
                     <td>
-                        <s:link view="/search.xhtml" value="#{account.id}">
+                        <s:link id="link" view="/search.xhtml" value="#{account.id}">
                             <f:param name="accountId" value="#{account.id}"/>
                         </s:link>
                     </td>
                     <td>#{account.accountNumber}</td>
                     <td>
-                        <h:outputText value="#{account.balance}">
+                        <h:outputText id="balance" value="#{account.balance}">
                             <f:convertNumber type="currency" currencySymbol="$"/> 
                         </h:outputText>
                     </td>
@@ -51,54 +51,58 @@
 
         <f:subview id="accountView" rendered="#{accountHome.idDefined}">
             <h2>Payments from Account #{accountHome.instance.accountNumber}</h2>
-            <table class="results">
-                <tr>
-                    <th>Status</th>
-                    <th>Payee</th>
-                    <th>Payment Amount</th>
-                    <th>Created Date</th>
-                    <th>Scheduled Date</th>
-                    <th>Cron</th>
-                    <th>Frequency</th>
-                    <th>Last Paid On</th>
-                </tr>
-                <ui:repeat value="#{accountHome.instance.payments}" var="payment">
-                    <tr>
-                        <td>
-                            <s:button action="#{paymentHome.cancel}" value="Cancel" rendered="#{payment.active}">
-                                <f:param name="paymentId" value="#{payment.id}"/>
-                            </s:button>
-                            <h:outputText value="not active" rendered="#{!payment.active}" />
-                        </td>                            
-                        <td>#{payment.payee}</td>
-                        <td>
-                            <h:outputText value="#{payment.amount}">
-                                <f:convertNumber type="currency" currencySymbol="$"/> 
-                            </h:outputText>
-                        </td>
-                        <td>
-                            <h:outputText value="#{payment.createdDate}">
-                                <f:convertDateTime type="date" dateStyle="medium" />
-                            </h:outputText>
-                        </td>
-                        <td>
-                            <h:outputText value="#{payment.paymentDate}">
-                                <f:convertDateTime type="date" dateStyle="medium" />
-                            </h:outputText>
-                        </td>
-                        <td>#{payment.paymentCron}</td>
-                        <td>#{payment.paymentFrequency}</td>
-                        <td>
-                            <h:outputText value="#{payment.lastPaid}">
-                                <f:convertDateTime type="date" dateStyle="medium" />
-                            </h:outputText>
-                        </td>
-                    </tr>
-                </ui:repeat>
+            <table id="payments" class="results">
+            	<thead>
+	            	<tr>
+	                    <th>Status</th>
+	                    <th>Payee</th>
+	                    <th>Payment Amount</th>
+	                    <th>Created Date</th>
+	                    <th>Scheduled Date</th>
+	                    <th>Cron</th>
+	                    <th>Frequency</th>
+	                    <th>Last Paid On</th>
+	                </tr>
+	           	</thead>
+	           	<tbody>
+	                <ui:repeat value="#{accountHome.instance.payments}" var="payment">
+	                    <tr>
+	                        <td>
+	                            <s:button action="#{paymentHome.cancel}" value="Cancel" rendered="#{payment.active}">
+	                                <f:param name="paymentId" value="#{payment.id}"/>
+	                            </s:button>
+	                            <h:outputText value="not active" rendered="#{!payment.active}" />
+	                        </td>                            
+	                        <td>#{payment.payee}</td>
+	                        <td>
+	                            <h:outputText value="#{payment.amount}">
+	                                <f:convertNumber type="currency" currencySymbol="$"/> 
+	                            </h:outputText>
+	                        </td>
+	                        <td>
+	                            <h:outputText value="#{payment.createdDate}">
+	                                <f:convertDateTime type="date" dateStyle="medium" />
+	                            </h:outputText>
+	                        </td>
+	                        <td>
+	                            <h:outputText value="#{payment.paymentDate}">
+	                                <f:convertDateTime type="date" dateStyle="medium" />
+	                            </h:outputText>
+	                        </td>
+	                        <td>#{payment.paymentCron}</td>
+	                        <td>#{payment.paymentFrequency}</td>
+	                        <td>
+	                            <h:outputText value="#{payment.lastPaid}">
+	                                <f:convertDateTime type="date" dateStyle="medium" />
+	                            </h:outputText>
+	                        </td>
+	                    </tr>
+	                </ui:repeat>
+	        	</tbody>
             </table>
 
             <h2>Make a payment from account #{accountHome.instance.accountNumber}:</h2>
-            <h:form>
+            <h:form id="paymentForm">
                 <s:validateAll>
                     <table>
                         <tr>
@@ -142,7 +146,7 @@
                 <p><b>Now, choose one of the following repeat payment schemes</b></p>
                 <p>Cron: 
                 <h:inputText id="paymentCron" value="#{newPayment.paymentCron}"/><br/> 
-                <h:commandButton value="Schedule Cron Job" 
+                <h:commandButton id="cronSubmit" value="Schedule Cron Job" 
                                  action="#{paymentHome.saveAndScheduleCron}" />
                 </p>
 
@@ -160,7 +164,7 @@
                     <f:selectItems value="#{newPayment.frequencies}" />
                   </ui:remove>
                 </h:selectOneRadio><br/>
-                <h:commandButton value="Schedule at Fixed Interval" 
+                <h:commandButton id="submit" value="Schedule at Fixed Interval" 
                                  action="#{paymentHome.saveAndSchedule}" />
                 </p>
                 

Modified: trunk/examples/seampay/view/search.xhtml
===================================================================
--- trunk/examples/seampay/view/search.xhtml	2008-11-11 09:41:19 UTC (rev 9550)
+++ trunk/examples/seampay/view/search.xhtml	2008-11-11 09:41:43 UTC (rev 9551)
@@ -31,16 +31,16 @@
                 <th>Account Number</th>
                 <th>Balance</th>
             </tr>
-            <ui:repeat value="#{accounts.resultList}" var="account">
+            <ui:repeat id="accountTable" value="#{accounts.resultList}" var="account">
                 <tr>
                     <td>
-                        <s:link view="/search.xhtml" value="#{account.id}">
+                        <s:link id="link" view="/search.xhtml" value="#{account.id}">
                             <f:param name="accountId" value="#{account.id}"/>
                         </s:link>
                     </td>
                     <td>#{account.accountNumber}</td>
                     <td>
-                        <h:outputText value="#{account.balance}">
+                        <h:outputText id="balance" value="#{account.balance}">
                             <f:convertNumber type="currency" currencySymbol="$"/> 
                         </h:outputText>
                     </td>
@@ -52,52 +52,56 @@
 
         <f:subview id="accountView" rendered="#{accountHome.idDefined}">
             <h2>Payments from Account #{accountHome.instance.accountNumber}</h2>
-            <table class="results">
-                <tr>
-                    <th>Status</th>
-                    <th>Payee</th>
-                    <th>Payment Amount</th>
-                    <th>Created Date</th>
-                    <th>Scheduled Date</th>
-                    <th>Frequency</th>
-                    <th>Last Paid On</th>
-                </tr>
-                <ui:repeat value="#{accountHome.instance.payments}" var="payment">
-                    <tr>
-                        <td>
-                            <s:button action="#{paymentHome.cancel}" value="Cancel" rendered="#{payment.active}">
-                                <f:param name="paymentId" value="#{payment.id}"/>
-                            </s:button>
-                            <h:outputText value="not active" rendered="#{!payment.active}" />
-                        </td>                            
-                        <td>#{payment.payee}</td>
-                        <td>
-                            <h:outputText value="#{payment.amount}">
-                                <f:convertNumber type="currency" currencySymbol="$"/> 
-                            </h:outputText>
-                        </td>
-                        <td>
-                            <h:outputText value="#{payment.createdDate}">
-                                <f:convertDateTime type="date" dateStyle="medium" />
-                            </h:outputText>
-                        </td>
-                        <td>
-                            <h:outputText value="#{payment.paymentDate}">
-                                <f:convertDateTime type="date" dateStyle="medium" />
-                            </h:outputText>
-                        </td>
-                        <td>#{payment.paymentFrequency}</td>
-                        <td>
-                            <h:outputText value="#{payment.lastPaid}">
-                                <f:convertDateTime type="date" dateStyle="medium" />
-                            </h:outputText>
-                        </td>
-                    </tr>
-                </ui:repeat>
+            <table id="payments" class="results">
+                <thead>
+                	<tr>
+	                    <th>Status</th>
+	                    <th>Payee</th>
+	                    <th>Payment Amount</th>
+	                    <th>Created Date</th>
+	                    <th>Scheduled Date</th>
+	                    <th>Frequency</th>
+	                    <th>Last Paid On</th>
+	                </tr>
+	            </thead>
+	            <tbody>
+	                <ui:repeat value="#{accountHome.instance.payments}" var="payment">
+	                    <tr>
+	                        <td>
+	                            <s:button action="#{paymentHome.cancel}" value="Cancel" rendered="#{payment.active}">
+	                                <f:param name="paymentId" value="#{payment.id}"/>
+	                            </s:button>
+	                            <h:outputText value="not active" rendered="#{!payment.active}" />
+	                        </td>                            
+	                        <td>#{payment.payee}</td>
+	                        <td>
+	                            <h:outputText value="#{payment.amount}">
+	                                <f:convertNumber type="currency" currencySymbol="$"/> 
+	                            </h:outputText>
+	                        </td>
+	                        <td>
+	                            <h:outputText value="#{payment.createdDate}">
+	                                <f:convertDateTime type="date" dateStyle="medium" />
+	                            </h:outputText>
+	                        </td>
+	                        <td>
+	                            <h:outputText value="#{payment.paymentDate}">
+	                                <f:convertDateTime type="date" dateStyle="medium" />
+	                            </h:outputText>
+	                        </td>
+	                        <td>#{payment.paymentFrequency}</td>
+	                        <td>
+	                            <h:outputText value="#{payment.lastPaid}">
+	                                <f:convertDateTime type="date" dateStyle="medium" />
+	                            </h:outputText>
+	                        </td>
+	                    </tr>
+	                </ui:repeat>
+	        	</tbody>
             </table>
 
             <h2>Make a payment from account #{accountHome.instance.accountNumber}:</h2>
-            <h:form>
+            <h:form id="paymentForm">
                 <s:validateAll>
                     <table>
                         <tr>
@@ -129,11 +133,11 @@
                                                   layout="lineDirection"
                                                   value="#{newPayment.paymentFrequency}">
                                     <s:convertEnum />
-                                    <s:enumItem enumValue="ONCE"         label="Only Once" />
-                                    <s:enumItem enumValue="EVERY_MINUTE" label="Every Minute (testing)" />
-                                    <s:enumItem enumValue="HOURLY"       label="Every Hour (testing)" />
-                                    <s:enumItem enumValue="DAILY"        label="Every Day" />
-                                    <s:enumItem enumValue="WEEKLY"       label="Every Week" />
+                                    <s:enumItem id="once" enumValue="ONCE"         label="Only Once" />
+                                    <s:enumItem id="everyMinute" enumValue="EVERY_MINUTE" label="Every Minute (testing)" />
+                                    <s:enumItem id="hourly" enumValue="HOURLY"       label="Every Hour (testing)" />
+                                    <s:enumItem id="daily" enumValue="DAILY"        label="Every Day" />
+                                    <s:enumItem id="weekly" enumValue="WEEKLY"       label="Every Week" />
                                     <ui:remove>
                                         <f:selectItems value="#{newPayment.frequencies}" />
                                     </ui:remove>
@@ -143,7 +147,7 @@
                     </table>
                 </s:validateAll>
                 
-                <h:commandButton value="Schedule" 
+                <h:commandButton id="submit" value="Schedule" 
                                  action="#{paymentHome.saveAndSchedule}" />
             </h:form>
         </f:subview>

Modified: trunk/src/test/ftest/build.xml
===================================================================
--- trunk/src/test/ftest/build.xml	2008-11-11 09:41:19 UTC (rev 9550)
+++ trunk/src/test/ftest/build.xml	2008-11-11 09:41:43 UTC (rev 9551)
@@ -55,6 +55,8 @@
       <testexample name="icefaces" />
       <testexample name="jpa" />
       <testexample name="nestedbooking" />
+      <testexample name="quartz" />
+      <testexample name="seampay" />
       <testexample name="spring" />
       <testexample name="wicket" />
 
@@ -82,6 +84,8 @@
       <cleanexample name="icefaces" />
       <cleanexample name="jpa" />
       <cleanexample name="nestedbooking" />
+      <cleanexample name="quartz" />
+      <cleanexample name="seampay" />
       <cleanexample name="spring" />
       <cleanexample name="wicket" />
    </target>
@@ -95,6 +99,8 @@
       <undeployexample name="icefaces" />
       <undeployexample name="jpa" />
       <undeployexample name="nestedbooking" />
+      <undeployexample name="quartz" />
+      <undeployexample name="seampay" />
       <undeployexample name="spring" />
       <undeployexample name="wicket" />
    </target>

Added: trunk/src/test/ftest/examples/quartz/build.xml
===================================================================
--- trunk/src/test/ftest/examples/quartz/build.xml	                        (rev 0)
+++ trunk/src/test/ftest/examples/quartz/build.xml	2008-11-11 09:41:43 UTC (rev 9551)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2008, Red Hat Middleware LLC, and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+--> 
+<project name="quartz.ftest.build" basedir="." default="build">
+   <property name="example.name" value="quartz"/>
+   <property name="jboss.deploy.target" value="deploy"/>
+   <property name="jboss.deploy.waittime" value="10"/>
+   <property name="jboss.undeploy.target" value="undeploy"/>
+   <property name="example.ready.check.url" value="seam-quartz/search.seam"/>
+   
+   <import file="../build.xml" />
+</project>

Added: trunk/src/test/ftest/examples/quartz/src/org/jboss/seam/example/quartz/test/selenium/QuartzPaymentTest.java
===================================================================
--- trunk/src/test/ftest/examples/quartz/src/org/jboss/seam/example/quartz/test/selenium/QuartzPaymentTest.java	                        (rev 0)
+++ trunk/src/test/ftest/examples/quartz/src/org/jboss/seam/example/quartz/test/selenium/QuartzPaymentTest.java	2008-11-11 09:41:43 UTC (rev 9551)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.quartz.test.selenium;
+
+import java.math.BigDecimal;
+import java.text.MessageFormat;
+import java.text.ParseException;
+
+import static org.testng.AssertJUnit.*;
+
+import org.jboss.seam.example.common.test.seampay.selenium.PaymentTest;
+import org.testng.annotations.Test;
+
+/**
+ * 
+ * @author jharting
+ * 
+ */
+public class QuartzPaymentTest extends PaymentTest
+{
+
+   /**
+    * Submits new payment using CRON and verifies that the balance is subtracted
+    * correctly
+    * 
+    * @throws ParseException
+    * @throws InterruptedException
+    */
+   @Test
+   public void testCRON() throws ParseException, InterruptedException
+   {
+      int account = 3;
+      BigDecimal amount = new BigDecimal(10);
+      String to = "foo";
+      String accountLinkLocator = MessageFormat.format(getProperty("ACCOUNT_TABLE_LINK"), account);
+      String accountBalanceLocator = MessageFormat.format(getProperty("ACCOUNT_TABLE_BALANCE"), account);
+      // send every 20 seconds
+      String cronExpression = "0/20 * * * * ?";
+
+      browser.click(accountLinkLocator);
+      browser.waitForPageToLoad(TIMEOUT);
+      // submit new cron job
+      browser.type(getProperty("PAYMENT_TO_FIELD"), to);
+      browser.type(getProperty("PAYMENT_AMOUNT_FIELD"), amount.toString());
+      browser.type(getProperty("PAYMENT_CRON_FIELD"), cronExpression);
+      browser.click(getProperty("PAYMENT_CRON_SUBMIT"));
+      browser.waitForPageToLoad(TIMEOUT);
+      assertTrue("Scheduled payment not confirmed.", browser.isTextPresent(MessageFormat.format(getProperty("PAYMENT_CONFIRMATION_MESSAGE"), to)));
+      assertEquals("Invalid count of payments.", 1, browser.getXpathCount(getProperty("PAYMENTS_COUNT")));
+      // wait
+      Thread.sleep(5000);
+      // get balance
+      browser.click(accountLinkLocator);
+      browser.waitForPageToLoad(TIMEOUT);
+      BigDecimal firstBalance = BigDecimal.valueOf(parseBalance(browser.getText(accountBalanceLocator)));
+      // wait 20 seconds
+      Thread.sleep(20000);
+      // get balance after 20 seconds
+      browser.click(accountLinkLocator);
+      browser.waitForPageToLoad(TIMEOUT);
+      BigDecimal secondBalance = BigDecimal.valueOf(parseBalance(browser.getText(accountBalanceLocator)));
+      // wait 20 seconds
+      Thread.sleep(20000);
+      // get balance after 40 seconds
+      browser.click(accountLinkLocator);
+      browser.waitForPageToLoad(TIMEOUT);
+      BigDecimal thirdBalance = BigDecimal.valueOf(parseBalance(browser.getText(accountBalanceLocator)));
+
+      BigDecimal expectedSecondBalance = firstBalance.subtract(amount);
+      BigDecimal expectedThirdBalance = firstBalance.subtract(amount).subtract(amount);
+      assertEquals("Incorrect balance after 20 seconds.", expectedSecondBalance, secondBalance);
+      assertEquals("Incorrect balance after 40 seconds.", expectedThirdBalance, thirdBalance);
+   }
+}

Added: trunk/src/test/ftest/examples/quartz/src/org/jboss/seam/example/quartz/test/selenium/quartz.properties
===================================================================
--- trunk/src/test/ftest/examples/quartz/src/org/jboss/seam/example/quartz/test/selenium/quartz.properties	                        (rev 0)
+++ trunk/src/test/ftest/examples/quartz/src/org/jboss/seam/example/quartz/test/selenium/quartz.properties	2008-11-11 09:41:43 UTC (rev 9551)
@@ -0,0 +1,34 @@
+ #
+ # JBoss, Home of Professional Open Source
+ # Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ # by the @authors tag. See the copyright.txt in the distribution for a
+ # full listing of individual contributors.
+ #
+ # This is free software; you can redistribute it and/or modify it
+ # under the terms of the GNU Lesser General Public License as
+ # published by the Free Software Foundation; either version 2.1 of
+ # the License, or (at your option) any later version.
+ #
+ # This software is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ # Lesser General Public License for more details.
+ #
+ # You should have received a copy of the GNU Lesser General Public
+ # License along with this software; if not, write to the Free
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ # 
+MAIN_PAGE = /seam-quartz/search.seam
+MAIN_PAGE_TITLE = Seam Pay
+ACCOUNT_TABLE_LINK = id=accountTable:{0}:link
+ACCOUNT_TABLE_BALANCE = id=accountTable:{0}:balance
+PAYMENT_TO_FIELD = id=accountView:paymentForm:payee
+PAYMENT_AMOUNT_FIELD = id=accountView:paymentForm:amount
+PAYMENT_CRON_FIELD = id=accountView:paymentForm:paymentCron
+PAYMENT_CRON_SUBMIT = id=accountView:paymentForm:cronSubmit
+PAYMENT_ONLY_ONCE_RADIO = id=accountView:paymentForm:radioList:0
+PAYMENT_EVERY_MINUTE_RADIO = id=accountView:paymentForm:radioList:1
+PAYMENT_SUBMIT = id=accountView:paymentForm:submit
+PAYMENT_CONFIRMATION_MESSAGE =Created a new payment to {0}
+PAYMENTS_COUNT = //table[@id='payments']/tbody/tr
\ No newline at end of file


Property changes on: trunk/src/test/ftest/examples/quartz/src/org/jboss/seam/example/quartz/test/selenium/quartz.properties
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/src/test/ftest/examples/quartz/testng.xml
===================================================================
--- trunk/src/test/ftest/examples/quartz/testng.xml	                        (rev 0)
+++ trunk/src/test/ftest/examples/quartz/testng.xml	2008-11-11 09:41:43 UTC (rev 9551)
@@ -0,0 +1,30 @@
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2008, Red Hat Middleware LLC, and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+--> 
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+<suite name="Quartz example" verbose="2" parallel="false">
+   <test name="Quartz example">
+      <parameter name="PROPERTY_FILE" value="/org/jboss/seam/example/quartz/test/selenium/quartz.properties" />
+      	<classes>
+		<class name="org.jboss.seam.example.quartz.test.selenium.QuartzPaymentTest" />
+      </classes>
+   </test>
+</suite>


Property changes on: trunk/src/test/ftest/examples/quartz/testng.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/src/test/ftest/examples/seampay/build.xml
===================================================================
--- trunk/src/test/ftest/examples/seampay/build.xml	                        (rev 0)
+++ trunk/src/test/ftest/examples/seampay/build.xml	2008-11-11 09:41:43 UTC (rev 9551)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2008, Red Hat Middleware LLC, and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+--> 
+<project name="seampay.ftest.build" basedir="." default="build">
+   <property name="example.name" value="seampay"/>
+   <property name="jboss.deploy.target" value="deploy"/>
+   <property name="jboss.deploy.waittime" value="10"/>
+   <property name="jboss.undeploy.target" value="undeploy"/>
+   <property name="example.ready.check.url" value="seam-pay/search.seam"/>
+   
+   <import file="../build.xml" />
+</project>

Added: trunk/src/test/ftest/examples/seampay/src/org/jboss/seam/example/seampay/test/selenium/seampay.properties
===================================================================
--- trunk/src/test/ftest/examples/seampay/src/org/jboss/seam/example/seampay/test/selenium/seampay.properties	                        (rev 0)
+++ trunk/src/test/ftest/examples/seampay/src/org/jboss/seam/example/seampay/test/selenium/seampay.properties	2008-11-11 09:41:43 UTC (rev 9551)
@@ -0,0 +1,32 @@
+ #
+ # JBoss, Home of Professional Open Source
+ # Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ # by the @authors tag. See the copyright.txt in the distribution for a
+ # full listing of individual contributors.
+ #
+ # This is free software; you can redistribute it and/or modify it
+ # under the terms of the GNU Lesser General Public License as
+ # published by the Free Software Foundation; either version 2.1 of
+ # the License, or (at your option) any later version.
+ #
+ # This software is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ # Lesser General Public License for more details.
+ #
+ # You should have received a copy of the GNU Lesser General Public
+ # License along with this software; if not, write to the Free
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ # 
+MAIN_PAGE = /seam-pay/search.seam
+MAIN_PAGE_TITLE = Seam Pay
+ACCOUNT_TABLE_LINK = id=accountTable:{0}:link
+ACCOUNT_TABLE_BALANCE = id=accountTable:{0}:balance
+PAYMENT_TO_FIELD = id=accountView:paymentForm:payee
+PAYMENT_AMOUNT_FIELD = id=accountView:paymentForm:amount
+PAYMENT_ONLY_ONCE_RADIO = id=accountView:paymentForm:radioList:0
+PAYMENT_EVERY_MINUTE_RADIO = id=accountView:paymentForm:radioList:1
+PAYMENT_SUBMIT = id=accountView:paymentForm:submit
+PAYMENT_CONFIRMATION_MESSAGE = Created a new payment to {0}
+PAYMENTS_COUNT = //table[@id='payments']/tbody/tr
\ No newline at end of file


Property changes on: trunk/src/test/ftest/examples/seampay/src/org/jboss/seam/example/seampay/test/selenium/seampay.properties
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/src/test/ftest/examples/seampay/testng.xml
===================================================================
--- trunk/src/test/ftest/examples/seampay/testng.xml	                        (rev 0)
+++ trunk/src/test/ftest/examples/seampay/testng.xml	2008-11-11 09:41:43 UTC (rev 9551)
@@ -0,0 +1,30 @@
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2008, Red Hat Middleware LLC, and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+--> 
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+<suite name="Seampay example" verbose="2" parallel="false">
+   <test name="Seampay example">
+      <parameter name="PROPERTY_FILE" value="/org/jboss/seam/example/seampay/test/selenium/seampay.properties" />
+      	<classes>
+		<class name="org.jboss.seam.example.common.test.seampay.selenium.PaymentTest" />
+      </classes>
+   </test>
+</suite>


Property changes on: trunk/src/test/ftest/examples/seampay/testng.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/seampay/selenium/PaymentTest.java
===================================================================
--- trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/seampay/selenium/PaymentTest.java	                        (rev 0)
+++ trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/seampay/selenium/PaymentTest.java	2008-11-11 09:41:43 UTC (rev 9551)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.common.test.seampay.selenium;
+
+import static org.testng.AssertJUnit.*;
+
+import java.math.BigDecimal;
+import java.text.MessageFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import org.jboss.seam.example.common.test.selenium.SeamSeleniumTest;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * 
+ * @author jharting
+ * 
+ */
+public class PaymentTest extends SeamSeleniumTest
+{
+
+   protected NumberFormat nf = NumberFormat.getNumberInstance();
+
+   @Override
+   @BeforeMethod
+   public void setUp()
+   {
+      super.setUp();
+      browser.open(getProperty("MAIN_PAGE"));
+      browser.waitForPageToLoad(TIMEOUT);
+   }
+
+   /**
+    * Submits new payment and asserts that remaining account balance is correct.
+    * 
+    * @throws ParseException
+    */
+   @Test
+   public void payOnceTest() throws ParseException
+   {
+      int account = 0;
+      BigDecimal amount = new BigDecimal(10);
+      String to = "foo";
+      String accountLinkLocator = MessageFormat.format(getProperty("ACCOUNT_TABLE_LINK"), account);
+      String accountBalanceLocator = MessageFormat.format(getProperty("ACCOUNT_TABLE_BALANCE"), account);
+
+      browser.click(accountLinkLocator);
+      browser.waitForPageToLoad(TIMEOUT);
+      BigDecimal expectedBalance = BigDecimal.valueOf(parseBalance(browser.getText(accountBalanceLocator)));
+      submitPayment(to, amount.toString(), getProperty("PAYMENT_ONLY_ONCE_RADIO"));
+      assertTrue("Scheduled payment not confirmed.", browser.isTextPresent(MessageFormat.format(getProperty("PAYMENT_CONFIRMATION_MESSAGE"), to)));
+      assertEquals("Invalid count of payments.", 1, browser.getXpathCount(getProperty("PAYMENTS_COUNT")));
+      browser.click(accountLinkLocator);
+      browser.waitForPageToLoad(TIMEOUT);
+      assertEquals("No money were subtracted from account", expectedBalance.subtract(amount), BigDecimal.valueOf(parseBalance(browser.getText(accountBalanceLocator))));
+   }
+
+   /**
+    * Submits new payment with one minute interval and verifies the balance
+    * after 60 seconds
+    * 
+    * @throws ParseException
+    * @throws InterruptedException
+    */
+   @Test
+   public void payEveryMinuteTest() throws ParseException, InterruptedException
+   {
+      int account = 1;
+      BigDecimal amount = new BigDecimal(10);
+      String to = "foo";
+      String accountLinkLocator = MessageFormat.format(getProperty("ACCOUNT_TABLE_LINK"), account);
+      String accountBalanceLocator = MessageFormat.format(getProperty("ACCOUNT_TABLE_BALANCE"), account);
+
+      browser.click(accountLinkLocator);
+      browser.waitForPageToLoad(TIMEOUT);
+      // create new payment
+      submitPayment(to, amount.toString(), getProperty("PAYMENT_EVERY_MINUTE_RADIO"));
+      assertTrue("Scheduled payment not confirmed.", browser.isTextPresent(MessageFormat.format(getProperty("PAYMENT_CONFIRMATION_MESSAGE"), to)));
+      assertEquals("Invalid count of payments.", 1, browser.getXpathCount(getProperty("PAYMENTS_COUNT")));
+      // wait
+      Thread.sleep(5000);
+      // get first balance
+      browser.click(accountLinkLocator);
+      browser.waitForPageToLoad(TIMEOUT);
+      BigDecimal firstBalance = BigDecimal.valueOf(parseBalance(browser.getText(accountBalanceLocator)));
+      // wait 60 seconds
+      Thread.sleep(60000);
+      // get second balance
+      browser.click(accountLinkLocator);
+      browser.waitForPageToLoad(TIMEOUT);
+      BigDecimal secondBalance = BigDecimal.valueOf(parseBalance(browser.getText(accountBalanceLocator)));
+      BigDecimal expectedSecondBalance = firstBalance.subtract(amount);
+      assertEquals("No money were subtracted from account after a minute", expectedSecondBalance, secondBalance);
+   }
+
+   protected void submitPayment(String to, String amount, String radio)
+   {
+      browser.type(getProperty("PAYMENT_TO_FIELD"), to);
+      browser.type(getProperty("PAYMENT_AMOUNT_FIELD"), amount.toString());
+      browser.check(radio);
+      browser.click(getProperty("PAYMENT_SUBMIT"));
+      browser.waitForPageToLoad(TIMEOUT);
+   }
+
+   protected Double parseBalance(String text) throws ParseException
+   {
+      String number = text.replaceAll("\\$", "").trim();
+      return (Double) nf.parse(number);
+   }
+}


Property changes on: trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/seampay/selenium/PaymentTest.java
___________________________________________________________________
Name: svn:executable
   + *




More information about the seam-commits mailing list