@Override public void setFetchDirection(int direction) throws SQLException { stat.setFetchDirection(direction); }
@Test(expected = SQLFeatureNotSupportedException.class) public void assertSetFetchDirection() throws SQLException { actual.setFetchDirection(0); }
/** * DOCUMENT ME! * * @throws SQLException DOCUMENT ME! */ public void testAccessorsAndMutators() throws SQLException { assertTrue( "Connection can not be null, and must be same connection", stmt.getConnection() == conn); // Set max rows, to exercise code in execute(), executeQuery() and executeUpdate() Statement accessorStmt = null; try { accessorStmt = conn.createStatement(); accessorStmt.setMaxRows(1); accessorStmt.setMaxRows(0); // FIXME, test that this actually affects rows returned accessorStmt.setMaxFieldSize(255); assertTrue("Max field size should match what was set", accessorStmt.getMaxFieldSize() == 255); try { accessorStmt.setMaxFieldSize(Integer.MAX_VALUE); fail("Should not be able to set max field size > max_packet_size"); } /* ignore */ catch (SQLException sqlEx) {; } accessorStmt.setCursorName("undef"); accessorStmt.setEscapeProcessing(true); accessorStmt.setFetchDirection(java.sql.ResultSet.FETCH_FORWARD); int fetchDirection = accessorStmt.getFetchDirection(); assertTrue( "Set fetch direction != get fetch direction", fetchDirection == java.sql.ResultSet.FETCH_FORWARD); try { accessorStmt.setFetchDirection(Integer.MAX_VALUE); fail("Should not be able to set fetch direction to invalid value"); } /* ignore */ catch (SQLException sqlEx) {; } try { accessorStmt.setMaxRows(50000000 + 10); fail("Should not be able to set max rows > 50000000"); } /* ignore */ catch (SQLException sqlEx) {; } try { accessorStmt.setMaxRows(Integer.MIN_VALUE); fail("Should not be able to set max rows < 0"); } /* ignore */ catch (SQLException sqlEx) {; } int fetchSize = stmt.getFetchSize(); try { accessorStmt.setMaxRows(4); accessorStmt.setFetchSize(Integer.MAX_VALUE); fail("Should not be able to set FetchSize > max rows"); } /* ignore */ catch (SQLException sqlEx) {; } try { accessorStmt.setFetchSize(-2); fail("Should not be able to set FetchSize < 0"); } /* ignore */ catch (SQLException sqlEx) {; } assertTrue( "Fetch size before invalid setFetchSize() calls should match fetch size now", fetchSize == stmt.getFetchSize()); } finally { if (accessorStmt != null) { try { accessorStmt.close(); } /* ignore */ catch (SQLException sqlEx) {; } accessorStmt = null; } } }