The aim of this suite is to provide tests that verify that JOnAS is conform to the EJB Specifications. This suite may be used to control that there is no regression when contributions are made in the JOnAS code. This suite is far from complete and will be incremented in the future. Everybody is welcome for writing and adding new testcases in this suite.
Note that this test suite has been done to test JOnAS, and its use to test other application servers is not straightforward.
Anyone can checkout source code from our anonymous CVS server. To do so, simply use the following commands (if you are using a GUI CVS client, configure it appropriatly):
cvs -d:pserver:anonymous@cvs.jonas.debian-sf.objectweb.org:/cvsroot/jonas login cvs -d:pserver:anonymous@cvs.jonas.debian-sf.objectweb.org:/cvsroot/jonas co jonas_tests
When prompted for a password for anonymous, simply press the Enter key.
Under jonas_tests
you can find currently these test suites :
conformance | test of EJB spec conformance |
stress | test of robustness and scalibility |
perfs | test used for performance measurements |
samplehttp | test used to do load tests for servlet+ejb |
conformance and stress are made of the following files and directories:
build.xml | ant file to build and run all the tests |
src | source files |
junit.sh | script to run 1 or more tests |
The set of sources is organized according to the package name. So, for the conformance test suite, the sources are located in src/org/objectweb/jonas/jtests :
beans | Each directory contains code for a set of beans (an ejb-jar file)
|
||||||||||||||||||||||||||||||||
clients | Each directory contains code for a set of test suites.
|
||||||||||||||||||||||||||||||||
dtds | A local copy of the dtds used in the deployment descriptors. (Useful to be able to edit friendly the DDs with emacs). After a cvs co, this directory is empty. You must run "ant dtds" to populate this directory. | ||||||||||||||||||||||||||||||||
tables | The definition of a session bean used for creating and initialize the database tables used by tests. This is not used in case of entity beans CMP2.x because the container is able to create the tables if they don't exist yet. | ||||||||||||||||||||||||||||||||
templates | Templates of a test suite. | ||||||||||||||||||||||||||||||||
util | Utility classes. |
This test has been designed to be compiled and run using Ant.
Ant must be installed (with the optional tasks package) and the environment variables
%ANT_HOME%
or $ANT_HOME
must be set.
$ANT_HOME/bin
must have been added to the PATH
environment variable.
The xalan product must be installed, and the xalan.jar
must be present in $ANT_HOME/lib
.
(xalan is necessary for the JUnitReport ant task).
The JUnit product must also be installed, and the junit.jar
must be present in $ANT_HOME/lib
.
For xalan and JUnit, you may also choose to update the file
$JONAS_ROOT/bin/unix/config_env (on Unix) or %JONAS_ROOT%\bin\nt\config_env.bat
(on Windows) by adding the path to xalan.jar
and junit.jar
in the predefined classpath used by JOnAS which is defined in this file.
clean | for deleting all generated classes |
install | for installing ejbjars under $JONAS_ROOT/ejbjars This target should be used to rebuild all the test suite. |
runtest | to run the all set and produce a report |
To build the jonas tests :
ant install
You can launch the complete JOnAS test suite via Ant and obtain a test suite report.
You should use the CLASSPATH environment variable or modify the predefined classpath used by JOnAS in the $JONAS_ROOT/bin/unix/config_env (on Unix) or %JONAS_ROOT%\bin\nt\config_env.bat (on Windows) file, by adding the path to jonas_tests/conformance/classes/$OBJECTWEB_ORB.
jonas.services
property.It may be interesting to launch only one of the suites or only one testcase of a test suite, particularly to debug a testcase that fails.
For that, there is a script jonas_tests/conformance/junit.sh that can be run. Depending on the number of arguments, you will run
Exemple:
sh junit.sh security sh junit.sh entity F_BasicHomeInterfaceEB testFinderEnumObjNotFound
In order to have an homogeneous suite we have defined strict naming conventions that it is worth to follow. This make easier the understanding of a test suite.
The coding convention are related to :
bdir | directory for this bean |
bname | name of this bean |
optional remote interface | bname |
optional home interface | bnameHome |
optional local interface | bnameLocal |
optional local home interface | bnameLocalHome |
bean class implementation | bnameXX |
optional primary key class | bnamePK |
jar file name | bname.jar |
ejb-name in dd | bnameXX |
display-name in dd | bdir/bnameXX |
JNDI name for home | bdirbnameXXHome |
table name in DB (entity) | JT_bdirbnameXX |
field names (entity CMP) | c_field |
XX must be one of the following values :
EB | entity bean with bean managed persistence |
EC | entity bean with container managed persistence(cmp version 1.x) |
EC2 | entity bean with container managed persistence(cmp version 2.x) |
SL | session bean stateless |
SF | session bean stateful |
SY | session bean stateful implementing Synchronization interface |
ST | session bean stateful with bean managed transactions |
MD | message driven bean |
Note : that these rules are inforced when using the Newbean tool.
Each directory in src/org/objectweb/jonas/jtests/clients holds a set of test suites relative to a common topic (entity, session, transaction, etc...). To ease the readability of these files and to know what Suite can be run with 1 testcase, we have enforced these naming conventions :
A_name.java | Abstract class holding test cases shared by several suites. These files cannot be run as a test suite, since they do not have a main. |
C_name.java | Composite Suites that link several Suites together. They can be run separatly, but not with only 1 testCase. Their main routine should be very simple, only 1 ligne. |
F_name.java | Final Suites that can be run separatly or with only 1 testCase. They must have a main routine with a -n arg to be able to be run with a specified test case. |
Coding conventions are the same for jonas or for jonas_tests. They must follow Code Conventions for the JavaTM Programming Language
Adding a new test case is pretty straightforward. Have a look at the test already written, and mimic them. Basically, you will not have to catch exceptions, most of the time, so the tests look very simple. You can refer to the junit primer for more details.
Today, you must follow the same rules than for jonas.