User: fleury
Date: 00/08/11 17:50:11
Modified: src/java/org/jboss/zol/testbean/client EjbossClient.java
Log:
count the number of tests
Revision Changes Path
1.14 +78 -75 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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- EjbossClient.java 2000/08/12 00:27:46 1.13
+++ EjbossClient.java 2000/08/12 00:50:11 1.14
@@ -30,11 +30,10 @@
/**
- * Sample client for the EJBoss nextGen container.
- * It works with the HelloWorld2.jar bean jar.
+ * Sample client for the jboss container.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
- * @version $Id: EjbossClient.java,v 1.13 2000/08/12 00:27:46 fleury Exp $
+ * @version $Id: EjbossClient.java,v 1.14 2000/08/12 00:50:11 fleury Exp $
*/
public class EjbossClient {
@@ -52,9 +51,12 @@
System.out.println("Welcome to the test Suite v1.0");
System.out.println("_____________________________________________");
System.out.println();
- System.out.print("Trying the context...");
+
+ int test = 0;
+
+ System.out.print(++test+"- "+"Trying the context...");
- Context ctx = new InitialContext();
+ Context ctx = new InitialContext();
System.out.println("OK");
@@ -62,27 +64,27 @@
System.out.println("Test Stateless Bean");
System.out.println("===================");
System.out.println();
- System.out.print("Looking up the home nextgen.StatelessSession...");
+ System.out.print(++test+"- "+"Looking up the home
nextgen.StatelessSession...");
StatelessSessionHome statelessSessionHome =
(StatelessSessionHome) ctx.lookup("nextgen.StatelessSession");
if (statelessSessionHome!= null ) System.out.println("ok");
- System.out.print("Calling create on StatelessSessionHome...");
+ System.out.print(++test+"- "+"Calling create on
StatelessSessionHome...");
StatelessSession statelessSession =
statelessSessionHome.create();
if (statelessSession != null) System.out.println("ok");
- System.out.print("Calling getEJBHome() on StatelessSession...");
+ System.out.print(++test+"- "+"Calling getEJBHome() on
StatelessSession...");
if (statelessSession.getEJBHome() != null) System.out.println("ok");
else throw new Exception ("Null home not OK");
- System.out.print("Calling Business Method A on StatelessSession... ");
+ System.out.print(++test+"- "+"Calling Business Method A on
StatelessSession... ");
statelessSession.callBusinessMethodA();
System.out.println("ok");
- System.out.println("Calling Business Method B on StatelessSession... ");
+ System.out.println(++test+"- "+"Calling Business Method B on
StatelessSession... ");
System.out.println(statelessSession.callBusinessMethodB());
- System.out.println("Calling Business Method C on StatelessSession... ");
+ System.out.println(++test+"- "+"Calling Business Method C on
StatelessSession... ");
System.out.println(statelessSession.callBusinessMethodC());
- System.out.println("Calling Business Method D on StatelessSession... ");
+ System.out.println(++test+"- "+"Calling Business Method D on
StatelessSession... ");
try {
statelessSession.callBusinessMethodD();
System.out.println("ERROR, no exception was thrown");
@@ -93,10 +95,10 @@
catch (Exception e) {
System.out.println("ERROR, type "+e.getClass());
}
- System.out.print("Calling Business Method E (getEJBObject) on
StatelessSession... ");
+ System.out.print(++test+"- "+"Calling Business Method E (getEJBObject)
on StatelessSession... ");
System.out.println(statelessSession.callBusinessMethodE());
- System.out.print("Calling testClassLoading on StatelessSession... ");
+ System.out.print(++test+"- "+"Calling testClassLoading on
StatelessSession... ");
try {
statelessSession.testClassLoading();
System.out.println("OK");
@@ -109,95 +111,95 @@
}
System.out.println("***Testing the various local Object class
calls");
- System.out.print("toString ... ");
+ System.out.print(++test+"- "+"toString ... ");
System.out.println(statelessSession.toString());
- System.out.print("hashCode ... ");
+ System.out.print(++test+"- "+"hashCode ... ");
System.out.println(statelessSession.hashCode());
- System.out.print("equals (same object) ... ");
+ System.out.print(++test+"- "+"equals (same object) ... ");
System.out.println(statelessSession.equals(statelessSession));
- System.out.print("equals (another object) (true under same
home)... ");
+ System.out.print(++test+"- "+"equals (another object) (true
under same home)... ");
System.out.println(statelessSession.equals(statelessSessionHome.create()));
System.out.println("***Testing the various local EJBObject
class calls");
- System.out.print("Get Primary Key ... ");
+ System.out.print(++test+"- "+"Get Primary Key ... ");
System.out.println(statelessSession.getPrimaryKey());
- System.out.print("Get Handle ... ");
+ System.out.print(++test+"- "+"Get Handle ... ");
Handle statelessHandle = statelessSession.getHandle();
if (statelessHandle != null) System.out.println("OK");
- System.out.print("Serialize handle and deserialize....");
+ System.out.print(++test+"- "+"Serialize handle and
deserialize..");
MarshalledObject mo = new MarshalledObject(statelessHandle);
Handle handle2 = (Handle) mo.get();
StatelessSession statelessSession2 = (StatelessSession)
handle2.getEJBObject();
if (statelessSession2 != null) System.out.println("OK");
- System.out.println("Calling businessMethodB on it...");
+ System.out.println(++test+"- "+"Calling businessMethodB on
it...");
System.out.println(statelessSession2.callBusinessMethodB());
- System.out.println("They should be
identical..."+statelessSession.isIdentical(statelessSession2));
+ System.out.println(++test+"- "+"They should be
identical..."+statelessSession.isIdentical(statelessSession2));
System.out.println("***Testing the various local EJBHome class
calls");
- System.out.print("Getting the metaData...");
+ System.out.print(++test+"- "+"Getting the metaData...");
EJBMetaData statelessMetaData =
statelessSessionHome.getEJBMetaData();
if (statelessMetaData != null) System.out.println("OK");
else System.out.println("NULL METADATA");
- System.out.println("Is stateless Session?
"+statelessMetaData.isStatelessSession());
- System.out.println("The remote class is
"+statelessMetaData.getRemoteInterfaceClass());
+ System.out.println(++test+"- "+"Is stateless Session?
"+statelessMetaData.isStatelessSession());
+ System.out.println(++test+"- "+"The remote class is
"+statelessMetaData.getRemoteInterfaceClass());
System.out.println("");
- System.out.print("Calling StatelessSession.remove()...");
+ System.out.print(++test+"- "+"Calling StatelessSession.remove()...");
statelessSession.remove();
System.out.println("ok");
- */
- /*
+ // */
+ ///*
System.out.println();
System.out.println("Test Stateful Bean");
System.out.println("==================");
System.out.println();
- System.out.print("Looking up the home nextgen.StatefulSession...");
+ System.out.print(++test+"- "+"Looking up the home
nextgen.StatefulSession...");
StatefulSessionHome statefulSessionHome =
(StatefulSessionHome) ctx.lookup("nextgen.StatefulSession");
if (statefulSessionHome!= null ) System.out.println("ok");
- System.out.print("Calling create on StatefulSessionHome with name
Marc...");
+ System.out.print(++test+"- "+"Calling create on StatefulSessionHome
with name Marc...");
StatefulSession statefulSession =
statefulSessionHome.create("Marc");
if (statefulSession != null) System.out.println("ok");
- System.out.print("Calling getEJBHome() on StatefulSession...");
+ System.out.print(++test+"- "+"Calling getEJBHome() on
StatefulSession...");
if (statefulSession.getEJBHome() != null) System.out.println("ok");
else throw new Exception ("null home not ok");
- System.out.println("Calling Business Method A on StatefulSession... ");
+ System.out.println(++test+"- "+"Calling Business Method A on
StatefulSession... ");
System.out.println(statefulSession.callBusinessMethodA());
- System.out.println("Calling Business Method A (state) on
StatefulSession... ");
+ System.out.println(++test+"- "+"Calling Business Method A (state) on
StatefulSession... ");
System.out.println(statefulSession.callBusinessMethodA());
- System.out.print("Calling Business Method B (EJBObject) on
StatefulSession... ");
+ System.out.print(++test+"- "+"Calling Business Method B (EJBObject) on
StatefulSession... ");
System.out.println(statefulSession.callBusinessMethodB());
System.out.println("***Testing the various local Object class
calls");
- System.out.print("toString ... ");
+ System.out.print(++test+"- "+"toString ... ");
System.out.println(statefulSession.toString());
- System.out.print("hashCode ... ");
+ System.out.print(++test+"- "+"hashCode ... ");
System.out.println(statefulSession.hashCode());
- System.out.print("equals (same object) ... ");
+ System.out.print(++test+"- "+"equals (same object) ... ");
System.out.println(statefulSession.equals(statefulSession));
- System.out.print("equals (another object) (false under same
home)... ");
+ System.out.print(++test+"- "+"equals (another object) (false
under same home)... ");
System.out.println(statefulSession.equals(statefulSessionHome.create()));
System.out.println("***Testing the various local EJBObject
class calls");
- System.out.print("Get Primary Key ... ");
+ System.out.print(++test+"- "+"Get Primary Key ... ");
System.out.println(statefulSession.getPrimaryKey());
- System.out.print("Get Handle ... ");
+ System.out.print(++test+"- "+"Get Handle ... ");
Handle statefulHandle = statefulSession.getHandle();
if (statefulHandle != null) System.out.println("OK");
- System.out.print("Serialize handle and deserialize....");
+ System.out.print(++test+"- "+"Serialize handle and
deserialize....");
MarshalledObject mo2 = new MarshalledObject(statefulHandle);
Handle statefulHandle2 = (Handle) mo2.get();
StatefulSession statefulSession2 = (StatefulSession)
statefulHandle2.getEJBObject();
if (statefulSession2 != null) System.out.println("OK");
- System.out.println("Calling businessMethodB on it...");
+ System.out.println(++test+"- "+"Calling businessMethodB on
it...");
System.out.println(statefulSession2.callBusinessMethodB());
- System.out.println("They should be
identical..."+statefulSession.isIdentical(statefulSession2));
+ System.out.println(++test+"- "+"They should be
identical..."+statefulSession.isIdentical(statefulSession2));
- System.out.print("Calling StatefulSession.remove()...");
+ System.out.print(++test+"- "+"Calling
StatefulSession.remove()...");
statefulSession.remove();
System.out.println("ok");
- System.out.print("Calling StatefulHome.remove(Handle) (for second
bean)...");
+ System.out.print(++test+"- "+"Calling StatefulHome.remove(Handle) (for
second bean)...");
statefulSessionHome.remove(statefulSession2.getHandle());
- */
+ //*/
///*
System.out.println();
@@ -205,10 +207,10 @@
System.out.println("Test Entity Bean CMP");
System.out.println("====================");
System.out.println();
- System.out.println("Looking up the home nextgen.EnterpriseEntity...ok");
+ System.out.println(++test+"- "+"Looking up the home
nextgen.EnterpriseEntity...ok");
EnterpriseEntityHome enterpriseEntityHome = (EnterpriseEntityHome)
ctx.lookup("nextgen.EnterpriseEntity");
- System.out.print("Calling find on EnterpriseEntityHome with name
Marc...");
+ System.out.print(++test+"- "+"Calling find on EnterpriseEntityHome with
name Marc...");
EnterpriseEntity enterpriseEntity = null;
try {
enterpriseEntity = enterpriseEntityHome.findByPrimaryKey("Marc");
@@ -217,13 +219,13 @@
if (enterpriseEntity == null) {
System.out.println("not found OK");
- System.out.print("Calling create on EnterpriseEntityHome with name
Marc...");
+ System.out.print(++test+"- "+"Calling create on
EnterpriseEntityHome with name Marc...");
enterpriseEntity = enterpriseEntityHome.create("Marc");
}
if (enterpriseEntity != null) System.out.println("ok");
- System.out.print("Calling for duplicate create and
DuplicateKeyException...");
+ System.out.print(++test+"- "+"Calling for duplicate create and
DuplicateKeyException...");
try {
enterpriseEntityHome.create("Marc");
System.out.println("I Really should not make it here");
@@ -232,11 +234,11 @@
catch (DuplicateKeyException dke) {
System.out.println("ok");
}
- System.out.print("Calling getEJBHome() on EntityCMP...");
+ System.out.print(++test+"- "+"Calling getEJBHome() on EntityCMP...");
if (enterpriseEntity.getEJBHome() != null) System.out.println("ok");
else throw new Exception ("new home not ok");
- System.out.print("Getting a new reference with findByPK...");
+ System.out.print(++test+"- "+"Getting a new reference with
findByPK...");
EnterpriseEntity enterpriseEntity2 = null;
try {
enterpriseEntity2 =
enterpriseEntityHome.findByPrimaryKey("Marc");
@@ -246,26 +248,26 @@
}
if (enterpriseEntity2 != null) System.out.println("ok");
else System.out.println("not ok");
- System.out.println("Calling Business Method A on enterpriseEntity... ");
+ System.out.println(++test+"- "+"Calling Business Method A on
enterpriseEntity... ");
System.out.println(enterpriseEntity.callBusinessMethodA());
- System.out.println("Calling Business Method A (again to
ejbLoad if TypeC) on enterpriseEntity... ");
+ System.out.println(++test+"- "+"Calling Business Method A
(again to ejbLoad if TypeC) on enterpriseEntity... ");
System.out.println(enterpriseEntity.callBusinessMethodA());
- System.out.println("Calling Business Method B (EJBObject from
entity) on enterpriseEntity...");
+ System.out.println(++test+"- "+"Calling Business Method B
(EJBObject from entity) on enterpriseEntity...");
System.out.println(enterpriseEntity.callBusinessMethodB());
- System.out.print("Calling method createEntity on enterpriseEntity... ");
+ System.out.print(++test+"- "+"Calling method createEntity on
enterpriseEntity... ");
EnterpriseEntity marc2 = enterpriseEntity.createEntity("marc2");
System.out.println("OK");
- System.out.print("Calling EnterpriseEntity.remove() for marc2...");
+ System.out.print(++test+"- "+"Calling EnterpriseEntity.remove() for
marc2...");
marc2.remove();
System.out.println("ok");
- System.out.print("Calling EnterpriseEntity.remove() for marc...");
+ System.out.print(++test+"- "+"Calling EnterpriseEntity.remove() for
marc...");
enterpriseEntity.remove();
System.out.println("ok");
@@ -282,28 +284,28 @@
System.out.println();
- System.out.print("Looking up home for nextgen.EntityBMP...");
+ System.out.print(++test+"- "+"Looking up home for
nextgen.EntityBMP...");
EntityBMPHome bmpHome = (EntityBMPHome) ctx.lookup("nextgen.EntityBMP");
if (bmpHome != null )System.out.println("ok");
// the current test will always return
- System.out.print("Calling create on the home...");
+ System.out.print(++test+"- "+"Calling create on the home...");
EntityBMP bmpBean = bmpHome.create("Marc");
if (bmpBean!= null) System.out.println("ok");
// Let's call a business method to see the flow of server calls
- System.out.print("Calling getEJBHome() on EntityBMP...");
+ System.out.print(++test+"- "+"Calling getEJBHome() on EntityBMP...");
if (bmpBean.getEJBHome() != null) System.out.println("ok");
else throw new Exception("Null Home");
- System.out.print("Calling business methodA on BMP bean...");
+ System.out.print(++test+"- "+"Calling business methodA on BMP bean...");
bmpBean.callBusinessMethodA();
- System.out.println("Calling business methodB (B2B) on BMP bean and it
says ");
+ System.out.println(++test+"- "+"Calling business methodB (B2B) on BMP
bean and it says ");
System.out.println(bmpBean.callBusinessMethodB());
- System.out.println("calling findCollectionKeys....");
+ System.out.println(++test+"- "+"calling findCollectionKeys....");
Collection pks = bmpHome.findCollectionKeys(3);
Iterator pkIterator = pks.iterator();
while (pkIterator.hasNext()) {
@@ -312,7 +314,7 @@
}
System.out.println("ok");
- System.out.println("calling findEnumeratedKeys....");
+ System.out.println(++test+"- "+"calling findEnumeratedKeys....");
Enumeration pksEnumeration = bmpHome.findEnumeratedKeys(3);
while (pksEnumeration.hasMoreElements()) {
EntityBMP currentBean = (EntityBMP)pksEnumeration.nextElement();
@@ -327,11 +329,11 @@
System.out.println("====================");
System.out.println();
- System.out.print("Looking up home for nextgen.EntityPK...");
+ System.out.print(++test+"- "+"Looking up home for nextgen.EntityPK...");
EntityPKHome pkHome = (EntityPKHome) ctx.lookup("nextgen.EntityPK");
if (pkHome != null )System.out.println("ok");
- System.out.print("Calling find on the home...");
+ System.out.print(++test+"- "+"Calling find on the home...");
EntityPK pkBean = null;
// Let's try to find the instance
@@ -341,24 +343,24 @@
} catch (Exception e) {
System.out.println("not found");
- System.out.print("Did not find the instance will create it...");
+ System.out.print(++test+"- "+"Did not find the instance will create
it...");
pkBean = pkHome.create(true, 10,100, 1000.0, "Marc");
}
if (pkBean!= null) System.out.println("ok");
- System.out.print("Retrieving other field...");
+ System.out.print(++test+"- "+"Retrieving other field...");
if (pkBean.getOtherField() == 0) {
System.out.println("0, ok");
} else {
System.out.println("failed");
}
- System.out.print("Setting it to 4...");
+ System.out.print(++test+"- "+"Setting it to 4...");
pkBean.setOtherField(4);
System.out.println("ok");
- System.out.print("Findind it again ... ") ;
+ System.out.print(++test+"- "+"Findind it again ... ") ;
// Now we should be able to find it
pkBean = pkHome.findByPrimaryKey(new AComplexPK(true, 10, 100,1000.0,
"Marc"));
@@ -366,7 +368,7 @@
if (pkBean != null) System.out.println("ok");
// check if the other field has been saved
- System.out.print("Retrieving other field again, should be
4...");
+ System.out.print(++test+"- "+"Retrieving other field again,
should be 4...");
int newValue = pkBean.getOtherField();
if (newValue == 4) {
System.out.println("4, ok");
@@ -375,9 +377,10 @@
}
// Now remove it
- System.out.println("Removing the bean...");
+ System.out.println(++test+"- "+"Removing the bean...");
pkBean.remove();
try {
+ System.out.println(++test+"- "+"I should not find it...");
pkBean = pkHome.findByPrimaryKey(new AComplexPK(true, 10, 100,
1000.0, "Marc"));
} catch (Exception e) {
@@ -388,7 +391,7 @@
System.out.println();
System.out.println();
System.out.println();
- System.out.println("Test OK, congratulations");
+ System.out.println("Test OK, "+test+" tests run, congratulations");
//*/