Author: shawkins
Date: 2009-04-08 19:00:01 -0400 (Wed, 08 Apr 2009)
New Revision: 733
Added:
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/PooledConnector.java
Log:
TEIID-481 fix for npe on pooled xa connections
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/PooledConnector.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/PooledConnector.java 2009-04-08
20:38:18 UTC (rev 732)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/PooledConnector.java 2009-04-08
23:00:01 UTC (rev 733)
@@ -100,6 +100,7 @@
@Override
public void start(ConnectorEnvironment environment)
throws ConnectorException {
+ this.environment = environment;
pool.initialize(environment);
if (xaPool != null) {
xaPool.initialize(environment);
Added:
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java
(rev 0)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java 2009-04-08
23:00:01 UTC (rev 733)
@@ -0,0 +1,58 @@
+/*
+ * 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.dqp.internal.pooling.connector;
+
+import java.util.Properties;
+
+import javax.transaction.Transaction;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.connector.api.ConnectorLogger;
+import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.xa.api.TransactionContext;
+import org.teiid.connector.xa.api.XAConnection;
+import org.teiid.connector.xa.api.XAConnector;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorEnvironmentImpl;
+
+import com.metamatrix.common.application.ApplicationEnvironment;
+
+public class TestPooledConnector {
+
+ @Test public void testGetXAConnection() throws Exception {
+ XAConnector connector = Mockito.mock(XAConnector.class);
+ PooledConnector pc = new PooledConnector(connector);
+ pc.start(new ConnectorEnvironmentImpl(new Properties(),
Mockito.mock(ConnectorLogger.class), new ApplicationEnvironment()));
+ TransactionContext tc = Mockito.mock(TransactionContext.class);
+ Mockito.stub(tc.getTransaction()).toReturn(Mockito.mock(Transaction.class));
+ Mockito.stub(tc.getTxnID()).toReturn("1"); //$NON-NLS-1$
+ XAConnection conn = pc.getXAConnection(Mockito.mock(ExecutionContext.class), tc);
+ conn.close();
+ XAConnection conn1 = pc.getXAConnection(Mockito.mock(ExecutionContext.class), tc);
+ assertSame(conn, conn1);
+ pc.stop();
+ }
+
+}
Property changes on:
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Show replies by date