[teiid-commits] teiid SVN: r4027 - in branches/8.0.x/client/src: test/java/org/teiid/jdbc and 1 other directory.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Mon Apr 23 14:13:48 EDT 2012
Author: shawkins
Date: 2012-04-23 14:13:47 -0400 (Mon, 23 Apr 2012)
New Revision: 4027
Removed:
branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAResourceImpl.java
Modified:
branches/8.0.x/client/src/main/java/org/teiid/jdbc/BaseDataSource.java
branches/8.0.x/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
branches/8.0.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java
branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestXAConnection.java
Log:
TEIID-2006 adding support for a set payload statement and optional encryption of requests and refactoring to simplify xaresourceimpl
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/BaseDataSource.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/BaseDataSource.java 2012-04-23 17:02:11 UTC (rev 4026)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/BaseDataSource.java 2012-04-23 18:13:47 UTC (rev 4027)
@@ -350,11 +350,7 @@
* @see javax.sql.XADataSource#getXAConnection(java.lang.String, java.lang.String)
*/
public XAConnection getXAConnection(final String userName, final String password) throws java.sql.SQLException {
- return XAConnectionImpl.newInstance(new XAConnectionImpl.ConnectionSource() {
-
- public ConnectionImpl createConnection() throws SQLException {
- return (ConnectionImpl)getConnection(userName, password);
- }});
+ return new XAConnectionImpl((ConnectionImpl) getConnection(userName, password));
}
public PooledConnection getPooledConnection() throws SQLException {
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2012-04-23 17:02:11 UTC (rev 4026)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2012-04-23 18:13:47 UTC (rev 4027)
@@ -100,7 +100,8 @@
private String debugLog;
// the last query annotations
private Collection<Annotation> annotations;
- private Properties connectionProps;
+ private Properties connectionProps;
+ private Properties payload;
public ConnectionImpl(ServerConnection serverConn, Properties info, String url) {
this.connectionProps = info;
@@ -829,6 +830,7 @@
}
public void recycleConnection() {
+ this.payload = null;
try {
//close all open statements
this.closeStatements();
@@ -1034,6 +1036,14 @@
public void setSchema(String schema) throws SQLException {
- }
-
+ }
+
+ public Properties getPayload() {
+ return payload;
+ }
+
+ public void setPayload(Properties payload) {
+ this.payload = payload;
+ }
+
}
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2012-04-23 17:02:11 UTC (rev 4026)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2012-04-23 18:13:47 UTC (rev 4027)
@@ -156,8 +156,8 @@
protected Map<String, Integer> outParamByName = new TreeMap<String, Integer>(String.CASE_INSENSITIVE_ORDER);
private static Pattern TRANSACTION_STATEMENT = Pattern.compile("\\s*(commit|rollback|(start\\s+transaction))\\s*;?", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
- private static Pattern SET_STATEMENT = Pattern.compile("\\s*set\\s+((?:session authorization)|(?:\\w+))\\s+(?:([a-zA-Z](?:\\w|_)*)|((?:'[^']*')+));?", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
- private static Pattern SHOW_STATEMENT = Pattern.compile("\\s*show\\s+(\\w*);?", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
+ private static Pattern SET_STATEMENT = Pattern.compile("\\s*set(?:\\s+(payload))?\\s+((?:session authorization)|(?:[a-zA-Z]\\w*))\\s+(?:([a-zA-Z]\\w*)|((?:'[^']*')+));?", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
+ private static Pattern SHOW_STATEMENT = Pattern.compile("\\s*show\\s+([a-zA-Z]\\w*);?", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
/**
* Factory Constructor
* @param driverConnection
@@ -430,14 +430,22 @@
if (resultsMode == ResultsMode.RESULTSET) {
throw new TeiidSQLException(JDBCPlugin.Util.getString("StatementImpl.set_result_set")); //$NON-NLS-1$
}
- String key = match.group(1);
- String value = match.group(2);
+ String key = match.group(2);
+ String value = match.group(3);
if (value == null) {
- value = match.group(3);
+ value = match.group(4);
value = StringUtil.replaceAll(value, "''", "'"); //$NON-NLS-1$ //$NON-NLS-2$
value = value.substring(1, value.length() - 1);
}
- if ("SESSION AUTHORIZATION".equalsIgnoreCase(key)) { //$NON-NLS-1$
+ if (match.group(1) != null) {
+ //payload case
+ Properties p = this.getMMConnection().getPayload();
+ if (p == null) {
+ p = new Properties();
+ this.getMMConnection().setPayload(p);
+ }
+ p.setProperty(key, value);
+ } else if ("SESSION AUTHORIZATION".equalsIgnoreCase(key)) { //$NON-NLS-1$
this.getMMConnection().changeUser(value, this.getMMConnection().getPassword());
} else if (key.equalsIgnoreCase(TeiidURL.CONNECTION.PASSWORD)) {
this.getMMConnection().setPassword(value);
@@ -589,7 +597,11 @@
this.getConnection().beginLocalTxnIfNeeded();
this.currentRequestID = this.driverConnection.nextRequestID();
// Create a request message
- reqMsg.setExecutionPayload(this.payload);
+ if (this.payload != null) {
+ reqMsg.setExecutionPayload(this.payload);
+ } else {
+ reqMsg.setExecutionPayload(this.getMMConnection().getPayload());
+ }
reqMsg.setCursorType(this.resultSetType);
reqMsg.setFetchSize(this.fetchSize);
reqMsg.setRowLimit(this.maxRows);
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java 2012-04-23 17:02:11 UTC (rev 4026)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java 2012-04-23 18:13:47 UTC (rev 4027)
@@ -32,15 +32,21 @@
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.sql.ConnectionEvent;
import javax.sql.ConnectionEventListener;
import javax.sql.StatementEventListener;
import javax.sql.XAConnection;
+import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
import org.teiid.client.security.InvalidSessionException;
import org.teiid.client.util.ExceptionUtil;
+import org.teiid.client.xa.XATransactionException;
+import org.teiid.client.xa.XidImpl;
import org.teiid.net.CommunicationException;
import org.teiid.net.ServerConnection;
import org.teiid.net.socket.SingleInstanceCommunicationException;
@@ -48,14 +54,8 @@
/**
* Implementation of XAConnection.
*/
-public class XAConnectionImpl implements XAConnection{
+public class XAConnectionImpl implements XAConnection, XAResource {
- interface ConnectionSource {
-
- ConnectionImpl createConnection() throws SQLException;
-
- }
-
private final class CloseInterceptor implements
InvocationHandler {
@@ -69,8 +69,7 @@
Method method,
Object[] args) throws Throwable {
if ("close".equals(method.getName())) { //$NON-NLS-1$
- this.proxiedConnection.recycleConnection();
- XAConnectionImpl.this.notifyListener(null);
+ close();
return null;
}
@@ -99,28 +98,32 @@
throw e.getTargetException();
}
}
+
+ void close() {
+ this.proxiedConnection.recycleConnection();
+ XAConnectionImpl.this.notifyListener(null);
+ }
}
+ private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
+
+ private int timeOut;
private Set<ConnectionEventListener> listeners;
- private XAResource resource;
private ConnectionImpl connection;
- private ConnectionSource cs;
-
+ private CloseInterceptor handler;
private boolean isClosed;
- public static XAConnectionImpl newInstance (ConnectionSource cs){
- return new XAConnectionImpl(cs);
- }
-
- public XAConnectionImpl(ConnectionSource cs){
- this.cs = cs;
+ public XAConnectionImpl(ConnectionImpl conn){
+ this.connection = conn;
}
public Connection getConnection() throws SQLException{
ConnectionImpl conn = getConnectionImpl();
-
- Connection result = (Connection)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {Connection.class}, new CloseInterceptor(conn));
-
+ if (handler != null) {
+ handler.close();
+ }
+ handler = new CloseInterceptor(conn);
+ Connection result = (Connection)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {Connection.class}, handler);
return result;
}
@@ -129,15 +132,6 @@
throw new SQLException(JDBCPlugin.Util.getString("MMXAConnection.connection_is_closed")); //$NON-NLS-1$
}
- if(connection == null){
- try{
- connection = cs.createConnection();
- }catch(SQLException e){
- notifyListener(e);
- throw e;
- }
- }
-
return connection;
}
@@ -156,10 +150,7 @@
}
public XAResource getXAResource() throws SQLException{
- if(resource == null){
- resource = XAResourceImpl.newInstance(this);
- }
- return resource;
+ return this;
}
public void close()throws SQLException{
@@ -195,4 +186,138 @@
public void removeStatementEventListener(StatementEventListener arg0) {
}
+
+ public void commit(Xid xid, boolean onePhase) throws XAException {
+ XidImpl mmXid = getMMXid(xid);
+ try{
+ getMMConnection().commitTransaction(mmXid, onePhase);
+ }catch(SQLException e){
+ String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedCommitTXN", xid, onePhase ? "true":"false"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ throw handleError(e, logMsg);
+ }
+ }
+
+ private XAException handleError(Exception e,String logMsg) {
+ logger.log(Level.SEVERE, logMsg, e);
+
+ if(e instanceof TeiidSQLException){
+ Throwable ex = ((TeiidSQLException)e).getCause();
+ if(ex instanceof XAException){
+ return (XAException)ex;
+ }
+ if (ex instanceof XATransactionException) {
+ return ((XATransactionException)ex).getXAException();
+ }
+ }
+ return new XAException(XAException.XAER_RMERR);
+ }
+
+ /**
+ * @see javax.transaction.xa.XAResource#end(javax.transaction.xa.Xid, int)
+ */
+ public void end(Xid xid, int flag) throws XAException {
+ XidImpl mmXid = getMMXid(xid);
+ try{
+ getMMConnection().endTransaction(mmXid, flag);
+ }catch(SQLException e){
+ String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedEndTXN", xid, new Integer(flag)); //$NON-NLS-1$
+ throw handleError(e, logMsg);
+ }
+ }
+
+ /**
+ * @see javax.transaction.xa.XAResource#forget(javax.transaction.xa.Xid)
+ */
+ public void forget(Xid xid) throws XAException {
+ XidImpl mmXid = getMMXid(xid);
+ try{
+ getMMConnection().forgetTransaction(mmXid);
+ }catch(SQLException e){
+ String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedForgetTXN", xid); //$NON-NLS-1$
+ throw handleError(e, logMsg);
+ }
+ }
+
+ public int getTransactionTimeout() throws XAException {
+ return timeOut;
+ }
+
+ public boolean isSameRM(XAResource arg0) throws XAException {
+ if (arg0 == this) {
+ return true;
+ }
+ if (!(arg0 instanceof XAConnectionImpl)) {
+ return false;
+ }
+ XAConnectionImpl other = (XAConnectionImpl)arg0;
+ try {
+ return this.getMMConnection().isSameProcess(other.getMMConnection());
+ } catch (CommunicationException e) {
+ throw handleError(e, JDBCPlugin.Util.getString("MMXAResource.FailedISSameRM")); //$NON-NLS-1$
+ }
+ }
+
+ public int prepare(Xid xid) throws XAException {
+ XidImpl mmXid = getMMXid(xid);
+ try{
+ return getMMConnection().prepareTransaction(mmXid);
+ }catch(SQLException e){
+ String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedPrepareTXN", xid); //$NON-NLS-1$
+ throw handleError(e, logMsg);
+ }
+ }
+
+ /**
+ * @see javax.transaction.xa.XAResource#recover(int)
+ */
+ public Xid[] recover(int flag) throws XAException {
+ try{
+ return getMMConnection().recoverTransaction(flag);
+ }catch(SQLException e){
+ String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedRecoverTXN", flag); //$NON-NLS-1$
+ throw handleError(e, logMsg);
+ }
+ }
+
+ public void rollback(Xid xid) throws XAException {
+ XidImpl mmXid = getMMXid(xid);
+ try{
+ getMMConnection().rollbackTransaction(mmXid);
+ }catch(SQLException e){
+ String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedRollbackTXN", xid); //$NON-NLS-1$
+ throw handleError(e, logMsg);
+ }
+ }
+
+ public boolean setTransactionTimeout(int seconds) throws XAException {
+ timeOut = seconds;
+ return true;
+ }
+
+ public void start(Xid xid, int flag) throws XAException {
+ XidImpl mmXid = getMMXid(xid);
+ try{
+ getMMConnection().startTransaction(mmXid, flag, timeOut);
+ }catch(SQLException e){
+ String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedStartTXN", xid, new Integer(flag)); //$NON-NLS-1$
+ handleError(e, logMsg);
+ }
+ }
+
+ private ConnectionImpl getMMConnection() throws XAException{
+ try{
+ return this.getConnectionImpl();
+ }catch(SQLException e){
+ throw new XAException(XAException.XAER_RMFAIL);
+ }
+ }
+
+ /**
+ * @param xid
+ * @return
+ * @throws XAException
+ */
+ private XidImpl getMMXid(Xid originalXid) {
+ return new XidImpl(originalXid);
+ }
}
Deleted: branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAResourceImpl.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAResourceImpl.java 2012-04-23 17:02:11 UTC (rev 4026)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAResourceImpl.java 2012-04-23 18:13:47 UTC (rev 4027)
@@ -1,209 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.jdbc;
-
-import java.sql.SQLException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import org.teiid.client.xa.XATransactionException;
-import org.teiid.client.xa.XidImpl;
-import org.teiid.net.CommunicationException;
-
-
-/**
- * Implementation of XAResource.
- */
-public class XAResourceImpl implements XAResource{
- private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
-
- private XAConnectionImpl mmConnection;
- private int timeOut;
-
- public static XAResourceImpl newInstance (XAConnectionImpl mmConnection){
- return new XAResourceImpl(mmConnection);
- }
-
- public XAResourceImpl(XAConnectionImpl mmConnection){
- this.mmConnection = mmConnection;
- }
-
- /**
- * @see javax.transaction.xa.XAResource#commit(javax.transaction.xa.Xid, boolean)
- */
- public void commit(Xid xid, boolean onePhase) throws XAException {
- XidImpl mmXid = getMMXid(xid);
- try{
- getMMConnection().commitTransaction(mmXid, onePhase);
- }catch(SQLException e){
- String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedCommitTXN", xid, onePhase ? "true":"false"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- throw handleError(e, logMsg);
- }
- }
-
- private XAException handleError(Exception e,String logMsg) {
- logger.log(Level.SEVERE, logMsg, e);
-
- if(e instanceof TeiidSQLException){
- Throwable ex = ((TeiidSQLException)e).getCause();
- if(ex instanceof XAException){
- return (XAException)ex;
- }
- if (ex instanceof XATransactionException) {
- return ((XATransactionException)ex).getXAException();
- }
- }
- return new XAException(XAException.XAER_RMERR);
- }
-
- /**
- * @see javax.transaction.xa.XAResource#end(javax.transaction.xa.Xid, int)
- */
- public void end(Xid xid, int flag) throws XAException {
- XidImpl mmXid = getMMXid(xid);
- try{
- getMMConnection().endTransaction(mmXid, flag);
- }catch(SQLException e){
- String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedEndTXN", xid, new Integer(flag)); //$NON-NLS-1$
- throw handleError(e, logMsg);
- }
- }
-
- /**
- * @see javax.transaction.xa.XAResource#forget(javax.transaction.xa.Xid)
- */
- public void forget(Xid xid) throws XAException {
- XidImpl mmXid = getMMXid(xid);
- try{
- getMMConnection().forgetTransaction(mmXid);
- }catch(SQLException e){
- String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedForgetTXN", xid); //$NON-NLS-1$
- throw handleError(e, logMsg);
- }
- }
-
- /**
- * @see javax.transaction.xa.XAResource#getTransactionTimeout()
- */
- public int getTransactionTimeout() throws XAException {
- return timeOut;
- }
-
- /**
- * @see javax.transaction.xa.XAResource#isSameRM(javax.transaction.xa.XAResource)
- */
- public boolean isSameRM(XAResource arg0) throws XAException {
- if (arg0 == this) {
- return true;
- }
- if (!(arg0 instanceof XAResourceImpl)) {
- return false;
- }
- XAResourceImpl other = (XAResourceImpl)arg0;
- try {
- return this.getMMConnection().isSameProcess(other.getMMConnection());
- } catch (CommunicationException e) {
- throw handleError(e, JDBCPlugin.Util.getString("MMXAResource.FailedISSameRM")); //$NON-NLS-1$
- }
- }
-
- /**
- * @see javax.transaction.xa.XAResource#prepare(javax.transaction.xa.Xid)
- */
- public int prepare(Xid xid) throws XAException {
- XidImpl mmXid = getMMXid(xid);
- try{
- return getMMConnection().prepareTransaction(mmXid);
- }catch(SQLException e){
- String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedPrepareTXN", xid); //$NON-NLS-1$
- throw handleError(e, logMsg);
- }
- }
-
- /**
- * @see javax.transaction.xa.XAResource#recover(int)
- */
- public Xid[] recover(int flag) throws XAException {
- try{
- return getMMConnection().recoverTransaction(flag);
- }catch(SQLException e){
- String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedRecoverTXN", flag); //$NON-NLS-1$
- throw handleError(e, logMsg);
- }
- }
-
- /**
- * @see javax.transaction.xa.XAResource#rollback(javax.transaction.xa.Xid)
- */
- public void rollback(Xid xid) throws XAException {
- XidImpl mmXid = getMMXid(xid);
- try{
- getMMConnection().rollbackTransaction(mmXid);
- }catch(SQLException e){
- String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedRollbackTXN", xid); //$NON-NLS-1$
- throw handleError(e, logMsg);
- }
- }
-
- /**
- * @see javax.transaction.xa.XAResource#setTransactionTimeout(int)
- */
- public boolean setTransactionTimeout(int seconds) throws XAException {
- timeOut = seconds;
- return true;
- }
-
- /**
- * @see javax.transaction.xa.XAResource#start(javax.transaction.xa.Xid, int)
- */
- public void start(Xid xid, int flag) throws XAException {
- XidImpl mmXid = getMMXid(xid);
- try{
- getMMConnection().startTransaction(mmXid, flag, timeOut);
- }catch(SQLException e){
- String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedStartTXN", xid, new Integer(flag)); //$NON-NLS-1$
- handleError(e, logMsg);
- }
- }
-
- private ConnectionImpl getMMConnection() throws XAException{
- try{
- return this.mmConnection.getConnectionImpl();
- }catch(SQLException e){
- throw new XAException(XAException.XAER_RMFAIL);
- }
- }
-
- /**
- * @param xid
- * @return
- * @throws XAException
- */
- private XidImpl getMMXid(Xid originalXid) {
- return new XidImpl(originalXid);
- }
-}
Modified: branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestXAConnection.java
===================================================================
--- branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestXAConnection.java 2012-04-23 17:02:11 UTC (rev 4026)
+++ branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestXAConnection.java 2012-04-23 18:13:47 UTC (rev 4027)
@@ -42,12 +42,7 @@
final ConnectionImpl mmConn = TestConnection.getMMConnection();
- XAConnectionImpl xaConn = new XAConnectionImpl(new XAConnectionImpl.ConnectionSource() {
- @Override
- public ConnectionImpl createConnection() throws SQLException {
- return mmConn;
- }
- });
+ XAConnectionImpl xaConn = new XAConnectionImpl(mmConn);
Connection conn = xaConn.getConnection();
StatementImpl stmt = (StatementImpl)conn.createStatement();
@@ -68,14 +63,9 @@
}
@Test public void testNotification() throws Exception {
- XAConnectionImpl xaConn = new XAConnectionImpl(new XAConnectionImpl.ConnectionSource() {
- @Override
- public ConnectionImpl createConnection() throws SQLException {
- ConnectionImpl c = Mockito.mock(ConnectionImpl.class);
- Mockito.doThrow(new SQLException(new InvalidSessionException())).when(c).commit();
- return c;
- }
- });
+ ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
+ Mockito.doThrow(new SQLException(new InvalidSessionException())).when(conn).commit();
+ XAConnectionImpl xaConn = new XAConnectionImpl(conn);
ConnectionEventListener cel = Mockito.mock(ConnectionEventListener.class);
xaConn.addConnectionEventListener(cel);
Connection c = xaConn.getConnection();
More information about the teiid-commits
mailing list