User: d_jencks
Date: 01/09/14 17:12:16
Modified: src/main/org/jboss/test/bmp/test BmpUnitTestCase.java
Log:
Made tests work and converted to JBossTestCase and logging
Revision Changes Path
1.2 +44 -68 jbosstest/src/main/org/jboss/test/bmp/test/BmpUnitTestCase.java
Index: BmpUnitTestCase.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/bmp/test/BmpUnitTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BmpUnitTestCase.java 2001/09/12 04:55:38 1.1
+++ BmpUnitTestCase.java 2001/09/15 00:12:16 1.2
@@ -1,3 +1,10 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
package org.jboss.test.bmp.test;
@@ -8,10 +15,11 @@
import org.jboss.test.bmp.interfaces.*;
import junit.framework.*;
-import org.jboss.test.util.Deploy;
+
+import org.jboss.test.JBossTestCase;
public class BmpUnitTestCase
- extends TestCase
+ extends JBossTestCase
{
private boolean deployed;
@@ -25,99 +33,89 @@
BMPHelperSessionHome sessionHome = (BMPHelperSessionHome)new InitialContext
().lookup ("bmp.BMPHelperSession");
BMPHelperSession session = sessionHome.create ();
- System.out.println ("looking up table:");
+ getLog().debug ("looking up table:");
boolean exists = session.existsSimpleBeanTable ();
if (exists)
{
- System.out.println ("table exists.");
- System.out.print ("delete it...");
+ getLog().debug ("table exists.");
+ getLog().debug ("delete it...");
session.dropSimpleBeanTable();
- System.out.println ("done.");
+ getLog().debug ("done.");
}
else
{
- System.out.println ("table does not exist.");
- System.out.print ("create it...");
+ getLog().debug ("table does not exist.");
+ getLog().debug ("create it...");
session.createSimpleBeanTable();
- System.out.println ("done.");
- System.out.println ();
+ getLog().debug ("done.");
- System.out.println ("start playing with bmp beans.");
- System.out.println ();
+ getLog().debug ("start playing with bmp beans.");
SimpleBMPHome home = (SimpleBMPHome)new InitialContext ().lookup
("bmp.SimpleBMP");
- System.out.println ("create bean1: 1, Daniel");
+ getLog().debug ("create bean1: 1, Daniel");
SimpleBMP b1 = home.create (1, "Daniel");
- System.out.println ("getName (): "+b1.getName ());
- System.out.println ();
+ getLog().debug ("getName (): "+b1.getName ());
- System.out.println ("create bean2: 2, Robert");
+ getLog().debug ("create bean2: 2, Robert");
b1 = home.create (2, "Robert");
- System.out.println ("getName (): "+b1.getName ());
- System.out.println ();
+ getLog().debug ("getName (): "+b1.getName ());
try
{
- System.out.println ("trying to create one with same primkey: 1,
Patrick");
+ getLog().debug ("trying to create one with same primkey: 1, Patrick");
b1 = home.create (1, "Patrick");
}
catch (Exception _e)
{
- System.out.println (_e.toString ());
+ getLog().debug (_e.toString ());
}
- System.out.println ();
- System.out.println ("create some more dummys:");
+ getLog().debug ("create some more dummys:");
for (int i = 0; i < 50; ++i)
home.create (i + 3, ("Dummy "+i));
- System.out.println ();
try
{
- System.out.println ("trying to find Robert again");
+ getLog().debug ("trying to find Robert again");
b1 = home.findByPrimaryKey (new Integer (2));
- System.out.println ("getName (): "+b1.getName ());
+ getLog().debug ("getName (): "+b1.getName ());
}
catch (Exception _e)
{
- System.out.println (_e.toString ());
+ getLog().debug (_e.toString ());
}
- System.out.println ();
try
{
- System.out.println ("trying to find an not existing bean");
+ getLog().debug ("trying to find an not existing bean");
b1 = home.findByPrimaryKey (new Integer (0));
- System.out.println ("getName (): "+b1.getName ());
+ getLog().debug ("getName (): "+b1.getName ());
}
catch (Exception _e)
{
- System.out.println (_e.toString ());
+ getLog().debug (_e.toString ());
}
- System.out.println ();
- System.out.println ("rename Daniel to Maria: 1, Daniel");
+ getLog().debug ("rename Daniel to Maria: 1, Daniel");
b1 = home.findByPrimaryKey (new Integer (1));
- System.out.println ("name old: " + b1.getName ());
+ getLog().debug ("name old: " + b1.getName ());
b1.setName ("Maria");
- System.out.println ("name new: " + b1.getName ());
+ getLog().debug ("name new: " + b1.getName ());
- System.out.println ();
- System.out.println ("find all beans:");
+ getLog().debug ("find all beans:");
Iterator it = home.findAll ().iterator ();
while (it.hasNext ())
{
- System.out.println ("found:"+((SimpleBMP)it.next ()).getName ());
+ getLog().debug ("found:"+((SimpleBMP)it.next ()).getName ());
}
- System.out.println ();
- System.out.println ("Now trying from within the Session bean (to be able
to rollback):");
- System.out.println (session.doTest ());
+ getLog().debug ("Now trying from within the Session bean (to be able to
rollback):");
+ getLog().debug (session.doTest ());
- System.out.println ("removing all beans:");
+ getLog().debug ("removing all beans:");
it = home.findAll ().iterator ();
while (it.hasNext ())
((SimpleBMP)it.next ()).remove ();
@@ -127,37 +125,15 @@
protected void setUp() throws Exception
{
-// if (deployed) return;
-// String deployDir = System.getProperty("jbosstest.deploy.dir");
-// if( deployDir == null )
-// deployDir = "../deploy";
-// System.out.println("deployDir = "+deployDir);
-// new org.jboss.jmx.client.Deployer().deploy(deployDir+"/bmp.jar");
-// deployed = true;
+ super.setUp();
+ deployJ2ee("bmp.jar");
}
- public static void main (String[] _args) throws Exception
+ protected void tearDown() throws Exception
{
- BmpUnitTestCase m = new BmpUnitTestCase("BmpUnitTestCase");
- m.setUp();
- m.testBMP();
+ undeployJ2ee("bmp.jar");
+ super.tearDown();
}
- /**
- * Setup the test suite.
- */
- public static Test suite() {
- TestSuite suite = new TestSuite();
-
- // add a test case to deploy our support applications
- String filename = "bmp.jar";
- suite.addTest(new Deploy.Deployer(filename));
-
- suite.addTest(new TestSuite(BmpUnitTestCase.class));
- // add a test case to undeploy our support applications
- suite.addTest(new Deploy.Undeployer(filename));
-
- return suite;
- }
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development