return (JdbcRowSet) Class.forName("com.sun.rowset.JdbcRowSetImpl")
.newInstance();
}
public void testBeforeInitial() throws Exception {
JdbcRowSet jrs = newJdbcRowSet();
// move cursor
try {
jrs.absolute(1);
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
try {
jrs.beforeFirst();
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
try {
jrs.afterLast();
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
try {
jrs.last();
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
try {
jrs.first();
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
try {
jrs.isAfterLast();
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
try {
jrs.isBeforeFirst();
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
try {
jrs.isFirst();
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
try {
jrs.isLast();
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
try {
jrs.getRow();
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
try {
jrs.getString(1);
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
// get properties
try {
jrs.getConcurrency();
fail("Should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
try {
jrs.getFetchDirection();
fail("Should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
assertEquals(0, jrs.getFetchSize());
assertEquals(ResultSet.TYPE_SCROLL_INSENSITIVE, jrs.getType());
assertNull(jrs.getTypeMap());
assertTrue(jrs.getEscapeProcessing());
// set properties
jrs.setConcurrency(RowSet.CONCUR_UPDATABLE);
jrs.setType(ResultSet.TYPE_FORWARD_ONLY);
jrs.setEscapeProcessing(false);
assertFalse(jrs.getEscapeProcessing());
// JdbcRowSet methods
try {
jrs.getAutoCommit();
fail("Should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
try {
jrs.commit();
fail("Should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
try {
jrs.setAutoCommit(false);
fail("Should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
try {
jrs.rollback();
fail("Should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
assertNull(jrs.getRowSetWarnings());
// update methods
try {
jrs.updateString(1, "test");
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
try {
jrs.insertRow();
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
jrs.close();
try {
jrs.clearWarnings();
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
try {
jrs.findColumn("ID");
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
try {
jrs.wasNull();
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
try {
jrs.getMetaData();
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
try {
jrs.getWarnings();
fail("Should throw SQLException");
} catch (SQLException e) {
// expected, Invalid state
}
}