User: user57  
  Date: 01/07/05 17:38:51

  Modified:    src/main/org/jboss/test/xa/bean XATestBean.java
  Log:
   o changed xatest.sh to use the JUnit runner & cleaned up classpath.
   o cleaned up commandline in mq-test.sh.
   o Changed XATest so that it deploys/tests/undeploys.
   o Added a createTables() method in XATestBean that will try to drop/create
     the required tables in the datasources.
   o Changd the jboss.xml to use java:/DefaultDS and java:/InstantDB for the
     two datasource references.
   o Updated the build for the xatest to include the org.jboss.test.util classes.
  
  Revision  Changes    Path
  1.3       +49 -1     jbosstest/src/main/org/jboss/test/xa/bean/XATestBean.java
  
  Index: XATestBean.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/xa/bean/XATestBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XATestBean.java   2001/01/07 23:14:43     1.2
  +++ XATestBean.java   2001/07/06 00:38:51     1.3
  @@ -14,7 +14,15 @@
   import javax.sql.DataSource;
   import org.jboss.test.xa.interfaces.CantSeeDataException;
   
  -public class XATestBean implements SessionBean {
  +public class XATestBean
  +    implements SessionBean
  +{
  +    public final static String DROP_TABLE =
  +        "DROP TABLE XA_TEST";
  +
  +    public final static String CREATE_TABLE =
  +        "CREATE TABLE XA_TEST(ID INTEGER NOT NULL PRIMARY KEY, DATA INTEGER NOT 
NULL)";
  +
       public final static String DB_1_NAME = "java:comp/env/jdbc/DBConnection1";
       public final static String DB_2_NAME = "java:comp/env/jdbc/DBConnection2";
   
  @@ -36,6 +44,46 @@
       public void setSessionContext(SessionContext parm1) throws EJBException {
       }
   
  +    protected void execute(DataSource ds, String sql) throws SQLException {
  +        Connection con = ds.getConnection();
  +        try {
  +            Statement s = con.createStatement();
  +            s.execute(sql);
  +            s.close();
  +        }
  +        finally {
  +            con.close();
  +        }
  +    }
  +
  +    protected void execute(Connection con, String sql) throws SQLException {
  +        Statement s = con.createStatement();
  +        s.execute(sql);
  +        s.close();
  +    }
  +    
  +    public void createTables() throws NamingException, SQLException {
  +        Context ctx = new InitialContext();
  +        try {
  +            DataSource ds1 = (DataSource)ctx.lookup(DB_1_NAME);
  +            try {
  +                execute(ds1, DROP_TABLE);
  +            }
  +            catch (Exception ignore) {}
  +            execute(ds1, CREATE_TABLE);
  +
  +            DataSource ds2 = (DataSource)ctx.lookup(DB_2_NAME);
  +            try {
  +                execute(ds2, DROP_TABLE);
  +            }
  +            catch (Exception ignore) {}
  +            execute(ds2, CREATE_TABLE);
  +        }
  +        finally {
  +            ctx.close();
  +        }
  +    }
  +    
       public void clearData() {
           try {
               Context ctx = new InitialContext();
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to