use of com.mockrunner.mock.jdbc.MockResultSet in project cayenne by apache.
the class JodaTestCase method resultSet.
ResultSet resultSet(Object value) throws SQLException {
MockResultSet rs = new MockResultSet("Test");
rs.addColumn("Col");
rs.addRow(new Object[] { value });
rs.next();
return rs;
}
use of com.mockrunner.mock.jdbc.MockResultSet in project cayenne by apache.
the class JDBCResultIteratorTest method testNextDataRow.
@Test
public void testNextDataRow() throws Exception {
Connection c = new MockConnection();
Statement s = new MockStatement(c);
MockResultSet rs = new MockResultSet("rs");
rs.addColumn("a", new Object[] { "1", "2", "3" });
RowDescriptor descriptor = new RowDescriptorBuilder().setResultSet(rs).getDescriptor(new ExtendedTypeMap());
RowReader<?> rowReader = new DefaultRowReaderFactory().rowReader(descriptor, new MockQueryMetadata(), mock(DbAdapter.class), Collections.<ObjAttribute, ColumnDescriptor>emptyMap());
JDBCResultIterator it = new JDBCResultIterator(s, rs, rowReader);
DataRow row = (DataRow) it.nextRow();
assertNotNull(row);
assertEquals(1, row.size());
assertEquals("1", row.get("a"));
}
use of com.mockrunner.mock.jdbc.MockResultSet in project cayenne by apache.
the class EnumTypeTest method testMaterializeStringObjectInnerEnum.
@Test
public void testMaterializeStringObjectInnerEnum() throws Exception {
EnumType type = new EnumType(InnerEnumHolder.InnerEnum.class);
MockResultSet rs = new MockResultSet("Test");
rs.addColumn("Enum");
rs.addRow(new Object[] { "b" });
rs.next();
Object o = type.materializeObject(rs, 1, Types.VARCHAR);
assertSame(InnerEnumHolder.InnerEnum.b, o);
}
use of com.mockrunner.mock.jdbc.MockResultSet in project cayenne by apache.
the class BooleanTypeTest method testMaterializeObjectFromResultSet.
@Test
public void testMaterializeObjectFromResultSet() throws Exception {
MockResultSet rs = new MockResultSet("") {
@Override
public boolean getBoolean(int i) throws SQLException {
return (i + 2) % 2 == 0;
}
};
BooleanType type = new BooleanType();
// assert identity as well as equality (see CAY-320)
assertSame(Boolean.FALSE, type.materializeObject(rs, 1, Types.BIT));
assertSame(Boolean.TRUE, type.materializeObject(rs, 2, Types.BIT));
}
use of com.mockrunner.mock.jdbc.MockResultSet in project cayenne by apache.
the class EnumTypeTest method testMaterializeNumericObject.
@Test
public void testMaterializeNumericObject() throws Exception {
EnumType type = new EnumType(MockEnum.class);
MockResultSet rs = new MockResultSet("Test");
rs.addColumn("Enum");
rs.addRow(new Object[] { new Integer(2) });
rs.next();
Object o = type.materializeObject(rs, 1, Types.NUMERIC);
assertSame(MockEnum.c, o);
}
Aggregations