[jboss-cvs] jboss-ejb3/src/test/org/jboss/ejb3/test/standalone/unit ...
Bill DeCoste
bdecoste at jboss.com
Mon Jul 24 17:28:28 EDT 2006
User: bdecoste
Date: 06/07/24 17:28:28
Modified: src/test/org/jboss/ejb3/test/standalone/unit
StandardTestCase.java
Log:
MDB cleanup, standalone test for standard testcases, fixed class level @Resources jndi env bindings
Revision Changes Path
1.3 +77 -20 jboss-ejb3/src/test/org/jboss/ejb3/test/standalone/unit/StandardTestCase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: StandardTestCase.java
===================================================================
RCS file: /cvsroot/jboss/jboss-ejb3/src/test/org/jboss/ejb3/test/standalone/unit/StandardTestCase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- StandardTestCase.java 30 Jun 2006 19:23:45 -0000 1.2
+++ StandardTestCase.java 24 Jul 2006 21:28:28 -0000 1.3
@@ -45,7 +45,7 @@
import org.jboss.logging.Logger;
/**
- * @version <tt>$Revision: 1.2 $</tt>
+ * @version <tt>$Revision: 1.3 $</tt>
* @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
*/
public class StandardTestCase extends TestCase
@@ -59,8 +59,8 @@
static
{
- tests.put("org.jboss.ejb3.test.jca.inflowmdb.unit.InflowUnitTestCase", "jmsinflowmdb.jar");
-// tests.put("org.jboss.ejb3.test.mdb.unit.MDBUnitTestCase", "mdb-test.jar");
+ tests.put("org.jboss.ejb3.test.jca.inflowmdb.unit.InflowUnitTestCase", new StandardTestCaseTest("jmsinflowmdb.jar", "testJMS", null));
+ tests.put("org.jboss.ejb3.test.mdb.unit.MDBUnitTestCase", new StandardTestCaseTest("mdb-test.jar", null, "security-beans.xml, mdbtest-service.xml"));
}
public StandardTestCase(String name)
@@ -75,7 +75,7 @@
// setup test so that embedded JBoss is started/stopped once for all tests here.
- TestSetup wrapper = new TestSetup(suite)
+ /* TestSetup wrapper = new TestSetup(suite)
{
protected void setUp()
{
@@ -88,15 +88,28 @@
}
};
- return wrapper;
+ return wrapper;*/
+
+ return suite;
}
- public static void startupEmbeddedJboss()
+ public static void startupEmbeddedJboss(StandardTestCaseTest test)
{
EJB3StandaloneBootstrap.boot(null);
EJB3StandaloneBootstrap.deployXmlResource("jboss-jms-beans.xml");
EJB3StandaloneBootstrap.deployXmlResource("embeddedjms/testjms.xml");
EJB3StandaloneBootstrap.deployXmlResource("standard/testjms.xml");
+ EJB3StandaloneBootstrap.deployXmlResource("jca-inflowmdb-beans.xml");
+
+ if (test.xmlResources != null)
+ {
+ StringTokenizer tokenizer = new StringTokenizer(test.xmlResources, ",");
+ while (tokenizer.hasMoreTokens())
+ {
+ String testXml = tokenizer.nextToken();
+ EJB3StandaloneBootstrap.deployXmlResource(testXml);
+ }
+ }
}
public static void shutdownEmbeddedJboss()
@@ -127,34 +140,66 @@
public void testStandardTests() throws Throwable
{
- log.info("!! testStandardTests");
Iterator standardTests = tests.keySet().iterator();
while (standardTests.hasNext())
{
String testClass = (String)standardTests.next();
- String testJars = (String)tests.get(testClass);
+ StandardTestCaseTest test = (StandardTestCaseTest)tests.get(testClass);
+ System.out.println("!! testClass " + testClass);
+
+ startupEmbeddedJboss(test);
EJB3StandaloneDeployer deployer = new EJB3StandaloneDeployer();
deployer.setKernel(EJB3StandaloneBootstrap.getKernel());
deployer.setJndiProperties(getInitialContextProperties());
- StringTokenizer tokenizer = new StringTokenizer(testJars, ",");
+ if (test.deployments != null)
+ {
+ StringTokenizer tokenizer = new StringTokenizer(test.deployments, ",");
while (tokenizer.hasMoreTokens())
{
String testJar = tokenizer.nextToken();
URL archive = Thread.currentThread().getContextClassLoader().getResource(testJar);
deployer.getArchives().add(archive);
}
+ }
+ if (test.testMethods != null)
+ runTest(deployer, testClass, test.testMethods);
+ else
runTest(deployer, testClass);
+
+ shutdownEmbeddedJboss();
}
}
- private void runTest(EJB3StandaloneDeployer deployer, String testClassName)
+ private void runTest(EJB3StandaloneDeployer deployer, String testClassName, String methods)
throws Exception
{
- log.info("!! runTest " + testClassName);
+ startTest(deployer);
+
+ Class testClass = Thread.currentThread().getContextClassLoader().loadClass(testClassName);
+ String[] constructorParams = {testClass.getName()};
+ Class[] constructorSignature = {String.class};
+ Constructor constructor = testClass.getConstructor(constructorSignature);
+ Object testCase = constructor.newInstance(constructorParams);
+ Class[] signature = new Class[0];
+ StringTokenizer methodTokenizer = new StringTokenizer(methods, ",");
+ Object[] params = new Object[0];
+ while (methodTokenizer.hasMoreTokens())
+ {
+ String methodName = methodTokenizer.nextToken();
+ Method method = testClass.getMethod(methodName, signature);
+ method.invoke(testCase, params);
+ }
+
+ stopTest(deployer);
+ }
+
+ private void runTest(EJB3StandaloneDeployer deployer, String testClassName)
+ throws Exception
+ {
startTest(deployer);
Class testClass = Thread.currentThread().getContextClassLoader().loadClass(testClassName);
@@ -166,10 +211,8 @@
Object[] params = new Object[0];
for (Method method: testClass.getMethods())
{
- log.info("!! checking method " + method.getName() + " " + method.getName().startsWith("test") + " " + method.isAccessible() + " " + method.getParameterTypes().length);
if (method.getName().startsWith("test") && method.getParameterTypes().length == 0)
{
- log.info("!!! invoking " + method.getName());
method.invoke(testCase, params);
}
}
@@ -190,4 +233,18 @@
deployer.stop();
deployer.destroy();
}
+
+ static class StandardTestCaseTest
+ {
+ public String deployments;
+ public String testMethods;
+ public String xmlResources;
+
+ public StandardTestCaseTest(String deployments, String testMethods, String xmlResources)
+ {
+ this.deployments = deployments;
+ this.testMethods = testMethods;
+ this.xmlResources = xmlResources;
+ }
+ }
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list