/** * Based on EricH regression test case */ package testsuite.simple; import java.sql.ResultSet; import java.lang.reflect.Method; import javax.sql.rowset.CachedRowSet; import testsuite.BaseTestCase; /** * @author Administrator * */ public class TestBug44656 extends BaseTestCase { /** * @param name */ public TestBug44656(String name) { super(name); // TODO Auto-generated constructor stub } public void testBug44656() throws Exception { try { System.out.println("java.vm.version : " + System.getProperty("java.vm.version")); System.out.println("java.vm.vendor : " + System.getProperty("java.vm.vendor")); System.out.println("java.runtime.version : " + System.getProperty("java.runtime.version")); System.out.println("os : " + System.getProperty("os.name") + ", " + System.getProperty("os.version") + ", " + System.getProperty("os.arch")); System.out.println("sun.management.compiler : " + System.getProperty("sun.management.compiler")); System.out.println("-------------------------------------------------"); String implClass = "com.sun.rowset.CachedRowSetImpl"; Class c; Method populate; try { c = Class.forName(implClass); } catch (ClassNotFoundException e) { System.out.println("skipping testBug44656. Requires: " + implClass); return; } populate = c.getMethod("populate", new Class[] { ResultSet.class }); try { createTable("bug44656", "(i1 INT UNSIGNED NOT NULL, i2 INT UNSIGNED NOT NULL, PRIMARY KEY(i1,i2))"); this.stmt.executeUpdate("Insert into bug44656 (i1, i2) values (1, 1)"); String sql = "SELECT * FROM bug44656"; this.rs = this.stmt.executeQuery(sql); // create a CachedRowSet and populate it CachedRowSet cachedRowSet = (CachedRowSet) c.newInstance(); populate.invoke(cachedRowSet, new Object[] { this.rs }); // scroll through CachedRowSet ... assertTrue(cachedRowSet.next()); assertEquals(1, cachedRowSet.getInt("i1")); assertEquals(1, cachedRowSet.getInt("i2")); assertFalse(cachedRowSet.next()); cachedRowSet.moveToInsertRow(); cachedRowSet.updateInt("i1", 1); cachedRowSet.updateInt("i2", 2); cachedRowSet.insertRow(); cachedRowSet.acceptChanges(); cachedRowSet.moveToCurrentRow(); } finally { closeMemberJDBCResources(); } } finally { closeMemberJDBCResources(); } } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub junit.textui.TestRunner.run(TestBug44656.class); } }