User: schaefera
Date: 02/04/12 16:54:12
Added: src/main/org/jboss/test/bank/test Tag: Branch_2_4
BankStressTestCase.java
Log:
Backport of the JBoss 3.0 stress tests w/o JMS and deadlock tests.
Revision Changes Path
No revision
No revision
1.5.2.1 +90 -53
jbosstest/src/main/org/jboss/test/bank/test/BankStressTestCase.java
Index: BankStressTestCase.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/bank/test/BankStressTestCase.java,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- BankStressTestCase.java 29 Jan 2002 21:59:59 -0000 1.5
+++ BankStressTestCase.java 12 Apr 2002 23:54:12 -0000 1.5.2.1
@@ -23,10 +23,11 @@
*
* @see <related>
* @author Author: d_jencks among many others
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.5.2.1 $
*/
public class BankStressTestCase
extends JBossTestCase
+//AS extends TestCase
{
// Constants -----------------------------------------------------
@@ -41,31 +42,33 @@
public BankStressTestCase(String name)
{
super(name);
+ System.out.println( "AS BankStressTestCase(), name: " + name );
}
// Public --------------------------------------------------------
public void testTeller()
throws Exception
{
+ System.out.println( "AS testTeller()" );
TellerHome home = (TellerHome)new
InitialContext().lookup(TellerHome.JNDI_NAME);
Teller teller = home.create();
BankHome bankHome = (BankHome)new InitialContext().lookup(BankHome.JNDI_NAME);
Bank bank = bankHome.create();
- getLog().debug("Acquire customers");
+ log.info("Acquire customers");
Customer marc = teller.getCustomer("Marc");
Customer rickard = teller.getCustomer("Rickard");
- getLog().debug("Acquire accounts");
+ log.info("Acquire accounts");
Account from = teller.getAccount(marc, 200);
Account to = teller.getAccount(rickard, 200);
- getLog().debug("Show balance");
- getLog().debug(from.getPrimaryKey()+":"+from.getBalance());
- getLog().debug(to.getPrimaryKey()+":"+to.getBalance());
+ log.info("Show balance");
+ log.info(from.getPrimaryKey()+":"+from.getBalance());
+ log.info(to.getPrimaryKey()+":"+to.getBalance());
- getLog().debug("Transfer money");
+ log.info("Transfer money");
long start = System.currentTimeMillis();
int iter = 10;
@@ -74,7 +77,7 @@
long end = System.currentTimeMillis();
getLog().info("Average call time: "+((end - start) / (iter*6)));
- getLog().debug("Show balance");
+ log.info("Show balance");
AccountHome accountHome = (AccountHome)new
InitialContext().lookup(AccountHome.JNDI_NAME);
Collection accts = accountHome.findAll();
Iterator enum = accts.iterator();
@@ -82,31 +85,34 @@
{
Account acct = (Account)enum.next();
AccountData data = acct.getData();
-
getLog().debug(data.getId()+"("+data.getOwner().getName()+"):"+data.getBalance());
+
log.info(data.getId()+"("+data.getOwner().getName()+"):"+data.getBalance());
acct.withdraw(data.getBalance()); // Clear
}
teller.remove();
+ System.out.println( "AS testTeller() ends" );
}
public void testBank()
throws Exception
{
- getLog().debug("Get code");
+ System.out.println( "AS testBank()" );
+ log.info("Get code");
BankHome bankHome = (BankHome)new InitialContext().lookup(BankHome.JNDI_NAME);
Bank bank = bankHome.create();
- getLog().debug("Bank id="+bank.getId());
+ log.info("Bank id="+bank.getId());
bank.remove();
+ System.out.println( "AS testBank() ends" );
}
/* public void testCustomer()
throws Exception
{
- getLog().debug("Customer test----------------------------------");
+ log.info("Customer test----------------------------------");
- getLog().debug("Create Customer");
+ log.info("Create Customer");
CustomerHome customerHome = (CustomerHome)new
InitialContext().lookup("Customer");
Account from, to;
try
@@ -126,11 +132,11 @@
to = accountHome.create("Rickard", 0);
}
- getLog().debug("Show balance");
- getLog().debug(from.getPrimaryKey()+":"+from.getBalance());
- getLog().debug(to.getPrimaryKey()+":"+to.getBalance());
+ log.info("Show balance");
+ log.info(from.getPrimaryKey()+":"+from.getBalance());
+ log.info(to.getPrimaryKey()+":"+to.getBalance());
- getLog().debug("Transfer money");
+ log.info("Transfer money");
TellerHome home = (TellerHome)new InitialContext().lookup("Teller");
Teller teller = home.create();
@@ -139,29 +145,32 @@
teller.transfer(from, to, 50);
teller.remove();
- getLog().debug("Show balance");
+ log.info("Show balance");
Iterator enum = accountHome.findAll();
while(enum.hasNext())
{
Account acct = (Account)enum.next();
- getLog().debug(acct.getPrimaryKey()+":"+acct.getBalance());
+ log.info(acct.getPrimaryKey()+":"+acct.getBalance());
acct.withdraw(acct.getBalance()); // Clear
}
- getLog().debug("Teller test done----------------------------------");
+ log.info("Teller test done----------------------------------");
}
*/
public void testMultiThread()
throws Exception
{
+ System.out.println( "AS testMultiThread()" );
TellerHome home = (TellerHome)new
InitialContext().lookup(TellerHome.JNDI_NAME);
final Teller teller = home.create();
- getLog().debug("Acquire customers");
+ log.info("Acquire customers");
+ System.out.println("AS Acquire customers");
Customer marc = teller.getCustomer("Marc");
Customer rickard = teller.getCustomer("Rickard");
- getLog().debug("Acquire accounts");
+ log.info("Acquire accounts");
+ System.out.println("AS Acquire accounts");
final Account from = teller.getAccount(marc, 50);
final Account to = teller.getAccount(rickard, 0);
@@ -171,11 +180,13 @@
iter = getThreadCount();
final int iterationCount = getIterationCount();
getLog().info("Start test. "+getThreadCount()+ " threads,
"+getIterationCount()+" iterations");
+ System.out.println("Start test. "+getThreadCount()+ " threads,
"+getIterationCount()+" iterations");
long start = System.currentTimeMillis();
for (int i = 0; i < getThreadCount(); i++)
{
Thread.sleep(50);
+ System.out.println( "AS testMultiThread() create new thread: " + i );
new Thread(new Runnable()
{
public void run()
@@ -189,10 +200,12 @@
{
if (exc != null) break;
+//AS System.out.println( "AS testMultiThread() transfer: " + j
);
teller.transfer(from,to,50);
teller.transfer(from,to,-50);
// Thread.currentThread().yield();
// logdebug(idx++);
+//AS System.out.println( "AS testMultiThread() transfer ends" );
}
} catch (Exception e)
{
@@ -201,9 +214,11 @@
synchronized(lock)
{
+ System.out.println( "AS testMultiThread() lock" );
iter--;
log.info("Only "+iter+" left");
lock.notifyAll();
+ System.out.println( "AS testMultiThread() lock ends" );
}
}
}).start();
@@ -213,6 +228,7 @@
{
while(iter>0)
{
+ System.out.println( "AS testMultiThread() lock wait !!" );
lock.wait();
}
}
@@ -226,15 +242,23 @@
getLog().info(to.getPrimaryKey()+":"+to.getBalance());
getLog().info("Time:"+(end-start));
getLog().info("Avg.
time/call(ms):"+((end-start)/(getThreadCount()*getIterationCount()*6)));
+
+ System.out.println("AS Show balance");
+ System.out.println("AS " + from.getPrimaryKey()+":"+from.getBalance());
+ System.out.println("AS " + to.getPrimaryKey()+":"+to.getBalance());
+ System.out.println("AS Time:"+(end-start));
+ System.out.println("AS Avg.
time/call(ms):"+((end-start)/(getThreadCount()*getIterationCount()*6)));
+ System.out.println( "AS testMultiThread() ends" );
}
public void testMultiThread2()
throws Exception
{
+ System.out.println( "AS testMultiThread2()" );
TellerHome home = (TellerHome)new
InitialContext().lookup(TellerHome.JNDI_NAME);
final Teller teller = home.create();
- getLog().debug("Acquire customers");
+ log.info("Acquire customers");
final Customer marc = teller.getCustomer("Marc");
final Customer rickard = teller.getCustomer("Rickard");
@@ -300,60 +324,64 @@
getLog().info("Time:"+(end-start));
getLog().info("Avg.
time/call(ms):"+((end-start)/(getThreadCount()*getIterationCount()*6)));
+ System.out.println( "AS testMultiThread2() ends" );
}
public void testTransaction()
throws Exception
{
+ System.out.println( "AS testTransaction()" );
TellerHome home = (TellerHome)new
InitialContext().lookup(TellerHome.JNDI_NAME);
Teller teller = home.create();
- getLog().debug("Acquire customers");
+ log.info("Acquire customers");
Customer marc = teller.getCustomer("Marc");
- getLog().debug("Marc acquired");
+ log.info("Marc acquired");
Customer rickard = teller.getCustomer("Rickard");
- getLog().debug("Rickard acquired");
+ log.info("Rickard acquired");
- getLog().debug("Acquire accounts");
+ log.info("Acquire accounts");
Account from = teller.getAccount(marc, 50);
Account to = teller.getAccount(rickard, 0);
- getLog().debug("Show balance");
- getLog().debug(from.getPrimaryKey()+":"+from.getBalance());
- getLog().debug(to.getPrimaryKey()+":"+to.getBalance());
+ log.info("Show balance");
+ log.info(from.getPrimaryKey()+":"+from.getBalance());
+ log.info(to.getPrimaryKey()+":"+to.getBalance());
- getLog().debug("Transfer money");
+ log.info("Transfer money");
teller.transfer(from, to, 50);
- getLog().debug("Transfer done");
+ log.info("Transfer done");
- getLog().debug("Show balance");
-
getLog().debug(from.getPrimaryKey()+"("+from.getOwner().getName()+"):"+from.getBalance());
-
getLog().debug(to.getPrimaryKey()+"("+to.getOwner().getName()+"):"+to.getBalance());
+ log.info("Show balance");
+
log.info(from.getPrimaryKey()+"("+from.getOwner().getName()+"):"+from.getBalance());
+ log.info(to.getPrimaryKey()+"("+to.getOwner().getName()+"):"+to.getBalance());
teller.remove();
+ System.out.println( "AS testTransaction() ends" );
}
public void testTransfer()
throws Exception
{
+ System.out.println( "AS testTransfer()" );
TellerHome home = (TellerHome)new
InitialContext().lookup(TellerHome.JNDI_NAME);
Teller teller = home.create();
- getLog().debug("Acquire customers");
+ log.info("Acquire customers");
Customer marc = teller.getCustomer("Marc");
- getLog().debug("Marc acquired");
+ log.info("Marc acquired");
Customer rickard = teller.getCustomer("Rickard");
- getLog().debug("Rickard acquired");
+ log.info("Rickard acquired");
- getLog().debug("Acquire accounts");
+ log.info("Acquire accounts");
Account from = teller.getAccount(marc, 50*getIterationCount());
Account to = teller.getAccount(rickard, 0);
- getLog().debug("Show balance");
- getLog().debug(from.getPrimaryKey()+":"+from.getBalance());
- getLog().debug(to.getPrimaryKey()+":"+to.getBalance());
+ log.info("Show balance");
+ log.info(from.getPrimaryKey()+":"+from.getBalance());
+ log.info(to.getPrimaryKey()+":"+to.getBalance());
getLog().info("Transfer money");
long start = System.currentTimeMillis();
@@ -363,27 +391,29 @@
getLog().info("Total time(ms):"+(end-start));
getLog().info("Avg. time/call(ms):"+((end-start)/(getIterationCount()*2)));
- getLog().debug("Show balance");
- getLog().debug(from.getPrimaryKey()+":"+from.getBalance());
- getLog().debug(to.getPrimaryKey()+":"+to.getBalance());
+ log.info("Show balance");
+ log.info(from.getPrimaryKey()+":"+from.getBalance());
+ log.info(to.getPrimaryKey()+":"+to.getBalance());
teller.remove();
+ System.out.println( "AS testTransfer() ends" );
}
public void testReadOnly()
throws Exception
{
+ System.out.println( "AS testReadOnly()" );
TellerHome home = (TellerHome)new
InitialContext().lookup(TellerHome.JNDI_NAME);
Teller teller = home.create();
- getLog().debug("Acquire customers");
+ log.info("Acquire customers");
Customer marc = teller.getCustomer("Marc");
- getLog().debug("Marc acquired");
+ log.info("Marc acquired");
Customer rickard = teller.getCustomer("Rickard");
- getLog().debug("Rickard acquired");
+ log.info("Rickard acquired");
- getLog().debug("Acquire accounts");
+ log.info("Acquire accounts");
Account from = teller.getAccount(marc, 50*getIterationCount());
Account to = teller.getAccount(rickard, 0);
@@ -403,11 +433,13 @@
getLog().info("Avg. time/call(ms):"+((end-start)/(getIterationCount()*4)));
teller.remove();
+ System.out.println( "AS testReadOnly() ends" );
}
public void testPassivation()
throws Exception
{
+ System.out.println( "AS testPassivation()" );
// Create a bunch of customers, to test passivation
CustomerHome home = (CustomerHome)new
InitialContext().lookup(CustomerHome.JNDI_NAME);
@@ -416,13 +448,15 @@
for (int i = 0; i < getIterationCount(); i++)
home.create(i+"", "Smith_"+i);
- getLog().debug("Customers created");
+ log.info("Customers created");
+ System.out.println( "AS testPassivation() ends" );
}
public void testFinder()
throws Exception
{
+ System.out.println( "AS testFinder()" );
//create some accounts
testPassivation();
AccountHome home = (AccountHome)new
InitialContext().lookup(AccountHome.JNDI_NAME);
@@ -432,13 +466,15 @@
while (enum.hasNext())
{
Account acct = (Account)enum.next();
- getLog().debug(acct.getOwner().getName()+":"+acct.getBalance());
+ log.info(acct.getOwner().getName()+":"+acct.getBalance());
}
+ System.out.println( "AS testFinder() ends" );
}
protected void setUp()
throws Exception
{
+ System.out.println( "AS setUp()" );
getLog().info("Remove accounts");
{
AccountHome home = (AccountHome)new
InitialContext().lookup(AccountHome.JNDI_NAME);
@@ -447,7 +483,7 @@
while(enum.hasNext())
{
Account acct = (Account)enum.next();
- getLog().debug("Removing "+acct.getPrimaryKey());
+ log.info("Removing "+acct.getPrimaryKey());
acct.remove();
}
}
@@ -459,10 +495,11 @@
while(enum.hasNext())
{
Customer cust = (Customer)enum.next();
- getLog().debug("Removing "+cust.getPrimaryKey());
+ log.info("Removing "+cust.getPrimaryKey());
cust.remove();
}
}
+ System.out.println( "AS setUp() ends" );
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development