org.jboss.test.util.ejb
Class EJBTestCase

java.lang.Object
  extended byTestCase
      extended byorg.jboss.test.util.ejb.EJBTestCase
Direct Known Subclasses:
EntityExceptionUnitTestCase (src) , ExceptionUnitTestCase (src) , KeyGenerationUnitTestCase (src) , LocalEjbTests (src) , NamingTests (src) , PageSizeUnitTestCase (src) , SimpleUnitTestCase (src)

public class EJBTestCase
extends TestCase

An ejb test case is an extension to test case where the test is executed in the ejb server's virtual machine. Two new methods setUpEJB and tearDownEJB have been added. These methods work just like setUp and tearDown except they run in a sepperate transaction. The execution order is as follows:

 	1. setUpEJB (TX 1)
 	2. run (TX 2)
 		2.1. runBare
 			2.1.1 setUp
 			2.1.2 
 			2.1.3 tearDown
 	3. ejbTearDown (TX 2)
 
For an ejb test case to run successfully, the following must be setup:
 	1. The ejb test case class must be availabe to the client vm.
 	2. The ejb test case class must be availabe to the EJBTestRunner bean
 			on the server.
 	3. The EJBTestRunnerHome must be bound to "ejb/EJBTestRunner" in the
 			jndi context obtained from new InitialContext();
 	4. The EJBTestRunner bean must be configured as specified in the 
 			EJBTestRunner javadoc.
 

See Also:
EJBTestRunner (src) , junit.framework.TestCase, Serialized Form

Field Summary
protected  java.util.Properties props
           
 
Constructor Summary
EJBTestCase(java.lang.String methodName)
          Constructs a test case that will run the method with the specified name.
 
Method Summary
 java.lang.String getEJBRunnerJndiName()
          Allow EJBTestCase subclasses to override the EJBRunnerHome JNDI name
 java.util.Properties getProps()
           
 boolean isServerSide()
          Is this class running on the server side?
 void run(TestResult result)
           
 void runBare()
           
 void setProps(java.util.Properties props)
           
 void setServerSide(boolean serverSide)
          Sets the flag that is used to determine if the class is running on the server side.
 void setUpEJB(java.util.Properties props)
          Sets up the ejb test case.
 void tearDownEJB(java.util.Properties props)
          Tears down the ejb test case.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

props

protected java.util.Properties props
Constructor Detail

EJBTestCase

public EJBTestCase(java.lang.String methodName)
Constructs a test case that will run the method with the specified name.

Parameters:
methodName - the name of the method that will executed when this test is run
Method Detail

setServerSide

public void setServerSide(boolean serverSide)
Sets the flag that is used to determine if the class is running on the server side.

Parameters:
serverSide - boolean flag that this class uses to determine if it's running on the server side.

isServerSide

public boolean isServerSide()
Is this class running on the server side?

Returns:
true if this class is running on the server side

getEJBRunnerJndiName

public java.lang.String getEJBRunnerJndiName()
Allow EJBTestCase subclasses to override the EJBRunnerHome JNDI name

Returns:
The JNDI name of the EJBRunnerHome home interface binding. The default is "ejb/EJBTestRunner"

getProps

public java.util.Properties getProps()
Returns:
the properties associated with the test case

setProps

public void setProps(java.util.Properties props)
Parameters:
props - the properties associated with the test case

run

public void run(TestResult result)

runBare

public void runBare()
             throws java.lang.Throwable
Throws:
java.lang.Throwable

setUpEJB

public void setUpEJB(java.util.Properties props)
              throws java.lang.Exception
Sets up the ejb test case. This method is called before each test is executed and is run in a private transaction.

Parameters:
props - the properties passed in from the client
Throws:
java.lang.Exception - if a problem occures

tearDownEJB

public void tearDownEJB(java.util.Properties props)
                 throws java.lang.Exception
Tears down the ejb test case. This method is called after each test is executed and is run in a private transaction.

Parameters:
props - the properties passed in from the client
Throws:
java.lang.Exception - if a problem occures