001: package test.org.mandarax.jdbc;
002:
003: /*
004: * Copyright (C) 1999-2004 <a href="mailto:mandarax@jbdietrich.com">Jens Dietrich</a>
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: */
020:
021: import junit.framework.TestSuite;
022: import java.sql.*;
023:
024: /**
025: * A test suite for queries issued using the net driver.
026: * @author <A HREF="mailto:mandarax@jbdietrich.com">Jens Dietrich</A>
027: * @version 3.3.2 <29 December 2004>
028: * @since 3.0
029: */
030:
031: public class NetQueryTests1 implements TestURLs {
032:
033: /**
034: * Launch the test suite. See TestRunner for interpretation
035: * of command line parameters.
036: * @see test.org.mandarax.testsupport.TestRunner
037: * @param args parameters
038: */
039: public static void main(String[] args) {
040: test.org.mandarax.testsupport.TestRunner.run(
041: test.org.mandarax.jdbc.NetQueryTests1.class, args);
042: }
043:
044: /**
045: * Get the test suite.
046: * @return a test suite
047: */
048: public static TestSuite suite() {
049:
050: TestSuite suite = new TestSuite(
051: "SQL Query tests using the net (client-server) driver");
052:
053: /* test kb:
054: "Tom", "Meier", "01/01/1960", 80, 1.80;
055: "John", "Meier", "01/01/1960", 90, 1.90;
056: "Jim", "Smith", "01/01/1970", 100, 1.90;
057: "Jack", "Smith", "01/01/1970", 60, 1.60;
058: "Tom", "Taylor", "01/01/1980", 70, 1.70;
059: "John", "Meijer", "01/01/1980", 80, 1.80;
060: "Jim", "Mejer", "01/01/1990", 50, 1.50;
061: */
062:
063: suite.addTest(new NetQueryTestCase1(7) {
064: public ResultSet query(Connection con) throws Exception {
065: Statement s = con.createStatement();
066: return s.executeQuery("select * from people");
067: }
068: });
069: suite.addTest(new NetQueryTestCase1(4) {
070: public ResultSet query(Connection con) throws Exception {
071: Statement s = con.createStatement();
072: return s
073: .executeQuery("select * from people where name like 'Me%'");
074: }
075: });
076: suite.addTest(new NetQueryTestCase1(4) {
077: public ResultSet query(Connection con) throws Exception {
078: PreparedStatement s = con
079: .prepareStatement("select * from people where name like ?");
080: s.setObject(1, "Me%");
081: return s.executeQuery();
082: }
083: });
084: suite.addTest(new NetQueryTestCase1(1) {
085: public ResultSet query(Connection con) throws Exception {
086: PreparedStatement s = con
087: .prepareStatement("select * from people where name = ? and size = ?");
088: s.setObject(1, "Meier");
089: s.setObject(2, new Double(1.8));
090: return s.executeQuery();
091: }
092: });
093:
094: suite.addTest(new NetQueryTestCase1(1) {
095: public ResultSet query(Connection con) throws Exception {
096: PreparedStatement s = con
097: .prepareStatement("select * from people where name = ? and size = ?");
098: s.setObject(1, "Meier");
099: s.setObject(2, new Double(1.8));
100: s.execute();
101: return s.getResultSet();
102: }
103: });
104: suite.addTest(new NetQueryTestCase1(0) {
105: public ResultSet query(Connection con) throws Exception {
106: Statement s = con.createStatement();
107: return s
108: .executeQuery("select * from people where name = 'name with whitespace'");
109: }
110: });
111: return suite;
112: }
113: }
|