<classpathentry kind="src" path="java"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="TOMCAT_LIBS_BASE/tomcat6-deps/dbcp/tomcat-dbcp.jar"/>
- <classpathentry kind="var" path="TOMCAT_LIBS_BASE"/>
<classpathentry combineaccessrules="false" kind="src" path="/tomcat-trunk"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
+ <classpathentry kind="var" path="TOMCAT_LIBS_BASE/tomcat6-deps/dbcp/tomcat-dbcp.jar"/>
+ <classpathentry kind="lib" path="mysql-connector-java-5.1.6-bin.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
super(name);
}
- protected void init() throws Exception {
+ public DataSourceProxy createDefaultDataSource() {
+ DataSourceProxy datasource = null;
PoolProperties p = new DefaultProperties();
p.setJmxEnabled(false);
p.setTestWhileIdle(false);
p.setRemoveAbandoned(false);
datasource = new org.apache.tomcat.jdbc.pool.DataSourceProxy();
datasource.setPoolProperties(p);
+ return datasource;
+ }
+
+ protected void init() throws Exception {
+ this.datasource = createDefaultDataSource();
}
protected void transferProperties() {
protected void tearDown() throws Exception {
+ try {datasource.close();}catch(Exception ignore){}
datasource = null;
tDatasource = null;
System.gc();
--- /dev/null
+package org.apache.tomcat.jdbc.test;
+
+import java.sql.Connection;
+
+import org.apache.tomcat.jdbc.pool.DataSourceProxy;
+
+public class TwoDataSources extends DefaultTestCase {
+
+ public TwoDataSources(String name) {
+ super(name);
+ }
+
+ public void testTwoDataSources() throws Exception {
+ DataSourceProxy d1 = this.createDefaultDataSource();
+ DataSourceProxy d2 = this.createDefaultDataSource();
+ d1.setRemoveAbandoned(true);
+ d1.setRemoveAbandonedTimeout(10);
+ d1.setTimeBetweenEvictionRunsMillis(1000);
+ d2.setRemoveAbandoned(false);
+ Connection c1 = d1.getConnection();
+ Connection c2 = d2.getConnection();
+ Thread.sleep(15000);
+ try {
+ c1.createStatement();
+ this.assertTrue("Connection should have been abandoned.",false);
+ }catch (Exception x) {
+ this.assertTrue("This is correct, c1 is abandoned",true);
+ }
+
+ try {
+ c2.createStatement();
+ this.assertTrue("Connection should not have been abandoned.",true);
+ }catch (Exception x) {
+ this.assertTrue("Connection c2 should be working",false);
+ }
+ try {
+ c1.close();
+ this.assertTrue("Connection should have been closed.",false);
+ }catch (Exception x) {
+ this.assertTrue("This is correct, c1 is closed",true);
+ }
+ try {
+ c2.close();
+ this.assertTrue("Connection c2 should not have been closed.",true);
+ }catch (Exception x) {
+ this.assertTrue("Connection c2 should be working",false);
+ }
+
+
+
+ }
+
+}