[jboss-cvs] JBossAS SVN: r75076 - in trunk/testsuite/src/main/org/jboss/test/jca: interfaces and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 25 13:07:23 EDT 2008
Author: adrian at jboss.org
Date: 2008-06-25 13:07:23 -0400 (Wed, 25 Jun 2008)
New Revision: 75076
Modified:
trunk/testsuite/src/main/org/jboss/test/jca/ejb/JDBCStatementTestsConnectionSessionBean.java
trunk/testsuite/src/main/org/jboss/test/jca/interfaces/JDBCStatementTestsConnectionSession.java
trunk/testsuite/src/main/org/jboss/test/jca/jdbc/TestConnection.java
trunk/testsuite/src/main/org/jboss/test/jca/test/JDBCStatementTestsConnectionUnitTestCase.java
Log:
[JBAS-5678] - Port tests from 4.2
Modified: trunk/testsuite/src/main/org/jboss/test/jca/ejb/JDBCStatementTestsConnectionSessionBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jca/ejb/JDBCStatementTestsConnectionSessionBean.java 2008-06-25 16:58:45 UTC (rev 75075)
+++ trunk/testsuite/src/main/org/jboss/test/jca/ejb/JDBCStatementTestsConnectionSessionBean.java 2008-06-25 17:07:23 UTC (rev 75076)
@@ -276,7 +276,102 @@
throw new EJBException(e);
}
}
+
+ public void testRollbackOnCloseNoTx()
+ {
+ TestConnection tc = null;
+ try
+ {
+ DataSource ds = (DataSource) new InitialContext().lookup("java:NoTxStatementTestsConnectionDS");
+ Connection c = ds.getConnection();
+ try
+ {
+ c.setAutoCommit(false);
+ WrappedConnection wc = (WrappedConnection) c;
+ Connection uc = wc.getUnderlyingConnection();
+ tc = (TestConnection) Proxy.getInvocationHandler(uc);
+ try
+ {
+ c.nativeSQL("ERROR");
+ }
+ catch (SQLException expected)
+ {
+ }
+ }
+ finally
+ {
+ try
+ {
+ c.close();
+ }
+ catch (SQLException ignored)
+ {
+ }
+ }
+
+ if (tc.isClosed() == false)
+ throw new RuntimeException("Connection was not closed");
+ if (tc.isRolledBack() == false)
+ throw new RuntimeException("Connection was not rolled back");
+ }
+ catch (SQLException e)
+ {
+ throw new EJBException(e);
+ }
+ catch (NamingException e)
+ {
+ throw new EJBException(e);
+ }
+ }
+
+ public void testRollbackOnCloseManagedTx()
+ {
+ TestConnection tc = null;
+ try
+ {
+ DataSource ds = (DataSource) new InitialContext().lookup("java:StatementTestsConnectionDS");
+ Connection c = ds.getConnection();
+ try
+ {
+ WrappedConnection wc = (WrappedConnection) c;
+ Connection uc = wc.getUnderlyingConnection();
+ tc = (TestConnection) Proxy.getInvocationHandler(uc);
+
+ try
+ {
+ c.nativeSQL("ERROR");
+ }
+ catch (SQLException expected)
+ {
+ }
+ }
+ finally
+ {
+ try
+ {
+ c.close();
+ }
+ catch (SQLException ignored)
+ {
+ }
+ }
+
+ if (tc.isClosed() == false)
+ throw new RuntimeException("Connection was not closed");
+ if (tc.isRolledBack() == false)
+ throw new RuntimeException("Connection was not rolled back");
+ }
+ catch (SQLException e)
+ {
+ throw new EJBException(e);
+ }
+ catch (NamingException e)
+ {
+ throw new EJBException(e);
+ }
+ }
+
public void ejbCreate()
{
}
Modified: trunk/testsuite/src/main/org/jboss/test/jca/interfaces/JDBCStatementTestsConnectionSession.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jca/interfaces/JDBCStatementTestsConnectionSession.java 2008-06-25 16:58:45 UTC (rev 75075)
+++ trunk/testsuite/src/main/org/jboss/test/jca/interfaces/JDBCStatementTestsConnectionSession.java 2008-06-25 17:07:23 UTC (rev 75076)
@@ -39,4 +39,7 @@
public void testLazyAutoCommit() throws java.rmi.RemoteException;
+ public void testRollbackOnCloseNoTx() throws java.rmi.RemoteException;
+
+ public void testRollbackOnCloseManagedTx() throws java.rmi.RemoteException;
}
Modified: trunk/testsuite/src/main/org/jboss/test/jca/jdbc/TestConnection.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jca/jdbc/TestConnection.java 2008-06-25 16:58:45 UTC (rev 75075)
+++ trunk/testsuite/src/main/org/jboss/test/jca/jdbc/TestConnection.java 2008-06-25 17:07:23 UTC (rev 75076)
@@ -48,6 +48,18 @@
private boolean closed;
+ private boolean rolledBack;
+
+ public boolean isClosed()
+ {
+ return closed;
+ }
+
+ public boolean isRolledBack()
+ {
+ return rolledBack;
+ }
+
public TestConnection(TestDriver driver)
{
this.driver = driver;
@@ -70,6 +82,10 @@
return closed;
if ("close".equals(name))
close();
+ if ("nativeSQL".equals(name))
+ nativeSQL((String) args[0]);
+ if ("rollback".equals(name))
+ rollback();
if ("createStatement".equals(name))
return createStatement();
if ("createPreparedStatement".equals(name))
@@ -108,4 +124,19 @@
{
return (PreparedStatement) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { PreparedStatement.class }, new TestPreparedStatement(driver));
}
+
+ public String nativeSQL(String sql)
+ {
+ if ("ERROR".equals(sql))
+ {
+ rolledBack = false;
+ throw new RuntimeException(sql);
+ }
+ return sql;
+ }
+
+ public void rollback()
+ {
+ rolledBack = true;
+ }
}
Modified: trunk/testsuite/src/main/org/jboss/test/jca/test/JDBCStatementTestsConnectionUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jca/test/JDBCStatementTestsConnectionUnitTestCase.java 2008-06-25 16:58:45 UTC (rev 75075)
+++ trunk/testsuite/src/main/org/jboss/test/jca/test/JDBCStatementTestsConnectionUnitTestCase.java 2008-06-25 17:07:23 UTC (rev 75076)
@@ -1,24 +1,24 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.test.jca.test;
import junit.framework.*;
@@ -97,4 +97,20 @@
s.testLazyAutoCommit();
}
+ public void testRollbackOnCloseNoTx() throws Exception
+ {
+ JDBCStatementTestsConnectionSessionHome home =
+ (JDBCStatementTestsConnectionSessionHome)getInitialContext().lookup("JDBCStatementTestsConnectionSession");
+ JDBCStatementTestsConnectionSession s = home.create();
+ s.testRollbackOnCloseNoTx();
+ }
+
+ public void testRollbackOnCloseManagedTx() throws Exception
+ {
+ JDBCStatementTestsConnectionSessionHome home =
+ (JDBCStatementTestsConnectionSessionHome)getInitialContext().lookup("JDBCStatementTestsConnectionSession");
+ JDBCStatementTestsConnectionSession s = home.create();
+ s.testRollbackOnCloseManagedTx();
+ }
+
}
More information about the jboss-cvs-commits
mailing list