[jboss-cvs] JBossAS SVN: r104894 - in projects/ejb-book/trunk: chxx-poker/src/test/java/org/jboss/ejb3/examples/chxx/transactions/ejb and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon May 17 21:20:01 EDT 2010
Author: ALRubinger
Date: 2010-05-17 21:20:00 -0400 (Mon, 17 May 2010)
New Revision: 104894
Added:
projects/ejb-book/trunk/chxx-poker/src/test/java/org/jboss/ejb3/examples/chxx/transactions/ejb/ExampleUserData.java
Modified:
projects/ejb-book/trunk/chxx-poker/src/test/java/org/jboss/ejb3/examples/chxx/transactions/TransactionalPokerGameIntegrationTest.java
projects/ejb-book/trunk/chxx-poker/src/test/java/org/jboss/ejb3/examples/chxx/transactions/ejb/DbInitializerBean.java
projects/ejb-book/trunk/testsupport/src/main/java/org/jboss/ejb3/examples/testsupport/dbinit/DbInitializerLocalBusiness.java
projects/ejb-book/trunk/testsupport/src/main/java/org/jboss/ejb3/examples/testsupport/dbquery/DbQueryBean.java
Log:
[EJBBOOK-25] Move Tx example user data out of common testsupport and into the proper example module
Modified: projects/ejb-book/trunk/chxx-poker/src/test/java/org/jboss/ejb3/examples/chxx/transactions/TransactionalPokerGameIntegrationTest.java
===================================================================
--- projects/ejb-book/trunk/chxx-poker/src/test/java/org/jboss/ejb3/examples/chxx/transactions/TransactionalPokerGameIntegrationTest.java 2010-05-18 01:17:48 UTC (rev 104893)
+++ projects/ejb-book/trunk/chxx-poker/src/test/java/org/jboss/ejb3/examples/chxx/transactions/TransactionalPokerGameIntegrationTest.java 2010-05-18 01:20:00 UTC (rev 104894)
@@ -38,6 +38,7 @@
import org.jboss.ejb3.examples.chxx.transactions.api.BankLocalBusiness;
import org.jboss.ejb3.examples.chxx.transactions.api.PokerGameLocalBusiness;
import org.jboss.ejb3.examples.chxx.transactions.ejb.DbInitializerBean;
+import org.jboss.ejb3.examples.chxx.transactions.ejb.ExampleUserData;
import org.jboss.ejb3.examples.chxx.transactions.ejb.ForcedTestException;
import org.jboss.ejb3.examples.chxx.transactions.ejb.TaskExecutionException;
import org.jboss.ejb3.examples.chxx.transactions.ejb.TxWrappingLocalBusiness;
@@ -45,7 +46,6 @@
import org.jboss.ejb3.examples.chxx.transactions.entity.User;
import org.jboss.ejb3.examples.chxx.transactions.impl.BankBean;
import org.jboss.ejb3.examples.chxx.transactions.impl.PokerServiceConstants;
-import org.jboss.ejb3.examples.testsupport.dbinit.DbInitializerBeanBase;
import org.jboss.ejb3.examples.testsupport.dbinit.DbInitializerLocalBusiness;
import org.jboss.ejb3.examples.testsupport.dbquery.DbQueryBean;
import org.jboss.ejb3.examples.testsupport.dbquery.DbQueryLocalBusiness;
@@ -188,11 +188,11 @@
{
// Init
- final long alrubingerAccountId = DbInitializerBeanBase.ACCOUNT_ALRUBINGER_ID;
+ final long alrubingerAccountId = ExampleUserData.ACCOUNT_ALRUBINGER_ID;
final long pokerAccountId = PokerServiceConstants.ACCOUNT_POKERGAME_ID;
// Ensure there's the expected amounts in both the ALR and Poker accounts
- final BigDecimal expectedinitialALR = DbInitializerLocalBusiness.INITIAL_ACCOUNT_BALANCE_ALR;
+ final BigDecimal expectedinitialALR = ExampleUserData.INITIAL_ACCOUNT_BALANCE_ALR;
final BigDecimal expectedinitialPoker = PokerServiceConstants.INITIAL_ACCOUNT_BALANCE_POKERGAME;
this.executeInTx(new CheckBalanceOfAccountTask(alrubingerAccountId, expectedinitialALR),
new CheckBalanceOfAccountTask(pokerAccountId, expectedinitialPoker));
@@ -249,7 +249,7 @@
public void sequenceOfBetsDoesntRollBackAll() throws Throwable
{
// Get the original balance for ALR; this is done outside a Tx
- final BigDecimal originalBalance = bank.getBalance(DbInitializerLocalBusiness.ACCOUNT_ALRUBINGER_ID);
+ final BigDecimal originalBalance = bank.getBalance(ExampleUserData.ACCOUNT_ALRUBINGER_ID);
log.info("Starting balance before playing poker: " + originalBalance);
// Execute 11 bets enclosed in a new Tx, and ensure that the account transfers
@@ -271,7 +271,7 @@
// Now we've ensured that from inside the calling Tx we saw the account balances
// were as expected. But we rolled back that enclosing Tx, so ensure that the outcome
// of the games was not ignored
- final BigDecimal afterBetsBalance = bank.getBalance(DbInitializerLocalBusiness.ACCOUNT_ALRUBINGER_ID);
+ final BigDecimal afterBetsBalance = bank.getBalance(ExampleUserData.ACCOUNT_ALRUBINGER_ID);
final int gameOutcomeCount = task.gameOutcomeCount;
new AssertGameOutcome(originalBalance, afterBetsBalance, gameOutcomeCount, betAmount).call();
}
@@ -349,14 +349,14 @@
{
// Find the starting balance
- final long alrubingerAccountId = DbInitializerLocalBusiness.ACCOUNT_ALRUBINGER_ID;
+ final long alrubingerAccountId = ExampleUserData.ACCOUNT_ALRUBINGER_ID;
final BigDecimal startingBalance = bank.getBalance(alrubingerAccountId);
// Now run 11 bets
for (int i = 0; i < 11; i++)
{
// Track whether we win or lose
- final boolean win = pokerGame.bet(DbInitializerLocalBusiness.ACCOUNT_ALRUBINGER_ID, betAmount);
+ final boolean win = pokerGame.bet(ExampleUserData.ACCOUNT_ALRUBINGER_ID, betAmount);
gameOutcomeCount += win ? 1 : -1;
}
log.info("Won " + gameOutcomeCount + " games at " + betAmount + "/game");
Modified: projects/ejb-book/trunk/chxx-poker/src/test/java/org/jboss/ejb3/examples/chxx/transactions/ejb/DbInitializerBean.java
===================================================================
--- projects/ejb-book/trunk/chxx-poker/src/test/java/org/jboss/ejb3/examples/chxx/transactions/ejb/DbInitializerBean.java 2010-05-18 01:17:48 UTC (rev 104893)
+++ projects/ejb-book/trunk/chxx-poker/src/test/java/org/jboss/ejb3/examples/chxx/transactions/ejb/DbInitializerBean.java 2010-05-18 01:20:00 UTC (rev 104894)
@@ -97,12 +97,12 @@
// ALR
final User alrubinger = new User();
- alrubinger.setId(USER_ALRUBINGER_ID);
- alrubinger.setName(USER_ALRUBINGER_NAME);
+ alrubinger.setId(ExampleUserData.USER_ALRUBINGER_ID);
+ alrubinger.setName(ExampleUserData.USER_ALRUBINGER_NAME);
final Account alrubingerAccount = new Account();
- alrubingerAccount.deposit(INITIAL_ACCOUNT_BALANCE_ALR);
+ alrubingerAccount.deposit(ExampleUserData.INITIAL_ACCOUNT_BALANCE_ALR);
alrubingerAccount.setOwner(alrubinger);
- alrubingerAccount.setId(ACCOUNT_ALRUBINGER_ID);
+ alrubingerAccount.setId(ExampleUserData.ACCOUNT_ALRUBINGER_ID);
alrubinger.setAccount(alrubingerAccount);
// Poker Game Service
Added: projects/ejb-book/trunk/chxx-poker/src/test/java/org/jboss/ejb3/examples/chxx/transactions/ejb/ExampleUserData.java
===================================================================
--- projects/ejb-book/trunk/chxx-poker/src/test/java/org/jboss/ejb3/examples/chxx/transactions/ejb/ExampleUserData.java (rev 0)
+++ projects/ejb-book/trunk/chxx-poker/src/test/java/org/jboss/ejb3/examples/chxx/transactions/ejb/ExampleUserData.java 2010-05-18 01:20:00 UTC (rev 104894)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.examples.chxx.transactions.ejb;
+
+import java.math.BigDecimal;
+
+/**
+ * Contains example user data to be seeded in testing
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface ExampleUserData
+{
+ /*
+ * Test Data
+ */
+
+ long USER_ALRUBINGER_ID = 2L;
+
+ String USER_ALRUBINGER_NAME = "Andrew Lee Rubinger";
+
+ long ACCOUNT_ALRUBINGER_ID = 2L;
+
+ BigDecimal INITIAL_ACCOUNT_BALANCE_ALR = new BigDecimal(500);
+}
Modified: projects/ejb-book/trunk/testsupport/src/main/java/org/jboss/ejb3/examples/testsupport/dbinit/DbInitializerLocalBusiness.java
===================================================================
--- projects/ejb-book/trunk/testsupport/src/main/java/org/jboss/ejb3/examples/testsupport/dbinit/DbInitializerLocalBusiness.java 2010-05-18 01:17:48 UTC (rev 104893)
+++ projects/ejb-book/trunk/testsupport/src/main/java/org/jboss/ejb3/examples/testsupport/dbinit/DbInitializerLocalBusiness.java 2010-05-18 01:20:00 UTC (rev 104894)
@@ -21,8 +21,6 @@
*/
package org.jboss.ejb3.examples.testsupport.dbinit;
-import java.math.BigDecimal;
-
/**
* Contract of an EJB which can reset and populate a database with
* known data for user tests
@@ -33,22 +31,6 @@
public interface DbInitializerLocalBusiness
{
//-------------------------------------------------------------------------------------||
- // Constants --------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /*
- * Test Data
- */
-
- long USER_ALRUBINGER_ID = 2L;
-
- String USER_ALRUBINGER_NAME = "Andrew Lee Rubinger";
-
- long ACCOUNT_ALRUBINGER_ID = 2L;
-
- BigDecimal INITIAL_ACCOUNT_BALANCE_ALR = new BigDecimal(500);
-
- //-------------------------------------------------------------------------------------||
// Contracts --------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
Modified: projects/ejb-book/trunk/testsupport/src/main/java/org/jboss/ejb3/examples/testsupport/dbquery/DbQueryBean.java
===================================================================
--- projects/ejb-book/trunk/testsupport/src/main/java/org/jboss/ejb3/examples/testsupport/dbquery/DbQueryBean.java 2010-05-18 01:17:48 UTC (rev 104893)
+++ projects/ejb-book/trunk/testsupport/src/main/java/org/jboss/ejb3/examples/testsupport/dbquery/DbQueryBean.java 2010-05-18 01:20:00 UTC (rev 104894)
@@ -34,7 +34,6 @@
* Used in validating pre- and postconditions during testing.
* All methods will be executed in an existing Transaction, which
* is {@link TransactionAttributeType#MANDATORY}.
- *
*
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
@@ -51,10 +50,6 @@
{
//-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- //-------------------------------------------------------------------------------------||
// Instance Members -------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
@@ -87,12 +82,4 @@
// Find
return em.find(type, id);
}
-
- //-------------------------------------------------------------------------------------||
- // Functional Methods -----------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- //-------------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
}
More information about the jboss-cvs-commits
mailing list