KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > smallsql > junit > TestExceptionMethods


1 /* =============================================================
2  * SmallSQL : a free Java DBMS library for the Java(tm) platform
3  * =============================================================
4  *
5  * (C) Copyright 2004-2006, by Volker Berlin.
6  *
7  * Project Info: http://www.smallsql.de/
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22  * USA.
23  *
24  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25  * in the United States and other countries.]
26  *
27  * ---------------
28  * TestExceptionMethods.java
29  * ---------------
30  * Author: Volker Berlin
31  *
32  * Created on 02.03.2005
33  */

34 package smallsql.junit;
35
36 import java.sql.Connection JavaDoc;
37 import java.sql.ResultSet JavaDoc;
38 import java.sql.SQLException JavaDoc;
39
40 /**
41  * @author Volker Berlin
42  */

43 public class TestExceptionMethods extends BasicTestCase {
44
45     public void testForwardOnly() throws Exception JavaDoc{
46         Connection JavaDoc con = AllTests.getConnection();
47         try{
48             con.createStatement().execute("Create Table ExceptionMethods(v varchar(30))");
49
50             con.createStatement().execute("Insert Into ExceptionMethods(v) Values('qwert')");
51
52             ResultSet JavaDoc rs = con.createStatement().executeQuery("Select * from ExceptionMethods");
53             assertEquals( true, rs.next() );
54             
55             try{
56                 rs.isBeforeFirst();
57                 fail("SQLException 'ResultSet is forward only' should be throw");
58             }catch(SQLException JavaDoc e){
59                 //TODO check error code of "ResultSet is forward only"
60
}
61
62             try{
63                 rs.isFirst();
64                 fail("SQLException 'ResultSet is forward only' should be throw");
65             }catch(SQLException JavaDoc e){
66                 //TODO check error code of "ResultSet is forward only"
67
}
68
69             try{
70                 rs.first();
71                 fail("SQLException 'ResultSet is forward only' should be throw");
72             }catch(SQLException JavaDoc e){
73                 //TODO check error code of "ResultSet is forward only"
74
}
75
76             try{
77                 rs.previous();
78                 fail("SQLException 'ResultSet is forward only' should be throw");
79             }catch(SQLException JavaDoc e){
80                 //TODO check error code of "ResultSet is forward only"
81
}
82
83             try{
84                 rs.last();
85                 fail("SQLException 'ResultSet is forward only' should be throw");
86             }catch(SQLException JavaDoc e){
87                 //TODO check error code of "ResultSet is forward only"
88
}
89             
90             try{
91                 rs.isLast();
92                 fail("SQLException 'ResultSet is forward only' should be throw");
93             }catch(SQLException JavaDoc e){
94                 //TODO check error code of "ResultSet is forward only"
95
}
96             
97             try{
98                 rs.isAfterLast();
99                 fail("SQLException 'ResultSet is forward only' should be throw");
100             }catch(SQLException JavaDoc e){
101                 //TODO check error code of "ResultSet is forward only"
102
}
103             
104             try{
105                 rs.afterLast();
106                 fail("SQLException 'ResultSet is forward only' should be throw");
107             }catch(SQLException JavaDoc e){
108                 //TODO check error code of "ResultSet is forward only"
109
}
110             
111             try{
112                 rs.absolute(1);
113                 fail("SQLException 'ResultSet is forward only' should be throw");
114             }catch(SQLException JavaDoc e){
115                 //TODO check error code of "ResultSet is forward only"
116
}
117             
118             try{
119                 rs.relative(1);
120                 fail("SQLException 'ResultSet is forward only' should be throw");
121             }catch(SQLException JavaDoc e){
122                 //TODO check error code of "ResultSet is forward only"
123
}
124         }finally{
125             dropTable( con, "ExceptionMethods" );
126         }
127     }
128
129 }
130
Popular Tags