commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From di...@apache.org
Subject cvs commit: jakarta-commons/dbcp/src/test/org/apache/commons/dbcp TestDelegatingConnection.java TestDelegatingPreparedStatement.java TestDelegatingStatement.java TesterConnection.java TesterDriver.java TesterPreparedStatement.java TesterResultSet.java
Date Wed, 15 Oct 2003 19:53:30 GMT
dirkv       2003/10/15 12:53:30

  Modified:    dbcp/src/test/org/apache/commons/dbcp
                        TestDelegatingConnection.java
                        TestDelegatingPreparedStatement.java
                        TestDelegatingStatement.java TesterConnection.java
                        TesterDriver.java TesterPreparedStatement.java
                        TesterResultSet.java
  Log:
  username/password on TesterConnection
  
  Revision  Changes    Path
  1.4       +4 -4      jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestDelegatingConnection.java
  
  Index: TestDelegatingConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestDelegatingConnection.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestDelegatingConnection.java	9 Oct 2003 21:05:29 -0000	1.3
  +++ TestDelegatingConnection.java	15 Oct 2003 19:53:30 -0000	1.4
  @@ -84,7 +84,7 @@
       private Connection delegateConn = null;
   
       public void setUp() throws Exception {
  -        delegateConn = new TesterConnection();
  +        delegateConn = new TesterConnection("test", "test");
           conn = new DelegatingConnection(delegateConn);
       }
   
  
  
  
  1.5       +4 -4      jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestDelegatingPreparedStatement.java
  
  Index: TestDelegatingPreparedStatement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestDelegatingPreparedStatement.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestDelegatingPreparedStatement.java	9 Oct 2003 21:05:29 -0000	1.4
  +++ TestDelegatingPreparedStatement.java	15 Oct 2003 19:53:30 -0000	1.5
  @@ -88,7 +88,7 @@
       private PreparedStatement delegateStmt = null;
   
       public void setUp() throws Exception {
  -        delegateConn = new TesterConnection();
  +        delegateConn = new TesterConnection("test", "test");
           conn = new DelegatingConnection(delegateConn);
       }
   
  
  
  
  1.5       +4 -4      jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestDelegatingStatement.java
  
  Index: TestDelegatingStatement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestDelegatingStatement.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestDelegatingStatement.java	9 Oct 2003 21:05:29 -0000	1.4
  +++ TestDelegatingStatement.java	15 Oct 2003 19:53:30 -0000	1.5
  @@ -88,7 +88,7 @@
       private Statement delegateStmt = null;
   
       public void setUp() throws Exception {
  -        delegateConn = new TesterConnection();
  +        delegateConn = new TesterConnection("test", "test");
           delegateStmt = new TesterStatement(delegateConn);
           conn = new DelegatingConnection(delegateConn);
           stmt = new DelegatingStatement(conn,delegateStmt);
  
  
  
  1.9       +23 -4     jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TesterConnection.java
  
  Index: TesterConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TesterConnection.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TesterConnection.java	9 Oct 2003 21:05:29 -0000	1.8
  +++ TesterConnection.java	15 Oct 2003 19:53:30 -0000	1.9
  @@ -61,13 +61,21 @@
   
   package org.apache.commons.dbcp;
   
  -import java.sql.*;
  +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;
   
   /**
    * A dummy {@link Connection}, for testing purposes.
  + * 
    * @author Rodney Waldhoff
  - * @version $Id$
  + * @author Dirk Verbeeck
  + * @version $Revision$ $Date$
    */
   public class TesterConnection implements Connection {
       protected boolean _open = true;
  @@ -78,6 +86,17 @@
       protected Map _typeMap = null;
       protected boolean _readOnly = false;
       protected SQLWarning warnings = null;
  +    protected String username = null;
  +    protected String password = null;
  +
  +    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;
  
  
  
  1.6       +19 -6     jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TesterDriver.java
  
  Index: TesterDriver.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TesterDriver.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TesterDriver.java	9 Oct 2003 21:05:29 -0000	1.5
  +++ TesterDriver.java	15 Oct 2003 19:53:30 -0000	1.6
  @@ -80,6 +80,10 @@
    * <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 Properties validUserPasswords = new Properties();
  @@ -94,6 +98,13 @@
           validUserPasswords.put("username", "password");
       }
   
  +    /** 
  +     * TesterDriver specific method to add users to the list of valid users 
  +     */
  +    public static void addUser(String username, String password) {
  +        validUserPasswords.put(username, password);
  +    }
  +
       public boolean acceptsURL(String url) throws SQLException {
           return CONNECT_STRING.startsWith(url);
       }
  @@ -119,13 +130,15 @@
           Connection conn = null;
           if (acceptsURL(url)) 
           {
  +            String username = "test";
  +            String password = "test";
               if (info != null) 
               {
  -                assertValidUserPassword(info.getProperty("user"), 
  -                                        info.getProperty("password"));
  +                username = info.getProperty("user");
  +                password = info.getProperty("password");
  +                assertValidUserPassword(username, password);
               }
  -            
  -            conn = new TesterConnection();
  +            conn = new TesterConnection(username, password);
           }
           
           return conn;
  
  
  
  1.9       +9 -2      jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TesterPreparedStatement.java
  
  Index: TesterPreparedStatement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TesterPreparedStatement.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TesterPreparedStatement.java	9 Oct 2003 21:05:29 -0000	1.8
  +++ TesterPreparedStatement.java	15 Oct 2003 19:53:30 -0000	1.9
  @@ -73,6 +73,13 @@
   import java.sql.SQLException;
   import java.util.Calendar;
   
  +/**
  + * 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;
  
  
  
  1.8       +42 -7     jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TesterResultSet.java
  
  Index: TesterResultSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TesterResultSet.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TesterResultSet.java	9 Oct 2003 21:05:29 -0000	1.7
  +++ TesterResultSet.java	15 Oct 2003 19:53:30 -0000	1.8
  @@ -61,25 +61,54 @@
   
   package org.apache.commons.dbcp;
   
  -import java.sql.*;
   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;
   
  +/**
  + * 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;
  +    }
  +
  +    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(--_rowsLeft > 0) {
  -            return true;
  -        } else {
  -            return false;
  +        if (_data != null) {
  +            _currentRow++;
  +            return _currentRow < _data.length;
  +        }
  +        else {
  +            if(--_rowsLeft > 0) {
  +                return true;
  +            } else {
  +                return false;
  +            }
           }
       }
   
  @@ -94,6 +123,9 @@
   
       public String getString(int columnIndex) throws SQLException {
           checkOpen();
  +        if (_data != null) {
  +            return (String) getObject(columnIndex);
  +        }
           return "String" + columnIndex;
       }
   
  @@ -277,6 +309,9 @@
   
       public Object getObject(int columnIndex) throws SQLException {
           checkOpen();
  +        if (_data != null) {
  +            return _data[_currentRow][columnIndex-1];
  +        }
           return new Object();
       }
   
  
  
  

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


Mime
View raw message