libcommons-dbcp-java-1.4.orig/ 0000755 0001750 0001750 00000000000 11337741616 016211 5 ustar drazzib drazzib libcommons-dbcp-java-1.4.orig/build.properties.sample 0000644 0001750 0001750 00000005143 11333570550 022702 0 ustar drazzib drazzib # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##########################################################################
# Sample Ant build.properties file
#
# This setup assumes dependent jars are in a local maven 2 repository.
# However the jars are located, the properties ending in ".jar" need to
# expand to full paths to the jars.
##########################################################################
# Repository base path
repository=${user.home}/.m2/repository
# commons-pool.jar - path to commons-pool-1.5.4.jar
commons-pool.home=${repository}/commons-pool/commons-pool/1.5.4
commons-pool.jar=${commons-pool.home}/commons-pool-1.5.4.jar
# JUnit
junit.home=${repository}/junit/junit/3.8.2
junit.jar=${junit.home}/junit-3.8.2.jar
# XML parser
xerces.home=${repository}/xerces/xercesImpl/2.4.0
xerces.jar=${xerces.home}/xercesImpl-2.4.0.jar
# Tomcat naming jars - needed only for JNDI tests
naming.common.home=${repository}/tomcat/naming-common/5.0.28
naming-common.jar=${naming.common.home}/naming-common-5.0.28.jar
naming.java.home=${repository}/tomcat/naming-java/5.0.28
naming-java.jar=${naming.java.home}/naming-java-5.0.28.jar
# Commons logging - dependency of naming jars
commons-logging.home=${repository}/commons-logging/commons-logging/1.1.1
commons-logging.jar=${commons-logging.home}/commons-logging-1.1.1.jar
# JTA - needed for managed connections
jta-spec.jar=${repository}/org/apache/geronimo/specs/geronimo-jta_1.1_spec/1.1/geronimo-jta_1.1_spec-1.1.jar
jta-impl.jar=${repository}/org/apache/geronimo/modules/geronimo-transaction/1.2-beta/geronimo-transaction-1.2-beta.jar
# JTA dependencies - required so the test cases run
backport-util-concurrent.jar=${repository}/backport-util-concurrent/backport-util-concurrent/2.2/backport-util-concurrent-2.2.jar
ejb-spec.jar=${repository}/org/apache/geronimo/specs/geronimo-ejb_2.1_spec/1.1/geronimo-ejb_2.1_spec-1.1.jar
libcommons-dbcp-java-1.4.orig/pom.xml 0000644 0001750 0001750 00000025577 11333570550 017537 0 ustar drazzib drazzib
org.apache.commonscommons-parent124.0.0commons-dbcpcommons-dbcp1.4Commons DBCP2001Commons Database Connection Poolinghttp://commons.apache.org/dbcp/people.apache.orgCommons DBCPscp://people.apache.org/www/commons.apache.org/dbcpjirahttp://issues.apache.org/jira/browse/DBCPscm:svn:http://svn.apache.org/repos/asf/commons/proper/dbcp/trunkscm:svn:https://svn.apache.org/repos/asf/commons/proper/dbcp/trunkhttp://svn.apache.org/viewvc/commons/proper/dbcp/trunkMorgan DelagrangemorgandGeir MagnussongeirmCraig McClanahancraigmccJohn McNallyjmcnallyMartin Poeschlmpoeschlmpoeschl@marmot.attucana.atRodney WaldhoffrwaldhoffDavid Weinrichdweinr1Dirk VerbeeckdirkvYoav Shapirayoavsyoavs@apache.orgApache Software FoundationPhil SteitzpsteitzJörg Schaiblejoehnijoerg.schaible@gmx.de+1Mark Thomasmarktmarkt@apache.orgApache Software FoundationTodd Carmichaeltoddc@concur.comWayne WoodfieldDain Sundstromdain@apache.orgPhilippe Mouawadcommons-poolcommons-pool1.5.4junitjunit3.8.2testorg.apache.geronimo.specsgeronimo-jta_1.1_spec1.1.1truetomcatnaming-common5.0.28testtomcatnaming-java5.0.28testcommons-loggingcommons-logging1.1.1testorg.apache.geronimo.modulesgeronimo-transaction1.2-betatest1.61.6dbcp1.4DBCP12310469src/javasrc/testsrc/testtestpool.jocl.META-INFNOTICE.txtLICENSE.txt${basedir}/src/testtestpool.joclorg.codehaus.mojocobertura-maven-plugin2.3org.apache.maven.pluginsmaven-surefire-pluginplain**/Tester*.java**/Test*$*.javamaven-assembly-pluginsrc/assembly/bin.xmlsrc/assembly/src.xmlgnuorg.codehaus.mojofindbugs-maven-plugin2.1NormalDefault${basedir}/findbugs-exclude-filter.xmlorg.codehaus.mojocobertura-maven-plugin2.3org.apache.maven.pluginsmaven-javadoc-plugin2.4
http://java.sun.com/j2se/1.5.0/docs/api
http://commons.apache.org/pool/api-1.5.4
http://java.sun.com/j2ee/sdk_1.3/techdocs/api
org.apache.maven.pluginsmaven-changes-plugin2.0${basedir}/xdocs/changes.xml%URL%/%ISSUE%
dbcp-release-notes.vm
src/templatechanges-reportorg.apache.maven.pluginsmaven-checkstyle-plugin2.1${basedir}/checkstyle.xmlfalseorg.apache.maven.pluginsmaven-pmd-plugin2.4checkstyle.xml${maven.compile.target}org.codehaus.mojoclirr-maven-plugin2.2.21.2.2info
libcommons-dbcp-java-1.4.orig/build.xml 0000644 0001750 0001750 00000026202 11333570550 020025 0 ustar drazzib drazzib
Checking dependencies
libcommons-dbcp-java-1.4.orig/RELEASE-NOTES.txt 0000644 0001750 0001750 00000023313 11333570550 020713 0 ustar drazzib drazzib
commons-dbcp-1.3/1.4 RELEASE NOTES
This release includes new features as well as bug fixes and enhancements. Some bug fixes
change semantics (e.g. connection close is now idempotent). The 1.3 and 1.4 releases of DBCP
are built from the same sources. Version 1.4 supports JDBC 4, so requires JDK 1.6.
Applications running under JDK 1.4-1.5 must use DBCP 1.3. Applications running under JDK 1.6
should use DBCP 1.4. Other than support for the added methods in JDBC 4, there is nothing new
or different in DBCP 1.4 vs. DBCP 1.3. The list of changes below since 1.2.2 applies to both
the 1.3 and 1.4 release. Other than the issue related to adding JDBC 4 support (DBCP-191),
all bug fixes or new features are included in both DBCP 1.3 and 1.4.
Changes since DBCP 1.2.2 include:
New features:
o DBCP-204: Made PoolingConnection pool CallableStatements. When BasicDataSource's
poolPreparedStatements property is true, CallableStatements are now
pooled along with PreparedStatements. The maxOpenPreparedStatements
property limits the combined number of Callable and Prepared statements
that can be in use at a given time. Thanks to Wei Chen.
o DBCP-226: Added a validationQueryTimeout configuration parameter to BasicDataSource
allowing the user to specify a timeout value (in seconds) for connection
validation queries.
o DBCP-175: Added a connectionInitSqls configuration parameter to BasicDataSource
allowing the user to specify a collection of SQL statements to execute
one time when a physical database connection is first opened. Thanks to Jiri Melichna and Jerome Lacoste.
o DBCP-228: Added support for pooling managed connections. Thanks to Dain Sundstrom.
o DBCP-230: Added BasicManagedDataSource, extending BasicDataSource.
Also improved extensibility of BasicDataSource by encapsulating
methods to create object pool, connection factory and datasource
instance previously embedded in createDataSource. Thanks to Dain Sundstrom.
Fixed Bugs:
o DBCP-320: Eliminated poolKeys cache from PerUserPoolDataSource.
o DBCP-321: Eliminated userKeys LRUMap cache from SharedPoolDataSource.
o DBCP-319: Made private fields final where possible. Thanks to Sebastian Bazley.
o DBCP-318: PerUserPoolDataSource.getPooledConnectionAndInfo multi-threading bug. Thanks to Sebastian Bazley.
o DBCP-315: Remove throws clause from method that does not throw an exception. Thanks to Sebastian Bazley.
o DBCP-313: Remove code that catches and ignores Exceptions when calling
PooledConnection.removeConnectionEventListener(ConnectionEventListener)
as the method does not throw any Exceptions. Thanks to Sebastian Bazley.
o DBCP-316: Remove impossible null check. Thanks to Sebastian Bazley.
o DBCP-303: Ensure Statement.getGeneratedKeys() works correctly with the CPDS
adapter. Thanks to Dave Oxley.
o DBCP-302: Removed incorrectly advertised ClassNotFoundException from
JOCLContentHandler.ConstructorDetails.createObject(). Thanks to Sebastian Bazley.
o DBCP-8: Handle user password changes for InstanceKeyDataSources.
o DBCP-294: Added PoolableManagedConnection and PoolableManagedConnectionFactory so that
pooled managed connections can unregister themselves from transaction registries,
avoiding resource leaks. Thanks to Philippe Mouawad.
o DBCP-212: PoolableConnectionFactory.makeObject() is no longer synchronized. This
provides improved response times when load spikes at the cost of a
faster rise in database server load. This change was made as a partial
fix for DBCP-212. The synchronization changes in Commons Pool 1.5 complete
the fix for this issue.
o DBCP-242: Reverted DelegatingConnection close to 1.2.2 version to ensure
open statements are closed before the underlying connection is closed.
o DBCP-235: Refactor DelegatingConnection and ManagedConnection enable overridden
equals() and hashcode() to work correctly.
o DBCP-215: Modified BasicDataSourceFactory to complete initialization of the pool
by creating initialSize connections rather than leaving this to lazy
initialization when the pool is used.
o DBCP-253: Eliminated masked _stmt field in descendents of DelegatingStatement.
o DBCP-191: Modified DBCP sources to support compilation under JDK 1.4-1.6
using Ant flags to do conditional compilation. Thanks to Michael Heuer and J. David Beutel.
o DBCP-272: Added a static initializer to BasicDatasource that calls
DriverManager.getDrivers() to force initialization before we ever do
anything that might use Class.forName() to load (and register) a JDBC
driver.
o DBCP-4: Eliminated direct System.out calls in AbandonedTrace.
o DBCP-264: Modified DelegatingStatment close to clear open batches.
o DBCP-255: Eliminated unused private "parent" field in AbandonedTrace.
o DBCP-273: Fixed errors handling boolean-valued Reference properties in
InstanceKeyObjectFactory, DriverAdapterCPDS that were causing
testOnBorrow and poolPreparedStatements properties to be incorrectly
set when creating objects from javax.naming.Reference instances. Thanks to Mark Lin.
o DBCP-271: Made private instance fields of AbandonedTrace volatile (parent,
createdBy, lastUsed, createdTime) or final (trace). Thanks to Sebastian Bazley.
o DBCP-270: Narrowed synchronization in AbandonedTrace to resolve an Evictor deadlock. Thanks to Filip Hanik.
o DBCP-218: Corrected Javadoc to state that getLoginTimeout and setLoginTimeout are
NOT supported by BasicDataSource.
o DBCP-221: BasicDataSource.close() now permanently marks the data source as closed,
and no new connections can be obtained from the data source. At close all
idle connections are destroyed and the method returns. As the remaining
active connections are closed, they are destroyed.
o DBCP-241: Eliminated potential sources of NullPointerExceptions in
PoolingConnection.
o DBCP-216: Improved error recovery and listener cleanup in
KeyedCPDSConnectionFactory. Substituted calls to destroyObject with
_pool.invalidateObject on error to ensure pool active count is
decremented on error events. Ensured that events from closed or invalid
connections are ignored and listeners are cleaned up. Thanks to Marcos Sanz.
o DBCP-245: Fixed error in SharedPoolDataSource causing incorrect passwords to be
stored under certain conditions. Thanks to Michael Drechsel.
o DBCP-237: Added exception handler to ensure that PooledConnections are not
orphaned when an exception occurs in setUpDefaults or clearWarnings in
IntanceKeyDataSource.getConnection. Thanks to Oliver Matz.
o DBCP-252: Made getPool synchronized in PoolableConnectionFactory.
Fixes inconsistent synchronization accessing _pool. Thanks to FindBugs.
o DBCP-252: Fixed inconsistent synchronization on _rollbackAfterValidation,
_validationQuery and _pool in CPDSConnectionFactory and
KeyedCPDSConnectionFactory by making the first two volatile and making
both getter and setter for _pool synchronized. Thanks to FindBugs.
Changes:
o DBCP-314: Renamed variables with duplicate names in different scopes. Thanks to Sebastian Bazley.
o DBCP-312: Clarified javadoc for BasicDataSource close() method. Thanks to Glen Mazza.
o DBCP-305: Use an API specific exception for logging abandoned objects to make
scanning the logs for these exceptions simpler and to provide a better
message that includes the creation time of the abandoned object. Thanks to Christopher Schultz.
o DBCP-203: Make the class loader used to load the JDBC driver configurable for the
BasicDatasource. Thanks to Mark Grand.
o DBCP-289: Made XADataSource configurable in BasicManagedDataSource. Thanks to Marc Kannegieer.
o DBCP-276: Added connectionProperties property to DriverAdapterCPDS.
o DBCP-265: Add a DelegatingDatabaseMetaData to track ResultSets returned from
DatabaseMetaData objects.
o DBCP-211: Added Maven 2 pom.xml. Removed a block of code from TestJOCLed that set
the Xerces parser manually. This was to support early JDKs. The 1.3
version of DBCP requires JDK 1.4+.
o DBCP-233: Changed behavior to allow Connection, Statement, PreparedStatement,
CallableStatement and ResultSet to be closed multiple times. The first
time close is called the resource is closed and any subsequent calls
have no effect. This behavior is required as per the JavaDocs for these
classes. Also added tests for closing all types multiple times and
updated any tests that incorrectly assert that a resource can not be
closed more then once. Fixes DBCP-3, DBCP-5, DBCP-23 and DBCP-134. Thanks to Dain Sundstrom.
o DBCP-11: Modified PoolingDataSource, PoolingDriver and DelegatingStatement to
assure that all returned Statements, PreparedStatements,
CallableStatements and ResultSets are wrapped with a delegating object,
which already properly handle the back pointers for Connection and
Statement. Also added tests to to assure that the *same* object used
to create the statement or result set is returned from either
getConnection() or getStatement(). Thanks to Dain Sundstrom.
o DBCP-143: SQLNestedException has been deprecated and will be replaced in DBCP 2.0 with
SQLException and standard Java exception chaining.
For complete information on commons-dbcp, including instructions on how to submit bug reports,
patches, or suggestions for improvement, see the commons-dbcp website:
http://commons.apache.org/dbcp/
libcommons-dbcp-java-1.4.orig/LICENSE.txt 0000644 0001750 0001750 00000026136 11333570550 020035 0 ustar drazzib drazzib
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
libcommons-dbcp-java-1.4.orig/findbugs-exclude-filter.xml 0000644 0001750 0001750 00000002310 11333570550 023433 0 ustar drazzib drazzib
*
libcommons-dbcp-java-1.4.orig/README.txt 0000644 0001750 0001750 00000002360 11333570550 017701 0 ustar drazzib drazzib Apache Commons DBCP
===========================
Welcome to the DBCP component of the Apache Commons
project (http://commons.apache.org).
DBCP now comes in two different versions, one to support JDBC 3
and one to support JDBC 4. Here is how it works:
DBCP 1.4 compiles and runs under JDK 1.6 only (JDBC 4)
DBCP 1.3 compiles and runs under JDK 1.4-1.5 only (JDBC 3)
DBCP 1.4 binaries should be used by applications running under JDK 1.6
DBCP 1.3 should be used when running under JDK 1.4 or 1.5.
There is no difference in the codebase supporting these two
versions, other than that the code implementing methods added
to support JDBC 4 has been filtered out of the DBCP 1.3 sources.
Both versions can be built using either Ant or Maven (version 2).
To build DBCP using Maven, type "mvn package" at a command line prompt
from the top-level directory of the source distribution (the directory
that contains the file named pom.xml).
DBCP can also be built using Ant from the build.xml file.
Locations of dependent jars for the Ant build need to be specified in
build.properties. There is a build.properties.sample file included in the
source distribution.
See http://commons.apache.org/dbcp/ for additional and
up-to-date information on Commons DBCP.
libcommons-dbcp-java-1.4.orig/checkstyle.xml 0000644 0001750 0001750 00000016673 11333570550 021077 0 ustar drazzib drazzib
libcommons-dbcp-java-1.4.orig/NOTICE.txt 0000644 0001750 0001750 00000000255 11333570550 017726 0 ustar drazzib drazzib Apache Commons DBCP
Copyright 2001-2010 The Apache Software Foundation
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).
libcommons-dbcp-java-1.4.orig/src/ 0000755 0001750 0001750 00000000000 11333570550 016771 5 ustar drazzib drazzib libcommons-dbcp-java-1.4.orig/src/assembly/ 0000755 0001750 0001750 00000000000 11337741616 020617 5 ustar drazzib drazzib libcommons-dbcp-java-1.4.orig/src/assembly/bin.xml 0000644 0001750 0001750 00000003137 11333570547 022114 0 ustar drazzib drazzib
bintar.gzzipfalseLICENSE.txtNOTICE.txtREADME.txtRELEASE-NOTES.txttarget*.jartarget/site/apidocsapidocs
libcommons-dbcp-java-1.4.orig/src/assembly/src.xml 0000644 0001750 0001750 00000003536 11333570547 022136 0 ustar drazzib drazzib
srctar.gzzip${project.artifactId}-${project.version}-srcbuild.properties.samplebuild.xmlcheckstyle.xmlLICENSE.txtLICENSE-header.txtNOTICE.txtpom.xmlREADME.txtRELEASE-NOTES.txttest-jar.xmlfindbugs-exclude-filter.xmldocsrcxdocs
libcommons-dbcp-java-1.4.orig/src/test/ 0000755 0001750 0001750 00000000000 11337741616 017757 5 ustar drazzib drazzib libcommons-dbcp-java-1.4.orig/src/test/testpool.jocl 0000644 0001750 0001750 00000004377 11333570547 022513 0 ustar drazzib drazzib
libcommons-dbcp-java-1.4.orig/src/test/org/ 0000755 0001750 0001750 00000000000 11333570547 020545 5 ustar drazzib drazzib libcommons-dbcp-java-1.4.orig/src/test/org/apache/ 0000755 0001750 0001750 00000000000 11333570547 021766 5 ustar drazzib drazzib libcommons-dbcp-java-1.4.orig/src/test/org/apache/commons/ 0000755 0001750 0001750 00000000000 11333570547 023441 5 ustar drazzib drazzib libcommons-dbcp-java-1.4.orig/src/test/org/apache/commons/jocl/ 0000755 0001750 0001750 00000000000 11337741616 024371 5 ustar drazzib drazzib libcommons-dbcp-java-1.4.orig/src/test/org/apache/commons/jocl/TestJOCLContentHandler.java 0000644 0001750 0001750 00000032410 11333570547 031453 0 ustar drazzib drazzib /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jocl;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.SAXException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.io.InputStream;
import java.io.IOException;
/**
* @version $Revision: 893803 $ $Date: 2009-12-24 14:10:46 -0500 (Thu, 24 Dec 2009) $
*/
public class TestJOCLContentHandler extends TestCase {
public TestJOCLContentHandler(String testName) {
super(testName);
if (Float.parseFloat(System.getProperty("java.specification.version")) <
1.6f) {
if(null == System.getProperty("org.xml.sax.driver")) {
System.setProperty("org.xml.sax.driver","org.apache.xerces.parsers.SAXParser");
}
}
}
public static Test suite() {
return new TestSuite(TestJOCLContentHandler.class);
}
public static void main(String args[]) {
String[] testCaseName = { TestJOCLContentHandler.class.getName() };
junit.textui.TestRunner.main(testCaseName);
}
private JOCLContentHandler jocl = null;
public void setUp() {
jocl = new JOCLContentHandler();
}
public void testPrimitives() throws Exception {
jocl.startDocument();
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","jocl","jocl",new AttributesImpl());
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","true");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","boolean","boolean",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","boolean","boolean");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","1");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","byte","byte",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","byte","byte");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","c");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","char","char",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","char","char");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","2.0");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","double","double",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","double","double");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","3.0");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","float","float",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","float","float");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","5");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","int","int",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","int","int");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","7");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","long","long",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","long","long");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","11");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","short","short",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","short","short");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","All your base are belong to us.");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","string","string",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","string","string");
}
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","jocl","jocl");
jocl.endDocument();
assertEquals(Boolean.TYPE,jocl.getType(0));
assertEquals(Byte.TYPE,jocl.getType(1));
assertEquals(Character.TYPE,jocl.getType(2));
assertEquals(Double.TYPE,jocl.getType(3));
assertEquals(Float.TYPE,jocl.getType(4));
assertEquals(Integer.TYPE,jocl.getType(5));
assertEquals(Long.TYPE,jocl.getType(6));
assertEquals(Short.TYPE,jocl.getType(7));
assertEquals(String.class,jocl.getType(8));
assertEquals(Boolean.TRUE,jocl.getValue(0));
assertEquals(new Byte("1"),jocl.getValue(1));
assertEquals(new Character('c'),jocl.getValue(2));
assertEquals(new Double("2.0"),jocl.getValue(3));
assertEquals(new Float("3.0"),jocl.getValue(4));
assertEquals(new Integer("5"),jocl.getValue(5));
assertEquals(new Long("7"),jocl.getValue(6));
assertEquals(new Short("11"),jocl.getValue(7));
assertEquals("All your base are belong to us.",jocl.getValue(8));
}
public void testObject() throws Exception {
jocl.startDocument();
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","jocl","jocl",new AttributesImpl());
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","null","null","CDATA","true");
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","class","class","CDATA","java.lang.String");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","object","object",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","object","object");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","class","class","CDATA","java.util.Date");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","object","object",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","object","object");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","class","class","CDATA","java.util.Date");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","object","object",attr);
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","345");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","long","long",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","long","long");
}
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","object","object");
// test array of 2 longs
{
AttributesImpl attr = new AttributesImpl();
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","array","array",attr);
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","12");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","long","long",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","long","long");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","34");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","long","long",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","long","long");
}
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","object","object");
// test collection of 2 Strings, one null
{
AttributesImpl attr = new AttributesImpl();
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","collection","collection",attr);
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","null","null","CDATA","true");
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","class","class","CDATA","java.lang.String");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","object","object",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","object","object");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","String #1");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","string","string",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","string","string");
}
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","object","object");
// test list of 1 Date, one Long
{
AttributesImpl attr = new AttributesImpl();
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","list","list",attr);
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","class","class","CDATA","java.util.Date");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","object","object",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","object","object");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","12");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","long","long",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","long","long");
}
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","object","object");
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","jocl","jocl");
jocl.endDocument();
assertEquals(String.class,jocl.getType(0));
assertEquals(java.util.Date.class,jocl.getType(1));
assertEquals(java.util.Date.class,jocl.getType(2));
assertTrue(jocl.getType(3).isArray());
assertEquals(Collection.class,jocl.getType(4));
assertEquals(List.class,jocl.getType(5));
assertTrue(null == jocl.getValue(0));
assertTrue(null != jocl.getValue(1));
assertEquals(new java.util.Date(345L),jocl.getValue(2));
Object[] objects = (Object[])jocl.getValue(3);
assertEquals(new Long(12L), objects[0]);
assertEquals(new Long(34L), objects[1]);
Iterator iterator = ((Collection)jocl.getValue(4)).iterator();
assertNull(iterator.next());
assertEquals("String #1", iterator.next());
List list = (List) jocl.getValue(5);
assertEquals(java.util.Date.class,list.get(0).getClass());
assertEquals(new Long(12L),list.get(1));
}
public void testParse()
throws IOException, SAXException
{
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("testpool.jocl");
JOCLContentHandler.parse(stream);
}
}
libcommons-dbcp-java-1.4.orig/src/test/org/apache/commons/jocl/TestAll.java 0000644 0001750 0001750 00000002674 11333570547 026614 0 ustar drazzib drazzib /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jocl;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* @version $Revision: 830125 $ $Date: 2009-10-27 06:36:25 -0400 (Tue, 27 Oct 2009) $
*/
public class TestAll extends TestCase {
public TestAll(String testName) {
super(testName);
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(TestJOCLContentHandler.suite());
return suite;
}
public static void main(String args[]) {
String[] testCaseName = { TestAll.class.getName() };
junit.textui.TestRunner.main(testCaseName);
}
}
libcommons-dbcp-java-1.4.orig/src/test/org/apache/commons/dbcp/ 0000755 0001750 0001750 00000000000 11337741616 024352 5 ustar drazzib drazzib libcommons-dbcp-java-1.4.orig/src/test/org/apache/commons/dbcp/TestPStmtPoolingBasicDataSource.java 0000644 0001750 0001750 00000021476 11333570547 033402 0 ustar drazzib drazzib /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbcp;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import junit.framework.Test;
import junit.framework.TestSuite;
/**
* TestSuite for BasicDataSource with prepared statement pooling enabled
*
* @author Dirk Verbeeck
* @version $Revision: 883383 $ $Date: 2009-11-23 10:52:21 -0500 (Mon, 23 Nov 2009) $
*/
public class TestPStmtPoolingBasicDataSource extends TestBasicDataSource {
public TestPStmtPoolingBasicDataSource(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestPStmtPoolingBasicDataSource.class);
}
public void setUp() throws Exception {
super.setUp();
// PoolPreparedStatements enabled, should not affect the basic tests
ds.setPoolPreparedStatements(true);
ds.setMaxOpenPreparedStatements(2);
}
public void tearDown() throws Exception {
super.tearDown();
// nothing to do here
}
public void testPreparedStatementPooling() throws Exception {
Connection conn = getConnection();
assertNotNull(conn);
PreparedStatement stmt1 = conn.prepareStatement("select 'a' from dual");
assertNotNull(stmt1);
PreparedStatement stmt2 = conn.prepareStatement("select 'b' from dual");
assertNotNull(stmt2);
assertTrue(stmt1 != stmt2);
// go over the maxOpen limit
PreparedStatement stmt3 = null;
try {
conn.prepareStatement("select 'c' from dual");
fail("expected SQLException");
}
catch (SQLException e) {}
// make idle
stmt2.close();
// test cleanup the 'b' statement
stmt3 = conn.prepareStatement("select 'c' from dual");
assertNotNull(stmt3);
assertTrue(stmt3 != stmt1);
assertTrue(stmt3 != stmt2);
// normal reuse of statement
stmt1.close();
PreparedStatement stmt4 = conn.prepareStatement("select 'a' from dual");
assertNotNull(stmt4);
}
/**
* Verifies that the prepared statement pool behaves as an LRU cache,
* closing least-recently-used statements idle in the pool to make room
* for new ones if necessary.
*/
public void testLRUBehavior() throws Exception {
ds.setMaxOpenPreparedStatements(3);
Connection conn = getConnection();
assertNotNull(conn);
// Open 3 statements and then close them into the pool
PreparedStatement stmt1 = conn.prepareStatement("select 'a' from dual");
PreparedStatement inner1 = (PreparedStatement) ((DelegatingPreparedStatement) stmt1).getInnermostDelegate();
PreparedStatement stmt2 = conn.prepareStatement("select 'b' from dual");
PreparedStatement inner2 = (PreparedStatement) ((DelegatingPreparedStatement) stmt2).getInnermostDelegate();
PreparedStatement stmt3 = conn.prepareStatement("select 'c' from dual");
PreparedStatement inner3 = (PreparedStatement) ((DelegatingPreparedStatement) stmt3).getInnermostDelegate();
stmt1.close();
Thread.sleep(100); // Make sure return timestamps are different
stmt2.close();
Thread.sleep(100);
stmt3.close();
// Pool now has three idle statements, getting another one will force oldest (stmt1) out
PreparedStatement stmt4 = conn.prepareStatement("select 'd' from dual");
assertNotNull(stmt4);
// Verify that inner1 has been closed
try {
inner1.clearParameters();
fail("expecting SQLExcption - statement should be closed");
} catch (SQLException ex) {
//Expected
}
// But others are still open
inner2.clearParameters();
inner3.clearParameters();
// Now make sure stmt1 does not come back from the dead
PreparedStatement stmt5 = conn.prepareStatement("select 'a' from dual");
PreparedStatement inner5 = (PreparedStatement) ((DelegatingPreparedStatement) stmt5).getInnermostDelegate();
assertNotSame(inner5, inner1);
// inner2 should be closed now
try {
inner2.clearParameters();
fail("expecting SQLExcption - statement should be closed");
} catch (SQLException ex) {
//Expected
}
// But inner3 should still be open
inner3.clearParameters();
}
// Bugzilla Bug 27246
// PreparedStatement cache should be different depending on the Catalog
public void testPStmtCatalog() throws Exception {
Connection conn = getConnection();
conn.setCatalog("catalog1");
DelegatingPreparedStatement stmt1 = (DelegatingPreparedStatement) conn.prepareStatement("select 'a' from dual");
TesterPreparedStatement inner1 = (TesterPreparedStatement) stmt1.getInnermostDelegate();
assertEquals("catalog1", inner1.getCatalog());
stmt1.close();
conn.setCatalog("catalog2");
DelegatingPreparedStatement stmt2 = (DelegatingPreparedStatement) conn.prepareStatement("select 'a' from dual");
TesterPreparedStatement inner2 = (TesterPreparedStatement) stmt2.getInnermostDelegate();
assertEquals("catalog2", inner2.getCatalog());
stmt2.close();
conn.setCatalog("catalog1");
DelegatingPreparedStatement stmt3 = (DelegatingPreparedStatement) conn.prepareStatement("select 'a' from dual");
TesterPreparedStatement inner3 = (TesterPreparedStatement) stmt1.getInnermostDelegate();
assertEquals("catalog1", inner3.getCatalog());
stmt3.close();
assertNotSame(inner1, inner2);
assertSame(inner1, inner3);
}
public void testPStmtPoolingWithNoClose() throws Exception {
ds.setMaxActive(1); // only one connection in pool needed
ds.setMaxIdle(1);
ds.setAccessToUnderlyingConnectionAllowed(true);
Connection conn1 = getConnection();
assertNotNull(conn1);
assertEquals(1, ds.getNumActive());
assertEquals(0, ds.getNumIdle());
PreparedStatement stmt1 = conn1.prepareStatement("select 'a' from dual");
assertNotNull(stmt1);
Statement inner1 = ((DelegatingPreparedStatement) stmt1).getInnermostDelegate();
assertNotNull(inner1);
stmt1.close();
Connection conn2 = conn1;
assertNotNull(conn2);
assertEquals(1, ds.getNumActive());
assertEquals(0, ds.getNumIdle());
PreparedStatement stmt2 = conn2.prepareStatement("select 'a' from dual");
assertNotNull(stmt2);
Statement inner2 = ((DelegatingPreparedStatement) stmt2).getInnermostDelegate();
assertNotNull(inner2);
assertSame(inner1, inner2);
}
public void testPStmtPoolingAccrossClose() throws Exception {
ds.setMaxActive(1); // only one connection in pool needed
ds.setMaxIdle(1);
ds.setAccessToUnderlyingConnectionAllowed(true);
Connection conn1 = getConnection();
assertNotNull(conn1);
assertEquals(1, ds.getNumActive());
assertEquals(0, ds.getNumIdle());
PreparedStatement stmt1 = conn1.prepareStatement("select 'a' from dual");
assertNotNull(stmt1);
Statement inner1 = ((DelegatingPreparedStatement) stmt1).getInnermostDelegate();
assertNotNull(inner1);
stmt1.close();
conn1.close();
assertEquals(0, ds.getNumActive());
assertEquals(1, ds.getNumIdle());
Connection conn2 = getConnection();
assertNotNull(conn2);
assertEquals(1, ds.getNumActive());
assertEquals(0, ds.getNumIdle());
PreparedStatement stmt2 = conn2.prepareStatement("select 'a' from dual");
assertNotNull(stmt2);
Statement inner2 = ((DelegatingPreparedStatement) stmt2).getInnermostDelegate();
assertNotNull(inner2);
assertSame(inner1, inner2);
}
}
libcommons-dbcp-java-1.4.orig/src/test/org/apache/commons/dbcp/TesterResultSet.java 0000644 0001750 0001750 00000065070 11333570547 030345 0 ustar drazzib drazzib /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbcp;
import java.math.BigDecimal;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.Calendar;
/* JDBC_4_ANT_KEY_BEGIN */
import java.io.InputStream;
import java.io.Reader;
import java.sql.NClob;
import java.sql.RowId;
import java.sql.SQLXML;
/* JDBC_4_ANT_KEY_END */
/**
* A dummy {@link ResultSet}, for testing purposes.
*
* @author Rodney Waldhoff
* @author Dirk Verbeeck
* @version $Revision: 883942 $ $Date: 2009-11-24 20:00:03 -0500 (Tue, 24 Nov 2009) $
*/
public class TesterResultSet implements ResultSet {
public TesterResultSet(Statement stmt) {
_statement = stmt;
}
public TesterResultSet(Statement stmt, Object[][] data) {
_statement = stmt;
_data = data;
}
public TesterResultSet(Statement stmt, Object[][] data, int type, int concurrency) {
_statement = stmt;
_data = data;
_type = type;
_concurrency = concurrency;
}
protected int _type = ResultSet.TYPE_FORWARD_ONLY;
protected int _concurrency = ResultSet.CONCUR_READ_ONLY;
protected Object[][] _data = null;
protected int _currentRow = -1;
protected Statement _statement = null;
protected int _rowsLeft = 2;
protected boolean _open = true;
public boolean next() throws SQLException {
checkOpen();
if (_data != null) {
_currentRow++;
return _currentRow < _data.length;
}
else {
if(--_rowsLeft > 0) {
return true;
} else {
return false;
}
}
}
public void close() throws SQLException {
if (!_open) {
return;
}
// Not all result sets are generated from statements eg DatabaseMetaData
if (_statement != null) {
((TesterStatement)_statement)._resultSet = null;
}
_open = false;
}
public boolean wasNull() throws SQLException {
checkOpen();
return false;
}
public String getString(int columnIndex) throws SQLException {
checkOpen();
if (columnIndex == -1) {
throw new SQLException("broken connection");
}
if (_data != null) {
return (String) getObject(columnIndex);
}
return "String" + columnIndex;
}
public boolean getBoolean(int columnIndex) throws SQLException {
checkOpen();
return true;
}
public byte getByte(int columnIndex) throws SQLException {
checkOpen();
return (byte)columnIndex;
}
public short getShort(int columnIndex) throws SQLException {
checkOpen();
return (short)columnIndex;
}
public int getInt(int columnIndex) throws SQLException {
checkOpen();
return (short)columnIndex;
}
public long getLong(int columnIndex) throws SQLException {
checkOpen();
return columnIndex;
}
public float getFloat(int columnIndex) throws SQLException {
checkOpen();
return columnIndex;
}
public double getDouble(int columnIndex) throws SQLException {
checkOpen();
return columnIndex;
}
/** @deprecated */
public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
checkOpen();
return new BigDecimal(columnIndex);
}
public byte[] getBytes(int columnIndex) throws SQLException {
checkOpen();
return new byte[] { (byte)columnIndex };
}
public java.sql.Date getDate(int columnIndex) throws SQLException {
checkOpen();
return null;
}
public java.sql.Time getTime(int columnIndex) throws SQLException {
checkOpen();
return null;
}
public java.sql.Timestamp getTimestamp(int columnIndex) throws SQLException {
checkOpen();
return null;
}
public java.io.InputStream getAsciiStream(int columnIndex) throws SQLException {
checkOpen();
return null;
}
/** @deprecated */
public java.io.InputStream getUnicodeStream(int columnIndex) throws SQLException {
checkOpen();
return null;
}
public java.io.InputStream getBinaryStream(int columnIndex) throws SQLException {
checkOpen();
return null;
}
public String getString(String columnName) throws SQLException {
checkOpen();
return columnName;
}
public boolean getBoolean(String columnName) throws SQLException {
checkOpen();
return true;
}
public byte getByte(String columnName) throws SQLException {
checkOpen();
return (byte)(columnName.hashCode());
}
public short getShort(String columnName) throws SQLException {
checkOpen();
return (short)(columnName.hashCode());
}
public int getInt(String columnName) throws SQLException {
checkOpen();
return (columnName.hashCode());
}
public long getLong(String columnName) throws SQLException {
checkOpen();
return columnName.hashCode();
}
public float getFloat(String columnName) throws SQLException {
checkOpen();
return columnName.hashCode();
}
public double getDouble(String columnName) throws SQLException {
checkOpen();
return columnName.hashCode();
}
/** @deprecated */
public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {
checkOpen();
return new BigDecimal(columnName.hashCode());
}
public byte[] getBytes(String columnName) throws SQLException {
checkOpen();
return columnName.getBytes();
}
public java.sql.Date getDate(String columnName) throws SQLException {
checkOpen();
return null;
}
public java.sql.Time getTime(String columnName) throws SQLException {
checkOpen();
return null;
}
public java.sql.Timestamp getTimestamp(String columnName) throws SQLException {
checkOpen();
return null;
}
public java.io.InputStream getAsciiStream(String columnName) throws SQLException {
checkOpen();
return null;
}
/** @deprecated */
public java.io.InputStream getUnicodeStream(String columnName) throws SQLException {
checkOpen();
return null;
}
public java.io.InputStream getBinaryStream(String columnName) throws SQLException {
checkOpen();
return null;
}
public SQLWarning getWarnings() throws SQLException {
checkOpen();
return null;
}
public void clearWarnings() throws SQLException {
checkOpen();
}
public String getCursorName() throws SQLException {
checkOpen();
return null;
}
public ResultSetMetaData getMetaData() throws SQLException {
checkOpen();
return null;
}
public Object getObject(int columnIndex) throws SQLException {
checkOpen();
if (_data != null) {
return _data[_currentRow][columnIndex-1];
}
return new Object();
}
public Object getObject(String columnName) throws SQLException {
checkOpen();
return columnName;
}
public int findColumn(String columnName) throws SQLException {
checkOpen();
return 1;
}
public java.io.Reader getCharacterStream(int columnIndex) throws SQLException {
checkOpen();
return null;
}
public java.io.Reader getCharacterStream(String columnName) throws SQLException {
checkOpen();
return null;
}
public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
checkOpen();
return new BigDecimal(columnIndex);
}
public BigDecimal getBigDecimal(String columnName) throws SQLException {
checkOpen();
return new BigDecimal(columnName.hashCode());
}
public boolean isBeforeFirst() throws SQLException {
checkOpen();
return _rowsLeft == 2;
}
public boolean isAfterLast() throws SQLException {
checkOpen();
return _rowsLeft < 0;
}
public boolean isFirst() throws SQLException {
checkOpen();
return _rowsLeft == 1;
}
public boolean isLast() throws SQLException {
checkOpen();
return _rowsLeft == 0;
}
public void beforeFirst() throws SQLException {
checkOpen();
}
public void afterLast() throws SQLException {
checkOpen();
}
public boolean first() throws SQLException {
checkOpen();
return false;
}
public boolean last() throws SQLException {
checkOpen();
return false;
}
public int getRow() throws SQLException {
checkOpen();
return 3 - _rowsLeft;
}
public boolean absolute( int row ) throws SQLException {
checkOpen();
return false;
}
public boolean relative( int rows ) throws SQLException {
checkOpen();
return false;
}
public boolean previous() throws SQLException {
checkOpen();
return false;
}
public void setFetchDirection(int direction) throws SQLException {
checkOpen();
}
public int getFetchDirection() throws SQLException {
checkOpen();
return 1;
}
public void setFetchSize(int rows) throws SQLException {
checkOpen();
}
public int getFetchSize() throws SQLException {
checkOpen();
return 2;
}
public int getType() throws SQLException {
return this._type;
}
public int getConcurrency() throws SQLException {
return this._concurrency;
}
public boolean rowUpdated() throws SQLException {
checkOpen();
return false;
}
public boolean rowInserted() throws SQLException {
checkOpen();
return false;
}
public boolean rowDeleted() throws SQLException {
checkOpen();
return false;
}
public void updateNull(int columnIndex) throws SQLException {
checkOpen();
}
public void updateBoolean(int columnIndex, boolean x) throws SQLException {
checkOpen();
}
public void updateByte(int columnIndex, byte x) throws SQLException {
checkOpen();
}
public void updateShort(int columnIndex, short x) throws SQLException {
checkOpen();
}
public void updateInt(int columnIndex, int x) throws SQLException {
checkOpen();
}
public void updateLong(int columnIndex, long x) throws SQLException {
checkOpen();
}
public void updateFloat(int columnIndex, float x) throws SQLException {
checkOpen();
}
public void updateDouble(int columnIndex, double x) throws SQLException {
checkOpen();
}
public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
checkOpen();
}
public void updateString(int columnIndex, String x) throws SQLException {
checkOpen();
}
public void updateBytes(int columnIndex, byte x[]) throws SQLException {
checkOpen();
}
public void updateDate(int columnIndex, java.sql.Date x) throws SQLException {
checkOpen();
}
public void updateTime(int columnIndex, java.sql.Time x) throws SQLException {
checkOpen();
}
public void updateTimestamp(int columnIndex, java.sql.Timestamp x) throws SQLException {
checkOpen();
}
public void updateAsciiStream(int columnIndex,
java.io.InputStream x,
int length) throws SQLException {
checkOpen();
}
public void updateBinaryStream(int columnIndex,
java.io.InputStream x,
int length) throws SQLException {
checkOpen();
}
public void updateCharacterStream(int columnIndex,
java.io.Reader x,
int length) throws SQLException {
checkOpen();
}
public void updateObject(int columnIndex, Object x, int scale)
throws SQLException {
checkOpen();
}
public void updateObject(int columnIndex, Object x) throws SQLException {
checkOpen();
}
public void updateNull(String columnName) throws SQLException {
checkOpen();
}
public void updateBoolean(String columnName, boolean x) throws SQLException {
checkOpen();
}
public void updateByte(String columnName, byte x) throws SQLException {
checkOpen();
}
public void updateShort(String columnName, short x) throws SQLException {
checkOpen();
}
public void updateInt(String columnName, int x) throws SQLException {
checkOpen();
}
public void updateLong(String columnName, long x) throws SQLException {
checkOpen();
}
public void updateFloat(String columnName, float x) throws SQLException {
checkOpen();
}
public void updateDouble(String columnName, double x) throws SQLException {
checkOpen();
}
public void updateBigDecimal(String columnName, BigDecimal x) throws SQLException {
checkOpen();
}
public void updateString(String columnName, String x) throws SQLException {
checkOpen();
}
public void updateBytes(String columnName, byte x[]) throws SQLException {
checkOpen();
}
public void updateDate(String columnName, java.sql.Date x) throws SQLException {
checkOpen();
}
public void updateTime(String columnName, java.sql.Time x) throws SQLException {
checkOpen();
}
public void updateTimestamp(String columnName, java.sql.Timestamp x)
throws SQLException {
checkOpen();
}
public void updateAsciiStream(String columnName,
java.io.InputStream x,
int length) throws SQLException {
checkOpen();
}
public void updateBinaryStream(String columnName,
java.io.InputStream x,
int length) throws SQLException {
checkOpen();
}
public void updateCharacterStream(String columnName,
java.io.Reader reader,
int length) throws SQLException {
checkOpen();
}
public void updateObject(String columnName, Object x, int scale)
throws SQLException {
checkOpen();
}
public void updateObject(String columnName, Object x) throws SQLException {
checkOpen();
}
public void insertRow() throws SQLException {
checkOpen();
}
public void updateRow() throws SQLException {
checkOpen();
}
public void deleteRow() throws SQLException {
checkOpen();
}
public void refreshRow() throws SQLException {
checkOpen();
}
public void cancelRowUpdates() throws SQLException {
checkOpen();
}
public void moveToInsertRow() throws SQLException {
checkOpen();
}
public void moveToCurrentRow() throws SQLException {
checkOpen();
}
public Statement getStatement() throws SQLException {
checkOpen();
return _statement;
}
public Object getObject(int i, java.util.Map map) throws SQLException {
checkOpen();
return new Object();
}
public Ref getRef(int i) throws SQLException {
checkOpen();
return null;
}
public Blob getBlob(int i) throws SQLException {
checkOpen();
return null;
}
public Clob getClob(int i) throws SQLException {
checkOpen();
return null;
}
public Array getArray(int i) throws SQLException {
checkOpen();
return null;
}
public Object getObject(String colName, java.util.Map map) throws SQLException {
checkOpen();
return colName;
}
public Ref getRef(String colName) throws SQLException {
checkOpen();
return null;
}
public Blob getBlob(String colName) throws SQLException {
checkOpen();
return null;
}
public Clob getClob(String colName) throws SQLException {
checkOpen();
return null;
}
public Array getArray(String colName) throws SQLException {
checkOpen();
return null;
}
public java.sql.Date getDate(int columnIndex, Calendar cal) throws SQLException {
checkOpen();
return null;
}
public java.sql.Date getDate(String columnName, Calendar cal) throws SQLException {
checkOpen();
return null;
}
public java.sql.Time getTime(int columnIndex, Calendar cal) throws SQLException {
checkOpen();
return null;
}
public java.sql.Time getTime(String columnName, Calendar cal) throws SQLException {
checkOpen();
return null;
}
public java.sql.Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
checkOpen();
return null;
}
public java.sql.Timestamp getTimestamp(String columnName, Calendar cal)
throws SQLException {
checkOpen();
return null;
}
protected void checkOpen() throws SQLException {
if(!_open) {
throw new SQLException("ResultSet is closed.");
}
}
public java.net.URL getURL(int columnIndex) throws SQLException {
throw new SQLException("Not implemented.");
}
public java.net.URL getURL(String columnName) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateRef(int columnIndex, java.sql.Ref x)
throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateRef(String columnName, java.sql.Ref x)
throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateBlob(int columnIndex, java.sql.Blob x)
throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateBlob(String columnName, java.sql.Blob x)
throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateClob(int columnIndex, java.sql.Clob x)
throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateClob(String columnName, java.sql.Clob x)
throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateArray(int columnIndex, java.sql.Array x)
throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateArray(String columnName, java.sql.Array x)
throws SQLException {
throw new SQLException("Not implemented.");
}
/* JDBC_4_ANT_KEY_BEGIN */
public boolean isWrapperFor(Class> iface) throws SQLException {
throw new SQLException("Not implemented.");
}
public T unwrap(Class iface) throws SQLException {
throw new SQLException("Not implemented.");
}
public RowId getRowId(int columnIndex) throws SQLException {
throw new SQLException("Not implemented.");
}
public RowId getRowId(String columnLabel) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateRowId(int columnIndex, RowId value) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateRowId(String columnLabel, RowId value) throws SQLException {
throw new SQLException("Not implemented.");
}
public int getHoldability() throws SQLException {
throw new SQLException("Not implemented.");
}
public boolean isClosed() throws SQLException {
return !_open;
}
public void updateNString(int columnIndex, String value) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateNString(String columnLabel, String value) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateNClob(int columnIndex, NClob value) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateNClob(String columnLabel, NClob value) throws SQLException {
throw new SQLException("Not implemented.");
}
public NClob getNClob(int columnIndex) throws SQLException {
throw new SQLException("Not implemented.");
}
public NClob getNClob(String columnLabel) throws SQLException {
throw new SQLException("Not implemented.");
}
public SQLXML getSQLXML(int columnIndex) throws SQLException {
throw new SQLException("Not implemented.");
}
public SQLXML getSQLXML(String columnLabel) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateSQLXML(int columnIndex, SQLXML value) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateSQLXML(String columnLabel, SQLXML value) throws SQLException {
throw new SQLException("Not implemented.");
}
public String getNString(int columnIndex) throws SQLException {
throw new SQLException("Not implemented.");
}
public String getNString(String columnLabel) throws SQLException {
throw new SQLException("Not implemented.");
}
public Reader getNCharacterStream(int columnIndex) throws SQLException {
throw new SQLException("Not implemented.");
}
public Reader getNCharacterStream(String columnLabel) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateNCharacterStream(int columnIndex, Reader reader, long length) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateAsciiStream(int columnIndex, InputStream inputStream, long length) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateBinaryStream(int columnIndex, InputStream inputStream, long length) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateCharacterStream(int columnIndex, Reader reader, long length) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateAsciiStream(String columnLabel, InputStream inputStream, long length) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateBinaryStream(String columnLabel, InputStream inputStream, long length) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateNCharacterStream(int columnIndex, Reader reader) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateAsciiStream(int columnIndex, InputStream inputStream) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateBinaryStream(int columnIndex, InputStream inputStream) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateCharacterStream(int columnIndex, Reader reader) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateAsciiStream(String columnLabel, InputStream inputStream) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateBinaryStream(String columnLabel, InputStream inputStream) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateClob(int columnIndex, Reader reader) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateClob(String columnLabel, Reader reader) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateNClob(int columnIndex, Reader reader) throws SQLException {
throw new SQLException("Not implemented.");
}
public void updateNClob(String columnLabel, Reader reader) throws SQLException {
throw new SQLException("Not implemented.");
}
/* JDBC_4_ANT_KEY_END */
}
libcommons-dbcp-java-1.4.orig/src/test/org/apache/commons/dbcp/TesterDriver.java 0000644 0001750 0001750 00000010154 11333570547 027637 0 ustar drazzib drazzib /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbcp;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.util.Properties;
/**
* Mock object implementing the java.sql.Driver interface.
* Returns TestConnection's from getConnection methods.
* Valid username, password combinations are:
*
*
*
user
password
*
foo
bar
*
u1
p1
*
u2
p2
*
username
password
*
*
* @author Rodney Waldhoff
* @author Dirk Verbeeck
* @version $Revision: 907288 $ $Date: 2010-02-06 14:42:58 -0500 (Sat, 06 Feb 2010) $
*/
public class TesterDriver implements Driver {
private static final Properties validUserPasswords = new Properties();
static {
try {
DriverManager.registerDriver(new TesterDriver());
} catch(Exception e) {
}
validUserPasswords.put("foo", "bar");
validUserPasswords.put("u1", "p1");
validUserPasswords.put("u2", "p2");
validUserPasswords.put("username", "password");
}
/**
* TesterDriver specific method to add users to the list of valid users
*/
public static void addUser(String username, String password) {
synchronized (validUserPasswords) {
validUserPasswords.put(username, password);
}
}
public boolean acceptsURL(String url) throws SQLException {
return CONNECT_STRING.startsWith(url);
}
private void assertValidUserPassword(String user, String password)
throws SQLException {
synchronized (validUserPasswords) {
String realPassword = validUserPasswords.getProperty(user);
if (realPassword == null) {
throw new SQLException(user + " is not a valid username.");
}
if (!realPassword.equals(password)) {
throw new SQLException(password + " is not the correct password for " + user
+ ". The correct password is " + realPassword);
}
}
}
public Connection connect(String url, Properties info) throws SQLException {
//return (acceptsURL(url) ? new TesterConnection() : null);
Connection conn = null;
if (acceptsURL(url))
{
String username = "test";
String password = "test";
if (info != null)
{
username = info.getProperty("user");
password = info.getProperty("password");
assertValidUserPassword(username, password);
}
conn = new TesterConnection(username, password);
}
return conn;
}
public int getMajorVersion() {
return MAJOR_VERSION;
}
public int getMinorVersion() {
return MINOR_VERSION;
}
public boolean jdbcCompliant() {
return true;
}
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) {
return new DriverPropertyInfo[0];
}
protected static final String CONNECT_STRING = "jdbc:apache:commons:testdriver";
// version numbers
protected static final int MAJOR_VERSION = 1;
protected static final int MINOR_VERSION = 0;
}
libcommons-dbcp-java-1.4.orig/src/test/org/apache/commons/dbcp/TesterDatabaseMetaData.java 0000644 0001750 0001750 00000046151 11333570547 031517 0 ustar drazzib drazzib /**
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbcp;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
/* JDBC_4_ANT_KEY_BEGIN */
import java.sql.RowIdLifetime;
/* JDBC_4_ANT_KEY_END */
import java.sql.SQLException;
/**
* Dummy {@link DatabaseMetaData} for tetsing purposes. Implements only those
* methods required by the test cases.
*/
public class TesterDatabaseMetaData implements DatabaseMetaData {
public boolean allProceduresAreCallable() throws SQLException {
return false;
}
public boolean allTablesAreSelectable() throws SQLException {
return false;
}
public boolean dataDefinitionCausesTransactionCommit() throws SQLException {
return false;
}
public boolean dataDefinitionIgnoredInTransactions() throws SQLException {
return false;
}
public boolean deletesAreDetected(int type) throws SQLException {
return false;
}
public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
return false;
}
public ResultSet getAttributes(String catalog, String schemaPattern,
String typeNamePattern, String attributeNamePattern)
throws SQLException {
return null;
}
public ResultSet getBestRowIdentifier(String catalog, String schema,
String table, int scope, boolean nullable) throws SQLException {
return null;
}
public String getCatalogSeparator() throws SQLException {
return null;
}
public String getCatalogTerm() throws SQLException {
return null;
}
public ResultSet getCatalogs() throws SQLException {
return null;
}
public ResultSet getColumnPrivileges(String catalog, String schema,
String table, String columnNamePattern) throws SQLException {
return null;
}
public ResultSet getColumns(String catalog, String schemaPattern,
String tableNamePattern, String columnNamePattern)
throws SQLException {
return null;
}
public Connection getConnection() throws SQLException {
return null;
}
public ResultSet getCrossReference(String parentCatalog,
String parentSchema, String parentTable, String foreignCatalog,
String foreignSchema, String foreignTable) throws SQLException {
return null;
}
public int getDatabaseMajorVersion() throws SQLException {
return 0;
}
public int getDatabaseMinorVersion() throws SQLException {
return 0;
}
public String getDatabaseProductName() throws SQLException {
return null;
}
public String getDatabaseProductVersion() throws SQLException {
return null;
}
public int getDefaultTransactionIsolation() throws SQLException {
return 0;
}
public int getDriverMajorVersion() {
return 0;
}
public int getDriverMinorVersion() {
return 0;
}
public String getDriverName() throws SQLException {
return null;
}
public String getDriverVersion() throws SQLException {
return null;
}
public ResultSet getExportedKeys(String catalog, String schema, String table)
throws SQLException {
return null;
}
public String getExtraNameCharacters() throws SQLException {
return null;
}
public String getIdentifierQuoteString() throws SQLException {
return null;
}
public ResultSet getImportedKeys(String catalog, String schema, String table)
throws SQLException {
return null;
}
public ResultSet getIndexInfo(String catalog, String schema, String table,
boolean unique, boolean approximate) throws SQLException {
return null;
}
public int getJDBCMajorVersion() throws SQLException {
return 0;
}
public int getJDBCMinorVersion() throws SQLException {
return 0;
}
public int getMaxBinaryLiteralLength() throws SQLException {
return 0;
}
public int getMaxCatalogNameLength() throws SQLException {
return 0;
}
public int getMaxCharLiteralLength() throws SQLException {
return 0;
}
public int getMaxColumnNameLength() throws SQLException {
return 0;
}
public int getMaxColumnsInGroupBy() throws SQLException {
return 0;
}
public int getMaxColumnsInIndex() throws SQLException {
return 0;
}
public int getMaxColumnsInOrderBy() throws SQLException {
return 0;
}
public int getMaxColumnsInSelect() throws SQLException {
return 0;
}
public int getMaxColumnsInTable() throws SQLException {
return 0;
}
public int getMaxConnections() throws SQLException {
return 0;
}
public int getMaxCursorNameLength() throws SQLException {
return 0;
}
public int getMaxIndexLength() throws SQLException {
return 0;
}
public int getMaxProcedureNameLength() throws SQLException {
return 0;
}
public int getMaxRowSize() throws SQLException {
return 0;
}
public int getMaxSchemaNameLength() throws SQLException {
return 0;
}
public int getMaxStatementLength() throws SQLException {
return 0;
}
public int getMaxStatements() throws SQLException {
return 0;
}
public int getMaxTableNameLength() throws SQLException {
return 0;
}
public int getMaxTablesInSelect() throws SQLException {
return 0;
}
public int getMaxUserNameLength() throws SQLException {
return 0;
}
public String getNumericFunctions() throws SQLException {
return null;
}
public ResultSet getPrimaryKeys(String catalog, String schema, String table)
throws SQLException {
return null;
}
public ResultSet getProcedureColumns(String catalog, String schemaPattern,
String procedureNamePattern, String columnNamePattern)
throws SQLException {
return null;
}
public String getProcedureTerm() throws SQLException {
return null;
}
public ResultSet getProcedures(String catalog, String schemaPattern,
String procedureNamePattern) throws SQLException {
return null;
}
public int getResultSetHoldability() throws SQLException {
return 0;
}
public String getSQLKeywords() throws SQLException {
return null;
}
public int getSQLStateType() throws SQLException {
return 0;
}
public String getSchemaTerm() throws SQLException {
return null;
}
public ResultSet getSchemas() throws SQLException {
return new TesterResultSet(null);
}
public String getSearchStringEscape() throws SQLException {
return null;
}
public String getStringFunctions() throws SQLException {
return null;
}
public ResultSet getSuperTables(String catalog, String schemaPattern,
String tableNamePattern) throws SQLException {
return null;
}
public ResultSet getSuperTypes(String catalog, String schemaPattern,
String typeNamePattern) throws SQLException {
return null;
}
public String getSystemFunctions() throws SQLException {
return null;
}
public ResultSet getTablePrivileges(String catalog, String schemaPattern,
String tableNamePattern) throws SQLException {
return null;
}
public ResultSet getTableTypes() throws SQLException {
return null;
}
public ResultSet getTables(String catalog, String schemaPattern,
String tableNamePattern, String[] types) throws SQLException {
return null;
}
public String getTimeDateFunctions() throws SQLException {
return null;
}
public ResultSet getTypeInfo() throws SQLException {
return null;
}
public ResultSet getUDTs(String catalog, String schemaPattern,
String typeNamePattern, int[] types) throws SQLException {
return null;
}
public String getURL() throws SQLException {
return null;
}
public String getUserName() throws SQLException {
return null;
}
public ResultSet getVersionColumns(String catalog, String schema,
String table) throws SQLException {
return null;
}
public boolean insertsAreDetected(int type) throws SQLException {
return false;
}
public boolean isCatalogAtStart() throws SQLException {
return false;
}
public boolean isReadOnly() throws SQLException {
return false;
}
public boolean locatorsUpdateCopy() throws SQLException {
return false;
}
public boolean nullPlusNonNullIsNull() throws SQLException {
return false;
}
public boolean nullsAreSortedAtEnd() throws SQLException {
return false;
}
public boolean nullsAreSortedAtStart() throws SQLException {
return false;
}
public boolean nullsAreSortedHigh() throws SQLException {
return false;
}
public boolean nullsAreSortedLow() throws SQLException {
return false;
}
public boolean othersDeletesAreVisible(int type) throws SQLException {
return false;
}
public boolean othersInsertsAreVisible(int type) throws SQLException {
return false;
}
public boolean othersUpdatesAreVisible(int type) throws SQLException {
return false;
}
public boolean ownDeletesAreVisible(int type) throws SQLException {
return false;
}
public boolean ownInsertsAreVisible(int type) throws SQLException {
return false;
}
public boolean ownUpdatesAreVisible(int type) throws SQLException {
return false;
}
public boolean storesLowerCaseIdentifiers() throws SQLException {
return false;
}
public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
return false;
}
public boolean storesMixedCaseIdentifiers() throws SQLException {
return false;
}
public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
return false;
}
public boolean storesUpperCaseIdentifiers() throws SQLException {
return false;
}
public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
return false;
}
public boolean supportsANSI92EntryLevelSQL() throws SQLException {
return false;
}
public boolean supportsANSI92FullSQL() throws SQLException {
return false;
}
public boolean supportsANSI92IntermediateSQL() throws SQLException {
return false;
}
public boolean supportsAlterTableWithAddColumn() throws SQLException {
return false;
}
public boolean supportsAlterTableWithDropColumn() throws SQLException {
return false;
}
public boolean supportsBatchUpdates() throws SQLException {
return false;
}
public boolean supportsCatalogsInDataManipulation() throws SQLException {
return false;
}
public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
return false;
}
public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
return false;
}
public boolean supportsCatalogsInProcedureCalls() throws SQLException {
return false;
}
public boolean supportsCatalogsInTableDefinitions() throws SQLException {
return false;
}
public boolean supportsColumnAliasing() throws SQLException {
return false;
}
public boolean supportsConvert() throws SQLException {
return false;
}
public boolean supportsConvert(int fromType, int toType)
throws SQLException {
return false;
}
public boolean supportsCoreSQLGrammar() throws SQLException {
return false;
}
public boolean supportsCorrelatedSubqueries() throws SQLException {
return false;
}
public boolean supportsDataDefinitionAndDataManipulationTransactions()
throws SQLException {
return false;
}
public boolean supportsDataManipulationTransactionsOnly()
throws SQLException {
return false;
}
public boolean supportsDifferentTableCorrelationNames() throws SQLException {
return false;
}
public boolean supportsExpressionsInOrderBy() throws SQLException {
return false;
}
public boolean supportsExtendedSQLGrammar() throws SQLException {
return false;
}
public boolean supportsFullOuterJoins() throws SQLException {
return false;
}
public boolean supportsGetGeneratedKeys() throws SQLException {
return false;
}
public boolean supportsGroupBy() throws SQLException {
return false;
}
public boolean supportsGroupByBeyondSelect() throws SQLException {
return false;
}
public boolean supportsGroupByUnrelated() throws SQLException {
return false;
}
public boolean supportsIntegrityEnhancementFacility() throws SQLException {
return false;
}
public boolean supportsLikeEscapeClause() throws SQLException {
return false;
}
public boolean supportsLimitedOuterJoins() throws SQLException {
return false;
}
public boolean supportsMinimumSQLGrammar() throws SQLException {
return false;
}
public boolean supportsMixedCaseIdentifiers() throws SQLException {
return false;
}
public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
return false;
}
public boolean supportsMultipleOpenResults() throws SQLException {
return false;
}
public boolean supportsMultipleResultSets() throws SQLException {
return false;
}
public boolean supportsMultipleTransactions() throws SQLException {
return false;
}
public boolean supportsNamedParameters() throws SQLException {
return false;
}
public boolean supportsNonNullableColumns() throws SQLException {
return false;
}
public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
return false;
}
public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
return false;
}
public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
return false;
}
public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
return false;
}
public boolean supportsOrderByUnrelated() throws SQLException {
return false;
}
public boolean supportsOuterJoins() throws SQLException {
return false;
}
public boolean supportsPositionedDelete() throws SQLException {
return false;
}
public boolean supportsPositionedUpdate() throws SQLException {
return false;
}
public boolean supportsResultSetConcurrency(int type, int concurrency)
throws SQLException {
return false;
}
public boolean supportsResultSetHoldability(int holdability)
throws SQLException {
return false;
}
public boolean supportsResultSetType(int type) throws SQLException {
return false;
}
public boolean supportsSavepoints() throws SQLException {
return false;
}
public boolean supportsSchemasInDataManipulation() throws SQLException {
return false;
}
public boolean supportsSchemasInIndexDefinitions() throws SQLException {
return false;
}
public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
return false;
}
public boolean supportsSchemasInProcedureCalls() throws SQLException {
return false;
}
public boolean supportsSchemasInTableDefinitions() throws SQLException {
return false;
}
public boolean supportsSelectForUpdate() throws SQLException {
return false;
}
public boolean supportsStatementPooling() throws SQLException {
return false;
}
public boolean supportsStoredProcedures() throws SQLException {
return false;
}
public boolean supportsSubqueriesInComparisons() throws SQLException {
return false;
}
public boolean supportsSubqueriesInExists() throws SQLException {
return false;
}
public boolean supportsSubqueriesInIns() throws SQLException {
return false;
}
public boolean supportsSubqueriesInQuantifieds() throws SQLException {
return false;
}
public boolean supportsTableCorrelationNames() throws SQLException {
return false;
}
public boolean supportsTransactionIsolationLevel(int level)
throws SQLException {
return false;
}
public boolean supportsTransactions() throws SQLException {
return false;
}
public boolean supportsUnion() throws SQLException {
return false;
}
public boolean supportsUnionAll() throws SQLException {
return false;
}
public boolean updatesAreDetected(int type) throws SQLException {
return false;
}
public boolean usesLocalFilePerTable() throws SQLException {
return false;
}
public boolean usesLocalFiles() throws SQLException {
return false;
}
/* JDBC_4_ANT_KEY_BEGIN */
public boolean isWrapperFor(Class> iface) throws SQLException {
return false;
}
public T unwrap(Class iface) throws SQLException {
return null;
}
public RowIdLifetime getRowIdLifetime() throws SQLException {
return null;
}
public ResultSet getSchemas(String catalog, String schemaPattern)
throws SQLException {
return null;
}
public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
return false;
}
public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
return false;
}
public ResultSet getClientInfoProperties() throws SQLException {
return null;
}
public ResultSet getFunctionColumns(String catalog, String schemaPattern,
String functionNamePattern, String columnNamePattern)
throws SQLException {
return null;
}
public ResultSet getFunctions(String catalog, String schemaPattern,
String functionNamePattern) throws SQLException {
return null;
}
/* JDBC_4_ANT_KEY_END */
}
libcommons-dbcp-java-1.4.orig/src/test/org/apache/commons/dbcp/managed/ 0000755 0001750 0001750 00000000000 11337741616 025746 5 ustar drazzib drazzib ././@LongLink 0000000 0000000 0000000 00000000147 00000000000 011567 L ustar root root libcommons-dbcp-java-1.4.orig/src/test/org/apache/commons/dbcp/managed/TestBasicManagedDataSource.java libcommons-dbcp-java-1.4.orig/src/test/org/apache/commons/dbcp/managed/TestBasicManagedDataSource.ja0000644 0001750 0001750 00000006445 11333570547 033403 0 ustar drazzib drazzib /**
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbcp.managed;
import java.sql.SQLException;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp.TestBasicDataSource;
import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
import junit.framework.Test;
import junit.framework.TestSuite;
/**
* TestSuite for BasicManagedDataSource
*/
public class TestBasicManagedDataSource extends TestBasicDataSource {
public TestBasicManagedDataSource(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestBasicManagedDataSource.class);
}
protected BasicDataSource createDataSource() throws Exception {
BasicManagedDataSource basicManagedDataSource = new BasicManagedDataSource();
basicManagedDataSource.setTransactionManager(new TransactionManagerImpl());
return basicManagedDataSource;
}
public void testHashCode() throws Exception {
// TODO reenable... hashcode doesn't work when accessToUnderlyingConnectionAllowed is false
}
/**
* JIRA: DBCP-294
* Verify that PoolableConnections created by BasicManagedDataSource unregister themselves
* when reallyClosed.
*/
public void testReallyClose() throws Exception {
BasicManagedDataSource basicManagedDataSource = new BasicManagedDataSource();
basicManagedDataSource.setTransactionManager(new TransactionManagerImpl());
basicManagedDataSource.setDriverClassName("org.apache.commons.dbcp.TesterDriver");
basicManagedDataSource.setUrl("jdbc:apache:commons:testdriver");
basicManagedDataSource.setUsername("username");
basicManagedDataSource.setPassword("password");
basicManagedDataSource.setMaxIdle(1);
// Create two connections
ManagedConnection conn = (ManagedConnection) basicManagedDataSource.getConnection();
assertNotNull(basicManagedDataSource.getTransactionRegistry().getXAResource(conn));
ManagedConnection conn2 = (ManagedConnection) basicManagedDataSource.getConnection();
conn2.close(); // Return one connection to the pool
conn.close(); // No room at the inn - this will trigger reallyClose(), which should unregister
try {
basicManagedDataSource.getTransactionRegistry().getXAResource(conn);
fail("Expecting SQLException - XAResources orphaned");
} catch (SQLException ex) {
// expected
}
conn2.close();
basicManagedDataSource.close();
}
}
libcommons-dbcp-java-1.4.orig/src/test/org/apache/commons/dbcp/managed/TestManagedDataSource.java 0000644 0001750 0001750 00000023035 11333570547 032762 0 ustar drazzib drazzib /**
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbcp.managed;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.dbcp.ConnectionFactory;
import org.apache.commons.dbcp.DelegatingConnection;
import org.apache.commons.dbcp.DriverConnectionFactory;
import org.apache.commons.dbcp.PoolableConnectionFactory;
import org.apache.commons.dbcp.PoolingDataSource;
import org.apache.commons.dbcp.TestConnectionPool;
import org.apache.commons.dbcp.TesterDriver;
import org.apache.commons.pool.ObjectPool;
import org.apache.commons.pool.impl.GenericObjectPool;
import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
import javax.transaction.TransactionManager;
import java.sql.Connection;
import java.util.Properties;
/**
* TestSuite for ManagedDataSource without a transaction in progress.
*
* @author Dain Sundstrom
* @version $Revision$
*/
public class TestManagedDataSource extends TestConnectionPool {
public TestManagedDataSource(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestManagedDataSource.class);
}
protected Connection getConnection() throws Exception {
return ds.getConnection();
}
protected PoolingDataSource ds = null;
private GenericObjectPool pool = null;
protected TransactionManager transactionManager;
public void setUp() throws Exception {
super.setUp();
// create a GeronimoTransactionManager for testing
transactionManager = new TransactionManagerImpl();
// create a driver connection factory
Properties properties = new Properties();
properties.setProperty("user", "username");
properties.setProperty("password", "password");
ConnectionFactory connectionFactory = new DriverConnectionFactory(new TesterDriver(), "jdbc:apache:commons:testdriver", properties);
// wrap it with a LocalXAConnectionFactory
XAConnectionFactory xaConnectionFactory = new LocalXAConnectionFactory(transactionManager, connectionFactory);
// create the pool
pool = new GenericObjectPool();
pool.setMaxActive(getMaxActive());
pool.setMaxWait(getMaxWait());
// create the pool object factory
PoolableConnectionFactory factory = new PoolableConnectionFactory(xaConnectionFactory, pool, null, "SELECT DUMMY FROM DUAL", true, true);
pool.setFactory(factory);
// finally create the datasource
ds = new ManagedDataSource(pool, xaConnectionFactory.getTransactionRegistry());
ds.setAccessToUnderlyingConnectionAllowed(true);
}
public void tearDown() throws Exception {
pool.close();
super.tearDown();
}
/**
* Verify the accessToUnderlyingConnectionAllowed propertly limits access to the physical connection.
*/
public void testAccessToUnderlyingConnectionAllowed() throws Exception {
ds.setAccessToUnderlyingConnectionAllowed(true);
ManagedConnection connection = (ManagedConnection) newConnection();
assertTrue(connection.isAccessToUnderlyingConnectionAllowed());
assertNotNull(connection.getDelegate());
assertNotNull(connection.getInnermostDelegate());
connection.close();
ds.setAccessToUnderlyingConnectionAllowed(false);
connection = (ManagedConnection) newConnection();
assertFalse(connection.isAccessToUnderlyingConnectionAllowed());
assertNull(connection.getDelegate());
assertNull(connection.getInnermostDelegate());
connection.close();
}
/**
* Verify that conection sharing is working (or not working) as expected.
*/
public void testSharedConnection() throws Exception {
DelegatingConnection connectionA = (DelegatingConnection) newConnection();
DelegatingConnection connectionB = (DelegatingConnection) newConnection();
assertFalse(connectionA.equals(connectionB));
assertFalse(connectionB.equals(connectionA));
assertFalse(connectionA.innermostDelegateEquals(connectionB.getInnermostDelegate()));
assertFalse(connectionB.innermostDelegateEquals(connectionA.getInnermostDelegate()));
connectionA.close();
connectionB.close();
}
public void testManagedConnectionEqualsSameDelegateNoUnderlyingAccess() throws Exception {
// Get a maximal set of connections from the pool
Connection[] c = new Connection[getMaxActive()];
for (int i = 0; i < c.length; i++) {
c[i] = newConnection();
}
// Close the delegate of one wrapper in the pool
((DelegatingConnection) c[0]).getDelegate().close();
// Disable access for the new connection
ds.setAccessToUnderlyingConnectionAllowed(false);
// Grab a new connection - should get c[0]'s closed connection
// so should be delegate-equivalent, so equal
Connection con = newConnection();
assertTrue(c[0].equals(con));
assertTrue(con.equals(c[0]));
for (int i = 0; i < c.length; i++) {
c[i].close();
}
ds.setAccessToUnderlyingConnectionAllowed(true);
}
public void testManagedConnectionEqualsSameDelegate() throws Exception {
// Get a maximal set of connections from the pool
Connection[] c = new Connection[getMaxActive()];
for (int i = 0; i < c.length; i++) {
c[i] = newConnection();
}
// Close the delegate of one wrapper in the pool
((DelegatingConnection) c[0]).getDelegate().close();
// Grab a new connection - should get c[0]'s closed connection
// so should be delegate-equivalent, so equal
Connection con = newConnection();
assertTrue(c[0].equals(con));
assertTrue(con.equals(c[0]));
for (int i = 0; i < c.length; i++) {
c[i].close();
}
}
/*
* JIRA: DBCP-198
*/
public void testManagedConnectionEqualsReflexive() throws Exception {
// Statndard setup - using DelegatingConnections
// returned from PoolableConnectionFactory
checkManagedConnectionEqualsReflexive();
// Force ManagedConnections to wrap non-Delegating connections
pool.close();
pool = new GenericObjectPool();
pool.setMaxActive(getMaxActive());
pool.setMaxWait(getMaxWait());
Properties props = new Properties();
props.setProperty("user", "username");
props.setProperty("password", "password");
NonDelegatingPoolableConnectionFactory factory = new NonDelegatingPoolableConnectionFactory(new DriverConnectionFactory(new TesterDriver(), "jdbc:apache:commons:testdriver", props), pool);
pool.setFactory(factory);
ds = new PoolingDataSource(pool);
checkManagedConnectionEqualsReflexive();
}
private void checkManagedConnectionEqualsReflexive() throws Exception {
Connection con = ds.getConnection();
Connection con2 = con;
assertTrue(con2.equals(con));
assertTrue(con.equals(con2));
con.close();
}
public void testManagedConnectionEqualsFail() throws Exception {
Connection con1 = ds.getConnection();
Connection con2 = ds.getConnection();
assertFalse(con1.equals(con2));
con1.close();
con2.close();
}
public void testManagedConnectionEqualsNull() throws Exception {
Connection con1 = ds.getConnection();
Connection con2 = null;
assertFalse(con1.equals(con2));
con1.close();
}
public void testManagedConnectionEqualsType() throws Exception {
Connection con1 = ds.getConnection();
Integer con2 = new Integer(0);
assertFalse(con1.equals(con2));
con1.close();
}
public void testManagedConnectionEqualInnermost() throws Exception {
ds.setAccessToUnderlyingConnectionAllowed(true);
DelegatingConnection con = (DelegatingConnection) ds.getConnection();
Connection inner = con.getInnermostDelegate();
ds.setAccessToUnderlyingConnectionAllowed(false);
DelegatingConnection con2 = new DelegatingConnection(inner);
assertTrue(con2.equals(con));
assertTrue(con.innermostDelegateEquals(con2.getInnermostDelegate()));
assertTrue(con2.innermostDelegateEquals(inner));
assertTrue(con.equals(con2));
}
/**
* Factory to return non-delegating connections for DBCP-198 test
*/
private static class NonDelegatingPoolableConnectionFactory
extends PoolableConnectionFactory {
public NonDelegatingPoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool) {
super(connFactory, pool, null, null, true, true);
}
synchronized public Object makeObject() throws Exception {
return _connFactory.createConnection();
}
}
}
././@LongLink 0000000 0000000 0000000 00000000146 00000000000 011566 L ustar root root libcommons-dbcp-java-1.4.orig/src/test/org/apache/commons/dbcp/managed/TestManagedDataSourceInTx.java libcommons-dbcp-java-1.4.orig/src/test/org/apache/commons/dbcp/managed/TestManagedDataSourceInTx.jav0000644 0001750 0001750 00000030753 11333570547 033431 0 ustar drazzib drazzib /**
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.dbcp.managed;
import org.apache.commons.dbcp.DelegatingConnection;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import junit.framework.Test;
import junit.framework.TestSuite;
import javax.transaction.Transaction;
/**
* TestSuite for ManagedDataSource with an active transaction in progress.
*
* @author Dain Sundstrom
* @version $Revision$
*/
public class TestManagedDataSourceInTx extends TestManagedDataSource {
public TestManagedDataSourceInTx(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestManagedDataSourceInTx.class);
}
public void setUp() throws Exception {
super.setUp();
transactionManager.begin();
}
public void tearDown() throws Exception {
if (transactionManager.getTransaction() != null) {
transactionManager.commit();
}
super.tearDown();
}
/**
* @see #testSharedConnection()
*/
public void testManagedConnectionEqualsFail() throws Exception {
// this test is invalid for managed conections since because
// two connections to the same datasource are supposed to share
// a single connection
}
public void testConnectionsAreDistinct() throws Exception {
Connection[] conn = new Connection[getMaxActive()];
for(int i=0;i