01: /*
02: * Copyright (C) 1999-2004 <a href="mailto:mandarax@jbdietrich.com">Jens Dietrich</a>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package test.org.mandarax.jdbc;
20:
21: import java.sql.*;
22:
23: /**
24: * Simple test case for queries - only one result is expected.
25: * Uses prepared statements with one variable. First another variable value is set
26: * and later updated.
27: * @author <A HREF="mailto:mandarax@jbdietrich.com">Jens Dietrich</A>
28: * @version 3.3.2 <29 December 2004>
29: * @since 3.0
30: */
31:
32: public class QueryTestCase4 extends AbstractQueryTestCase {
33:
34: private String colName = null;
35: private int expected = -1;
36: private Object paramValue = null;
37:
38: /*
39: * Constructor.
40: * @param url the kb url
41: * @param sql the sql statement
42: * @param expected the number of expected results
43: */
44: public QueryTestCase4(String url, String sql, int expectedResults) {
45: super (url, sql);
46: this .expected = expectedResults;
47: }
48:
49: /**
50: * Perform the test.
51: */
52: public void test() throws Exception {
53:
54: Connection connection = java.sql.DriverManager
55: .getConnection(url);
56: Statement stmnt = connection.createStatement();
57: ResultSet rs = stmnt.executeQuery(sql);
58: int counter = 0;
59: while (rs.next())
60: counter++;
61: rs.close();
62: connection.close();
63: assertTrue(counter == expected);
64: }
65:
66: }
|