rwaldhoff 2002/10/31 13:41:51 Modified: dbcp/src/test/org/apache/commons/dbcp TestAll.java TesterPreparedStatement.java TesterStatement.java Added: dbcp/src/test/org/apache/commons/dbcp TestDelegatingPreparedStatement.java TestDelegatingStatement.java Log: add tests for bugzilla bug #12733 Revision Changes Path 1.3 +7 -5 jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestAll.java Index: TestAll.java =================================================================== RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestAll.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TestAll.java 5 Aug 2002 06:42:01 -0000 1.2 +++ TestAll.java 31 Oct 2002 21:41:50 -0000 1.3 @@ -1,5 +1,5 @@ /* - * $Header$ + * $Id$ * $Revision$ * $Date$ * @@ -7,7 +7,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2001 The Apache Software Foundation. All rights + * Copyright (c) 2001-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -66,7 +66,7 @@ /** * @author Rodney Waldhoff - * @version $Id$ + * @version $Revision$ $Date$ */ public class TestAll extends TestCase { public TestAll(String testName) { @@ -76,6 +76,8 @@ public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest(TestManual.suite()); + suite.addTest(TestDelegatingStatement.suite()); + suite.addTest(TestDelegatingPreparedStatement.suite()); suite.addTest(TestJdbc2PoolDataSource.suite()); return suite; } 1.3 +17 -7 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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TesterPreparedStatement.java 19 Mar 2002 06:05:34 -0000 1.2 +++ TesterPreparedStatement.java 31 Oct 2002 21:41:50 -0000 1.3 @@ -1,5 +1,5 @@ /* - * $Header$ + * $Id$ * $Revision$ * $Date$ * @@ -7,7 +7,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2001 The Apache Software Foundation. All rights + * Copyright (c) 2001-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,7 +68,8 @@ import java.math.BigDecimal; public class TesterPreparedStatement extends TesterStatement implements PreparedStatement { - protected ResultSetMetaData _resultSetMetaData = null; + private ResultSetMetaData _resultSetMetaData = null; + private String _sql = null; public TesterPreparedStatement(Connection conn) { super(conn); @@ -76,11 +77,16 @@ public TesterPreparedStatement(Connection conn, String sql) { super(conn); + _sql = sql; } public ResultSet executeQuery(String sql) throws SQLException { checkOpen(); - return new TesterResultSet(this); + if("null".equals(sql)) { + return null; + } else { + return new TesterResultSet(this); + } } public int executeUpdate(String sql) throws SQLException { @@ -90,7 +96,11 @@ public ResultSet executeQuery() throws SQLException { checkOpen(); - return new TesterResultSet(this); + if("null".equals(_sql)) { + return null; + } else { + return new TesterResultSet(this); + } } public int executeUpdate() throws SQLException { 1.3 +8 -4 jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TesterStatement.java Index: TesterStatement.java =================================================================== RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TesterStatement.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TesterStatement.java 19 Mar 2002 06:05:34 -0000 1.2 +++ TesterStatement.java 31 Oct 2002 21:41:50 -0000 1.3 @@ -1,5 +1,5 @@ /* - * $Header$ + * $Id$ * $Revision$ * $Date$ * @@ -87,7 +87,11 @@ public ResultSet executeQuery(String sql) throws SQLException { checkOpen(); - return new TesterResultSet(this); + if("null".equals(sql)) { + return null; + } else { + return new TesterResultSet(this); + } } public int executeUpdate(String sql) throws SQLException { 1.1 jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestDelegatingPreparedStatement.java Index: TestDelegatingPreparedStatement.java =================================================================== /* * $Id: TestDelegatingPreparedStatement.java,v 1.1 2002/10/31 21:41:50 rwaldhoff Exp $ * $Revision: 1.1 $ * $Date: 2002/10/31 21:41:50 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Commons", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.commons.dbcp; import java.sql.Connection; import java.sql.PreparedStatement; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * @author Rodney Waldhoff * @version $Revision: 1.1 $ $Date: 2002/10/31 21:41:50 $ */ public class TestDelegatingPreparedStatement extends TestCase { public TestDelegatingPreparedStatement(String testName) { super(testName); } public static Test suite() { return new TestSuite(TestDelegatingPreparedStatement.class); } private DelegatingConnection conn = null; private Connection delegateConn = null; private DelegatingPreparedStatement stmt = null; private PreparedStatement delegateStmt = null; public void setUp() throws Exception { delegateConn = new TesterConnection(); conn = new DelegatingConnection(delegateConn); } public void testExecuteQueryReturnsNull() throws Exception { delegateStmt = new TesterPreparedStatement(delegateConn,"null"); stmt = new DelegatingPreparedStatement(conn,delegateStmt); assertNull(stmt.executeQuery()); } public void testExecuteQueryReturnsNotNull() throws Exception { delegateStmt = new TesterPreparedStatement(delegateConn,"select * from foo"); stmt = new DelegatingPreparedStatement(conn,delegateStmt); assertTrue(null != stmt.executeQuery()); } public void testGetDelegate() throws Exception { delegateStmt = new TesterPreparedStatement(delegateConn,"select * from foo"); stmt = new DelegatingPreparedStatement(conn,delegateStmt); assertEquals(delegateStmt,stmt.getDelegate()); } } 1.1 jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestDelegatingStatement.java Index: TestDelegatingStatement.java =================================================================== /* * $Id: TestDelegatingStatement.java,v 1.1 2002/10/31 21:41:50 rwaldhoff Exp $ * $Revision: 1.1 $ * $Date: 2002/10/31 21:41:50 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Commons", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.commons.dbcp; import java.sql.Connection; import java.sql.Statement; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * @author Rodney Waldhoff * @version $Revision: 1.1 $ $Date: 2002/10/31 21:41:50 $ */ public class TestDelegatingStatement extends TestCase { public TestDelegatingStatement(String testName) { super(testName); } public static Test suite() { return new TestSuite(TestDelegatingStatement.class); } private DelegatingConnection conn = null; private Connection delegateConn = null; private DelegatingStatement stmt = null; private Statement delegateStmt = null; public void setUp() throws Exception { delegateConn = new TesterConnection(); delegateStmt = new TesterStatement(delegateConn); conn = new DelegatingConnection(delegateConn); stmt = new DelegatingStatement(conn,delegateStmt); } public void testExecuteQueryReturnsNull() throws Exception { assertNull(stmt.executeQuery("null")); } public void testGetDelegate() throws Exception { assertEquals(delegateStmt,stmt.getDelegate()); } }
-- To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>