User: fleury
Date: 00/09/07 22:16:33
Modified: src/java/org/jboss/zol/testbean/client EjbossClient.java
Log:
new bean for testing transaction behaviour
Revision Changes Path
1.19 +97 -35 zola/src/java/org/jboss/zol/testbean/client/EjbossClient.java
Index: EjbossClient.java
===================================================================
RCS file:
/products/cvs/ejboss/zola/src/java/org/jboss/zol/testbean/client/EjbossClient.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- EjbossClient.java 2000/08/25 21:53:21 1.18
+++ EjbossClient.java 2000/09/08 05:16:33 1.19
@@ -27,13 +27,15 @@
import org.jboss.zol.testbean.interfaces.EntityPK;
import org.jboss.zol.testbean.interfaces.BusinessMethodException;
import org.jboss.zol.testbean.interfaces.AComplexPK;
+import org.jboss.zol.testbean.interfaces.TxSessionHome;
+import org.jboss.zol.testbean.interfaces.TxSession;
/**
* Sample client for the jboss container.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
-* @version $Id: EjbossClient.java,v 1.18 2000/08/25 21:53:21 fleury Exp $
+* @version $Id: EjbossClient.java,v 1.19 2000/09/08 05:16:33 fleury Exp $
*/
public class EjbossClient {
@@ -48,10 +50,11 @@
System.out.println("Copyright (C), The jBoss Organization, 2000");
System.out.println("_____________________________________________");
System.out.println();
- System.out.println("Welcome to the test Suite v1.0");
+ System.out.println("Welcome to the test Suite v1.2");
System.out.println("_____________________________________________");
System.out.println();
-
+
+ Date startDate = new Date();
int test = 0;
System.out.print(++test+"- "+"Trying the context...");
@@ -59,7 +62,7 @@
Context ctx = new InitialContext();
System.out.println("OK");
- ///*
+ ///*
System.out.println();
System.out.println("Test Stateless Bean");
System.out.println("===================");
@@ -82,7 +85,7 @@
System.out.println("ok");
System.out.println(++test+"- "+"Calling Business Method B on
StatelessSession... ");
System.out.println(statelessSession.callBusinessMethodB());
- System.out.println(++test+"- "+"Calling Business Method
B(String) on StatelessSession... ");
+ System.out.println(++test+"- "+"Calling Business Method B(String) on
StatelessSession... ");
System.out.println(statelessSession.callBusinessMethodB("of wisdom"));
System.out.println(++test+"- "+"Calling Business Method C on
StatelessSession... ");
System.out.println(statelessSession.callBusinessMethodC());
@@ -171,10 +174,10 @@
System.out.println(statefulSession.callBusinessMethodA());
System.out.print(++test+"- "+"Calling Business Method B (EJBObject) on
StatefulSession... ");
System.out.println(statefulSession.callBusinessMethodB());
-
- System.out.println(++test+"- "+"Calling Business Method
B(String) on StatefulSession... ");
+
+ System.out.println(++test+"- "+"Calling Business Method B(String) on
StatefulSession... ");
System.out.println(statefulSession.callBusinessMethodB("of wisdom"));
-
+
System.out.println("***Testing the various local Object class calls");
System.out.print(++test+"- "+"toString ... ");
@@ -283,9 +286,9 @@
System.out.println(++test+"- "+"Calling Business Method B (EJBObject
from entity) on enterpriseEntity...");
System.out.println(enterpriseEntity.callBusinessMethodB());
- System.out.println(++test+"- "+"Calling Business Method
B(String) on EnterpriseEntity... ");
+ System.out.println(++test+"- "+"Calling Business Method B(String) on
EnterpriseEntity... ");
System.out.println(enterpriseEntity.callBusinessMethodB("of wisdom"));
-
+
System.out.print(++test+"- "+"Calling getOtherField (non pk) on
enterpriseEntity...");
System.out.println("value: "+enterpriseEntity.getOtherField());
@@ -298,7 +301,7 @@
if (value == 4) System.out.println("value is "+value+", OK");
else System.out.println("NOT OK value is "+value);
- System.out.println("***Testing the various local Object class
calls");
+ System.out.println("***Testing the various local Object class calls");
System.out.print(++test+"- "+"toString ... ");
System.out.println(enterpriseEntity.toString());
System.out.print(++test+"- "+"hashCode ... ");
@@ -325,16 +328,16 @@
enterpriseEntityHome.remove(enterpriseEntity3.getHandle());
System.out.println("OK");
- System.out.print(++test+"- "+"Calling
enterpriseEntity.remove() (should fail)...");
- try {
- enterpriseEntity.remove();
- System.out.println("NOT OK");
- }
- catch (Exception e) {
- System.out.println("OK");
- }
+ System.out.print(++test+"- "+"Calling enterpriseEntity.remove() (should
fail)...");
+ try {
+ enterpriseEntity.remove();
+ System.out.println("NOT OK");
+ }
+ catch (Exception e) {
+ System.out.println("OK");
+ }
- System.out.print(++test+"- "+"Calling
EnterpriseEntity.create() for marc6...");
+ System.out.print(++test+"- "+"Calling EnterpriseEntity.create() for
marc6...");
EnterpriseEntity marc6 = enterpriseEntityHome.create("marc6");
System.out.println("ok");
@@ -346,11 +349,11 @@
System.out.print(++test+"- "+"removing by PK on home (marc2)...");
enterpriseEntityHome.remove(marc2.getPrimaryKey());
System.out.println("ok");
-
- System.out.print(++test+"- "+"Calling
enterpriseEntity.remove() (marc6)...");
+
+ System.out.print(++test+"- "+"Calling enterpriseEntity.remove()
(marc6)...");
marc6.remove();
System.out.println("ok");
-
+
System.out.println();
@@ -387,10 +390,10 @@
System.out.println(++test+"- "+"Calling business methodB (B2B) on BMP
bean and it says ");
System.out.println(bmpBean.callBusinessMethodB());
-
- System.out.println(++test+"- "+"Calling Business Method
B(String) on BMP... ");
+
+ System.out.println(++test+"- "+"Calling Business Method B(String) on
BMP... ");
System.out.println(bmpBean.callBusinessMethodB("of wisdom"));
-
+
System.out.println(++test+"- "+"calling findCollectionKeys....");
Collection pks = bmpHome.findCollectionKeys(3);
Iterator pkIterator = pks.iterator();
@@ -462,22 +465,22 @@
System.out.println("failed, value is " + newValue);
}
- // Get a new EJBObject for this guy
- // Now we should be able to find it
+ // Get a new EJBObject for this guy
+ // Now we should be able to find it
System.out.print(++test+"- "+"gettting a new reference ... ") ;
- EntityPK pkBean2 = pkHome.findByPrimaryKey(new
AComplexPK(true, 10, 100,1000.0, "Marc"));
+ EntityPK pkBean2 = pkHome.findByPrimaryKey(new AComplexPK(true, 10,
100,1000.0, "Marc"));
if (pkBean2 != null) System.out.println("ok");
- System.out.print(++test+"- "+"Retrieving other field again,
should be 4...");
+ System.out.print(++test+"- "+"Retrieving other field again, should be
4...");
int newValue2 = pkBean2.getOtherField();
if (newValue2 == 4) {
System.out.println("4, ok");
} else {
System.out.println("failed, value is " + newValue2);
- }
+ }
-
-
-
+
+
+
// Now remove it
System.out.println(++test+"- "+"Removing the bean...");
pkBean.remove();
@@ -490,14 +493,73 @@
}
+
+ ///*
+ System.out.println();
+ System.out.println();
+ System.out.println("Test TxSession");
+ System.out.println("==============");
+ System.out.println();
+
+ System.out.print(++test+"- "+"Looking up home for
nextgen.TxSession...");
+ TxSessionHome txHome = (TxSessionHome) ctx.lookup("nextgen.TxSession");
+ if (txHome != null )System.out.println("ok");
+
+ System.out.print(++test+"- "+"Calling create on the home...");
+ TxSession txBean = null;
+
+ // Let's try to create the instance
+ try {
+
+ txBean = txHome.create();
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ }
+
+
+ if (txBean!= null) System.out.println("ok");
+
+ System.out.print(++test+"- "+"calling supports... ");
+ System.out.println(txBean.txSupports());
+
+ System.out.print(++test+"- "+"calling required... ");
+ System.out.println(txBean.txRequired());
+
+ System.out.print(++test+"- "+"calling requiresNew... ");
+ System.out.println(txBean.txRequiresNew());
+
+ System.out.print(++test+"- "+"calling not supported... ");
+ System.out.println(txBean.txNotSupported());
+
+ System.out.print(++test+"- "+"calling mandatory (should get an
exception)...");
+ try {
+ System.out.println(txBean.txMandatory());
+ } catch (Exception e) {
+ System.out.println("got Exception, ok");
+ }
+
+ System.out.print(++test+"- "+"calling requiredToSupports... ");
+ System.out.println(txBean.requiredToSupports());
+
+ System.out.print(++test+"- "+"calling requiredToNotSupported... ");
+ System.out.println(txBean.requiredToNotSupported());
+
+ System.out.print(++test+"- "+"calling requiredToRequiresNew... ");
+ System.out.println(txBean.requiredToRequiresNew());
+
+
+
System.out.println();
System.out.println();
System.out.println();
System.out.println("Test OK, "+test+" tests run, congratulations");
//*/
-
+
+ Date finishDate = new Date();
+ System.out.println("Tests took
"+(finishDate.getTime()-startDate.getTime())+" milliseconds");
/*
System.out.println("Speed test now (1000 iterations) ...");
Date startDate = new Date();