Examples of BankData


Examples of org.jboss.test.banknew.interfaces.BankData

            // Let this thread sleep because the next person must ready first
            // This is also here to avoid that the threads start at the same time
            Thread.sleep( lRandom.nextInt( 2 * Constants.ONE_MINUTE ) );
            // Get bank first
            Collection lBanks = getBankSession().getBanks();
            BankData lBank = (BankData) lBanks.iterator().next();
            mLog.debug( "run(), tread id: " + mId + ", got bank: " + lBank );
            // Loop of business interactions
            while( !mExit && mException == null ) {
               CustomerData lCustomer = null;
               mLog.debug( "run(), tread id: " + mId + ", create or find customer" );
               if( lRandom.nextInt( 100 ) < 10 ) {
                  mLog.debug( "run(), thread id: " + mId + ", create new customer" );
                  lCustomer = getCustomerSession().createCustomer( lBank.getId(), "test", 100 );
                  mCustomerCount++;
                  mLog.debug( "run(), thread id: " + mId + ", new customer: " + lCustomer );
               } else {
                  int i = 0;
                  while( lCustomer == null ) {
                     i++;
                     try {
                        int lCustomerId = lRandom.nextInt( mCustomerCount );
                        mLog.debug( "run(), thread id: " + mId + ", look up customer, id: " + lCustomerId );
                        lCustomer = getBankSession().getCustomer( "" + lCustomerId );
                        mLog.debug( "run(), thread id: " + mId + ", found customer: " + lCustomer );
                     }
                     catch( FinderException fe ) {
                        if( i > 100 ) {
                           throw fe;
                        }
                     }
                  }
               }
               mLog.debug( "run(), tread id: " + mId + ", create or find account" );
               // Get accounts and decide if to create a new account
               List lAccounts = (List) getCustomerSession().getAccounts( lCustomer.getId() );
               AccountData lAccount = null;
               if( lRandom.nextInt( 100 ) < 5 ) {
                  try {
                     lAccount = getCustomerSession().createAccount(
                        lCustomer.getId(), lRandom.nextInt( 3 ), 123
                     );
                     mLog.debug( "run(), thread id: " + mId + ", created account: " + lAccount );
                  }
                  catch( CreateException ce ) {
                  }
               }
               if( lAccount == null ) {
                  lAccount = (AccountData) lAccounts.get( lRandom.nextInt( lAccounts.size() ) );
                  mLog.debug( "run(), thread id: " + mId + ", got account: " + lAccount );
               }
               if( lAccount == null ) {
                  throw new RuntimeException( "Could not find an account" );
               }
               // Do some business methods
               int lLoops = lRandom.nextInt( 10 );
               for( int i = 0; i < lLoops; i++ ) {
                  int lSelection = lRandom.nextInt( 4 );
                  mLog.debug( "run(), thread: " + mId + ", business selection : " + lSelection );
                  switch( lSelection ) {
                     case 0:
                        // Withdraw money when balance is greater than 50
                        if( lAccount.getBalance() > 50 ) {
                           getAccountSession().withdraw( lAccount.getId(), lRandom.nextInt( 50 ) );
                        }
                        break;
                     case 1:
                        if( lAccounts.size() > 1 && lAccount.getBalance() > 50 ) {
                           AccountData lOtherAccount = null;
                           while( true ) {
                              lOtherAccount = (AccountData) lAccounts.get( lRandom.nextInt( lAccounts.size() ) );
                              if( lOtherAccount.getType() != lAccount.getType() ) {
                                 // Found another account type
                                 break;
                              }
                           }
                           while( true ) {
                              try {
                                 getAccountSession().transfer( lAccount.getId(), lOtherAccount.getId(), lRandom.nextInt( 50 ) );
                                 break;
                              }
                              catch( ServerException se ) {
                                 checkServerException( se );
                              }
                           }
                        }
                        break;
                     case 2:
                        if( lAccount.getBalance() > 50 ) {
                           List lCustomers = (List) getBankSession().getCustomers( lBank.getId() );
                           if( lCustomers.size() > 1 ) {
                              CustomerData lOtherCustomer = null;
                              while( true ) {
                                 lOtherCustomer = (CustomerData) lCustomers.get( lRandom.nextInt( lCustomers.size() ) );
                                 if( !lOtherCustomer.getId().equals( lCustomer.getId() ) ) {
View Full Code Here

Examples of org.jboss.test.banknew.interfaces.BankData

      CustomerSession lCustomer = lCustomerHome.create();
      AccountSession lAccount = lAccountHome.create();
      TellerSession lTeller = lTellerHome.create();
     
      // Create a bank the root of everything
      BankData lBankData = lBank.createBank( "Andy's TestBank", "12345 XMass Avenue, New JBoss, GA" );
     
      // Check all the methods on teller inteface because that
      // is what we are here working with primarly
      CustomerData lCustomerData = lTeller.createCustomer( lBankData.getId(), "One", 100 );
      CustomerData lCustomerData2 = lTeller.getCustomer( lCustomerData.getId() );
      Collection lCustomers = lTeller.getCustomers( lBankData.getId() );
     
      AccountData lAccountData = lTeller.createAccount( lCustomerData.getId(), Constants.SAVING, 150 );
      AccountData lAccountData2 = lTeller.getAccount( lCustomerData.getId(), Constants.SAVING );
      AccountData lAccountData3 = lTeller.getAccount( lAccountData.getId() );
      AccountData lAccountData4 = lTeller.getAccount( lCustomerData.getId(), Constants.CHECKING );
      Collection lAccounts = lTeller.getAccounts( lCustomerData.getId() );
     
      lTeller.deposit( lAccountData4.getId(), 75 );
      lTeller.withdraw( lAccountData3.getId(), 63 );
      lTeller.transfer( lAccountData4.getId(), lAccountData3.getId(), 52 );
     
      lTeller.removeAccount( lAccountData4.getId() );
      lTeller.removeAccount( lAccountData.getId() );
      lTeller.removeCustomer( lCustomerData.getId() );
     
      lBank.removeBank( lBankData.getId() );
      log.debug( "testEnvironment() ends" );
   }
View Full Code Here

Examples of org.jboss.test.banknew.interfaces.BankData

      AccountSessionHome lAccountHome = (AccountSessionHome) mContext.lookup( AccountSessionHome.JNDI_NAME );
      BankSession lBankSession = lBankHome.create();
      Collection lBanks = lBankSession.getBanks();
      Iterator i = lBanks.iterator();
      while( i.hasNext() ) {
         BankData lBank = (BankData) i.next();
         // Get all customers
         CustomerSession lCustomerSession = lCustomerHome.create();
         Collection lCustomers = lCustomerSession.getCustomers( lBank.getId() );
         Iterator j = lCustomers.iterator();
         while( j.hasNext() ) {
            CustomerData lCustomer = (CustomerData) j.next();
            // Get all accounts
            AccountSession lAccountSession = lAccountHome.create();
            Collection lAccounts = lAccountSession.getAccounts( lCustomer.getId() );
            Iterator k = lAccounts.iterator();
            while( k.hasNext() ) {
               AccountData lAccount = (AccountData) k.next();
               lAccountSession.removeAccount( lAccount.getId() );
            }
            lCustomerSession.removeCustomer( lCustomer.getId() );
         }
         lBankSession.removeBank( lBank.getId() );
      }
      log.debug( "setUp() ends" );
   }
View Full Code Here

Examples of org.jboss.test.banknew.interfaces.BankData

   public void setupBank()
      throws Exception
   {
      //AS ToDo
      log.debug( "setupBank(), create bank" );
      BankData lBank = getBankSession().createBank( "Andy's TestBank", "12345 XMass Avenue, New JBoss, GA" );
      for( int i = 0; i < INITIAL_NUMBER_OF_CUSTOMERS; i++ ) {
         log.debug( "setupBank(), create customer #: " + i );
         CustomerData lCustomer = getCustomerSession().createCustomer( lBank.getId(), "test", 100 );
      }
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.