/** test next(), get result set and close without walking through */ @Test public void testNext3() throws Exception { ResultSetImpl rs = new ResultSetImpl(exampleResultsMsg1(), statement); assertEquals(new Integer(0), new Integer(rs.getRow())); rs.close(); }
@Test public void testPrevious() throws Exception { List[] results = exampleResults1(5); ResultSetImpl rs = new ResultSetImpl(exampleResultsMsg1(), statement); while (rs.next()) { // just walk to the end; } // walk reversely; int i = results.length - 1; while (rs.previous()) { List expected = new ArrayList(1); expected.add(new Integer(i + 1)); assertEquals(expected, rs.getCurrentRecord()); i--; } rs.close(); }
/** * test next(), whether the result set's cursor is positioned on next row or * not */ @Test public void testNext1() throws Exception { ResultSetImpl rs = new ResultSetImpl(exampleResultsMsg1(), statement); // point to first row boolean actual = rs.next(); boolean expected = true; assertEquals(" Actual doesn't match with expected. ", expected, actual); //$NON-NLS-1$ rs.close(); }
/** test next(), when hasNext() == false */ @Test public void testNext5() throws Exception { ResultSetImpl rs = new ResultSetImpl(exampleResultsMsg1(), statement); while (rs.next()) { // just walk through until hasNext() == false; } boolean actual = rs.hasNext(); boolean expected = false; assertEquals(expected, actual); rs.close(); }
/** test hasNext(), actual result set should return FALSE. */ @Test public void testHasNext1() throws Exception { ResultSetImpl rs = new ResultSetImpl(exampleResultsMsg1(), statement); while (rs.next()) { // just walk through } boolean actual = rs.hasNext(); boolean expected = false; assertEquals(expected, actual); rs.close(); }
/** test next(), walk through partial rows of a result set */ @Test public void testNext4() throws Exception { List[] results = exampleResults1(5); ResultSetImpl rs = new ResultSetImpl(exampleResultsMsg1(), statement); for (int i = 0; i < results.length - 1; i++) { rs.next(); List actual = rs.getCurrentRecord(); List expected = results[i]; assertEquals(expected, actual); } rs.close(); }
/** test hasNext(), actual result set should return TRUE. */ @Test public void testHasNext2() throws Exception { List[] results = exampleResults1(5); ResultSetImpl rs = new ResultSetImpl(exampleResultsMsg1(), statement); for (int i = 1; i < results.length; i++) { rs.next(); } boolean actual = rs.hasNext(); boolean expected = true; assertEquals(expected, actual); rs.close(); }
/** test next(), walk through all rows of a result set and compare each row. */ @Test public void testNext2() throws Exception { List[] results = exampleResults1(5); ResultSetImpl rs = new ResultSetImpl(exampleResultsMsg1(), statement); int i = 0; while (rs.next()) { // walk through and compare List actual = rs.getCurrentRecord(); List expected = results[i]; assertEquals(expected, actual); i++; } rs.close(); }