Search in sources :

Example 6 with MockResultSet

use of com.mockrunner.mock.jdbc.MockResultSet in project cayenne by apache.

the class EnumTypeTest method testMaterializeNumericObjectInnerEnum.

@Test
public void testMaterializeNumericObjectInnerEnum() throws Exception {
    EnumType type = new EnumType(InnerEnumHolder.InnerEnum.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(InnerEnumHolder.InnerEnum.c, o);
}
Also used : MockResultSet(com.mockrunner.mock.jdbc.MockResultSet) Test(org.junit.Test)

Example 7 with MockResultSet

use of com.mockrunner.mock.jdbc.MockResultSet in project cayenne by apache.

the class EnumTypeTest method testMaterializeStringObject.

@Test
public void testMaterializeStringObject() throws Exception {
    EnumType type = new EnumType(MockEnum.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(MockEnum.b, o);
}
Also used : MockResultSet(com.mockrunner.mock.jdbc.MockResultSet) Test(org.junit.Test)

Example 8 with MockResultSet

use of com.mockrunner.mock.jdbc.MockResultSet in project cayenne by apache.

the class JDBCResultIteratorTest method testClose.

@Test
public void testClose() throws Exception {
    Connection c = new MockConnection();
    MockStatement s = new MockStatement(c);
    MockResultSet rs = new MockResultSet("rs");
    rs.addColumn("a", new Object[] { "1", "2", "3" });
    RowReader<?> rowReader = mock(RowReader.class);
    try (JDBCResultIterator it = new JDBCResultIterator(s, rs, rowReader)) {
        assertFalse(rs.isClosed());
        assertFalse(s.isClosed());
        assertFalse(c.isClosed());
    }
    assertTrue(rs.isClosed());
    assertTrue(s.isClosed());
}
Also used : Connection(java.sql.Connection) MockConnection(com.mockrunner.mock.jdbc.MockConnection) MockStatement(com.mockrunner.mock.jdbc.MockStatement) MockResultSet(com.mockrunner.mock.jdbc.MockResultSet) MockConnection(com.mockrunner.mock.jdbc.MockConnection) Test(org.junit.Test)

Aggregations

MockResultSet (com.mockrunner.mock.jdbc.MockResultSet)8 Test (org.junit.Test)7 MockConnection (com.mockrunner.mock.jdbc.MockConnection)2 MockStatement (com.mockrunner.mock.jdbc.MockStatement)2 Connection (java.sql.Connection)2 Statement (java.sql.Statement)1 DataRow (org.apache.cayenne.DataRow)1 DefaultRowReaderFactory (org.apache.cayenne.access.jdbc.reader.DefaultRowReaderFactory)1 ExtendedTypeMap (org.apache.cayenne.access.types.ExtendedTypeMap)1 DbAdapter (org.apache.cayenne.dba.DbAdapter)1 MockQueryMetadata (org.apache.cayenne.query.MockQueryMetadata)1