1 19 20 package org.netbeans.modules.db.test.jdbcstub; 21 22 import java.sql.ResultSet ; 23 import java.sql.SQLException ; 24 import java.util.Arrays ; 25 import java.util.Collections ; 26 import java.util.List ; 27 import junit.framework.TestCase; 28 29 33 public class ResultSetImplTest extends TestCase { 34 35 public ResultSetImplTest(String name) { 36 super(name); 37 } 38 39 public void testEmpty() throws Exception { 40 ResultSet rs = JDBCStubUtil.createResultSet(Collections.EMPTY_LIST); 41 assertFalse(rs.next()); 42 } 43 44 public void testNextAndGetObject() throws Exception { 45 46 List col1 = Arrays.asList(new String [] { "FOO", "foo1", "foo2"}); 47 List col2 = Arrays.asList(new String [] { "BAR", "bar1", "bar2"}); 48 49 ResultSet rs = JDBCStubUtil.createResultSet(Arrays.asList(new List [] { col1, col2 })); 50 51 try { 52 rs.getObject("foo1"); 53 fail("SQLException thrown if next() not previously called"); 54 } catch (SQLException e) { } 55 56 assertTrue(rs.next()); 57 58 assertEquals("foo1", rs.getObject("FOO")); 59 assertEquals("bar1", rs.getObject("BAR")); 60 61 try { 62 rs.getObject("inexistent"); 63 fail("SQLException thrown if unkown column name"); 64 } catch (SQLException e) { } 65 66 assertTrue(rs.next()); 67 assertEquals("bar2", rs.getObject("BAR")); 68 assertEquals("foo2", rs.getObject("FOO")); 69 70 assertFalse(rs.next()); 71 assertFalse(rs.next()); 72 } 73 } 74 | Popular Tags |