use of com.dangdang.ddframe.rdb.sharding.jdbc.fixture.MockRowSetResultSet in project sharding-jdbc by dangdangdotcom.
the class MemoryResultSetTest method test.
@Test
public void test() throws SQLException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
MockResultSet mockResultSet = new MockResultSet<>(input);
MockRowSetResultSet rs = new MockRowSetResultSet(mockResultSet);
assertThat(rs.getStatement(), nullValue());
assertThat(rs.getFetchSize(), is(1));
assertThat(rs.getMetaData().getColumnCount(), is(1));
assertThat(rs.getFetchDirection(), is(ResultSet.FETCH_FORWARD));
assertThat(rs.getType(), is(ResultSet.TYPE_FORWARD_ONLY));
assertThat(rs.getConcurrency(), is(ResultSet.CONCUR_READ_ONLY));
rs.clearWarnings();
assertThat(rs.getWarnings(), nullValue());
assertThat(rs.next(), is(true));
if (scale > 0) {
assertThat(ResultSet.class.getMethod(methodName, int.class, int.class).invoke(rs, 1, scale), is(result));
assertThat(ResultSet.class.getMethod(methodName, String.class, int.class).invoke(rs, "name", scale), is(result));
} else if (null != cal) {
assertThat(ResultSet.class.getMethod(methodName, int.class, Calendar.class).invoke(rs, 1, cal), is(result));
assertThat(ResultSet.class.getMethod(methodName, String.class, Calendar.class).invoke(rs, "name", cal), is(result));
} else {
assertThat(ResultSet.class.getMethod(methodName, int.class).invoke(rs, 1), is(result));
assertThat(ResultSet.class.getMethod(methodName, String.class).invoke(rs, "name"), is(result));
}
if (null == result || null == input) {
assertThat(rs.wasNull(), is(true));
} else {
assertThat(rs.wasNull(), is(false));
}
assertThat(rs.next(), is(false));
assertThat(rs.isClosed(), is(false));
rs.close();
assertThat(rs.isClosed(), is(true));
}
Aggregations