*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ---------------
* TestExceptionMethods.java
* ---------------
* Author: Volker Berlin
*
* Created on 02.03.2005
*/
package smallsql.junit;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
public class TestExceptionMethods extends BasicTestCase {
public void testForwardOnly() throws Exception{
Connection con = AllTests.getConnection();
try{
con.createStatement().execute("Create Table ExceptionMethods(v varchar(30))");
con.createStatement().execute("Insert Into ExceptionMethods(v) Values('qwert')");
ResultSet rs = con.createStatement().executeQuery("Select * from ExceptionMethods");
assertEquals( true, rs.next() );
try{
rs.isBeforeFirst();
fail("SQLException 'ResultSet is forward only' should be throw");
}catch(SQLException e){
}
try{
rs.isFirst();
fail("SQLException 'ResultSet is forward only' should be throw");
}catch(SQLException e){
}
try{
rs.first();
fail("SQLException 'ResultSet is forward only' should be throw");
}catch(SQLException e){
}
try{
rs.previous();
fail("SQLException 'ResultSet is forward only' should be throw");
}catch(SQLException e){
}
try{
rs.last();
fail("SQLException 'ResultSet is forward only' should be throw");
}catch(SQLException e){
}
try{
rs.isLast();
fail("SQLException 'ResultSet is forward only' should be throw");
}catch(SQLException e){
}
try{
rs.isAfterLast();
fail("SQLException 'ResultSet is forward only' should be throw");
}catch(SQLException e){
}
try{
rs.afterLast();
fail("SQLException 'ResultSet is forward only' should be throw");
}catch(SQLException e){
}
try{
rs.absolute(1);
fail("SQLException 'ResultSet is forward only' should be throw");
}catch(SQLException e){
}
try{
rs.relative(1);
fail("SQLException 'ResultSet is forward only' should be throw");
}catch(SQLException e){
}
}finally{
try{
con.createStatement().execute("Drop Table ExceptionMethods");
}catch(Throwable e){}
}
}
}