From: Adrian B. <adr...@jb...> - 2005-06-20 22:56:49
|
User: adrian Date: 05/06/20 18:56:08 Modified: src/main/org/jboss/test/jca/ejb XAExceptionSessionBean.java UnshareableConnectionStatefulBean.java RollbackOnlyReleaseConnectionSessionBean.java ConnectionFactorySerializationTestSessionBean.java UnshareableConnectionSessionBean.java ReentrantBean.java HAConnectionSessionBean.java XAExceptionTestSessionBean.java LocalWrapperCleanupTestSessionBean.java CachedConnectionSessionBean.java JDBCStatementTestsConnectionSessionBean.java ThreadLocalDB.java PreparedStatementBean.java UserTxSessionBean.java Log: Port JCA test changes from jboss4 Revision Changes Path 1.4 +62 -91 jbosstest/src/main/org/jboss/test/jca/ejb/XAExceptionSessionBean.java (In the diff below, changes in quantity of whitespace are not shown.) Index: XAExceptionSessionBean.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jca/ejb/XAExceptionSessionBean.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- XAExceptionSessionBean.java 27 Aug 2003 04:33:18 -0000 1.3 +++ XAExceptionSessionBean.java 20 Jun 2005 22:56:08 -0000 1.4 @@ -1,4 +1,3 @@ - /* * JBoss, the OpenSource J2EE webOS * @@ -6,13 +5,8 @@ * See terms of license at gnu.org. * */ - package org.jboss.test.jca.ejb; - - - -import java.rmi.RemoteException; import javax.ejb.EJBException; import javax.ejb.SessionBean; import javax.ejb.SessionContext; @@ -23,6 +17,8 @@ import javax.resource.cci.Connection; import javax.resource.cci.ConnectionFactory; import javax.transaction.xa.XAException; + +import org.jboss.logging.Logger; import org.jboss.mx.util.MBeanServerLocator; import org.jboss.test.jca.adapter.TestConnection; import org.jboss.test.jca.adapter.TestConnectionFactory; @@ -30,12 +26,9 @@ /** * XAExceptionSessionBean.java * - * - * Created: Tue Sep 10 21:34:30 2002 - * * @author <a href="mailto:d_j...@us...">David Jencks</a> - * @version - * + * @author <a href="mailto:ad...@jb...">Adrian Brock</a> + * @version <tt>$Revision: 1.4 $</tt> * * @ejb:bean name="XAExceptionSession" * jndi-name="test/XAExceptionSessionHome" @@ -45,8 +38,12 @@ * @ejb.transaction type="Required" * */ +public class XAExceptionSessionBean implements SessionBean +{ + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; -public class XAExceptionSessionBean implements SessionBean { + private Logger log = Logger.getLogger(XAExceptionSessionBean.class); private SessionContext sessionContext; @@ -58,7 +55,6 @@ { } - /** * Describe <code>testXAException</code> method here. * @ejb.interface-method @@ -69,12 +65,12 @@ { InitialContext ctx = new InitialContext(); - ConnectionFactory cf1 = (ConnectionFactory)ctx.lookup("java:/JBossTestCF"); - ConnectionFactory cf2 = (ConnectionFactory)ctx.lookup("java:/JBossTestCF2"); + ConnectionFactory cf1 = (ConnectionFactory) ctx.lookup("java:/JBossTestCF"); + ConnectionFactory cf2 = (ConnectionFactory) ctx.lookup("java:/JBossTestCF2"); Connection c1 = cf1.getConnection(); try { - TestConnection c2 = (TestConnection)cf2.getConnection(); + TestConnection c2 = (TestConnection) cf2.getConnection(); try { c2.setFailInPrepare(true, XAException.XA_RBROLLBACK); @@ -82,23 +78,19 @@ finally { c2.close(); - } // end of try-catch - - + } } finally { c1.close(); - } // end of try-catch - + } } catch (Exception e) { - e.printStackTrace(); + log.warn("Unexpected: ", e); throw new EJBException("unexpected exception: " + e); - } // end of try-catch } - + } /** * Describe <code>testXAException</code> method here. @@ -110,25 +102,24 @@ { InitialContext ctx = new InitialContext(); - ConnectionFactory cf1 = (ConnectionFactory)ctx.lookup("java:/JBossTestCF"); - TestConnection c1 = (TestConnection)cf1.getConnection(); + ConnectionFactory cf1 = (ConnectionFactory) ctx.lookup("java:/JBossTestCF"); + TestConnection c1 = (TestConnection) cf1.getConnection(); try { c1.setFailInCommit(true, XAException.XAER_RMERR); - } finally { c1.close(); - } // end of try-catch + } } catch (Exception e) { - e.printStackTrace(); + log.warn("Unexpected: ", e); throw new EJBException("unexpected exception: " + e); - } // end of try-catch + } } /** @@ -138,7 +129,7 @@ */ public void simulateConnectionError() { - System.out.println("Simulating connection error"); + log.info("Simulating connection error"); try { InitialContext ctx = new InitialContext(); @@ -157,7 +148,7 @@ { if (e.getMessage().equals("Simulated exception") == false) { - e.printStackTrace(); + log.warn("Unexpected: ", e); throw new EJBException(e.getMessage()); } else @@ -174,7 +165,7 @@ */ public void simulateConnectionErrorWithTwoHandles() { - System.out.println("Simulating connection error with two handles"); + log.info("Simulating connection error with two handles"); try { InitialContext ctx = new InitialContext(); @@ -207,7 +198,7 @@ { if (e.getMessage().equals("Simulated exception") == false) { - e.printStackTrace(); + log.warn("Unexpected: ", e); throw new EJBException(e.getMessage()); } else @@ -224,7 +215,7 @@ */ public void simulateError(String failure, int count) { - System.out.println(failure + " start"); + log.info(failure + " teststart"); try { long available = getAvailableConnections(); @@ -242,18 +233,13 @@ } } if (available != getAvailableConnections()) - throw new EJBException("Expected " + available + - " got " + getAvailableConnections() + " connections"); + throw new EJBException("Expected " + available + " got " + getAvailableConnections() + " connections"); } catch (Exception e) { - e.printStackTrace(); + log.warn("Unexpected: ", e); throw new EJBException(e.getMessage()); } - finally - { - flushConnections(); - } } /** @@ -263,7 +249,7 @@ */ public void simulateFactoryError(String failure, int count) { - System.out.println(failure + " start"); + log.info(failure + " start"); TestConnectionFactory cf = null; try { @@ -283,42 +269,28 @@ } } if (available != getAvailableConnections()) - throw new EJBException("Expected " + available + - " got " + getAvailableConnections() + " connections"); + throw new EJBException("Expected " + available + " got " + getAvailableConnections() + " connections"); } catch (Exception e) { - e.printStackTrace(); + log.warn("Unexpected: ", e); throw new EJBException(e.getMessage()); } finally { + sessionContext.setRollbackOnly(); if (cf != null) - failure = null; - flushConnections(); + cf.setFailure(null); } } - public long getAvailableConnections() - throws Exception + + public long getAvailableConnections() throws Exception { MBeanServer server = MBeanServerLocator.locateJBoss(); return ((Long) server.getAttribute(new ObjectName("jboss.jca:service=ManagedConnectionPool,name=JBossTestCF"), "AvailableConnectionCount")).longValue(); } - public void flushConnections() - { - try - { - MBeanServer server = MBeanServerLocator.locateJBoss(); - server.invoke(new ObjectName("jboss.jca:service=ManagedConnectionPool,name=JBossTestCF"), "flush", new Object[0], new String[0]); - } - catch (Exception e) - { - throw new EJBException(e); - } - } - public void ejbActivate() { } @@ -342,4 +314,3 @@ } } - 1.3 +3 -2 jbosstest/src/main/org/jboss/test/jca/ejb/UnshareableConnectionStatefulBean.java (In the diff below, changes in quantity of whitespace are not shown.) Index: UnshareableConnectionStatefulBean.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jca/ejb/UnshareableConnectionStatefulBean.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- UnshareableConnectionStatefulBean.java 24 Sep 2003 21:36:53 -0000 1.2 +++ UnshareableConnectionStatefulBean.java 20 Jun 2005 22:56:08 -0000 1.3 @@ -21,11 +21,13 @@ * A stateful session bean that has an unshareable resource * * @author <a href="mailto:ad...@jb...">Adrian Brock</a> + * @version <tt>$Revision: 1.3 $</tt> */ public class UnshareableConnectionStatefulBean implements SessionBean { - private SessionContext ctx; + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; Connection c; @@ -110,7 +112,6 @@ public void setSessionContext(SessionContext ctx) { - this.ctx = ctx; } public void unsetSessionContext() 1.3 +125 -111 jbosstest/src/main/org/jboss/test/jca/ejb/RollbackOnlyReleaseConnectionSessionBean.java (In the diff below, changes in quantity of whitespace are not shown.) Index: RollbackOnlyReleaseConnectionSessionBean.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jca/ejb/RollbackOnlyReleaseConnectionSessionBean.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- RollbackOnlyReleaseConnectionSessionBean.java 21 Oct 2004 07:50:44 -0000 1.2 +++ RollbackOnlyReleaseConnectionSessionBean.java 20 Jun 2005 22:56:08 -0000 1.3 @@ -4,7 +4,6 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ - package org.jboss.test.jca.ejb; import java.rmi.RemoteException; @@ -12,30 +11,22 @@ import java.sql.SQLException; import javax.ejb.CreateException; - +import javax.ejb.EJBException; import javax.ejb.SessionBean; import javax.ejb.SessionContext; -import javax.naming.InitialContext; +import javax.management.MBeanServer; import javax.management.ObjectName; -import javax.naming.NamingException; -import org.apache.log4j.Category; -import javax.transaction.UserTransaction; -import javax.ejb.EJBException; - -import org.jboss.jmx.adaptor.rmi.RMIAdaptor; - - -import org.jboss.test.jca.adapter.TestConnectionFactory; -import org.jboss.test.jca.adapter.TestConnection; +import javax.naming.InitialContext; +import org.jboss.logging.Logger; +import org.jboss.mx.util.MBeanServerLocator; /** * RollbackOnlyReleaseConnectionSessionBean.java * - * - * Created: 20-Oct-2004 - * * @author <a href="mailto:noe...@jb...">Noel Rocher</a> + * @version <tt>$Revision: 1.3 $</tt> + * * @ejb.bean name="RollbackOnlyReleaseConnectionSession" * display-name="Name for RollbackOnlyReleaseConnectionSession" * description="Description for RollbackOnlyReleaseConnectionSession" @@ -44,24 +35,28 @@ * view-type="remote" * transaction-type = "Container" * @ejb.transaction type = "Required" - * - * */ -public class RollbackOnlyReleaseConnectionSessionBean implements SessionBean { - - private SessionContext bean_context; - private Category log = Category.getInstance(getClass().getName()); + */ +public class RollbackOnlyReleaseConnectionSessionBean implements SessionBean +{ + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; + private SessionContext bean_context; + private Logger log = Logger.getLogger(getClass()); public void ejbCreate() throws CreateException { } + /** * */ - public RollbackOnlyReleaseConnectionSessionBean() {super();} - + public RollbackOnlyReleaseConnectionSessionBean() + { + super(); + } /** * @ejb.interface-method view-type = "both" @@ -70,35 +65,45 @@ public boolean testConnectionRelease() throws java.rmi.RemoteException { Connection conn = null; - long pre_connection_number=0; - long post_connection_number=0; - boolean result=false; - try { + long pre_connection_number = 0; + long post_connection_number = 0; + boolean result = false; + try + { // set Transaction to Rollback Only this.bean_context.setRollbackOnly(); Thread.sleep(500); // simulate some processing - javax.sql.DataSource ds = (javax.sql.DataSource)(new InitialContext()).lookup("java:DefaultDS"); + javax.sql.DataSource ds = (javax.sql.DataSource) (new InitialContext()).lookup("java:DefaultDS"); pre_connection_number = getConnectionInUseNumber(); conn = ds.getConnection(); conn.createStatement().execute("select 1"); conn.close(); - } catch (org.jboss.util.NestedSQLException ignore) {// this is the expected exception} - } catch (Exception e) { - e.printStackTrace(); + } + catch (SQLException e) + {// this is the expected exception} + } + catch (Exception e) + { + log.warn("Unexpected ", e); throw new EJBException("unexpected exception: " + e); } - finally { - try { + finally + { + try + { conn.close(); - } catch (Exception ignore) {} } - + catch (Exception ignore) + { + } + } // compare in use connection numbers - try { + try + { post_connection_number = getConnectionInUseNumber(); log.debug("Pre # = " + pre_connection_number + " ; Post #" + post_connection_number); if (pre_connection_number == post_connection_number) @@ -111,8 +116,10 @@ log.debug("Test is *NOT* OK "); result = false; } - } catch (Exception e) { - e.printStackTrace(); + } + catch (Exception e) + { + log.warn("Unexpected: ", e); throw new EJBException("unexpected exception: " + e); } @@ -120,25 +127,32 @@ } - - private long getConnectionInUseNumber() throws Exception { - long result=0; - result = ((Long)((RMIAdaptor)(new InitialContext()).lookup("jmx/invoker/RMIAdaptor")).getAttribute(new ObjectName("jboss.jca:name=DefaultDS,service=ManagedConnectionPool"), "InUseConnectionCount")).longValue(); + long result = 0; + MBeanServer server = MBeanServerLocator.locateJBoss(); + result = ((Long) server.getAttribute( + new ObjectName("jboss.jca:name=DefaultDS,service=ManagedConnectionPool"), "InUseConnectionCount")) + .longValue(); return result; } + public void ejbActivate() throws EJBException, RemoteException + { + } - public void ejbActivate() throws EJBException, RemoteException {} - public void ejbPassivate() throws EJBException, RemoteException {} - public void ejbRemove() throws EJBException, RemoteException {} + public void ejbPassivate() throws EJBException, RemoteException + { + } - public void setSessionContext(SessionContext ctx) - throws EJBException, - RemoteException { + public void ejbRemove() throws EJBException, RemoteException + { + } + + public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException + { - bean_context=ctx; + bean_context = ctx; } -}// RollbackOnlyReleaseConnectionSessionBean +} 1.5 +6 -16 jbosstest/src/main/org/jboss/test/jca/ejb/ConnectionFactorySerializationTestSessionBean.java (In the diff below, changes in quantity of whitespace are not shown.) Index: ConnectionFactorySerializationTestSessionBean.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jca/ejb/ConnectionFactorySerializationTestSessionBean.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -b -r1.4 -r1.5 --- ConnectionFactorySerializationTestSessionBean.java 27 Aug 2003 04:33:18 -0000 1.4 +++ ConnectionFactorySerializationTestSessionBean.java 20 Jun 2005 22:56:08 -0000 1.5 @@ -1,4 +1,3 @@ - /* * JBoss, the OpenSource J2EE webOS * @@ -6,13 +5,8 @@ * See terms of license at gnu.org. * */ - package org.jboss.test.jca.ejb; - - - - import java.rmi.MarshalledObject; import java.rmi.RemoteException; import java.sql.Connection; @@ -21,30 +15,26 @@ import javax.ejb.SessionContext; import javax.naming.InitialContext; import javax.sql.DataSource; -import org.apache.log4j.Category; + +import org.jboss.logging.Logger; /** * ConnectionFactorySerializationTestSessionBean.java * - * - * Created: Thu May 23 23:30:27 2002 - * * @author <a href="mailto:d_j...@us...">David Jencks</a> - * @version - * + * @version $Revision: 1.5 $ * * @ejb:bean name="ConnectionFactorySerializationTestSession" * jndi-name="ConnectionFactorySerializationTestSession" * view-type="remote" * type="Stateless" - * */ - public class ConnectionFactorySerializationTestSessionBean implements SessionBean { - - private final Category log = Category.getInstance(getClass()); + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; + private final Logger log = Logger.getLogger(getClass()); /** * Describe <code>testConnectionFactorySerialization</code> method here. 1.4 +3 -2 jbosstest/src/main/org/jboss/test/jca/ejb/UnshareableConnectionSessionBean.java (In the diff below, changes in quantity of whitespace are not shown.) Index: UnshareableConnectionSessionBean.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jca/ejb/UnshareableConnectionSessionBean.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- UnshareableConnectionSessionBean.java 1 Feb 2005 01:16:11 -0000 1.3 +++ UnshareableConnectionSessionBean.java 20 Jun 2005 22:56:08 -0000 1.4 @@ -21,11 +21,13 @@ * A stateless session bean that invokes a stateful session with an unshareable resource * * @author <a href="mailto:ad...@jb...">Adrian Brock</a> + * @version <tt>$Revision: 1.4 $</tt> */ public class UnshareableConnectionSessionBean implements SessionBean { - private SessionContext ctx; + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; public void runTest() { @@ -64,7 +66,6 @@ public void setSessionContext(SessionContext ctx) { - this.ctx = ctx; } public void unsetSessionContext() 1.2 +41 -87 jbosstest/src/main/org/jboss/test/jca/ejb/ReentrantBean.java (In the diff below, changes in quantity of whitespace are not shown.) Index: ReentrantBean.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jca/ejb/ReentrantBean.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- ReentrantBean.java 31 Jul 2002 18:59:47 -0000 1.1 +++ ReentrantBean.java 20 Jun 2005 22:56:08 -0000 1.2 @@ -1,4 +1,3 @@ - /* * JBoss, the OpenSource J2EE webOS * @@ -6,30 +5,25 @@ * See terms of license at gnu.org. * */ - package org.jboss.test.jca.ejb; import java.rmi.RemoteException; import java.sql.Connection; + import javax.ejb.CreateException; import javax.ejb.EJBException; import javax.ejb.EntityBean; import javax.ejb.EntityContext; -import javax.ejb.RemoveException; import javax.naming.InitialContext; import javax.sql.DataSource; import org.jboss.test.jca.interfaces.Reentrant; - /** * ReentrantBean.java tests if CachedConnectionManager works with reentrant ejbs. * - * - * Created: Wed Jul 31 13:27:44 2002 - * * @author <a href="mailto:d_j...@us...">David Jencks</a> - * @version + * @version <tt>$Revision: 1.2 $</tt> * * @ejb.bean * jndi-name="ejb/jca/Reentrant" @@ -43,19 +37,20 @@ * */ -public class ReentrantBean - implements EntityBean +public class ReentrantBean implements EntityBean { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; private Integer id; private EntityContext ctx; - public ReentrantBean (){ + public ReentrantBean() + { } - /** * Creates a new <code>ejbCreate</code> instance. * @@ -83,13 +78,13 @@ public void ejbPostCreate(Integer id, Reentrant other) throws CreateException, RemoteException { this.id = id; - Reentrant me = (Reentrant)ctx.getEJBObject(); + Reentrant me = (Reentrant) ctx.getEJBObject(); Connection c = null; try { try { - DataSource ds = (DataSource)new InitialContext().lookup("java:/DefaultDS"); + DataSource ds = (DataSource) new InitialContext().lookup("java:/DefaultDS"); c = ds.getConnection(); if (other != null) { @@ -123,90 +118,49 @@ } } - /** - * Describe <code>findByPrimaryKey</code> method here. - * - * @param id an <code>Integer</code> value - * @return an <code>Integer</code> value - */ public Integer ejbFindByPrimaryKey(Integer id) { return id; } - // implementation of javax.ejb.EntityBean interface - /** - * - * @exception javax.ejb.EJBException <description> - * @exception java.rmi.RemoteException <description> - */ public void ejbActivate() { - // TODO: implement this javax.ejb.EntityBean method } - /** - * - * @exception javax.ejb.EJBException <description> - * @exception java.rmi.RemoteException <description> - */ public void ejbLoad() { - this.id = (Integer)ctx.getPrimaryKey(); + this.id = (Integer) ctx.getPrimaryKey(); } - /** - * - * @exception javax.ejb.EJBException <description> - * @exception java.rmi.RemoteException <description> - */ public void ejbPassivate() { - // TODO: implement this javax.ejb.EntityBean method } - /** - * - * @exception javax.ejb.RemoveException <description> - * @exception javax.ejb.EJBException <description> - * @exception java.rmi.RemoteException <description> - */ public void ejbRemove() throws EJBException { - // TODO: implement this javax.ejb.EntityBean method } - /** - * - * @exception javax.ejb.EJBException <description> - * @exception java.rmi.RemoteException <description> - */ public void ejbStore() throws EJBException { - // TODO: implement this javax.ejb.EntityBean method } - /** - * - * @param param1 <description> - * @exception javax.ejb.EJBException <description> - * @exception java.rmi.RemoteException <description> - */ public void setEntityContext(EntityContext ctx) { this.ctx = ctx; } - /** - * - * @exception javax.ejb.EJBException <description> - * @exception java.rmi.RemoteException <description> - */ public void unsetEntityContext() { ctx = null; } + public String toString() + { + if (id == null) + return null; + else + return id.toString(); + } } 1.3 +4 -1 jbosstest/src/main/org/jboss/test/jca/ejb/HAConnectionSessionBean.java (In the diff below, changes in quantity of whitespace are not shown.) Index: HAConnectionSessionBean.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jca/ejb/HAConnectionSessionBean.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- HAConnectionSessionBean.java 1 Apr 2005 10:39:17 -0000 1.2 +++ HAConnectionSessionBean.java 20 Jun 2005 22:56:08 -0000 1.3 @@ -34,11 +34,14 @@ * type="Stateless" * * @author <a href="mailto:al...@jb...">Alexey Loubyansky</a> - * @version <tt>$Revision: 1.2 $</tt> + * @version <tt>$Revision: 1.3 $</tt> */ public class HAConnectionSessionBean implements SessionBean { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; + private static final Logger log = Logger.getLogger(HAConnectionSessionBean.class); private SessionContext ctx; 1.4 +34 -39 jbosstest/src/main/org/jboss/test/jca/ejb/XAExceptionTestSessionBean.java (In the diff below, changes in quantity of whitespace are not shown.) Index: XAExceptionTestSessionBean.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jca/ejb/XAExceptionTestSessionBean.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- XAExceptionTestSessionBean.java 27 Aug 2003 04:33:18 -0000 1.3 +++ XAExceptionTestSessionBean.java 20 Jun 2005 22:56:08 -0000 1.4 @@ -1,4 +1,3 @@ - /* * JBoss, the OpenSource J2EE webOS * @@ -6,20 +5,16 @@ * See terms of license at gnu.org. * */ - package org.jboss.test.jca.ejb; - - - -import java.rmi.RemoteException; import javax.ejb.EJBException; import javax.ejb.SessionBean; import javax.ejb.SessionContext; import javax.ejb.TransactionRolledbackLocalException; import javax.naming.InitialContext; import javax.transaction.TransactionRolledbackException; -import org.apache.log4j.Logger; + +import org.jboss.logging.Logger; import org.jboss.test.jca.interfaces.XAExceptionSession; import org.jboss.test.jca.interfaces.XAExceptionSessionHome; import org.jboss.test.jca.interfaces.XAExceptionSessionLocal; @@ -28,24 +23,22 @@ /** * XAExceptionTestSessionBean.java * - * - * Created: Wed Sep 11 00:38:00 2002 - * * @author <a href="mailto:d_j...@us...">David Jencks</a> - * @version - * + * @version <tt>$Revision: 1.4 $</tt> * * @ejb:bean name="XAExceptionTestSession" * jndi-name="test/XAExceptionTestSessionHome" * view-type="remote" * type="Stateless" * @ejb.transaction type="Never" - * */ +public class XAExceptionTestSessionBean implements SessionBean +{ -public class XAExceptionTestSessionBean implements SessionBean { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; - private Logger log = Logger.getLogger(getClass().getName()); + private Logger log = Logger.getLogger(getClass()); /** * Describe <code>ejbCreate</code> method here. @@ -55,7 +48,6 @@ { } - /** * Describe <code>testXAException</code> method here. * @ejb.interface-method @@ -64,7 +56,8 @@ { try { - XAExceptionSessionHome xh = (XAExceptionSessionHome)new InitialContext().lookup("test/XAExceptionSessionHome"); + XAExceptionSessionHome xh = (XAExceptionSessionHome) new InitialContext() + .lookup("test/XAExceptionSessionHome"); XAExceptionSession x = xh.create(); try { @@ -72,15 +65,15 @@ } catch (TransactionRolledbackException tre) { - System.out.println("Test worked"); + log.info("Test worked"); return; - } // end of try-catch + } } catch (Exception e) { log.info("unexpected exception", e); throw new EJBException("Unexpected exception: " + e); - } // end of try-catch + } throw new EJBException("No exception"); } @@ -92,7 +85,8 @@ { try { - XAExceptionSessionLocalHome xh = (XAExceptionSessionLocalHome)new InitialContext().lookup("test/XAExceptionSessionLocalHome"); + XAExceptionSessionLocalHome xh = (XAExceptionSessionLocalHome) new InitialContext() + .lookup("test/XAExceptionSessionLocalHome"); XAExceptionSessionLocal x = xh.create(); try { @@ -102,13 +96,13 @@ { log.info("Test worked"); return; - } // end of try-catch + } } catch (Exception e) { log.info("unexpected exception", e); throw new EJBException("Unexpected exception: " + e); - } // end of try-catch + } throw new EJBException("No exception"); } @@ -120,7 +114,8 @@ { try { - XAExceptionSessionHome xh = (XAExceptionSessionHome)new InitialContext().lookup("test/XAExceptionSessionHome"); + XAExceptionSessionHome xh = (XAExceptionSessionHome) new InitialContext() + .lookup("test/XAExceptionSessionHome"); XAExceptionSession x = xh.create(); try { @@ -128,15 +123,15 @@ } catch (TransactionRolledbackException tre) { - System.out.println("Test worked"); + log.info("Test worked"); return; - } // end of try-catch + } } catch (Exception e) { log.info("unexpected exception", e); throw new EJBException("Unexpected exception: " + e); - } // end of try-catch + } throw new EJBException("No exception"); } @@ -148,7 +143,8 @@ { try { - XAExceptionSessionLocalHome xh = (XAExceptionSessionLocalHome)new InitialContext().lookup("test/XAExceptionSessionLocalHome"); + XAExceptionSessionLocalHome xh = (XAExceptionSessionLocalHome) new InitialContext() + .lookup("test/XAExceptionSessionLocalHome"); XAExceptionSessionLocal x = xh.create(); try { @@ -158,13 +154,13 @@ { log.info("Test worked"); return; - } // end of try-catch + } } catch (Exception e) { log.info("unexpected exception", e); throw new EJBException("Unexpected exception: " + e); - } // end of try-catch + } throw new EJBException("No exception"); } @@ -189,4 +185,3 @@ } } - 1.8 +93 -116 jbosstest/src/main/org/jboss/test/jca/ejb/LocalWrapperCleanupTestSessionBean.java (In the diff below, changes in quantity of whitespace are not shown.) Index: LocalWrapperCleanupTestSessionBean.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jca/ejb/LocalWrapperCleanupTestSessionBean.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -b -r1.7 -r1.8 --- LocalWrapperCleanupTestSessionBean.java 25 Oct 2003 15:10:15 -0000 1.7 +++ LocalWrapperCleanupTestSessionBean.java 20 Jun 2005 22:56:08 -0000 1.8 @@ -1,4 +1,3 @@ - /* * JBoss, the OpenSource J2EE webOS * @@ -6,33 +5,26 @@ * See terms of license at gnu.org. * */ - - package org.jboss.test.jca.ejb; - -import java.rmi.RemoteException; import java.sql.Connection; +import java.sql.ResultSet; import java.sql.Statement; + import javax.ejb.EJBException; import javax.ejb.SessionBean; import javax.ejb.SessionContext; import javax.naming.InitialContext; import javax.sql.DataSource; -import org.apache.log4j.Category; -import org.jboss.resource.adapter.jdbc.WrappedConnection; -import java.sql.ResultSet; import javax.transaction.UserTransaction; +import org.jboss.resource.adapter.jdbc.WrappedConnection; + /** * LocalWrapperCleanupTestSessionBean.java * - * - * Created: Thu May 23 14:50:16 2002 - * * @author <a href="mailto:d_j...@us...">David Jencks</a> - * @version - * + * @version $Revision: 1.8 $ * * @ejb:bean name="LocalWrapperCleanupTestSession" * jndi-name="LocalWrapperCleanupTestSession" @@ -40,13 +32,11 @@ * type="Stateless" * */ - -public class LocalWrapperCleanupTestSessionBean - implements SessionBean +public class LocalWrapperCleanupTestSessionBean implements SessionBean { - private Category log = Category.getInstance(getClass().getName()); - + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; /** * Describe <code>testAutoCommitInReturnedConnection</code> method here. @@ -59,12 +49,12 @@ { try { - DataSource ds = (DataSource)new InitialContext().lookup("java:/SingleConnectionDS"); + DataSource ds = (DataSource) new InitialContext().lookup("java:/SingleConnectionDS"); Connection c = ds.getConnection(); if (c.getAutoCommit() == false) { throw new EJBException("Initial autocommit state false!"); - } // end of if () + } c.setAutoCommit(false); c.commit(); c.close(); @@ -72,20 +62,19 @@ if (c.getAutoCommit() == false) { throw new EJBException("Returned and reaccessed autocommit state false!"); - } // end of if () + } c.close(); } catch (EJBException e) { throw e; - } // end of try-catch + } catch (Exception e) { throw new EJBException("Untested problem in test: " + e); - } // end of catch } - + } /** * Describe <code>testAutoCommit</code> method here. @@ -98,19 +87,19 @@ { try { - DataSource ds = (DataSource)new InitialContext().lookup("java:/DefaultDS"); + DataSource ds = (DataSource) new InitialContext().lookup("java:/DefaultDS"); Connection c1 = ds.getConnection(); - Connection uc1 = ((WrappedConnection)c1).getUnderlyingConnection(); + Connection uc1 = ((WrappedConnection) c1).getUnderlyingConnection(); if (c1.getAutoCommit() == false) { throw new EJBException("Initial autocommit state false!"); - } // end of if () + } Connection c2 = ds.getConnection(); if (c2.getAutoCommit() == false) { throw new EJBException("Initial autocommit state false!"); - } // end of if () + } Statement s1 = c1.createStatement(); Statement s2 = c2.createStatement(); s1.execute("create table autocommittest (id integer)"); @@ -122,7 +111,7 @@ if (!rs2.next()) { throw new EJBException("Row not visible to other connection, autocommit failed"); - } // end of if () + } rs2.close(); } @@ -133,21 +122,19 @@ c1.close(); s2.close(); c2.close(); - } // end of try-catch - + } } catch (EJBException e) { throw e; - } // end of try-catch + } catch (Exception e) { throw new EJBException("Untested problem in test: " + e); - } // end of catch - } + } /** * Describe <code>testAutoCommitOffInUserTx</code> method here. @@ -160,32 +147,32 @@ { try { - DataSource ds = (DataSource)new InitialContext().lookup("java:/DefaultDS"); + DataSource ds = (DataSource) new InitialContext().lookup("java:/DefaultDS"); Connection c1 = ds.getConnection(); - Connection uc1 = ((WrappedConnection)c1).getUnderlyingConnection(); + Connection uc1 = ((WrappedConnection) c1).getUnderlyingConnection(); if (c1.getAutoCommit() == false) { throw new EJBException("Initial autocommit state false!"); - } // end of if () + } Statement s1 = c1.createStatement(); s1.execute("create table autocommittest (id integer)"); try { - UserTransaction ut = (UserTransaction)new InitialContext().lookup("UserTransaction"); + UserTransaction ut = (UserTransaction) new InitialContext().lookup("UserTransaction"); ut.begin(); s1.execute("insert into autocommittest values (1)"); if (uc1.getAutoCommit()) { throw new EJBException("Underlying autocommit is true in user tx!"); - } // end of if () + } ut.rollback(); ResultSet rs1 = s1.executeQuery("select * from autocommittest where id = 1"); if (rs1.next()) { throw new EJBException("Row committed, autocommit still on!"); - } // end of if () + } rs1.close(); } @@ -194,19 +181,17 @@ s1.execute("drop table autocommittest"); s1.close(); c1.close(); - } // end of try-catch - + } } catch (EJBException e) { throw e; - } // end of try-catch + } catch (Exception e) { throw new EJBException("Untested problem in test: " + e); - } // end of catch - + } } /** @@ -221,7 +206,7 @@ try { createTable(); - UserTransaction ut = (UserTransaction)new InitialContext().lookup("UserTransaction"); + UserTransaction ut = (UserTransaction) new InitialContext().lookup("UserTransaction"); ut.begin(); insertAndCheckAutoCommit(); ut.rollback(); @@ -229,15 +214,15 @@ catch (EJBException e) { throw e; - } // end of try-catch + } catch (Exception e) { throw new EJBException("Untested problem in test: " + e); - } // end of catch + } finally { checkRowAndDropTable(); - } // end of try-catch + } } @@ -250,9 +235,9 @@ { try { - DataSource ds = (DataSource)new InitialContext().lookup("java:/DefaultDS"); + DataSource ds = (DataSource) new InitialContext().lookup("java:/DefaultDS"); Connection c1 = ds.getConnection(); - Connection uc1 = ((WrappedConnection)c1).getUnderlyingConnection(); + Connection uc1 = ((WrappedConnection) c1).getUnderlyingConnection(); Statement s1 = null; try { @@ -280,7 +265,7 @@ if (s1 != null) s1.close(); c1.close(); - } // end of try-catch + } } catch (EJBException e) { @@ -303,13 +288,12 @@ { try { - DataSource ds = (DataSource)new InitialContext().lookup("java:/DefaultDS"); + DataSource ds = (DataSource) new InitialContext().lookup("java:/DefaultDS"); Connection c1 = ds.getConnection(); - Connection uc1 = ((WrappedConnection)c1).getUnderlyingConnection(); if (c1.getAutoCommit() == false) { throw new EJBException("Initial autocommit state false!"); - } // end of if () + } Statement s1 = c1.createStatement(); try @@ -321,16 +305,16 @@ { s1.close(); c1.close(); - } // end of try-catch + } } catch (EJBException e) { throw e; - } // end of try-catch + } catch (Exception e) { throw new EJBException("Untested problem in test: " + e); - } // end of catch + } } @@ -345,9 +329,9 @@ { try { - DataSource ds = (DataSource)new InitialContext().lookup("java:/DefaultDS"); + DataSource ds = (DataSource) new InitialContext().lookup("java:/DefaultDS"); Connection c1 = ds.getConnection(); - Connection uc1 = ((WrappedConnection)c1).getUnderlyingConnection(); + Connection uc1 = ((WrappedConnection) c1).getUnderlyingConnection(); Statement s1 = c1.createStatement(); try { @@ -355,25 +339,24 @@ if (uc1.getAutoCommit()) { throw new EJBException("Underlying autocommit is true in user tx!"); - } // end of if () + } } finally { s1.close(); c1.close(); - } // end of try-catch - + } } catch (EJBException e) { throw e; - } // end of try-catch + } catch (Exception e) { throw new EJBException("Untested problem in test: " + e); - } // end of catch + } } @@ -388,13 +371,12 @@ { try { - DataSource ds = (DataSource)new InitialContext().lookup("java:/DefaultDS"); + DataSource ds = (DataSource) new InitialContext().lookup("java:/DefaultDS"); Connection c1 = ds.getConnection(); - Connection uc1 = ((WrappedConnection)c1).getUnderlyingConnection(); if (c1.getAutoCommit() == false) { throw new EJBException("Initial autocommit state false!"); - } // end of if () + } Statement s1 = c1.createStatement(); try @@ -403,7 +385,7 @@ if (rs1.next()) { throw new EJBException("Row committed, autocommit still on!"); - } // end of if () + } rs1.close(); } @@ -412,14 +394,13 @@ s1.execute("drop table autocommittest"); s1.close(); c1.close(); - } // end of try-catch - + } } catch (EJBException e) { throw e; - } // end of try-catch + } catch (Exception e) { throw new EJBException("Untested problem in test: " + e); @@ -427,7 +408,6 @@ } - /** * Describe <code>testTxIsolationInReturnedConnection</code> method here. * @@ -478,7 +458,6 @@ { } - public void ejbActivate() { } @@ -498,6 +477,4 @@ public void unsetSessionContext() { } - } - 1.4 +18 -28 jbosstest/src/main/org/jboss/test/jca/ejb/CachedConnectionSessionBean.java (In the diff below, changes in quantity of whitespace are not shown.) Index: CachedConnectionSessionBean.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jca/ejb/CachedConnectionSessionBean.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- CachedConnectionSessionBean.java 30 Aug 2003 15:44:30 -0000 1.3 +++ CachedConnectionSessionBean.java 20 Jun 2005 22:56:08 -0000 1.4 @@ -1,4 +1,3 @@ - /* * JBoss, the OpenSource J2EE webOS * @@ -6,12 +5,8 @@ * See terms of license at gnu.org. * */ - package org.jboss.test.jca.ejb; - - - import java.rmi.RemoteException; import java.sql.Connection; import java.sql.PreparedStatement; @@ -30,12 +25,8 @@ /** * CachedConnectionSessionBean.java * - * - * Created: Sun Mar 10 17:55:51 2002 - * * @author <a href="mailto:d_j...@us...">David Jencks</a> - * @version - * + * @version <tt>$Revision: 1.4 $</tt> * * @ejb:bean name="CachedConnectionSession" * jndi-name="CachedConnectionSession" @@ -47,6 +38,8 @@ public class CachedConnectionSessionBean implements SessionBean { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; private Connection conn; private Category log = Category.getInstance(getClass().getName()); private SessionContext ctx; @@ -64,8 +57,7 @@ } catch (Exception e) { - //ignore - } // end of try-catch + } try { @@ -77,12 +69,12 @@ finally { s.close(); - } // end of try-catch + } } catch (SQLException e) { log.error("sql exception in create table", e); - } // end of try-catch + } } /** @@ -102,12 +94,12 @@ finally { s.close(); - } // end of try-catch + } } catch (SQLException e) { log.error("sql exception in drop", e); - } // end of try-catch + } } /** @@ -132,12 +124,12 @@ finally { p.close(); - } // end of try-catch + } } catch (SQLException e) { log.error("sql exception in insert", e); - } // end of try-catch + } } /** @@ -160,20 +152,20 @@ if (rs.next()) { return rs.getString(1); - } // end of if () + } return null; } finally { rs.close(); p.close(); - } // end of try-catch + } } catch (SQLException e) { log.error("sql exception in fetch", e); return null; - } // end of try-catch + } } private Connection getConn() { @@ -181,11 +173,11 @@ { log.info("ejb activate never called, conn == null"); ejbActivate(); - } // end of if () + } if (conn == null) { throw new IllegalStateException("could not get a connection"); - } // end of if () + } return conn; } @@ -244,11 +236,11 @@ catch (NamingException e) { log.error("naming exception in activate", e); - } // end of try-catch + } catch (SQLException e) { log.error("sql exception in activate", e); - } // end of try-catch + } } @@ -261,7 +253,7 @@ catch (SQLException e) { log.error("sql exception in passivate", e); - } // end of try-catch + } conn = null; log = null; } @@ -278,6 +270,4 @@ public void unsetSessionContext() throws RemoteException { } - } - 1.3 +10 -14 jbosstest/src/main/org/jboss/test/jca/ejb/JDBCStatementTestsConnectionSessionBean.java (In the diff below, changes in quantity of whitespace are not shown.) Index: JDBCStatementTestsConnectionSessionBean.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jca/ejb/JDBCStatementTestsConnectionSessionBean.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- JDBCStatementTestsConnectionSessionBean.java 16 Feb 2003 19:36:03 -0000 1.2 +++ JDBCStatementTestsConnectionSessionBean.java 20 Jun 2005 22:56:08 -0000 1.3 @@ -1,4 +1,3 @@ - /* * JBoss, the OpenSource J2EE webOS * @@ -6,7 +5,6 @@ * See terms of license at gnu.org. * */ - package org.jboss.test.jca.ejb; import javax.ejb.SessionBean; @@ -23,11 +21,8 @@ /** * JDBCStatementTestsConnectionSessionBean.java * - * - * Created: Fri Feb 14 15:01:38 2003 - * * @author <a href="mailto:d_j...@us...">David Jencks</a> - * @version + * @version $Revision: 1.3 $ * * @ejb:bean name="JDBCStatementTestsConnectionSession" * jndi-name="JDBCStatementTestsConnectionSession" @@ -35,13 +30,14 @@ * view-type="both" * type="Stateless" */ - public class JDBCStatementTestsConnectionSessionBean implements SessionBean { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; + public JDBCStatementTestsConnectionSessionBean() { } - /** * The <code>testConnectionObtainable</code> method gets * connections from the TestDriver after setting fail to true. @@ -69,7 +65,7 @@ if (closeCount1 == tc.getClosedCount()) { throw new EJBException("no connections closed!, closedCount: " + closeCount1); - } // end of if () + } c.close(); for (int i = 0; i < 10; i++) { @@ -79,19 +75,19 @@ if (closeCount == tc.getClosedCount()) { throw new EJBException("no connections closed! at iteration: " + i + ", closedCount: " + closeCount); - } // end of if () + } c.close(); - } // end of for () + } } catch (SQLException e) { throw new EJBException(e); - } // end of try-catch + } catch (NamingException e) { throw new EJBException(e); - } // end of try-catch + } } @@ -119,4 +115,4 @@ { } -}// JDBCStatementTestsConnectionSessionBean +} 1.3 +3 -5 jbosstest/src/main/org/jboss/test/jca/ejb/ThreadLocalDB.java (In the diff below, changes in quantity of whitespace are not shown.) Index: ThreadLocalDB.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jca/ejb/ThreadLocalDB.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- ThreadLocalDB.java 30 Aug 2003 15:44:30 -0000 1.2 +++ ThreadLocalDB.java 20 Jun 2005 22:56:08 -0000 1.3 @@ -1,4 +1,3 @@ - /* * JBoss, the OpenSource J2EE webOS * @@ -9,16 +8,16 @@ package org.jboss.test.jca.ejb; import java.sql.Connection; -import java.sql.Statement; + import javax.naming.InitialContext; import javax.sql.DataSource; /** * Thread Local Database + * * @author <a href="mailto:ad...@jb...">Adrian Brock</a> - * @version + * @version <tt>$Revision: 1.3 $</tt> */ - public class ThreadLocalDB { private static ThreadLocal tl = new ThreadLocal(); @@ -59,4 +58,3 @@ return (Connection) tl.get(); } } - 1.2 +3 -1 jbosstest/src/main/org/jboss/test/jca/ejb/PreparedStatementBean.java (In the diff below, changes in quantity of whitespace are not shown.) Index: PreparedStatementBean.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jca/ejb/PreparedStatementBean.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- PreparedStatementBean.java 5 Dec 2004 23:43:14 -0000 1.1 +++ PreparedStatementBean.java 20 Jun 2005 22:56:08 -0000 1.2 @@ -30,11 +30,13 @@ /** A BMP bean which exercises the prepared statement cache. * * @author Sco...@jb... - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class PreparedStatementBean implements EntityBean { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; static Logger log = Logger.getLogger(PreparedStatementBean.class); private EntityContext ctx = null; private DataSource ds; 1.2 +10 -14 jbosstest/src/main/org/jboss/test/jca/ejb/UserTxSessionBean.java (In the diff below, changes in quantity of whitespace are not shown.) Index: UserTxSessionBean.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jca/ejb/UserTxSessionBean.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- UserTxSessionBean.java 29 Jun 2002 07:23:23 -0000 1.1 +++ UserTxSessionBean.java 20 Jun 2005 22:56:08 -0000 1.2 @@ -7,26 +7,21 @@ package org.jboss.test.jca.ejb; +import javax.ejb.EJBException; import javax.ejb.SessionBean; import javax.ejb.SessionContext; import javax.naming.InitialContext; -import javax.naming.NamingException; -import org.apache.log4j.Category; import javax.transaction.UserTransaction; -import javax.ejb.EJBException; -import org.jboss.test.jca.adapter.TestConnectionFactory; +import org.jboss.logging.Logger; import org.jboss.test.jca.adapter.TestConnection; - +import org.jboss.test.jca.adapter.TestConnectionFactory; /** * UserTxSessionBean.java * - * - * Created: Thu Jun 27 09:02:18 2002 - * * @author <a href="mailto:d_j...@us...">David Jencks</a> - * @version + * @version <tt>$Revision: 1.2 $</tt> * * @ejb.bean name="UserTxSession" * jndi-name="UserTxSession" @@ -36,13 +31,14 @@ * transaction-type="Bean" * @ejb.transaction type="NotSupported" */ - public class UserTxSessionBean implements SessionBean { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; private SessionContext ctx; - private Category log = Category.getInstance(getClass().getName()); + private Logger log = Logger.getLogger(getClass()); public UserTxSessionBean() { @@ -73,7 +69,7 @@ catch (Exception e) { throw new EJBException(e.getMessage()); - } // end of try-catch + } } @@ -101,7 +97,7 @@ catch (Exception e) { throw new EJBException(e.getMessage()); - } // end of try-catch + } } @@ -131,4 +127,4 @@ this.ctx = null; } -}// UserTxSessionBean +} |