From: David J. <d_j...@us...> - 2002-08-20 04:59:50
|
User: d_jencks Date: 02/08/19 21:59:49 Added: src/main/org/jboss/test/jca/test XAResourceUnitTestCase.java Log: First draft of port of Igor Fedorenko's XAResource tests to test jca adapters running inside jboss. Currently only tests firebird driver if present. To test wrapped xadatasources, deploy one and add a section to suite in XAResourceUnitTestCase. A class for jms tests is included but the doStuff is not implemented. Some changes to base test classes prevent tests from being reported if setup fails: this reduces the total test count. These generally show tests=0, errors=1 Revision Changes Path 1.1 jbosstest/src/main/org/jboss/test/jca/test/XAResourceUnitTestCase.java Index: XAResourceUnitTestCase.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. * */ package org.jboss.test.jca.test; import javax.management.ObjectName; import org.jboss.test.JBossTestCase; import org.jboss.test.JBossTestServices; import org.jboss.test.JBossTestSetup; import junit.framework.Test; import junit.framework.TestSuite; /** * XAResourceUnitTestCase.java * * * Created: Thu Aug 15 22:31:49 2002 * * @author <a href="mailto:d_j...@us...">David Jencks</a> * @version */ public class XAResourceUnitTestCase extends JBossTestCase { private final static ObjectName XARESOURCETEST_NAME = createObjectName("jboss.test.jca:service=XAResourceTest"); private final static ObjectName JDBC_HELPER = createObjectName("jboss.test.jca:service=JDBCHelper"); /** @todo write the jms helper */ private final static ObjectName JMS_HELPER = createObjectName("jboss.test.jca:service=JMSHelper"); private static ObjectName createObjectName(final String name) { try { return new ObjectName(name); } catch (Exception e) { throw new RuntimeException("Could not create object names!!" + e); } // end of try-catch } private final static String OBJECT_NAME_NAME = ObjectName.class.getName(); public XAResourceUnitTestCase(String name) { super(name); } public static Test suite() throws Exception { try { JBossTestServices.getStaticLog().info("in suite"); TestSuite suite = new TestSuite(); TestSuite test = new TestSuite(XAResourceUnitTestCase.class); //To add tests for another xa capable jca adapter, deploy the adapter and add a section like this, // using the object name of the ManagedConnectionFactory mbean. for some reason I no longer // remember, I named these in the pattern jboss.jca:service=XaTxDS,name=<jndiname> //tests will be run only for adapters that are present. ObjectName mcfName = new ObjectName("jboss.jca:service=XaTxDS,name=FirebirdDS"); boolean reg = JBossTestServices.isRegistered(mcfName); if (JBossTestServices.isRegistered(mcfName)) { JBossTestServices.getStaticLog().info("Addding firebird tests"); JBossTestSetup wrapper = new XAResourceTestSetup(test, mcfName, JDBC_HELPER); suite.addTest(wrapper); } // end of if () else { JBossTestServices.getStaticLog().info("not adding firebird tests"); } // end of else //END OF SECTION to copy for each adapter you wish to test. return getDeploySetup(suite, "jcaxaresourcetest.sar"); } catch (Exception e) { e.printStackTrace(); JBossTestServices.getStaticLog().info("exception setting up", e); throw e; } // end of try-catch } public static class XAResourceTestSetup extends JBossTestSetup { private final ObjectName mcfName; private final ObjectName helperName; XAResourceTestSetup(final Test test, final ObjectName mcfName, final ObjectName helperName) { super(test); this.mcfName = mcfName; this.helperName = helperName; } protected void setUp() throws Exception { //deploymentException = null; //try { JBossTestServices.invoke(XARESOURCETEST_NAME, "setUp", new Object[] {mcfName, JDBC_HELPER}, new String[] {OBJECT_NAME_NAME, OBJECT_NAME_NAME}); this.getLog().debug("setup with mcf " + mcfName); //} catch (Exception ex) { // Throw this in testServerFound() instead. //deploymentException = ex; // } } protected void tearDown() throws Exception { JBossTestServices.invoke(XARESOURCETEST_NAME, "tearDown", new Object[] {}, new String[] {}); this.getLog().debug("tore down with mcf: " + mcfName); } } public void testSimpleCommitXid() throws Exception { invoke(XARESOURCETEST_NAME, "testSimpleCommitXid", new Object[] {}, new String[] {}); } public void testSimpleRollbackXid() throws Exception { invoke(XARESOURCETEST_NAME, "testSimpleRollbackXid", new Object[] {}, new String[] {}); } public void testSimpleCommitTx() throws Exception { invoke(XARESOURCETEST_NAME, "testSimpleCommitTx", new Object[] {}, new String[] {}); } public void testSimpleRollbackTx() throws Exception { invoke(XARESOURCETEST_NAME, "testSimpleRollbackTx", new Object[] {}, new String[] {}); } public void testRaw590816() throws Exception { invoke(XARESOURCETEST_NAME, "testRaw590816", new Object[] {}, new String[] {}); } public void test585632() throws Exception { invoke(XARESOURCETEST_NAME, "test585632", new Object[] {}, new String[] {}); } public void test590816() throws Exception { invoke(XARESOURCETEST_NAME, "test590816", new Object[] {}, new String[] {}); } }// XAResourceUnitTestCase |