User: starksm
Date: 02/04/17 12:06:45
Modified: src/main/org/jboss/test/bank/test Tag: Branch_2_4 Main.java
Log:
Add tests of creating and removing an entity using the default commit
option to test caching.
Revision Changes Path
No revision
No revision
1.1.1.1.2.2 +29 -52 jbosstest/src/main/org/jboss/test/bank/test/Attic/Main.java
Index: Main.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/bank/test/Attic/Main.java,v
retrieving revision 1.1.1.1.2.1
retrieving revision 1.1.1.1.2.2
diff -u -r1.1.1.1.2.1 -r1.1.1.1.2.2
--- Main.java 9 Jul 2001 01:06:02 -0000 1.1.1.1.2.1
+++ Main.java 17 Apr 2002 19:06:45 -0000 1.1.1.1.2.2
@@ -21,7 +21,7 @@
*
* @see <related>
* @author $Author: starksm $
- * @version $Revision: 1.1.1.1.2.1 $
+ * @version $Revision: 1.1.1.1.2.2 $
*/
public class Main
extends TestCase
@@ -99,56 +99,31 @@
System.out.println("Bank id="+bank.getId());
bank.remove();
}
-
-/* public void testCustomer()
+
+ public void testCreateRemoveCustomer()
throws Exception
{
- System.out.println("Customer test----------------------------------");
-
- System.out.println("Create Customer");
- CustomerHome customerHome = (CustomerHome)new
InitialContext().lookup("Customer");
- Account from, to;
- try
- {
- from = accountHome.findByPrimaryKey("Marc");
- from.deposit(200);
- } catch (FinderException e)
- {
- from = accountHome.create("Marc", 200);
- }
-
- try
- {
- to = accountHome.findByPrimaryKey("Rickard");
- } catch (FinderException e)
- {
- to = accountHome.create("Rickard", 0);
- }
-
- System.out.println("Show balance");
- System.out.println(from.getPrimaryKey()+":"+from.getBalance());
- System.out.println(to.getPrimaryKey()+":"+to.getBalance());
+
System.out.println("testCreateRemoveCustomer----------------------------------");
- System.out.println("Transfer money");
- TellerHome home = (TellerHome)new InitialContext().lookup("Teller");
+ System.out.println("Create Customer");
+ CustomerHome customerHome = (CustomerHome) new
InitialContext().lookup(CustomerHome.JNDI_NAME);
+ Customer customer = customerHome.create("123456789", "Customer1");
+ System.out.println("Customer name="+customer.getName());
+ customer.remove();
+ // Recreate the customer
+ System.out.println("Recreate Customer");
+ customer = customerHome.create("123456789", "Customer1");
+ System.out.println("Customer name="+customer.getName());
+ customer.remove();
+ }
+ public void testCreateRemoveCustomerInTx()
+ throws Exception
+ {
+
System.out.println("testCreateRemoveCustomerInTx----------------------------------");
+ TellerHome home = (TellerHome)new
InitialContext().lookup(TellerHome.JNDI_NAME);
Teller teller = home.create();
-
- long start = System.currentTimeMillis();
- for (int i = 0; i < 100; i++)
- teller.transfer(from, to, 50);
- teller.remove();
-
- System.out.println("Show balance");
- Iterator enum = accountHome.findAll();
- while(enum.hasNext())
- {
- Account acct = (Account)enum.next();
- System.out.println(acct.getPrimaryKey()+":"+acct.getBalance());
- acct.withdraw(acct.getBalance()); // Clear
- }
- System.out.println("Teller test done----------------------------------");
+ teller.createAndRemove("123456789", "Customer1");
}
-*/
public void testMultiThread()
throws Exception
@@ -456,7 +431,7 @@
acct.remove();
}
}
-
+
System.out.println("Remove customers");
{
CustomerHome home = (CustomerHome)new
InitialContext().lookup(CustomerHome.JNDI_NAME);
@@ -471,10 +446,11 @@
}
}
- public static Test suite() {
+ public static Test suite()
+ {
TestSuite suite = new TestSuite();
-
- try {
+ try
+ {
String filename = "../deploy/bank.jar";
System.out.println("Deploying...");
Deploy.deploy(filename);
@@ -484,7 +460,8 @@
// add a test case to undeploy our support applications
suite.addTest(new Deploy.Undeployer(filename));
}
- catch (Throwable t) {
+ catch (Throwable t)
+ {
t.printStackTrace();
System.exit(0);
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development