You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/10/25 10:37:17 UTC

[tomcat] branch 7.0.x updated (0c756e4 -> 8191a6a)

This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


    from 0c756e4  Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63829
     new 8ba4f46  Add TestBasicDataSource from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
     new addbdbe  Add TesterDriver from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
     new baf5895  Add TesterConnection from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
     new 6b81f37  Add TesterDatabaseMetaData from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
     new 11f3f49  Add TesterResulSet from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
     new 36f7f4b  Add TesterPreparedStatement from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
     new 053ca10  Add TesterCallableStatement from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
     new edf36aa  Add TesterStatement from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
     new f406df2  Add TesterClassLoader from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
     new 9480651  Add TestConnectionPool from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
     new 1fd365f  Repackaging.
     new 2015090  Remove unused imports.
     new b18ab5f  Generics.
     new 89ca499  Rename abstract test class so runner does not try to execute test cases in it.
     new 8191a6a  Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63833

The 15 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../dbcp/dbcp/PoolableConnectionFactory.java       |   4 +-
 .../dbcp/dbcp/AbstractConnectionPoolTest.java      | 914 +++++++++++++++++++
 .../tomcat/dbcp/dbcp/TestBasicDataSource.java      | 592 +++++++++++++
 .../tomcat/dbcp/dbcp/TesterCallableStatement.java  | 473 ++++++++++
 .../apache/tomcat/dbcp/dbcp/TesterClassLoader.java |  38 +-
 .../apache/tomcat/dbcp/dbcp/TesterConnection.java  | 366 ++++++++
 .../tomcat/dbcp/dbcp/TesterDatabaseMetaData.java   | 777 ++++++++++++++++
 test/org/apache/tomcat/dbcp/dbcp/TesterDriver.java | 134 +++
 .../tomcat/dbcp/dbcp/TesterPreparedStatement.java  | 367 ++++++++
 .../apache/tomcat/dbcp/dbcp/TesterResultSet.java   | 986 +++++++++++++++++++++
 .../apache/tomcat/dbcp/dbcp/TesterStatement.java   | 310 +++++++
 webapps/docs/changelog.xml                         |   6 +
 12 files changed, 4949 insertions(+), 18 deletions(-)
 create mode 100644 test/org/apache/tomcat/dbcp/dbcp/AbstractConnectionPoolTest.java
 create mode 100644 test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java
 create mode 100644 test/org/apache/tomcat/dbcp/dbcp/TesterCallableStatement.java
 copy java/org/apache/tomcat/dbcp/dbcp/ConnectionFactory.java => test/org/apache/tomcat/dbcp/dbcp/TesterClassLoader.java (58%)
 create mode 100644 test/org/apache/tomcat/dbcp/dbcp/TesterConnection.java
 create mode 100644 test/org/apache/tomcat/dbcp/dbcp/TesterDatabaseMetaData.java
 create mode 100644 test/org/apache/tomcat/dbcp/dbcp/TesterDriver.java
 create mode 100644 test/org/apache/tomcat/dbcp/dbcp/TesterPreparedStatement.java
 create mode 100644 test/org/apache/tomcat/dbcp/dbcp/TesterResultSet.java
 create mode 100644 test/org/apache/tomcat/dbcp/dbcp/TesterStatement.java


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 07/15: Add TesterCallableStatement from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 053ca1075545ba61cce553e6829ffa2265e0d1cc
Author: Phil Steitz <ph...@gmail.com>
AuthorDate: Sat Oct 19 14:42:46 2019 -0700

    Add TesterCallableStatement from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
---
 .../tomcat/dbcp/dbcp/TesterCallableStatement.java  | 473 +++++++++++++++++++++
 1 file changed, 473 insertions(+)

diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterCallableStatement.java b/test/org/apache/tomcat/dbcp/dbcp/TesterCallableStatement.java
new file mode 100644
index 0000000..851dfbf
--- /dev/null
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterCallableStatement.java
@@ -0,0 +1,473 @@
+/**
+ *
+ * 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.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.Ref;
+import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Map;
+/* JDBC_4_ANT_KEY_BEGIN */
+import java.sql.NClob;
+import java.sql.RowId;
+import java.sql.SQLXML;
+/* JDBC_4_ANT_KEY_END */
+
+/**
+ * Trivial implementation of a CallableStatement to avoid null pointer exceptions in tests.
+ *
+ * @author Dain Sundstrom
+ * @version $Revision$
+ */
+public class TesterCallableStatement extends TesterPreparedStatement implements CallableStatement {
+
+    public TesterCallableStatement(Connection conn) {
+        super(conn);
+    }
+
+    public TesterCallableStatement(Connection conn, String sql) {
+        super(conn, sql);
+    }
+
+    public TesterCallableStatement(Connection conn, String sql, int resultSetType, int resultSetConcurrency) {
+        super(conn, sql, resultSetType, resultSetConcurrency);
+    }
+
+    public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException {
+    }
+
+    public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException {
+    }
+
+    public boolean wasNull() throws SQLException {
+        return false;
+    }
+
+    public String getString(int parameterIndex) throws SQLException {
+        return null;
+    }
+
+    public boolean getBoolean(int parameterIndex) throws SQLException {
+        return false;
+    }
+
+    public byte getByte(int parameterIndex) throws SQLException {
+        return 0;
+    }
+
+    public short getShort(int parameterIndex) throws SQLException {
+        return 0;
+    }
+
+    public int getInt(int parameterIndex) throws SQLException {
+        return 0;
+    }
+
+    public long getLong(int parameterIndex) throws SQLException {
+        return 0;
+    }
+
+    public float getFloat(int parameterIndex) throws SQLException {
+        return 0;
+    }
+
+    public double getDouble(int parameterIndex) throws SQLException {
+        return 0;
+    }
+
+    /**
+     * @deprecated
+     */
+    public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException {
+        return null;
+    }
+
+    public byte[] getBytes(int parameterIndex) throws SQLException {
+        return new byte[0];
+    }
+
+    public Date getDate(int parameterIndex) throws SQLException {
+        return null;
+    }
+
+    public Time getTime(int parameterIndex) throws SQLException {
+        return null;
+    }
+
+    public Timestamp getTimestamp(int parameterIndex) throws SQLException {
+        return null;
+    }
+
+    public Object getObject(int parameterIndex) throws SQLException {
+        return null;
+    }
+
+    public BigDecimal getBigDecimal(int parameterIndex) throws SQLException {
+        return null;
+    }
+
+    public Object getObject(int i, Map map) throws SQLException {
+        return null;
+    }
+
+    public Ref getRef(int i) throws SQLException {
+        return null;
+    }
+
+    public Blob getBlob(int i) throws SQLException {
+        return null;
+    }
+
+    public Clob getClob(int i) throws SQLException {
+        return null;
+    }
+
+    public Array getArray(int i) throws SQLException {
+        return null;
+    }
+
+    public Date getDate(int parameterIndex, Calendar cal) throws SQLException {
+        return null;
+    }
+
+    public Time getTime(int parameterIndex, Calendar cal) throws SQLException {
+        return null;
+    }
+
+    public Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException {
+        return null;
+    }
+
+    public void registerOutParameter(int paramIndex, int sqlType, String typeName) throws SQLException {
+    }
+
+    public void registerOutParameter(String parameterName, int sqlType) throws SQLException {
+    }
+
+    public void registerOutParameter(String parameterName, int sqlType, int scale) throws SQLException {
+    }
+
+    public void registerOutParameter(String parameterName, int sqlType, String typeName) throws SQLException {
+    }
+
+    public URL getURL(int parameterIndex) throws SQLException {
+        return null;
+    }
+
+    public void setURL(String parameterName, URL val) throws SQLException {
+    }
+
+    public void setNull(String parameterName, int sqlType) throws SQLException {
+    }
+
+    public void setBoolean(String parameterName, boolean x) throws SQLException {
+    }
+
+    public void setByte(String parameterName, byte x) throws SQLException {
+    }
+
+    public void setShort(String parameterName, short x) throws SQLException {
+    }
+
+    public void setInt(String parameterName, int x) throws SQLException {
+    }
+
+    public void setLong(String parameterName, long x) throws SQLException {
+    }
+
+    public void setFloat(String parameterName, float x) throws SQLException {
+    }
+
+    public void setDouble(String parameterName, double x) throws SQLException {
+    }
+
+    public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException {
+    }
+
+    public void setString(String parameterName, String x) throws SQLException {
+    }
+
+    public void setBytes(String parameterName, byte x[]) throws SQLException {
+    }
+
+    public void setDate(String parameterName, Date x) throws SQLException {
+    }
+
+    public void setTime(String parameterName, Time x) throws SQLException {
+    }
+
+    public void setTimestamp(String parameterName, Timestamp x) throws SQLException {
+    }
+
+    public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException {
+    }
+
+    public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException {
+    }
+
+    public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException {
+    }
+
+    public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException {
+    }
+
+    public void setObject(String parameterName, Object x) throws SQLException {
+    }
+
+    public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException {
+    }
+
+    public void setDate(String parameterName, Date x, Calendar cal) throws SQLException {
+    }
+
+    public void setTime(String parameterName, Time x, Calendar cal) throws SQLException {
+    }
+
+    public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException {
+    }
+
+    public void setNull(String parameterName, int sqlType, String typeName) throws SQLException {
+    }
+
+    public String getString(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public boolean getBoolean(String parameterName) throws SQLException {
+        return false;
+    }
+
+    public byte getByte(String parameterName) throws SQLException {
+        return 0;
+    }
+
+    public short getShort(String parameterName) throws SQLException {
+        return 0;
+    }
+
+    public int getInt(String parameterName) throws SQLException {
+        return 0;
+    }
+
+    public long getLong(String parameterName) throws SQLException {
+        return 0;
+    }
+
+    public float getFloat(String parameterName) throws SQLException {
+        return 0;
+    }
+
+    public double getDouble(String parameterName) throws SQLException {
+        return 0;
+    }
+
+    public byte[] getBytes(String parameterName) throws SQLException {
+        return new byte[0];
+    }
+
+    public Date getDate(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public Time getTime(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public Timestamp getTimestamp(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public Object getObject(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public BigDecimal getBigDecimal(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public Object getObject(String parameterName, Map map) throws SQLException {
+        return null;
+    }
+
+    public Ref getRef(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public Blob getBlob(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public Clob getClob(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public Array getArray(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public Date getDate(String parameterName, Calendar cal) throws SQLException {
+        return null;
+    }
+
+    public Time getTime(String parameterName, Calendar cal) throws SQLException {
+        return null;
+    }
+
+    public Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLException {
+        return null;
+    }
+
+    public URL getURL(String parameterName) throws SQLException {
+        return null;
+    }
+/* JDBC_4_ANT_KEY_BEGIN */
+
+    public RowId getRowId(int parameterIndex) throws SQLException {
+        return null;
+    }
+
+    public RowId getRowId(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public void setRowId(String parameterName, RowId value) throws SQLException {
+    }
+
+    public void setNString(String parameterName, String value) throws SQLException {
+    }
+
+    public void setNCharacterStream(String parameterName, Reader reader, long length) throws SQLException {
+    }
+
+    public void setNClob(String parameterName, NClob value) throws SQLException {
+    }
+
+    public void setClob(String parameterName, Reader reader, long length) throws SQLException {
+    }
+
+    public void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException {
+    }
+
+    public void setNClob(String parameterName, Reader reader, long length) throws SQLException {
+    }
+
+    public NClob getNClob(int parameterIndex) throws SQLException {
+        return null;
+    }
+
+    public NClob getNClob(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public void setSQLXML(String parameterName, SQLXML value) throws SQLException {
+    }
+
+    public SQLXML getSQLXML(int parameterIndex) throws SQLException {
+        return null;
+    }
+
+    public SQLXML getSQLXML(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public String getNString(int parameterIndex) throws SQLException {
+        return null;
+    }
+
+    public String getNString(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public Reader getNCharacterStream(int parameterIndex) throws SQLException {
+        return null;
+    }
+
+    public Reader getNCharacterStream(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public Reader getCharacterStream(int parameterIndex) throws SQLException {
+        return null;
+    }
+
+    public Reader getCharacterStream(String parameterName) throws SQLException {
+        return null;
+    }
+
+    public void setBlob(String parameterName, Blob blob) throws SQLException {
+    }
+
+    public void setClob(String parameterName, Clob clob) throws SQLException {
+    }
+
+    public void setAsciiStream(String parameterName, InputStream inputStream, long length) throws SQLException {
+    }
+
+    public void setBinaryStream(String parameterName, InputStream inputStream, long length) throws SQLException {
+    }
+
+    public void setCharacterStream(String parameterName, Reader reader, long length) throws SQLException {
+    }
+
+    public void setAsciiStream(String parameterName, InputStream inputStream) throws SQLException {
+    }
+
+    public void setBinaryStream(String parameterName, InputStream inputStream) throws SQLException {
+    }
+
+    public void setCharacterStream(String parameterName, Reader reader) throws SQLException {
+    }
+
+    public void setNCharacterStream(String parameterName, Reader reader) throws SQLException {
+    }
+
+    public void setClob(String parameterName, Reader reader) throws SQLException {
+    }
+
+    public void setBlob(String parameterName, InputStream inputStream) throws SQLException {
+    }
+
+    public void setNClob(String parameterName, Reader reader) throws SQLException {
+    }
+/* JDBC_4_ANT_KEY_END */
+
+    /* JDBC_4_1_ANT_KEY_BEGIN */
+    @Override
+    public <T> T getObject(int parameterIndex, Class<T> type)
+            throws SQLException {
+        return null;
+    }
+
+    @Override
+    public <T> T getObject(String parameterName, Class<T> type)
+            throws SQLException {
+        return null;
+    }
+    /* JDBC_4_1_ANT_KEY_END */
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 03/15: Add TesterConnection from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit baf58959e48c939805e0cb6f7a07277bf7ab89e6
Author: Phil Steitz <ph...@gmail.com>
AuthorDate: Sat Oct 19 14:10:18 2019 -0700

    Add TesterConnection from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
---
 .../apache/tomcat/dbcp/dbcp/TesterConnection.java  | 366 +++++++++++++++++++++
 1 file changed, 366 insertions(+)

diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterConnection.java b/test/org/apache/tomcat/dbcp/dbcp/TesterConnection.java
new file mode 100644
index 0000000..1c1fd25
--- /dev/null
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterConnection.java
@@ -0,0 +1,366 @@
+/*
+ * 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.CallableStatement;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+import java.util.Map;
+/* JDBC_4_ANT_KEY_BEGIN */
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.NClob;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLXML;
+import java.sql.Struct;
+import java.util.Properties;
+/* JDBC_4_ANT_KEY_END */
+import java.util.concurrent.Executor;
+
+/**
+ * A dummy {@link Connection}, for testing purposes.
+ *
+ * @author Rodney Waldhoff
+ * @author Dirk Verbeeck
+ * @version $Revision$ $Date$
+ */
+public class TesterConnection implements Connection {
+    protected boolean _open = true;
+    protected boolean _autoCommit = true;
+    protected int _transactionIsolation = 1;
+    protected DatabaseMetaData _metaData = new TesterDatabaseMetaData();
+    protected String _catalog = null;
+    protected Map _typeMap = null;
+    protected boolean _readOnly = false;
+    protected SQLWarning warnings = null;
+    protected String username = null;
+    protected String password = null;
+    protected Exception failure;
+
+    public TesterConnection(String username, String password) {
+        this.username = username;
+        this.password = password;
+    }
+
+    public String getUsername() {
+        return this.username;
+    }
+
+    public void setWarnings(SQLWarning warning) {
+        this.warnings = warning;
+    }
+
+    public void clearWarnings() throws SQLException {
+        checkOpen();
+        warnings = null;
+    }
+
+    public void close() throws SQLException {
+        checkFailure();
+        _open = false;
+    }
+
+    public void commit() throws SQLException {
+        checkOpen();
+        if (isReadOnly()) {
+            throw new SQLException("Cannot commit a readonly connection");
+        }
+    }
+
+    public Statement createStatement() throws SQLException {
+        checkOpen();
+        return new TesterStatement(this);
+    }
+
+    public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
+        checkOpen();
+        return new TesterStatement(this);
+    }
+
+    public boolean getAutoCommit() throws SQLException {
+        checkOpen();
+        return _autoCommit;
+    }
+
+    public String getCatalog() throws SQLException {
+        checkOpen();
+        return _catalog;
+    }
+
+    public DatabaseMetaData getMetaData() throws SQLException {
+        checkOpen();
+        return _metaData;
+    }
+
+    public int getTransactionIsolation() throws SQLException {
+        checkOpen();
+        return _transactionIsolation;
+    }
+
+    public Map getTypeMap() throws SQLException {
+        checkOpen();
+        return _typeMap;
+    }
+
+    public SQLWarning getWarnings() throws SQLException {
+        checkOpen();
+        return warnings;
+    }
+
+    public boolean isClosed() throws SQLException {
+        checkFailure();
+        return !_open;
+    }
+
+    public boolean isReadOnly() throws SQLException {
+        checkOpen();
+        return _readOnly;
+    }
+
+    public String nativeSQL(String sql) throws SQLException {
+        checkOpen();
+        return sql;
+    }
+
+    public CallableStatement prepareCall(String sql) throws SQLException {
+        checkOpen();
+        if ("warning".equals(sql)) {
+            setWarnings(new SQLWarning("warning in prepareCall"));
+        }
+        return new TesterCallableStatement(this);
+    }
+
+    public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+        checkOpen();
+        return new TesterCallableStatement(this);
+    }
+
+    public PreparedStatement prepareStatement(String sql) throws SQLException {
+        checkOpen();
+        if("null".equals(sql)) {
+            return null;
+        } if("invalid".equals(sql)) {
+            throw new SQLException("invalid query");
+        } if ("broken".equals(sql)) {
+            throw new SQLException("broken connection");
+        }
+        return new TesterPreparedStatement(this, sql);
+    }
+
+    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+        checkOpen();
+        return new TesterPreparedStatement(this, sql, resultSetType, resultSetConcurrency);
+    }
+
+    public void rollback() throws SQLException {
+        checkOpen();
+        if (isReadOnly()) {
+            throw new SQLException("Cannot rollback a readonly connection");
+        }
+    }
+
+    public void setAutoCommit(boolean autoCommit) throws SQLException {
+        checkOpen();
+        _autoCommit = autoCommit;
+    }
+
+    public void setCatalog(String catalog) throws SQLException {
+        checkOpen();
+        _catalog = catalog;
+    }
+
+    public void setReadOnly(boolean readOnly) throws SQLException {
+        checkOpen();
+        _readOnly = readOnly;
+    }
+
+    public void setTransactionIsolation(int level) throws SQLException {
+        checkOpen();
+        _transactionIsolation = level;
+    }
+
+    public void setTypeMap(Map map) throws SQLException {
+        checkOpen();
+        _typeMap = map;
+    }
+
+    protected void checkOpen() throws SQLException {
+        if(!_open) {
+            throw new SQLException("Connection is closed.");
+        }
+        checkFailure();
+    }
+
+    protected void checkFailure() throws SQLException {
+        if (failure != null) {
+            throw (SQLException) new SQLException("TesterConnection failure").initCause(failure);
+        }
+    }
+
+    public void setFailure(Exception failure) {
+        this.failure = failure;
+    }
+
+    public int getHoldability() throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setHoldability(int holdability) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public java.sql.Savepoint setSavepoint() throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public java.sql.Savepoint setSavepoint(String name) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void rollback(java.sql.Savepoint savepoint) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void releaseSavepoint(java.sql.Savepoint savepoint) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public Statement createStatement(int resultSetType,
+                                     int resultSetConcurrency,
+                                     int resultSetHoldability)
+        throws SQLException {
+        return createStatement();
+    }
+
+    public PreparedStatement prepareStatement(String sql, int resultSetType,
+                                              int resultSetConcurrency,
+                                              int resultSetHoldability)
+        throws SQLException {
+        return prepareStatement(sql);
+    }
+
+    public CallableStatement prepareCall(String sql, int resultSetType,
+                                         int resultSetConcurrency,
+                                         int resultSetHoldability)
+        throws SQLException {
+        return prepareCall(sql);
+    }
+
+    public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
+        throws SQLException {
+        return prepareStatement(sql);
+    }
+
+    public PreparedStatement prepareStatement(String sql, int columnIndexes[])
+        throws SQLException {
+        return prepareStatement(sql);
+    }
+
+    public PreparedStatement prepareStatement(String sql, String columnNames[])
+        throws SQLException {
+        return prepareStatement(sql);
+    }
+
+/* JDBC_4_ANT_KEY_BEGIN */
+
+    public boolean isWrapperFor(Class<?> iface) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public Blob createBlob() throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public Clob createClob() throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public NClob createNClob() throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public SQLXML createSQLXML() throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public boolean isValid(int timeout) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setClientInfo(String name, String value) throws SQLClientInfoException {
+        throw new SQLClientInfoException();
+    }
+
+    public void setClientInfo(Properties properties) throws SQLClientInfoException {
+        throw new SQLClientInfoException();
+    }
+
+    public Properties getClientInfo() throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public String getClientInfo(String name) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+/* JDBC_4_ANT_KEY_END */
+
+    /* JDBC_4_1_ANT_KEY_BEGIN */
+    @Override
+    public void setSchema(String schema) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    @Override
+    public String getSchema() throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    @Override
+    public void abort(Executor executor) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    @Override
+    public void setNetworkTimeout(Executor executor, int milliseconds)
+            throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    @Override
+    public int getNetworkTimeout() throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+    /* JDBC_4_1_ANT_KEY_END */
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 06/15: Add TesterPreparedStatement from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 36f7f4b42f8b2e10123e822056dc40043f522803
Author: Phil Steitz <ph...@gmail.com>
AuthorDate: Sat Oct 19 14:40:57 2019 -0700

    Add TesterPreparedStatement from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
---
 .../tomcat/dbcp/dbcp/TesterPreparedStatement.java  | 367 +++++++++++++++++++++
 1 file changed, 367 insertions(+)

diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterPreparedStatement.java b/test/org/apache/tomcat/dbcp/dbcp/TesterPreparedStatement.java
new file mode 100644
index 0000000..cf2ab2c
--- /dev/null
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterPreparedStatement.java
@@ -0,0 +1,367 @@
+/*
+ * 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.Connection;
+import java.sql.PreparedStatement;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+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 PreparedStatement}, for testing purposes.
+ * 
+ * @author Rodney Waldhoff
+ * @author Dirk Verbeeck
+ * @version $Revision$ $Date$
+ */
+public class TesterPreparedStatement extends TesterStatement implements PreparedStatement {
+    private ResultSetMetaData _resultSetMetaData = null;
+    private String _sql = null;
+    private String _catalog = null;
+
+    public TesterPreparedStatement(Connection conn) {
+        super(conn);
+        try {
+            _catalog = conn.getCatalog();
+        } catch (SQLException e) { }
+    }
+
+    public TesterPreparedStatement(Connection conn, String sql) {
+        super(conn);
+        _sql = sql;
+        try {
+            _catalog = conn.getCatalog();
+        } catch (SQLException e) { }
+    }
+
+    public TesterPreparedStatement(Connection conn, String sql, int resultSetType, int resultSetConcurrency) {
+        super(conn, resultSetType, resultSetConcurrency);
+        _sql = sql;
+        try {
+            _catalog = conn.getCatalog();
+        } catch (SQLException e) { }
+    }
+    
+    /** for junit test only */
+    public String getCatalog() {
+        return _catalog;
+    }
+
+    public ResultSet executeQuery(String sql) throws SQLException {
+        checkOpen();
+        if("null".equals(sql)) {
+            return null;
+        } else {
+            return new TesterResultSet(this, null, _resultSetType, _resultSetConcurrency);
+        }
+    }
+
+    public int executeUpdate(String sql) throws SQLException {
+        checkOpen();
+        return _rowsUpdated;
+    }
+
+    public ResultSet executeQuery() throws SQLException {
+        checkOpen();
+        if("null".equals(_sql)) {
+            return null;
+        } else {
+            return new TesterResultSet(this, null, _resultSetType, _resultSetConcurrency);
+        }
+    }
+
+    public int executeUpdate() throws SQLException {
+        checkOpen();
+        return _rowsUpdated;
+    }
+
+    public void setNull(int parameterIndex, int sqlType) throws SQLException {
+        checkOpen();
+    }
+
+    public void setBoolean(int parameterIndex, boolean x) throws SQLException {
+        checkOpen();
+    }
+
+    public void setByte(int parameterIndex, byte x) throws SQLException {
+        checkOpen();
+    }
+
+    public void setShort(int parameterIndex, short x) throws SQLException {
+        checkOpen();
+    }
+
+    public void setInt(int parameterIndex, int x) throws SQLException {
+        checkOpen();
+    }
+
+    public void setLong(int parameterIndex, long x) throws SQLException {
+        checkOpen();
+    }
+
+    public void setFloat(int parameterIndex, float x) throws SQLException {
+        checkOpen();
+    }
+
+    public void setDouble(int parameterIndex, double x) throws SQLException {
+        checkOpen();
+    }
+
+    public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException {
+        checkOpen();
+    }
+
+    public void setString(int parameterIndex, String x) throws SQLException {
+        checkOpen();
+    }
+
+    public void setBytes(int parameterIndex, byte x[]) throws SQLException {
+        checkOpen();
+    }
+
+    public void setDate(int parameterIndex, java.sql.Date x) throws SQLException {
+        checkOpen();
+    }
+
+    public void setTime(int parameterIndex, java.sql.Time x) throws SQLException {
+        checkOpen();
+    }
+
+    public void setTimestamp(int parameterIndex, java.sql.Timestamp x) throws SQLException {
+        checkOpen();
+    }
+
+    public void setAsciiStream(int parameterIndex, java.io.InputStream x, int length) throws SQLException {
+        checkOpen();
+    }
+
+    /** @deprecated */
+    public void setUnicodeStream(int parameterIndex, java.io.InputStream x, int length) throws SQLException {
+        checkOpen();
+    }
+
+    public void setBinaryStream(int parameterIndex, java.io.InputStream x, int length) throws SQLException {
+        checkOpen();
+    }
+
+    public void clearParameters() throws SQLException {
+        checkOpen();
+    }
+
+    public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException {
+        checkOpen();
+    }
+
+    public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException {
+        checkOpen();
+    }
+
+    public void setObject(int parameterIndex, Object x) throws SQLException {
+        checkOpen();
+    }
+
+
+    public boolean execute() throws SQLException {
+        checkOpen(); return true;
+    }
+
+    public void addBatch() throws SQLException {
+        checkOpen();
+    }
+
+    public void setCharacterStream(int parameterIndex, java.io.Reader reader, int length) throws SQLException {
+        checkOpen();
+    }
+
+    public void setRef (int i, Ref x) throws SQLException {
+        checkOpen();
+    }
+
+    public void setBlob (int i, Blob x) throws SQLException {
+        checkOpen();
+    }
+
+    public void setClob (int i, Clob x) throws SQLException {
+        checkOpen();
+    }
+
+    public void setArray (int i, Array x) throws SQLException {
+        checkOpen();
+    }
+
+    public ResultSetMetaData getMetaData() throws SQLException {
+        checkOpen();
+        return _resultSetMetaData;
+    }
+
+    public void setDate(int parameterIndex, java.sql.Date x, Calendar cal) throws SQLException {
+        checkOpen();
+    }
+
+    public void setTime(int parameterIndex, java.sql.Time x, Calendar cal) throws SQLException {
+        checkOpen();
+    }
+
+    public void setTimestamp(int parameterIndex, java.sql.Timestamp x, Calendar cal) throws SQLException {
+        checkOpen();
+    }
+
+    public void setNull (int paramIndex, int sqlType, String typeName) throws SQLException {
+        checkOpen();
+    }
+
+    public boolean getMoreResults(int current) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public ResultSet getGeneratedKeys() throws SQLException {
+        return new TesterResultSet(this, null, _resultSetType, _resultSetConcurrency);
+    }
+
+    public int executeUpdate(String sql, int autoGeneratedKeys)
+        throws SQLException {
+        checkOpen(); return 0;
+    }
+
+    public int executeUpdate(String sql, int columnIndexes[])
+        throws SQLException {
+        checkOpen(); return 0;
+    }
+
+    public int executeUpdate(String sql, String columnNames[])
+        throws SQLException {
+        checkOpen(); return 0;
+    }
+
+    public boolean execute(String sql, int autoGeneratedKeys)
+        throws SQLException {
+        checkOpen(); return true;
+    }
+
+    public boolean execute(String sl, int columnIndexes[])
+        throws SQLException {
+        checkOpen(); return true;
+    }
+
+    public boolean execute(String sql, String columnNames[])
+        throws SQLException {
+        checkOpen(); return true;
+    }
+
+    public int getResultSetHoldability() throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setURL(int parameterIndex, java.net.URL x)
+        throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public java.sql.ParameterMetaData getParameterMetaData() throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+/* JDBC_4_ANT_KEY_BEGIN */
+
+    public void setRowId(int parameterIndex, RowId value) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setNString(int parameterIndex, String value) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setNClob(int parameterIndex, NClob value) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setClob(int parameterIndex, Reader reader, long length) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setSQLXML(int parameterIndex, SQLXML value) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setAsciiStream(int parameterIndex, InputStream inputStream, long length) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setBinaryStream(int parameterIndex, InputStream inputStream, long length) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setAsciiStream(int parameterIndex, InputStream inputStream) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setBinaryStream(int parameterIndex, InputStream inputStream) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setNCharacterStream(int parameterIndex, Reader reader) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setClob(int parameterIndex, Reader reader) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public void setNClob(int parameterIndex, Reader reader) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+/* JDBC_4_ANT_KEY_END */
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 05/15: Add TesterResulSet from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 11f3f4949c94a1c96fcfcb0fe257976ff69b5921
Author: Phil Steitz <ph...@gmail.com>
AuthorDate: Sat Oct 19 14:39:01 2019 -0700

    Add TesterResulSet from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
---
 .../apache/tomcat/dbcp/dbcp/TesterResultSet.java   | 985 +++++++++++++++++++++
 1 file changed, 985 insertions(+)

diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterResultSet.java b/test/org/apache/tomcat/dbcp/dbcp/TesterResultSet.java
new file mode 100644
index 0000000..bc8134a
--- /dev/null
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterResultSet.java
@@ -0,0 +1,985 @@
+/*
+ * 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$ $Date$
+ */
+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> T unwrap(Class<T> 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 */
+
+    /* JDBC_4_1_ANT_KEY_BEGIN */
+    @Override
+    public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    @Override
+    public <T> T getObject(String columnLabel, Class<T> type)
+            throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+    /* JDBC_4_1_ANT_KEY_END */
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 11/15: Repackaging.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 1fd365f70cee897860f8f6342a8a4acbb2f3370b
Author: Phil Steitz <ph...@gmail.com>
AuthorDate: Sun Oct 20 09:37:12 2019 -0700

    Repackaging.
---
 .../apache/tomcat/dbcp/dbcp/TestBasicDataSource.java | 20 ++++++++++++--------
 .../apache/tomcat/dbcp/dbcp/TestConnectionPool.java  |  2 +-
 .../tomcat/dbcp/dbcp/TesterCallableStatement.java    |  2 +-
 .../apache/tomcat/dbcp/dbcp/TesterClassLoader.java   |  2 +-
 .../apache/tomcat/dbcp/dbcp/TesterConnection.java    |  2 +-
 .../tomcat/dbcp/dbcp/TesterDatabaseMetaData.java     |  2 +-
 test/org/apache/tomcat/dbcp/dbcp/TesterDriver.java   |  4 ++--
 .../tomcat/dbcp/dbcp/TesterPreparedStatement.java    |  2 +-
 .../org/apache/tomcat/dbcp/dbcp/TesterResultSet.java |  2 +-
 .../org/apache/tomcat/dbcp/dbcp/TesterStatement.java |  2 +-
 10 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java b/test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java
index c98e4bd..734e681 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.dbcp;
+package org.apache.tomcat.dbcp.dbcp;
 
 import java.io.IOException;
 import java.sql.Connection;
@@ -27,6 +27,10 @@ import javax.sql.DataSource;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertNotNull;
 
 /**
  * TestSuite for BasicDataSource
@@ -53,8 +57,8 @@ public class TestBasicDataSource extends TestConnectionPool {
     public void setUp() throws Exception {
         super.setUp();
         ds = createDataSource();
-        ds.setDriverClassName("org.apache.commons.dbcp.TesterDriver");
-        ds.setUrl("jdbc:apache:commons:testdriver");
+        ds.setDriverClassName("org.apache.tomcat.dbcp.dbcp.TesterDriver");
+        ds.setUrl("jdbc:apache:tomcat:dbcp:testdriver");
         ds.setMaxActive(getMaxActive());
         ds.setMaxWait(getMaxWait());
         ds.setDefaultAutoCommit(true);
@@ -479,8 +483,8 @@ public class TestBasicDataSource extends TestConnectionPool {
         ds.close();
         ds = null;
         ds = createDataSource();
-        ds.setDriverClassName("org.apache.commons.dbcp.TesterDriver");
-        ds.setUrl("jdbc:apache:commons:testdriver");
+        ds.setDriverClassName("org.apache.tomcat.dbcp.dbcp.TesterDriver");
+        ds.setUrl("jdbc:apache:tomcat:dbcp:testdriver");
         ds.setMaxActive(getMaxActive());
         ds.setMaxWait(getMaxWait());
         ds.setDefaultAutoCommit(true);
@@ -526,8 +530,8 @@ public class TestBasicDataSource extends TestConnectionPool {
         ds.close();
         ds = null;
         ds = createDataSource();
-        ds.setDriverClassName("org.apache.commons.dbcp.TesterConnRequestCountDriver");
-        ds.setUrl("jdbc:apache:commons:testerConnRequestCountDriver");
+        ds.setDriverClassName("org.apache.tomcat.dbcp.dbcp.TesterConnRequestCountDriver");
+        ds.setUrl("jdbc:apache:tomcat:dbcp:testerConnRequestCountDriver");
         ds.setValidationQuery("SELECT DUMMY FROM DUAL");
         ds.setUsername("username");
 
@@ -568,7 +572,7 @@ public class TestBasicDataSource extends TestConnectionPool {
  * TesterDriver that keeps a static count of connection requests.
  */
 class TesterConnRequestCountDriver extends TesterDriver {
-    protected static final String CONNECT_STRING = "jdbc:apache:commons:testerConnRequestCountDriver";
+    protected static final String CONNECT_STRING = "jdbc:apache:tomcat:dbcp:testerConnRequestCountDriver";
     private static int connectionRequestCount = 0;
 
 	@Override
diff --git a/test/org/apache/tomcat/dbcp/dbcp/TestConnectionPool.java b/test/org/apache/tomcat/dbcp/dbcp/TestConnectionPool.java
index 004a054..b458263 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TestConnectionPool.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TestConnectionPool.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.dbcp;
+package org.apache.tomcat.dbcp.dbcp;
 
 import java.sql.Connection;
 import java.sql.PreparedStatement;
diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterCallableStatement.java b/test/org/apache/tomcat/dbcp/dbcp/TesterCallableStatement.java
index 851dfbf..d463cc1 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TesterCallableStatement.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterCallableStatement.java
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.commons.dbcp;
+package org.apache.tomcat.dbcp.dbcp;
 
 import java.io.InputStream;
 import java.io.Reader;
diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterClassLoader.java b/test/org/apache/tomcat/dbcp/dbcp/TesterClassLoader.java
index 166041c..6cda3ac 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TesterClassLoader.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterClassLoader.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.dbcp;
+package org.apache.tomcat.dbcp.dbcp;
 
 import java.util.HashSet;
 import java.util.Set;
diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterConnection.java b/test/org/apache/tomcat/dbcp/dbcp/TesterConnection.java
index 1c1fd25..8b14447 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TesterConnection.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterConnection.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.dbcp;
+package org.apache.tomcat.dbcp.dbcp;
 
 import java.sql.CallableStatement;
 import java.sql.Connection;
diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterDatabaseMetaData.java b/test/org/apache/tomcat/dbcp/dbcp/TesterDatabaseMetaData.java
index 95dae0c..c99c28b 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TesterDatabaseMetaData.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterDatabaseMetaData.java
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.commons.dbcp;
+package org.apache.tomcat.dbcp.dbcp;
 
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterDriver.java b/test/org/apache/tomcat/dbcp/dbcp/TesterDriver.java
index 26eff85..6e2fca2 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TesterDriver.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterDriver.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.dbcp;
+package org.apache.tomcat.dbcp.dbcp;
 
 import java.sql.Connection;
 import java.sql.Driver;
@@ -125,7 +125,7 @@ public class TesterDriver implements Driver {
     }
     /* JDBC_4_1_ANT_KEY_END */
 
-    protected static final String CONNECT_STRING = "jdbc:apache:commons:testdriver";
+    protected static final String CONNECT_STRING = "jdbc:apache:tomcat:dbcp:testdriver";
 
     // version numbers
     protected static final int MAJOR_VERSION = 1;
diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterPreparedStatement.java b/test/org/apache/tomcat/dbcp/dbcp/TesterPreparedStatement.java
index cf2ab2c..d210733 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TesterPreparedStatement.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterPreparedStatement.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.dbcp;
+package org.apache.tomcat.dbcp.dbcp;
 
 import java.math.BigDecimal;
 import java.sql.Array;
diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterResultSet.java b/test/org/apache/tomcat/dbcp/dbcp/TesterResultSet.java
index bc8134a..410ecfc 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TesterResultSet.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterResultSet.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.dbcp;
+package org.apache.tomcat.dbcp.dbcp;
 
 import java.math.BigDecimal;
 import java.sql.Array;
diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterStatement.java b/test/org/apache/tomcat/dbcp/dbcp/TesterStatement.java
index 4a81e10..9aebccf 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TesterStatement.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterStatement.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.dbcp;
+package org.apache.tomcat.dbcp.dbcp;
 
 import java.sql.Connection;
 import java.sql.ResultSet;


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 13/15: Generics.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit b18ab5fb864b39b3af32090d85169e4b6887a37b
Author: psteitz <ps...@apache.org>
AuthorDate: Sun Oct 20 12:03:49 2019 -0700

    Generics.
---
 test/org/apache/tomcat/dbcp/dbcp/TestConnectionPool.java      | 4 ++--
 test/org/apache/tomcat/dbcp/dbcp/TesterCallableStatement.java | 4 ++--
 test/org/apache/tomcat/dbcp/dbcp/TesterConnection.java        | 6 +++---
 test/org/apache/tomcat/dbcp/dbcp/TesterResultSet.java         | 5 +++--
 4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/test/org/apache/tomcat/dbcp/dbcp/TestConnectionPool.java b/test/org/apache/tomcat/dbcp/dbcp/TestConnectionPool.java
index b458263..f0ea905 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TestConnectionPool.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TestConnectionPool.java
@@ -73,7 +73,7 @@ public abstract class TestConnectionPool extends TestCase {
     }
     
     /** Connections opened during the course of a test */
-    protected Stack connections = new Stack();
+    protected Stack<Connection> connections = new Stack<Connection>();
     
     /** Acquire a connection and push it onto the connections stack */
     protected Connection newConnection() throws Exception {
@@ -520,7 +520,7 @@ public abstract class TestConnectionPool extends TestCase {
      */
     public void testHashing() throws Exception {
         Connection con = getConnection();
-        Hashtable hash = new Hashtable();
+        Hashtable<Connection, String> hash = new Hashtable<Connection, String>();
         hash.put(con, "test");
         assertEquals("test", hash.get(con));
         assertTrue(hash.containsKey(con));
diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterCallableStatement.java b/test/org/apache/tomcat/dbcp/dbcp/TesterCallableStatement.java
index d463cc1..a4b9a42 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TesterCallableStatement.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterCallableStatement.java
@@ -132,7 +132,7 @@ public class TesterCallableStatement extends TesterPreparedStatement implements
         return null;
     }
 
-    public Object getObject(int i, Map map) throws SQLException {
+    public Object getObject(int i, Map<String,Class<?>> map) throws SQLException {
         return null;
     }
 
@@ -311,7 +311,7 @@ public class TesterCallableStatement extends TesterPreparedStatement implements
         return null;
     }
 
-    public Object getObject(String parameterName, Map map) throws SQLException {
+    public Object getObject(String parameterName, Map<String,Class<?>> map) throws SQLException {
         return null;
     }
 
diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterConnection.java b/test/org/apache/tomcat/dbcp/dbcp/TesterConnection.java
index 8b14447..9e4e492 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TesterConnection.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterConnection.java
@@ -50,7 +50,7 @@ public class TesterConnection implements Connection {
     protected int _transactionIsolation = 1;
     protected DatabaseMetaData _metaData = new TesterDatabaseMetaData();
     protected String _catalog = null;
-    protected Map _typeMap = null;
+    protected Map<String,Class<?>> _typeMap = null;
     protected boolean _readOnly = false;
     protected SQLWarning warnings = null;
     protected String username = null;
@@ -117,7 +117,7 @@ public class TesterConnection implements Connection {
         return _transactionIsolation;
     }
 
-    public Map getTypeMap() throws SQLException {
+    public Map<String,Class<?>> getTypeMap() throws SQLException {
         checkOpen();
         return _typeMap;
     }
@@ -199,7 +199,7 @@ public class TesterConnection implements Connection {
         _transactionIsolation = level;
     }
 
-    public void setTypeMap(Map map) throws SQLException {
+    public void setTypeMap(Map<String,Class<?>> map) throws SQLException {
         checkOpen();
         _typeMap = map;
     }
diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterResultSet.java b/test/org/apache/tomcat/dbcp/dbcp/TesterResultSet.java
index 410ecfc..6d562f4 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TesterResultSet.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterResultSet.java
@@ -28,6 +28,7 @@ import java.sql.SQLException;
 import java.sql.SQLWarning;
 import java.sql.Statement;
 import java.util.Calendar;
+import java.util.Map;
 /* JDBC_4_ANT_KEY_BEGIN */
 import java.io.InputStream;
 import java.io.Reader;
@@ -632,7 +633,7 @@ public class TesterResultSet implements ResultSet {
     }
 
 
-    public Object getObject(int i, java.util.Map map) throws SQLException {
+    public Object getObject(int i, Map<String,Class<?>> map) throws SQLException {
         checkOpen();
         return new Object();
     }
@@ -657,7 +658,7 @@ public class TesterResultSet implements ResultSet {
         return null;
     }
 
-    public Object getObject(String colName, java.util.Map map) throws SQLException {
+    public Object getObject(String colName, Map<String,Class<?>> map) throws SQLException {
         checkOpen();
         return colName;
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 12/15: Remove unused imports.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 2015090e55abc9272dd8b6f010a1a568c8263398
Author: psteitz <ps...@apache.org>
AuthorDate: Sun Oct 20 12:02:46 2019 -0700

    Remove unused imports.
---
 test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java b/test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java
index 734e681..4ea483f 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java
@@ -27,10 +27,6 @@ import javax.sql.DataSource;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertNotNull;
 
 /**
  * TestSuite for BasicDataSource


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 10/15: Add TestConnectionPool from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 9480651047c408bcf931612b68c8319145b31e89
Author: Phil Steitz <ph...@gmail.com>
AuthorDate: Sat Oct 19 14:49:54 2019 -0700

    Add TestConnectionPool from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
---
 .../tomcat/dbcp/dbcp/TestConnectionPool.java       | 914 +++++++++++++++++++++
 1 file changed, 914 insertions(+)

diff --git a/test/org/apache/tomcat/dbcp/dbcp/TestConnectionPool.java b/test/org/apache/tomcat/dbcp/dbcp/TestConnectionPool.java
new file mode 100644
index 0000000..004a054
--- /dev/null
+++ b/test/org/apache/tomcat/dbcp/dbcp/TestConnectionPool.java
@@ -0,0 +1,914 @@
+/*
+ * 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.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Hashtable;
+import java.util.Stack;
+
+import junit.framework.TestCase;
+
+// XXX FIX ME XXX
+// this class still needs some cleanup, but at least
+// this consolidates most of the relevant test code
+// in a fairly re-usable fashion
+// XXX FIX ME XXX
+
+/**
+ * Base test suite for DBCP pools.
+ * 
+ * @author Rodney Waldhoff
+ * @author Sean C. Sullivan
+ * @author John McNally
+ * @author Dirk Verbeeck
+ * @version $Revision$ $Date$
+ */
+public abstract class TestConnectionPool extends TestCase {
+    public TestConnectionPool(String testName) {
+        super(testName);
+    }
+
+    public void tearDown() throws Exception {
+        super.tearDown();
+        // Close any connections opened by the test
+        while (!connections.isEmpty()) {
+            Connection conn = (Connection) connections.pop();
+            try {
+                conn.close();
+            } catch (Exception ex) { 
+                // ignore
+            } finally {
+                conn = null;
+            }
+        }
+    }
+
+    protected abstract Connection getConnection() throws Exception;
+    
+    protected int getMaxActive() {
+        return 10;
+    }
+    
+    protected long getMaxWait() {
+        return 100L;
+    }
+    
+    /** Connections opened during the course of a test */
+    protected Stack connections = new Stack();
+    
+    /** Acquire a connection and push it onto the connections stack */
+    protected Connection newConnection() throws Exception {
+        Connection connection = getConnection();
+        connections.push(connection);
+        return connection;
+    }
+
+    // ----------- Utility Methods --------------------------------- 
+
+    protected String getUsername(Connection conn) throws SQLException {
+        Statement stmt = conn.createStatement();
+        ResultSet rs = stmt.executeQuery("select username");
+        if (rs.next()) {
+            return rs.getString(1);
+        }
+        return null;
+    }
+
+    // ----------- tests --------------------------------- 
+
+    public void testClearWarnings() throws Exception {
+        Connection[] c = new Connection[getMaxActive()];
+        for (int i = 0; i < c.length; i++) {
+            c[i] = newConnection();
+            assertTrue(c[i] != null);
+            
+            // generate SQLWarning on connection
+            c[i].prepareCall("warning");
+        }
+
+        for (int i = 0; i < c.length; i++) {
+            assertNotNull(c[i].getWarnings());
+        }
+
+        for (int i = 0; i < c.length; i++) {
+            c[i].close();
+        }
+        
+        for (int i = 0; i < c.length; i++) {
+            c[i] = newConnection();
+        }        
+
+        for (int i = 0; i < c.length; i++) {
+            // warnings should have been cleared by putting the connection back in the pool
+            assertNull(c[i].getWarnings());
+        }
+
+        for (int i = 0; i < c.length; i++) {
+            c[i].close();
+        }
+    }
+
+    public void testIsClosed() throws Exception {
+        for(int i=0;i<getMaxActive();i++) {
+            Connection conn = newConnection();
+            assertNotNull(conn);
+            assertTrue(!conn.isClosed());
+            PreparedStatement stmt = conn.prepareStatement("select * from dual");
+            assertNotNull(stmt);
+            ResultSet rset = stmt.executeQuery();
+            assertNotNull(rset);
+            assertTrue(rset.next());
+            rset.close();
+            stmt.close();
+            conn.close();
+            assertTrue(conn.isClosed());
+        }
+    }
+
+    /**
+     * Verify the close method can be called multiple times on a single connection without
+     * an exception being thrown.
+     */
+    public void testCanCloseConnectionTwice() throws Exception {
+        for (int i = 0; i < getMaxActive(); i++) { // loop to show we *can* close again once we've borrowed it from the pool again
+            Connection conn = newConnection();
+            assertNotNull(conn);
+            assertTrue(!conn.isClosed());
+            conn.close();
+            assertTrue(conn.isClosed());
+            conn.close();
+            assertTrue(conn.isClosed());
+        }
+    }
+
+    public void testCanCloseStatementTwice() throws Exception {
+        Connection conn = newConnection();
+        assertNotNull(conn);
+        assertTrue(!conn.isClosed());
+        for(int i=0;i<2;i++) { // loop to show we *can* close again once we've borrowed it from the pool again
+            Statement stmt = conn.createStatement();
+            assertNotNull(stmt);
+            assertFalse(isClosed(stmt));
+            stmt.close();
+            assertTrue(isClosed(stmt));
+            stmt.close();
+            assertTrue(isClosed(stmt));
+            stmt.close();
+            assertTrue(isClosed(stmt));
+        }
+        conn.close();
+    }
+
+    public void testCanClosePreparedStatementTwice() throws Exception {
+        Connection conn = newConnection();
+        assertNotNull(conn);
+        assertTrue(!conn.isClosed());
+        for(int i=0;i<2;i++) { // loop to show we *can* close again once we've borrowed it from the pool again
+            PreparedStatement stmt = conn.prepareStatement("select * from dual");
+            assertNotNull(stmt);
+            assertFalse(isClosed(stmt));
+            stmt.close();
+            assertTrue(isClosed(stmt));
+            stmt.close();
+            assertTrue(isClosed(stmt));
+            stmt.close();
+            assertTrue(isClosed(stmt));
+        }
+        conn.close();
+    }
+
+    public void testCanCloseCallableStatementTwice() throws Exception {
+        Connection conn = newConnection();
+        assertNotNull(conn);
+        assertTrue(!conn.isClosed());
+        for(int i=0;i<2;i++) { // loop to show we *can* close again once we've borrowed it from the pool again
+            PreparedStatement stmt = conn.prepareCall("select * from dual");
+            assertNotNull(stmt);
+            assertFalse(isClosed(stmt));
+            stmt.close();
+            assertTrue(isClosed(stmt));
+            stmt.close();
+            assertTrue(isClosed(stmt));
+            stmt.close();
+            assertTrue(isClosed(stmt));
+        }
+        conn.close();
+    }
+
+    public void testCanCloseResultSetTwice() throws Exception {
+        Connection conn = newConnection();
+        assertNotNull(conn);
+        assertTrue(!conn.isClosed());
+        for(int i=0;i<2;i++) { // loop to show we *can* close again once we've borrowed it from the pool again
+            PreparedStatement stmt = conn.prepareStatement("select * from dual");
+            assertNotNull(stmt);
+            ResultSet rset = stmt.executeQuery();
+            assertNotNull(rset);
+            assertFalse(isClosed(rset));
+            rset.close();
+            assertTrue(isClosed(rset));
+            rset.close();
+            assertTrue(isClosed(rset));
+            rset.close();
+            assertTrue(isClosed(rset));
+        }
+        conn.close();
+    }
+
+    public void testBackPointers() throws Exception {
+        // normal statement
+        Connection conn = newConnection();
+        assertBackPointers(conn, conn.createStatement());
+        conn = newConnection();
+        assertBackPointers(conn, conn.createStatement(0, 0));
+        conn = newConnection();
+        assertBackPointers(conn, conn.createStatement(0, 0, 0));
+
+        // prepared statement
+        conn = newConnection();
+        assertBackPointers(conn, conn.prepareStatement("select * from dual"));
+        conn = newConnection();
+        assertBackPointers(conn, conn.prepareStatement("select * from dual", 0));
+        conn = newConnection();
+        assertBackPointers(conn, conn.prepareStatement("select * from dual", 0, 0));
+        conn = newConnection();
+        assertBackPointers(conn, conn.prepareStatement("select * from dual", 0, 0, 0));
+        conn = newConnection();
+        assertBackPointers(conn, conn.prepareStatement("select * from dual", new int[0]));
+        conn = newConnection();
+        assertBackPointers(conn, conn.prepareStatement("select * from dual", new String[0]));
+
+        // callable statement
+        conn = newConnection();
+        assertBackPointers(conn, conn.prepareCall("select * from dual"));
+        conn = newConnection();
+        assertBackPointers(conn, conn.prepareCall("select * from dual", 0, 0));
+        conn = newConnection();
+        assertBackPointers(conn, conn.prepareCall("select * from dual", 0, 0, 0));
+    }
+
+    protected void assertBackPointers(Connection conn, Statement statement) throws SQLException {
+        assertFalse(conn.isClosed());
+        assertFalse(isClosed(statement));
+
+        assertSame("statement.getConnection() should return the exact same connection instance that was used to create the statement",
+                conn, statement.getConnection());
+
+        ResultSet resultSet = statement.getResultSet();
+        assertFalse(isClosed(resultSet));
+        assertSame("resultSet.getStatement() should return the exact same statement instance that was used to create the result set",
+                statement, resultSet.getStatement());
+
+        ResultSet executeResultSet = statement.executeQuery("select * from dual");
+        assertFalse(isClosed(executeResultSet));
+        assertSame("resultSet.getStatement() should return the exact same statement instance that was used to create the result set",
+                statement, executeResultSet.getStatement());
+
+        ResultSet keysResultSet = statement.getGeneratedKeys();
+        assertFalse(isClosed(keysResultSet));
+        assertSame("resultSet.getStatement() should return the exact same statement instance that was used to create the result set",
+                statement, keysResultSet.getStatement());
+
+        ResultSet preparedResultSet = null;
+        if (statement instanceof PreparedStatement) {
+            PreparedStatement preparedStatement = (PreparedStatement) statement;
+            preparedResultSet = preparedStatement.executeQuery();
+            assertFalse(isClosed(preparedResultSet));
+            assertSame("resultSet.getStatement() should return the exact same statement instance that was used to create the result set",
+                    statement, preparedResultSet.getStatement());
+        }
+
+
+        resultSet.getStatement().getConnection().close();
+        assertTrue(conn.isClosed());
+        assertTrue(isClosed(statement));
+        assertTrue(isClosed(resultSet));
+        assertTrue(isClosed(executeResultSet));
+        assertTrue(isClosed(keysResultSet));
+        if (preparedResultSet != null) {
+            assertTrue(isClosed(preparedResultSet));
+        }
+    }
+
+    public void testSimple() throws Exception {
+        Connection conn = newConnection();
+        assertNotNull(conn);
+        PreparedStatement stmt = conn.prepareStatement("select * from dual");
+        assertNotNull(stmt);
+        ResultSet rset = stmt.executeQuery();
+        assertNotNull(rset);
+        assertTrue(rset.next());
+        rset.close();
+        stmt.close();
+        conn.close();
+    }
+
+    public void testRepeatedBorrowAndReturn() throws Exception {
+        for(int i=0;i<100;i++) {
+            Connection conn = newConnection();
+            assertNotNull(conn);
+            PreparedStatement stmt = conn.prepareStatement("select * from dual");
+            assertNotNull(stmt);
+            ResultSet rset = stmt.executeQuery();
+            assertNotNull(rset);
+            assertTrue(rset.next());
+            rset.close();
+            stmt.close();
+            conn.close();
+        }
+    }
+
+    public void testSimple2() throws Exception {
+        Connection conn = newConnection();
+        assertNotNull(conn);
+        {
+            PreparedStatement stmt = conn.prepareStatement("select * from dual");
+            assertNotNull(stmt);
+            ResultSet rset = stmt.executeQuery();
+            assertNotNull(rset);
+            assertTrue(rset.next());
+            rset.close();
+            stmt.close();
+        }
+        {
+            PreparedStatement stmt = conn.prepareStatement("select * from dual");
+            assertNotNull(stmt);
+            ResultSet rset = stmt.executeQuery();
+            assertNotNull(rset);
+            assertTrue(rset.next());
+            rset.close();
+            stmt.close();
+        }
+        conn.close();
+        try {
+            conn.createStatement();
+            fail("Can't use closed connections");
+        } catch(SQLException e) {
+            // expected
+        }
+
+        conn = newConnection();
+        assertNotNull(conn);
+        {
+            PreparedStatement stmt = conn.prepareStatement("select * from dual");
+            assertNotNull(stmt);
+            ResultSet rset = stmt.executeQuery();
+            assertNotNull(rset);
+            assertTrue(rset.next());
+            rset.close();
+            stmt.close();
+        }
+        {
+            PreparedStatement stmt = conn.prepareStatement("select * from dual");
+            assertNotNull(stmt);
+            ResultSet rset = stmt.executeQuery();
+            assertNotNull(rset);
+            assertTrue(rset.next());
+            rset.close();
+            stmt.close();
+        }
+        conn.close();
+        conn = null;
+    }
+
+    public void testPooling() throws Exception {  
+        // Grab a maximal set of open connections from the pool
+        Connection[] c = new Connection[getMaxActive()];
+        Connection[] u = new Connection[getMaxActive()];
+        for (int i = 0; i < c.length; i++) {
+            c[i] = newConnection();
+            if (c[i] instanceof DelegatingConnection) {
+                u[i] = ((DelegatingConnection) c[i]).getInnermostDelegate();
+            } else {
+                for (int j = 0; j <= i; j++) {
+                    c[j].close();
+                }
+                return; // skip this test   
+            }
+        }        
+        // Close connections one at a time and get new ones, making sure
+        // the new ones come from the pool
+        for (int i = 0; i < c.length; i++) {
+            c[i].close();
+            Connection con = newConnection();
+            Connection underCon = 
+                ((DelegatingConnection) con).getInnermostDelegate();
+            assertTrue("Failed to get connection", underCon != null);
+            boolean found = false;
+            for (int j = 0; j < c.length; j++) {
+                if (underCon == u[j]) {
+                    found = true;
+                    break;
+                }
+            }
+            assertTrue("New connection not from pool", found);
+            con.close();
+        }
+    }
+    
+    public void testAutoCommitBehavior() throws Exception {
+        Connection conn = newConnection();
+        assertNotNull(conn);
+        assertTrue(conn.getAutoCommit());
+        conn.setAutoCommit(false);
+        conn.close();
+        
+        Connection conn2 = newConnection();
+        assertTrue( conn2.getAutoCommit() );
+        
+        Connection conn3 = newConnection();
+        assertTrue( conn3.getAutoCommit() );
+
+        conn2.close();
+        
+        conn3.close();
+    }
+    
+    /** @see "http://issues.apache.org/bugzilla/show_bug.cgi?id=12400" */
+    public void testConnectionsAreDistinct() throws Exception {
+        Connection[] conn = new Connection[getMaxActive()];
+        for(int i=0;i<conn.length;i++) {
+            conn[i] = newConnection();
+            for(int j=0;j<i;j++) {
+                assertTrue(conn[j] != conn[i]);
+                assertTrue(!conn[j].equals(conn[i]));
+            }
+        }
+        for(int i=0;i<conn.length;i++) {
+            conn[i].close();
+        }
+    }
+
+
+    public void testOpening() throws Exception {
+        Connection[] c = new Connection[getMaxActive()];
+        // test that opening new connections is not closing previous
+        for (int i = 0; i < c.length; i++) {
+            c[i] = newConnection();
+            assertTrue(c[i] != null);
+            for (int j = 0; j <= i; j++) {
+                assertTrue(!c[j].isClosed());
+            }
+        }
+
+        for (int i = 0; i < c.length; i++) {
+            c[i].close();
+        }
+    }
+
+    public void testClosing() throws Exception {
+        Connection[] c = new Connection[getMaxActive()];
+        // open the maximum connections
+        for (int i = 0; i < c.length; i++) {
+            c[i] = newConnection();
+        }
+
+        // close one of the connections
+        c[0].close();
+        assertTrue(c[0].isClosed());
+
+        // get a new connection
+        c[0] = newConnection();
+
+        for (int i = 0; i < c.length; i++) {
+            c[i].close();
+        }
+    }
+
+    public void testMaxActive() throws Exception {
+        Connection[] c = new Connection[getMaxActive()];
+        for (int i = 0; i < c.length; i++) {
+            c[i] = newConnection();
+            assertTrue(c[i] != null);
+        }
+
+        try {
+            newConnection();
+            fail("Allowed to open more than DefaultMaxActive connections.");
+        } catch (java.sql.SQLException e) {
+            // should only be able to open 10 connections, so this test should
+            // throw an exception
+        }
+
+        for (int i = 0; i < c.length; i++) {
+            c[i].close();
+        }
+    }
+    
+    /**
+     * DBCP-128: BasicDataSource.getConnection()
+     * Connections don't work as hashtable keys 
+     */
+    public void testHashing() throws Exception {
+        Connection con = getConnection();
+        Hashtable hash = new Hashtable();
+        hash.put(con, "test");
+        assertEquals("test", hash.get(con));
+        assertTrue(hash.containsKey(con));
+        assertTrue(hash.contains("test")); 
+        hash.clear();
+        con.close();
+    }
+
+    public void testThreaded() {
+        TestThread[] threads = new TestThread[getMaxActive()];
+        for(int i=0;i<threads.length;i++) {
+            threads[i] = new TestThread(50,50);
+            Thread t = new Thread(threads[i]);
+            t.start();
+        }
+        for(int i=0;i<threads.length;i++) {
+            while(!(threads[i]).complete()) {
+                try {
+                    Thread.sleep(100L);
+                } catch(Exception e) {
+                    // ignored
+                }
+            }
+            if(threads[i].failed()) {
+                fail("Thread failed: " + i);
+            }
+        }
+    }
+
+    class TestThread implements Runnable {
+        java.util.Random _random = new java.util.Random();
+        boolean _complete = false;
+        boolean _failed = false;
+        int _iter = 100;
+        int _delay = 50;
+
+        public TestThread() {
+        }
+
+        public TestThread(int iter) {
+            _iter = iter;
+        }
+
+        public TestThread(int iter, int delay) {
+            _iter = iter;
+            _delay = delay;
+        }
+
+        public boolean complete() {
+            return _complete;
+        }
+
+        public boolean failed() {
+            return _failed;
+        }
+
+        public void run() {
+            for(int i=0;i<_iter;i++) {
+                try {
+                    Thread.sleep(_random.nextInt(_delay));
+                } catch(Exception e) {
+                    // ignored
+                }
+                Connection conn = null;
+                PreparedStatement stmt = null;
+                ResultSet rset = null;
+                try {
+                    conn = newConnection();
+                    stmt = conn.prepareStatement("select 'literal', SYSDATE from dual");
+                    rset = stmt.executeQuery();
+                    try {
+                        Thread.sleep(_random.nextInt(_delay));
+                    } catch(Exception e) {
+                        // ignored
+                    }
+                } catch(Exception e) {
+                    e.printStackTrace();
+                    _failed = true;
+                    _complete = true;
+                    break;
+                } finally {
+                    try { if (rset != null) rset.close(); } catch(Exception e) { }
+                    try { if (stmt != null) stmt.close(); } catch(Exception e) { }
+                    try { if (conn != null) conn.close(); } catch(Exception e) { }
+                }
+            }
+            _complete = true;
+        }
+    }
+
+    // Bugzilla Bug 24328: PooledConnectionImpl ignores resultsetType 
+    // and Concurrency if statement pooling is not enabled
+    // http://issues.apache.org/bugzilla/show_bug.cgi?id=24328
+    public void testPrepareStatementOptions() throws Exception 
+    {
+        Connection conn = newConnection();
+        assertNotNull(conn);
+        PreparedStatement stmt = conn.prepareStatement("select * from dual", 
+            ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
+        assertNotNull(stmt);
+        ResultSet rset = stmt.executeQuery();
+        assertNotNull(rset);
+        assertTrue(rset.next());
+        
+        assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, rset.getType());
+        assertEquals(ResultSet.CONCUR_UPDATABLE, rset.getConcurrency());
+        
+        rset.close();
+        stmt.close();
+        conn.close();
+    }
+
+    // Bugzilla Bug 24966: NullPointer with Oracle 9 driver
+    // wrong order of passivate/close when a rset isn't closed
+    public void testNoRsetClose() throws Exception {
+        Connection conn = newConnection();
+        assertNotNull(conn);
+        PreparedStatement stmt = conn.prepareStatement("test");
+        assertNotNull(stmt);
+        ResultSet rset = stmt.getResultSet();
+        assertNotNull(rset);
+        // forget to close the resultset: rset.close();
+        stmt.close();
+        conn.close();
+    }
+    
+    // Bugzilla Bug 26966: Connectionpool's connections always returns same
+    public void testHashCode() throws Exception {
+        Connection conn1 = newConnection();
+        assertNotNull(conn1);
+        Connection conn2 = newConnection();
+        assertNotNull(conn2);
+
+        assertTrue(conn1.hashCode() != conn2.hashCode());
+    }
+
+    protected boolean isClosed(Statement statement) {
+        try {
+            statement.getWarnings();
+            return false;
+        } catch (SQLException e) {
+            // getWarnings throws an exception if the statement is
+            // closed, but could throw an exception for other reasons
+            // in this case it is good enought to assume the statement
+            // is closed
+            return true;
+        }
+    }
+
+    protected boolean isClosed(ResultSet resultSet) {
+        try {
+            resultSet.getWarnings();
+            return false;
+        } catch (SQLException e) {
+            // getWarnings throws an exception if the statement is
+            // closed, but could throw an exception for other reasons
+            // in this case it is good enought to assume the result set
+            // is closed
+            return true;
+        }
+    }
+
+    private static final boolean DISPLAY_THREAD_DETAILS=
+        Boolean.valueOf(System.getProperty("TestConnectionPool.display.thread.details", "false")).booleanValue();
+    // To pass this to a Maven test, use:
+    // mvn test -DargLine="-DTestConnectionPool.display.thread.details=true"
+    // @see http://jira.codehaus.org/browse/SUREFIRE-121
+    
+    /**
+     * Launches a group of 2 * getMaxActive() threads, each of which will attempt to obtain a connection
+     * from the pool, hold it for <holdTime> ms, and then return it to the pool.  If <loopOnce> is false,
+     * threads will continue this process indefinitely.  If <expectError> is true, exactly 1/2 of the
+     * threads are expected to either throw exceptions or fail to complete. If <expectError> is false,
+     * all threads are expected to complete successfully.
+     * 
+     * @param holdTime time in ms that a thread holds a connection before returning it to the pool
+     * @param expectError whether or not an error is expected
+     * @param loopOnce whether threads should complete the borrow - hold - return cycle only once, or loop indefinitely
+     * @param maxWait passed in by client - has no impact on the test itself, but does get reported
+     * 
+     * @throws Exception
+     */
+    protected void multipleThreads(final int holdTime, final boolean expectError, final boolean loopOnce, final long maxWait)
+            throws Exception {
+                long startTime = timeStamp();
+                final PoolTest[] pts = new PoolTest[2 * getMaxActive()];
+                // Catch Exception so we can stop all threads if one fails
+                ThreadGroup threadGroup = new ThreadGroup("foo") {
+                    public void uncaughtException(Thread t, Throwable e) {
+                        for (int i = 0; i < pts.length; i++) {
+                            pts[i].stop();
+                        }
+                    }
+                };
+                // Create all the threads
+                for (int i = 0; i < pts.length; i++) {
+                    pts[i] = new PoolTest(threadGroup, holdTime, expectError, loopOnce);    
+                }
+                // Start all the threads
+                for (int i = 0; i < pts.length; i++) {
+                    pts[i].start();    
+                }
+
+                // Give all threads a chance to start and succeed
+                Thread.sleep(300L);
+
+                // Stop threads
+                for (int i = 0; i < pts.length; i++) {
+                    pts[i].stop();
+                }   
+                
+                /*
+                 * Wait for all threads to terminate.
+                 * This is essential to ensure that all threads have a chance to update success[0]
+                 * and to ensure that the variable is published correctly.
+                 */
+                int done=0;
+                int failed=0;
+                int didNotRun = 0;
+                int loops=0;
+                for (int i = 0; i < pts.length; i++) {
+                    final PoolTest poolTest = pts[i];
+                    poolTest.thread.join();
+                    loops += poolTest.loops;
+                    final String state = poolTest.state;
+                    if (DONE.equals(state)){
+                        done++;
+                    }
+                    if (poolTest.loops == 0){
+                        didNotRun++;
+                    }
+                    final Throwable thrown = poolTest.thrown;
+                    if (thrown != null) {
+                        failed++;
+                        if (!expectError || !(thrown instanceof SQLException)){
+                            System.out.println("Unexpected error: "+thrown.getMessage());
+                        }
+                    }
+                }
+            
+                long time = timeStamp() - startTime;
+                System.out.println("Multithread test time = " + time
+                        + " ms. Threads: " + pts.length
+                        + ". Loops: " + loops
+                        + ". Hold time: " + holdTime
+                        + ". Maxwait: " + maxWait
+                        + ". Done: " + done
+                        + ". Did not run: " + didNotRun
+                        + ". Failed: " + failed
+                        + ". expectError: " + expectError
+                        );
+                if (expectError) {
+                    if (DISPLAY_THREAD_DETAILS || (pts.length/2 != failed)){
+                        long offset = pts[0].created - 1000; // To reduce size of output numbers, but ensure they have 4 digits
+                        System.out.println("Offset: "+offset);
+                        for (int i = 0; i < pts.length; i++) {
+                            PoolTest pt = pts[i];
+                            System.out.println(
+                                    "Pre: " + (pt.preconnected-offset) // First, so can sort on this easily
+                                    + ". Post: " + (pt.postconnected != 0 ? Long.toString(pt.postconnected-offset): "-")
+                                    + ". Hash: " + pt.connHash
+                                    + ". Startup: " + (pt.started-pt.created)
+                                    + ". getConn(): " + (pt.connected != 0 ? Long.toString(pt.connected-pt.preconnected) : "-")
+                                    + ". Runtime: " + (pt.ended-pt.started)
+                                    + ". IDX: " + i
+                                    + ". Loops: " + pt.loops
+                                    + ". State: " + pt.state
+                                    + ". thrown: "+ pt.thrown
+                                    + "."
+                                    );
+                        }                        
+                    }
+                    if (didNotRun > 0){
+                        System.out.println("NOTE: some threads did not run the code: "+didNotRun);
+                    }
+                    // Perform initial sanity check:
+                    assertTrue("Expected some of the threads to fail",failed > 0);
+                    // Assume that threads that did not run would have timed out.
+                    assertEquals("WARNING: Expected half the threads to fail",pts.length/2,failed+didNotRun);
+                } else {
+                    assertEquals("Did not expect any threads to fail",0,failed);
+                }
+            }
+    private static int currentThreadCount = 0;
+
+    private static final String DONE = "Done";
+
+    protected class PoolTest implements Runnable {
+        /**
+         * The number of milliseconds to hold onto a database connection
+         */
+        private final int connHoldTime;
+
+        private volatile boolean isRun;
+
+        private String state; // No need to be volatile if it is read after the thread finishes
+
+        private final Thread thread;
+
+        private Throwable thrown;
+
+        // Debug for DBCP-318
+        private final long created; // When object was created
+        private long started; // when thread started
+        private long ended; // when thread ended
+        private long preconnected; // just before connect
+        private long connected; // when thread last connected
+        private long postconnected; // when thread released connection
+        private int loops = 0;
+        private int connHash = 0; // Connection identity hashCode (to see which one is reused)
+
+        private final boolean stopOnException; // If true, don't rethrow Exception
+        
+        private final boolean loopOnce; // If true, don't repeat loop
+
+        public PoolTest(ThreadGroup threadGroup, int connHoldTime, boolean isStopOnException) {
+            this(threadGroup, connHoldTime, isStopOnException, false);
+        }
+
+        private PoolTest(ThreadGroup threadGroup, int connHoldTime, boolean isStopOnException, boolean once) {
+            this.loopOnce = once;
+            this.connHoldTime = connHoldTime;
+            stopOnException = isStopOnException;
+            isRun = true; // Must be done here so main thread is guaranteed to be able to set it false
+            thrown = null;
+            thread =
+                new Thread(threadGroup, this, "Thread+" + currentThreadCount++);
+            thread.setDaemon(false);
+            created = timeStamp();
+        }
+
+        public void start(){
+            thread.start();
+        }
+
+        public void run() {
+            started = timeStamp();
+            try {
+                while (isRun) {
+                    loops++;
+                    state = "Getting Connection";
+                    preconnected = timeStamp();
+                    Connection conn = getConnection();
+                    connHash = System.identityHashCode(((DelegatingConnection)conn).getInnermostDelegate());
+                    connected = timeStamp();
+                    state = "Using Connection";
+                    assertNotNull(conn);
+                    PreparedStatement stmt =
+                        conn.prepareStatement("select * from dual");
+                    assertNotNull(stmt);
+                    ResultSet rset = stmt.executeQuery();
+                    assertNotNull(rset);
+                    assertTrue(rset.next());
+                    state = "Holding Connection";
+                    Thread.sleep(connHoldTime);
+                    state = "Closing ResultSet";
+                    rset.close();
+                    state = "Closing Statement";
+                    stmt.close();
+                    state = "Closing Connection";
+                    conn.close();
+                    postconnected = timeStamp();
+                    state = "Closed";
+                    if (loopOnce){
+                        break; // Or could set isRun=false
+                    }
+                }
+                state = DONE;
+            } catch (Throwable t) {
+                thrown = t;
+                if (!stopOnException) {
+                    throw new RuntimeException();
+                }
+            } finally {
+                ended = timeStamp();                
+            }
+        }
+
+        public void stop() {
+            isRun = false;
+        }
+
+        public Thread getThread() {
+            return thread;
+        }
+    }
+
+    long timeStamp() {
+        return System.currentTimeMillis();// JVM 1.5+ System.nanoTime() / 1000000; 
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 04/15: Add TesterDatabaseMetaData from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 6b81f37775f4f9954f7228d7472008c9e524af1e
Author: Phil Steitz <ph...@gmail.com>
AuthorDate: Sat Oct 19 14:14:31 2019 -0700

    Add TesterDatabaseMetaData from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
---
 .../tomcat/dbcp/dbcp/TesterDatabaseMetaData.java   | 777 +++++++++++++++++++++
 1 file changed, 777 insertions(+)

diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterDatabaseMetaData.java b/test/org/apache/tomcat/dbcp/dbcp/TesterDatabaseMetaData.java
new file mode 100644
index 0000000..95dae0c
--- /dev/null
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterDatabaseMetaData.java
@@ -0,0 +1,777 @@
+/**
+ *
+ * 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> T unwrap(Class<T> 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 */
+
+    /* JDBC_4_1_ANT_KEY_BEGIN */
+    @Override
+    public ResultSet getPseudoColumns(String catalog, String schemaPattern,
+            String tableNamePattern, String columnNamePattern)
+            throws SQLException {
+        return null;
+    }
+
+    @Override
+    public boolean generatedKeyAlwaysReturned() throws SQLException {
+        return false;
+    }
+    /* JDBC_4_1_ANT_KEY_END */
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 09/15: Add TesterClassLoader from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit f406df20d22c62244cc2df9633693f5622d381a5
Author: Phil Steitz <ph...@gmail.com>
AuthorDate: Sat Oct 19 14:46:09 2019 -0700

    Add TesterClassLoader from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
---
 .../apache/tomcat/dbcp/dbcp/TesterClassLoader.java | 40 ++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterClassLoader.java b/test/org/apache/tomcat/dbcp/dbcp/TesterClassLoader.java
new file mode 100644
index 0000000..166041c
--- /dev/null
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterClassLoader.java
@@ -0,0 +1,40 @@
+/*
+ * 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.util.HashSet;
+import java.util.Set;
+
+/**
+ * Simple class loader that just records the classes it was asked to load.
+ */
+public class TesterClassLoader extends ClassLoader {
+
+    private Set<String> loadedClasses = new HashSet<String>();
+    
+    @Override
+    protected synchronized Class<?> loadClass(String name, boolean resolve)
+            throws ClassNotFoundException {
+        Class<?> clazz =  super.loadClass(name, resolve);
+        loadedClasses.add(name);
+        return clazz;
+    }
+
+    public boolean didLoad(String className) {
+        return loadedClasses.contains(className);
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 14/15: Rename abstract test class so runner does not try to execute test cases in it.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 89ca499adbc34e02183906520540a2171a07eef5
Author: Phil Steitz <ph...@gmail.com>
AuthorDate: Sun Oct 20 15:39:08 2019 -0700

    Rename abstract test class so runner does not try to execute test cases in it.
---
 .../dbcp/{TestConnectionPool.java => AbstractConnectionPoolTest.java} | 4 ++--
 test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java             | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/org/apache/tomcat/dbcp/dbcp/TestConnectionPool.java b/test/org/apache/tomcat/dbcp/dbcp/AbstractConnectionPoolTest.java
similarity index 99%
rename from test/org/apache/tomcat/dbcp/dbcp/TestConnectionPool.java
rename to test/org/apache/tomcat/dbcp/dbcp/AbstractConnectionPoolTest.java
index f0ea905..758f4e5 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TestConnectionPool.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/AbstractConnectionPoolTest.java
@@ -42,8 +42,8 @@ import junit.framework.TestCase;
  * @author Dirk Verbeeck
  * @version $Revision$ $Date$
  */
-public abstract class TestConnectionPool extends TestCase {
-    public TestConnectionPool(String testName) {
+public abstract class AbstractConnectionPoolTest extends TestCase {
+    public AbstractConnectionPoolTest(String testName) {
         super(testName);
     }
 
diff --git a/test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java b/test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java
index 4ea483f..79e5d76 100644
--- a/test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java
+++ b/test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java
@@ -34,7 +34,7 @@ import junit.framework.TestSuite;
  * @author Dirk Verbeeck
  * @version $Revision$ $Date$
  */
-public class TestBasicDataSource extends TestConnectionPool {
+public class TestBasicDataSource extends AbstractConnectionPoolTest {
     public TestBasicDataSource(String testName) {
         super(testName);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 15/15: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63833

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 8191a6aa8f3600cb48db064e23d89b7d9623ccc0
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Oct 25 12:36:44 2019 +0200

    Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63833
    
    Avoid potential NPE. Patch by Guoxiong Li.
---
 java/org/apache/tomcat/dbcp/dbcp/PoolableConnectionFactory.java | 4 +++-
 webapps/docs/changelog.xml                                      | 6 ++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/dbcp/dbcp/PoolableConnectionFactory.java b/java/org/apache/tomcat/dbcp/dbcp/PoolableConnectionFactory.java
index b04fa6f..af71261 100644
--- a/java/org/apache/tomcat/dbcp/dbcp/PoolableConnectionFactory.java
+++ b/java/org/apache/tomcat/dbcp/dbcp/PoolableConnectionFactory.java
@@ -640,7 +640,9 @@ public class PoolableConnectionFactory implements PoolableObjectFactory<Poolable
 
     @Override
     public void destroyObject(PoolableConnection obj) throws Exception {
-        obj.reallyClose();
+        if (obj != null) {
+            obj.reallyClose();
+        }
     }
 
     @Override
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 16c7cb4..a1cf0a4 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -115,6 +115,12 @@
         Windows since compiled versions of those components are already
         included within the zip distriubutions. (markt)
       </fix>
+      <fix>
+        <bug>63833</bug>: Fix an error in the generification of the copied
+        Commons DBCP 1.x code that caused a <code>NullPointerException</code> if
+        a DataSource was configured with a database that did not exist. Patch
+        provided by Guoxiong Li. (markt)
+      </fix>
     </changelog>
   </subsection>
 </section>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 01/15: Add TestBasicDataSource from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 8ba4f4603bbf523aa912a28287f7de8e5efc843d
Author: Phil Steitz <ph...@gmail.com>
AuthorDate: Sat Oct 19 13:41:48 2019 -0700

    Add TestBasicDataSource from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
---
 .../tomcat/dbcp/dbcp/TestBasicDataSource.java      | 592 +++++++++++++++++++++
 1 file changed, 592 insertions(+)

diff --git a/test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java b/test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java
new file mode 100644
index 0000000..c98e4bd
--- /dev/null
+++ b/test/org/apache/tomcat/dbcp/dbcp/TestBasicDataSource.java
@@ -0,0 +1,592 @@
+/*
+ * 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.io.IOException;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Properties;
+
+import javax.sql.DataSource;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * TestSuite for BasicDataSource
+ * 
+ * @author Dirk Verbeeck
+ * @version $Revision$ $Date$
+ */
+public class TestBasicDataSource extends TestConnectionPool {
+    public TestBasicDataSource(String testName) {
+        super(testName);
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestBasicDataSource.class);
+    }
+
+    protected Connection getConnection() throws Exception {
+        return ds.getConnection();
+    }
+
+    protected BasicDataSource ds = null;
+    private static final String CATALOG = "test catalog";
+
+    public void setUp() throws Exception {
+        super.setUp();
+        ds = createDataSource();
+        ds.setDriverClassName("org.apache.commons.dbcp.TesterDriver");
+        ds.setUrl("jdbc:apache:commons:testdriver");
+        ds.setMaxActive(getMaxActive());
+        ds.setMaxWait(getMaxWait());
+        ds.setDefaultAutoCommit(true);
+        ds.setDefaultReadOnly(false);
+        ds.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
+        ds.setDefaultCatalog(CATALOG);
+        ds.setUsername("username");
+        ds.setPassword("password");
+        ds.setValidationQuery("SELECT DUMMY FROM DUAL");
+        ds.setConnectionInitSqls(Arrays.asList(new String[] { "SELECT 1", "SELECT 2"}));
+        ds.setDriverClassLoader(new TesterClassLoader());
+    }
+
+    protected BasicDataSource createDataSource() throws Exception {
+        return new BasicDataSource();
+    }
+
+    public void tearDown() throws Exception {
+        super.tearDown();
+        ds.close();
+        ds = null;
+    }
+
+    public void testClose() throws Exception {
+        ds.setAccessToUnderlyingConnectionAllowed(true);
+
+        // active connection is held open when ds is closed
+        Connection activeConnection = getConnection();
+        Connection rawActiveConnection = ((DelegatingConnection) activeConnection).getInnermostDelegate();
+        assertFalse(activeConnection.isClosed());
+        assertFalse(rawActiveConnection.isClosed());
+
+        // idle connection is in pool but closed
+        Connection idleConnection = getConnection();
+        Connection rawIdleConnection = ((DelegatingConnection) idleConnection).getInnermostDelegate();
+        assertFalse(idleConnection.isClosed());
+        assertFalse(rawIdleConnection.isClosed());
+
+        // idle wrapper should be closed but raw connection should be open
+        idleConnection.close();
+        assertTrue(idleConnection.isClosed());
+        assertFalse(rawIdleConnection.isClosed());
+
+        ds.close();
+
+        // raw idle connection should now be closed
+        assertTrue(rawIdleConnection.isClosed());
+
+        // active connection should still be open
+        assertFalse(activeConnection.isClosed());
+        assertFalse(rawActiveConnection.isClosed());
+
+        // now close the active connection
+        activeConnection.close();
+
+        // both wrapper and raw active connection should be closed
+        assertTrue(activeConnection.isClosed());
+        assertTrue(rawActiveConnection.isClosed());
+        
+        // Verify SQLException on getConnection after close
+        try {
+            getConnection();
+            fail("Expecting SQLException");
+        } catch (SQLException ex) {
+            // Expected
+        }
+        
+        // Redundant close is OK
+        ds.close();
+        
+    }
+
+    public void testSetProperties() throws Exception {
+        // normal
+        ds.setConnectionProperties("name1=value1;name2=value2;name3=value3");
+        assertEquals(3, ds.connectionProperties.size());
+        assertEquals("value1", ds.connectionProperties.getProperty("name1"));
+        assertEquals("value2", ds.connectionProperties.getProperty("name2"));
+        assertEquals("value3", ds.connectionProperties.getProperty("name3"));
+
+        // make sure all properties are replaced
+        ds.setConnectionProperties("name1=value1;name2=value2");
+        assertEquals(2, ds.connectionProperties.size());
+        assertEquals("value1", ds.connectionProperties.getProperty("name1"));
+        assertEquals("value2", ds.connectionProperties.getProperty("name2"));
+        assertFalse(ds.connectionProperties.containsKey("name3"));
+
+        // no value is empty string
+        ds.setConnectionProperties("name1=value1;name2");
+        assertEquals(2, ds.connectionProperties.size());
+        assertEquals("value1", ds.connectionProperties.getProperty("name1"));
+        assertEquals("", ds.connectionProperties.getProperty("name2"));
+
+        // no value (with equals) is empty string
+        ds.setConnectionProperties("name1=value1;name2=");
+        assertEquals(2, ds.connectionProperties.size());
+        assertEquals("value1", ds.connectionProperties.getProperty("name1"));
+        assertEquals("", ds.connectionProperties.getProperty("name2"));
+
+        // single value
+        ds.setConnectionProperties("name1=value1");
+        assertEquals(1, ds.connectionProperties.size());
+        assertEquals("value1", ds.connectionProperties.getProperty("name1"));
+
+        // single value with trailing ;
+        ds.setConnectionProperties("name1=value1;");
+        assertEquals(1, ds.connectionProperties.size());
+        assertEquals("value1", ds.connectionProperties.getProperty("name1"));
+
+        // single value wit no value
+        ds.setConnectionProperties("name1");
+        assertEquals(1, ds.connectionProperties.size());
+        assertEquals("", ds.connectionProperties.getProperty("name1"));
+
+        // null should throw a NullPointerException
+        try {
+            ds.setConnectionProperties(null);
+            fail("Expected NullPointerException");
+        } catch (NullPointerException e) {
+            // expected
+        }
+    }
+    
+    public void testTransactionIsolationBehavior() throws Exception {
+        Connection conn = getConnection();
+        assertNotNull(conn);
+        assertEquals(Connection.TRANSACTION_READ_COMMITTED, conn.getTransactionIsolation());
+        conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
+        conn.close();
+        
+        Connection conn2 = getConnection();
+        assertEquals(Connection.TRANSACTION_READ_COMMITTED, conn2.getTransactionIsolation());
+        
+        Connection conn3 = getConnection();
+        assertEquals(Connection.TRANSACTION_READ_COMMITTED, conn3.getTransactionIsolation());
+
+        conn2.close();
+        
+        conn3.close();
+    }
+
+    public void testPooling() throws Exception {
+        // this also needs access to the underlying connection
+        ds.setAccessToUnderlyingConnectionAllowed(true);
+        super.testPooling();
+    }    
+    
+    public void testNoAccessToUnderlyingConnectionAllowed() throws Exception {
+        // default: false
+        assertEquals(false, ds.isAccessToUnderlyingConnectionAllowed());
+        
+        Connection conn = getConnection();
+        Connection dconn = ((DelegatingConnection) conn).getDelegate();
+        assertNull(dconn);
+        
+        dconn = ((DelegatingConnection) conn).getInnermostDelegate();
+        assertNull(dconn);
+    }
+
+    public void testAccessToUnderlyingConnectionAllowed() throws Exception {
+        ds.setAccessToUnderlyingConnectionAllowed(true);
+        assertEquals(true, ds.isAccessToUnderlyingConnectionAllowed());
+        
+        Connection conn = getConnection();
+        Connection dconn = ((DelegatingConnection) conn).getDelegate();
+        assertNotNull(dconn);
+        
+        dconn = ((DelegatingConnection) conn).getInnermostDelegate();
+        assertNotNull(dconn);
+        
+        assertTrue(dconn instanceof TesterConnection);
+    }
+    
+    public void testEmptyValidationQuery() throws Exception {
+        assertNotNull(ds.getValidationQuery());
+        
+        ds.setValidationQuery("");
+        assertNull(ds.getValidationQuery());
+
+        ds.setValidationQuery("   ");
+        assertNull(ds.getValidationQuery());
+    }
+
+    public void testInvalidValidationQuery() {
+        try {
+            ds.setValidationQuery("invalid");
+            ds.getConnection();
+            fail("expected SQLException");
+        }
+        catch (SQLException e) {
+            if (e.toString().indexOf("invalid") < 0) {
+                fail("expected detailed error message");
+            }
+        }
+    }
+    
+    public void testValidationQueryTimoutFail() {
+        ds.setTestOnBorrow(true);
+        ds.setValidationQueryTimeout(3); // Too fast for TesterStatement
+        try {
+            ds.getConnection();
+            fail("expected SQLException");
+        } catch (SQLException ex) {
+            if (ex.toString().indexOf("timeout") < 0) {
+                fail("expected timeout error message");
+            }
+        }
+    }
+    
+    public void testValidationQueryTimeoutZero() throws Exception {
+        ds.setTestOnBorrow(true);
+        ds.setTestOnReturn(true);
+        ds.setValidationQueryTimeout(0);
+        Connection con = ds.getConnection();
+        con.close();
+    }
+    
+    public void testValidationQueryTimeoutNegative() throws Exception {
+        ds.setTestOnBorrow(true);
+        ds.setTestOnReturn(true);
+        ds.setValidationQueryTimeout(-1);
+        Connection con = ds.getConnection();
+        con.close();
+    }
+    
+    public void testValidationQueryTimeoutSucceed() throws Exception {
+        ds.setTestOnBorrow(true);
+        ds.setTestOnReturn(true);
+        ds.setValidationQueryTimeout(100); // Works for TesterStatement
+        Connection con = ds.getConnection();
+        con.close();
+    }
+
+    public void testEmptyInitConnectionSql() throws Exception {
+        ds.setConnectionInitSqls(Arrays.asList(new String[]{"", "   "}));
+        assertNotNull(ds.getConnectionInitSqls());
+        assertEquals(0, ds.getConnectionInitSqls().size());
+
+        ds.setConnectionInitSqls(null);
+        assertNotNull(ds.getConnectionInitSqls());
+        assertEquals(0, ds.getConnectionInitSqls().size());
+    }
+
+    public void testInvalidConnectionInitSql() {
+        try {
+            ds.setConnectionInitSqls(Arrays.asList(new String[]{"SELECT 1","invalid"}));
+            ds.getConnection();
+            fail("expected SQLException");
+        }
+        catch (SQLException e) {
+            if (e.toString().indexOf("invalid") < 0) {
+                fail("expected detailed error message");
+            }
+        }
+    }
+
+    public void testSetValidationTestProperties() {
+        // defaults
+        assertEquals(true, ds.getTestOnBorrow());
+        assertEquals(false, ds.getTestOnReturn());
+        assertEquals(false, ds.getTestWhileIdle());
+
+        ds.setTestOnBorrow(true);
+        ds.setTestOnReturn(true);
+        ds.setTestWhileIdle(true);
+        assertEquals(true, ds.getTestOnBorrow());
+        assertEquals(true, ds.getTestOnReturn());
+        assertEquals(true, ds.getTestWhileIdle());
+
+        ds.setTestOnBorrow(false);
+        ds.setTestOnReturn(false);
+        ds.setTestWhileIdle(false);
+        assertEquals(false, ds.getTestOnBorrow());
+        assertEquals(false, ds.getTestOnReturn());
+        assertEquals(false, ds.getTestWhileIdle());
+    }
+
+    public void testNoValidationQuery() throws Exception {
+        ds.setTestOnBorrow(true);
+        ds.setTestOnReturn(true);
+        ds.setTestWhileIdle(true);
+        ds.setValidationQuery("");
+        
+        Connection conn = ds.getConnection();
+        conn.close();
+
+        assertEquals(false, ds.getTestOnBorrow());
+        assertEquals(false, ds.getTestOnReturn());
+        assertEquals(false, ds.getTestWhileIdle());
+    }
+    
+    public void testDefaultCatalog() throws Exception {
+        Connection[] c = new Connection[getMaxActive()];
+        for (int i = 0; i < c.length; i++) {
+            c[i] = getConnection();
+            assertTrue(c[i] != null);
+            assertEquals(CATALOG, c[i].getCatalog()); 
+        }
+
+        for (int i = 0; i < c.length; i++) {
+            c[i].setCatalog("error");
+            c[i].close();
+        }
+        
+        for (int i = 0; i < c.length; i++) {
+            c[i] = getConnection();
+            assertTrue(c[i] != null);
+            assertEquals(CATALOG, c[i].getCatalog()); 
+        }        
+
+        for (int i = 0; i < c.length; i++) {
+            c[i].close();
+        }
+    }
+    
+    public void testSetAutoCommitTrueOnClose() throws Exception {
+        ds.setAccessToUnderlyingConnectionAllowed(true);
+        ds.setDefaultAutoCommit(false);
+        
+        Connection conn = getConnection();
+        assertNotNull(conn);
+        assertEquals(false, conn.getAutoCommit());
+
+        Connection dconn = ((DelegatingConnection) conn).getInnermostDelegate();
+        assertNotNull(dconn);
+        assertEquals(false, dconn.getAutoCommit());
+
+        conn.close();
+
+        assertEquals(true, dconn.getAutoCommit());
+    }
+
+    public void testInitialSize() throws Exception {
+        ds.setMaxActive(20);
+        ds.setMaxIdle(20);
+        ds.setInitialSize(10);
+
+        Connection conn = getConnection();
+        assertNotNull(conn);
+        conn.close();
+
+        assertEquals(0, ds.getNumActive());
+        assertEquals(10, ds.getNumIdle());
+    }
+
+    // Bugzilla Bug 28251:  Returning dead database connections to BasicDataSource
+    // isClosed() failure blocks returning a connection to the pool 
+    public void testIsClosedFailure() throws SQLException {
+        ds.setAccessToUnderlyingConnectionAllowed(true);
+        Connection conn = ds.getConnection();
+        assertNotNull(conn);
+        assertEquals(1, ds.getNumActive());
+        
+        // set an IO failure causing the isClosed mathod to fail
+        TesterConnection tconn = (TesterConnection) ((DelegatingConnection)conn).getInnermostDelegate();
+        tconn.setFailure(new IOException("network error"));
+        
+        try {
+            conn.close();
+            fail("Expected SQLException");
+        }
+        catch(SQLException ex) { }
+
+        assertEquals(0, ds.getNumActive());
+    }
+    
+    /** 
+     * Bugzilla Bug 29054: 
+     * The BasicDataSource.setTestOnReturn(boolean) is not carried through to 
+     * the GenericObjectPool variable _testOnReturn.
+     */ 
+    public void testPropertyTestOnReturn() throws Exception {
+        ds.setValidationQuery("select 1 from dual");
+        ds.setTestOnBorrow(false);
+        ds.setTestWhileIdle(false);
+        ds.setTestOnReturn(true);
+        
+        Connection conn = ds.getConnection();
+        assertNotNull(conn);
+        
+        assertEquals(false, ds.connectionPool.getTestOnBorrow());
+        assertEquals(false, ds.connectionPool.getTestWhileIdle());
+        assertEquals(true, ds.connectionPool.getTestOnReturn());
+    }
+    
+    /**
+     * Bugzilla Bug 29055: AutoCommit and ReadOnly
+     * The DaffodilDB driver throws an SQLException if 
+     * trying to commit or rollback a readOnly connection. 
+     */
+    public void testRollbackReadOnly() throws Exception {
+        ds.setDefaultReadOnly(true);
+        ds.setDefaultAutoCommit(false);
+        
+        Connection conn = ds.getConnection();
+        assertNotNull(conn);
+        conn.close();
+    }
+    
+    /**
+     * Bugzilla Bug 29832: Broken behaviour for BasicDataSource.setMaxActive(0)
+     * MaxActive == 0 should throw SQLException on getConnection.
+     * Results from Bug 29863 in commons-pool.
+     */
+    public void testMaxActiveZero() throws Exception {
+        ds.setMaxActive(0);
+        
+        try {
+            Connection conn = ds.getConnection();
+            assertNotNull(conn);
+            fail("SQLException expected");
+            
+        } catch (SQLException e) {
+            // test OK
+        }
+    }
+    /**
+     * JIRA DBCP-93: If an SQLException occurs after the GenericObjectPool is
+     * initialized in createDataSource, the evictor task is not cleaned up.
+     */
+    public void testCreateDataSourceCleanupThreads() throws Exception {
+        ds.close();
+        ds = null;
+        ds = createDataSource();
+        ds.setDriverClassName("org.apache.commons.dbcp.TesterDriver");
+        ds.setUrl("jdbc:apache:commons:testdriver");
+        ds.setMaxActive(getMaxActive());
+        ds.setMaxWait(getMaxWait());
+        ds.setDefaultAutoCommit(true);
+        ds.setDefaultReadOnly(false);
+        ds.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
+        ds.setDefaultCatalog(CATALOG);
+        ds.setUsername("username");
+        // Set timeBetweenEvictionRuns > 0, so evictor is created
+        ds.setTimeBetweenEvictionRunsMillis(100);
+        // Make password incorrect, so createDataSource will throw
+        ds.setPassword("wrong");
+        ds.setValidationQuery("SELECT DUMMY FROM DUAL");
+        int threadCount = Thread.activeCount();
+        for (int i = 0; i < 10; i++) {
+            try {
+                ds.getConnection();
+            } catch (SQLException ex) {
+                // ignore
+            }
+        }
+        // Allow one extra thread for JRockit compatibility
+        assertTrue(Thread.activeCount() <= threadCount + 1);
+    }
+    
+    /**
+     * JIRA DBCP-333: Check that a custom class loader is used.
+     * @throws Exception 
+     */
+    public void testDriverClassLoader() throws Exception {
+        getConnection();
+        ClassLoader cl = ds.getDriverClassLoader();
+        assertNotNull(cl);
+        assertTrue(cl instanceof TesterClassLoader);
+        assertTrue(((TesterClassLoader) cl).didLoad(ds.getDriverClassName()));
+    }
+    
+    /**
+     * JIRA: DBCP-342, DBCP-93
+     * Verify that when errors occur during BasicDataSource initialization, GenericObjectPool
+     * Evictors are cleaned up.
+     */
+    public void testCreateDataSourceCleanupEvictor() throws Exception {
+        ds.close();
+        ds = null;
+        ds = createDataSource();
+        ds.setDriverClassName("org.apache.commons.dbcp.TesterConnRequestCountDriver");
+        ds.setUrl("jdbc:apache:commons:testerConnRequestCountDriver");
+        ds.setValidationQuery("SELECT DUMMY FROM DUAL");
+        ds.setUsername("username");
+
+        // Make password incorrect, so createDataSource will throw
+        ds.setPassword("wrong");
+        // Set timeBetweenEvictionRuns > 0, so evictor will be created
+        ds.setTimeBetweenEvictionRunsMillis(100);
+        // Set min idle > 0, so evictor will try to make connection as many as idle count
+        ds.setMinIdle(2);
+
+        // Prevent concurrent execution of threads executing test subclasses 
+        synchronized (TesterConnRequestCountDriver.class) {
+    	    TesterConnRequestCountDriver.initConnRequestCount();
+
+    	    // user request 10 times
+    	    for (int i=0; i<10; i++) {
+    	        try {
+    	            @SuppressWarnings("unused")
+    	            DataSource ds2 = ds.createDataSource();
+    	        } catch (SQLException e) {
+    	            // Ignore
+    	        }
+    	    }
+ 
+    	    // sleep 1000ms. evictor will be invoked 10 times if running.
+    	    Thread.sleep(1000);
+
+    	    // Make sure there have been no Evictor-generated requests (count should be 10, from requests above)
+    	    assertEquals(10, TesterConnRequestCountDriver.getConnectionRequestCount());
+        }
+    	
+        // make sure cleanup is complete
+        assertNull(ds.connectionPool);
+    }
+}
+
+/**
+ * TesterDriver that keeps a static count of connection requests.
+ */
+class TesterConnRequestCountDriver extends TesterDriver {
+    protected static final String CONNECT_STRING = "jdbc:apache:commons:testerConnRequestCountDriver";
+    private static int connectionRequestCount = 0;
+
+	@Override
+    public Connection connect(String url, Properties info) throws SQLException {
+        connectionRequestCount++;
+        return super.connect(url, info);
+    }
+
+    @Override
+    public boolean acceptsURL(String url) throws SQLException {
+        return CONNECT_STRING.startsWith(url);
+    }
+
+	public static int getConnectionRequestCount() {
+	    return connectionRequestCount;
+	}
+
+    public static void initConnRequestCount() {
+	    connectionRequestCount = 0;
+    }
+};


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 02/15: Add TesterDriver from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit addbdbee01ea7b68912ca1d5a4a9126c066df649
Author: Phil Steitz <ph...@gmail.com>
AuthorDate: Sat Oct 19 13:52:22 2019 -0700

    Add TesterDriver from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
---
 test/org/apache/tomcat/dbcp/dbcp/TesterDriver.java | 134 +++++++++++++++++++++
 1 file changed, 134 insertions(+)

diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterDriver.java b/test/org/apache/tomcat/dbcp/dbcp/TesterDriver.java
new file mode 100644
index 0000000..26eff85
--- /dev/null
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterDriver.java
@@ -0,0 +1,134 @@
+/*
+ * 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.sql.SQLFeatureNotSupportedException;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+/**
+ * Mock object implementing the <code>java.sql.Driver</code> interface.
+ * Returns <code>TestConnection</code>'s from getConnection methods.
+ * Valid username, password combinations are:
+ *
+ * <table>
+ * <tr><th>user</th><th>password</th></tr>
+ * <tr><td>foo</td><td>bar</td></tr>
+ * <tr><td>u1</td><td>p1</td></tr>
+ * <tr><td>u2</td><td>p2</td></tr>
+ * <tr><td>username</td><td>password</td></tr>
+ * </table>
+ *
+ * @author Rodney Waldhoff
+ * @author Dirk Verbeeck
+ * @version $Revision$ $Date$
+ */
+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];
+    }
+
+    /* JDBC_4_1_ANT_KEY_BEGIN */
+    @Override
+    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+        throw new SQLFeatureNotSupportedException();
+    }
+    /* JDBC_4_1_ANT_KEY_END */
+
+    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;
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 08/15: Add TesterStatement from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit edf36aa3cb199f5cd06e99fe76441d2977e774c6
Author: Phil Steitz <ph...@gmail.com>
AuthorDate: Sat Oct 19 14:44:43 2019 -0700

    Add TesterStatement from Commons DBCP 1.5 branch, commit fa9c1eb250c76dd9af5ee23bf2ecd5351cad4e04.
---
 .../apache/tomcat/dbcp/dbcp/TesterStatement.java   | 310 +++++++++++++++++++++
 1 file changed, 310 insertions(+)

diff --git a/test/org/apache/tomcat/dbcp/dbcp/TesterStatement.java b/test/org/apache/tomcat/dbcp/dbcp/TesterStatement.java
new file mode 100644
index 0000000..4a81e10
--- /dev/null
+++ b/test/org/apache/tomcat/dbcp/dbcp/TesterStatement.java
@@ -0,0 +1,310 @@
+/*
+ * 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.ResultSet;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+
+/**
+ * A dummy {@link Statement}, for testing purposes.
+ *
+ * @author Rodney Waldhoff
+ * @author Dirk Verbeeck
+ * @version $Revision$ $Date$
+ */
+public class TesterStatement implements Statement {
+    public TesterStatement(Connection conn) {
+        _connection = conn;
+    }
+
+    public TesterStatement(Connection conn, int resultSetType, int resultSetConcurrency) {
+        _connection = conn;
+        _resultSetType = resultSetType;
+        _resultSetConcurrency = resultSetConcurrency;
+    }
+
+    protected Connection _connection = null;
+    protected boolean _open = true;
+    protected int _rowsUpdated = 1;
+    protected boolean _executeResponse = true;
+    protected int _maxFieldSize = 1024;
+    protected int _maxRows = 1024;
+    protected boolean _escapeProcessing = false;
+    protected int _queryTimeout = 1000;
+    protected String _cursorName = null;
+    protected int _fetchDirection = 1;
+    protected int _fetchSize = 1;
+    protected int _resultSetConcurrency = 1;
+    protected int _resultSetType = 1;
+    protected ResultSet _resultSet = null;
+
+    public ResultSet executeQuery(String sql) throws SQLException {
+        checkOpen();
+        if("null".equals(sql)) {
+            return null;
+        }
+        if("invalid".equals(sql)) {
+            throw new SQLException("invalid query");
+        }
+        if ("broken".equals(sql)) {
+            throw new SQLException("broken connection");
+        }
+        if("select username".equals(sql)) {
+            String username = ((TesterConnection) _connection).getUsername();
+            Object[][] data = {{username}};
+            return new TesterResultSet(this, data);
+        } else {
+            // Simulate timeout if queryTimout is set to less than 5 seconds
+            if (_queryTimeout > 0 && _queryTimeout < 5) {
+                throw new SQLException("query timeout");
+            }
+            return new TesterResultSet(this);
+        }
+    }
+
+    public int executeUpdate(String sql) throws SQLException {
+        checkOpen();
+        return _rowsUpdated;
+    }
+
+    public void close() throws SQLException {
+        // calling close twice has no effect
+        if (!_open) {
+            return;
+        }
+
+        _open = false;
+        if (_resultSet != null) {
+            _resultSet.close();
+            _resultSet = null;
+        }
+    }
+
+    public int getMaxFieldSize() throws SQLException {
+        checkOpen();
+        return _maxFieldSize;
+    }
+
+    public void setMaxFieldSize(int max) throws SQLException {
+        checkOpen();
+        _maxFieldSize = max;
+    }
+
+    public int getMaxRows() throws SQLException {
+        checkOpen();
+        return _maxRows;
+    }
+
+    public void setMaxRows(int max) throws SQLException {
+        checkOpen();
+        _maxRows = max;
+    }
+
+    public void setEscapeProcessing(boolean enable) throws SQLException {
+        checkOpen();
+        _escapeProcessing = enable;
+    }
+
+    public int getQueryTimeout() throws SQLException {
+        checkOpen();
+        return _queryTimeout;
+    }
+
+    public void setQueryTimeout(int seconds) throws SQLException {
+        checkOpen();
+        _queryTimeout = seconds;
+    }
+
+    public void cancel() throws SQLException {
+        checkOpen();
+    }
+
+    public SQLWarning getWarnings() throws SQLException {
+        checkOpen();
+        return null;
+    }
+
+    public void clearWarnings() throws SQLException {
+        checkOpen();
+    }
+
+    public void setCursorName(String name) throws SQLException {
+        checkOpen();
+        _cursorName = name;
+    }
+
+    public boolean execute(String sql) throws SQLException {
+        checkOpen();
+        if("invalid".equals(sql)) {
+            throw new SQLException("invalid query");
+        }
+        return _executeResponse;
+    }
+
+    public ResultSet getResultSet() throws SQLException {
+        checkOpen();
+        if (_resultSet == null) {
+            _resultSet = new TesterResultSet(this);
+        }
+        return _resultSet;
+    }
+
+    public int getUpdateCount() throws SQLException {
+        checkOpen();
+        return _rowsUpdated;
+    }
+
+    public boolean getMoreResults() throws SQLException {
+        checkOpen();
+        return false;
+    }
+
+    public void setFetchDirection(int direction) throws SQLException {
+        checkOpen();
+        _fetchDirection = direction;
+    }
+
+    public int getFetchDirection() throws SQLException {
+        checkOpen();
+        return _fetchDirection;
+    }
+
+    public void setFetchSize(int rows) throws SQLException {
+        checkOpen();
+        _fetchSize = rows;
+    }
+
+    public int getFetchSize() throws SQLException {
+        checkOpen();
+        return _fetchSize;
+    }
+
+    public int getResultSetConcurrency() throws SQLException {
+        checkOpen();
+        return _resultSetConcurrency;
+    }
+
+    public int getResultSetType() throws SQLException {
+        checkOpen();
+        return _resultSetType;
+    }
+
+    public void addBatch(String sql) throws SQLException {
+        checkOpen();
+    }
+
+    public void clearBatch() throws SQLException {
+        checkOpen();
+    }
+
+    public int[] executeBatch() throws SQLException {
+        checkOpen();
+        return new int[0];
+    }
+
+    public Connection getConnection() throws SQLException {
+        checkOpen();
+        return _connection;
+    }
+
+    protected void checkOpen() throws SQLException {
+        if(!_open) {
+            throw new SQLException("Connection is closed.");
+        }
+    }
+
+    public boolean getMoreResults(int current) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public ResultSet getGeneratedKeys() throws SQLException {
+        return new TesterResultSet(this);
+    }
+
+    public int executeUpdate(String sql, int autoGeneratedKeys)
+        throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public int executeUpdate(String sql, int columnIndexes[])
+        throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public int executeUpdate(String sql, String columnNames[])
+        throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public boolean execute(String sql, int autoGeneratedKeys)
+        throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public boolean execute(String sql, int columnIndexes[])
+        throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public boolean execute(String sql, String columnNames[])
+        throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public int getResultSetHoldability() throws SQLException {
+        checkOpen();
+        throw new SQLException("Not implemented.");
+    }
+
+/* JDBC_4_ANT_KEY_BEGIN */
+
+    public boolean isWrapperFor(Class<?> iface) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public boolean isClosed() throws SQLException {
+        return !_open;
+    }
+
+    public void setPoolable(boolean poolable) throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+
+    public boolean isPoolable() throws SQLException {
+        throw new SQLException("Not implemented.");
+    }
+/* JDBC_4_ANT_KEY_END */
+
+    /* JDBC_4_1_ANT_KEY_BEGIN */
+    @Override
+    public void closeOnCompletion() throws SQLException {
+    }
+
+    @Override
+    public boolean isCloseOnCompletion() throws SQLException {
+        return false;
+    }
+    /* JDBC_4_1_ANT_KEY_END */
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org