Search in sources :

Example 1 with DefaultRowReaderFactory

use of org.apache.cayenne.access.jdbc.reader.DefaultRowReaderFactory 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"));
}
Also used : MockStatement(com.mockrunner.mock.jdbc.MockStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) MockConnection(com.mockrunner.mock.jdbc.MockConnection) MockResultSet(com.mockrunner.mock.jdbc.MockResultSet) MockConnection(com.mockrunner.mock.jdbc.MockConnection) DataRow(org.apache.cayenne.DataRow) ExtendedTypeMap(org.apache.cayenne.access.types.ExtendedTypeMap) DefaultRowReaderFactory(org.apache.cayenne.access.jdbc.reader.DefaultRowReaderFactory) MockQueryMetadata(org.apache.cayenne.query.MockQueryMetadata) DbAdapter(org.apache.cayenne.dba.DbAdapter) MockStatement(com.mockrunner.mock.jdbc.MockStatement) Test(org.junit.Test)

Example 2 with DefaultRowReaderFactory

use of org.apache.cayenne.access.jdbc.reader.DefaultRowReaderFactory in project cayenne by apache.

the class SchemaBuilder method initNode.

private void initNode(DataMap map) {
    DataNode node = new DataNode(map.getName());
    node.setJdbcEventLogger(jdbcEventLogger);
    node.setAdapter(dbAdapter);
    node.setDataSource(dataSourceFactory.getSharedDataSource());
    // setup test extended types
    node.getAdapter().getExtendedTypes().registerType(new StringET1ExtendedType());
    // tweak mapping with a delegate
    for (Procedure proc : map.getProcedures()) {
        unitDbAdapter.tweakProcedure(proc);
    }
    filterDataMap(map);
    node.addDataMap(map);
    node.setSchemaUpdateStrategy(new SkipSchemaUpdateStrategy());
    node.setRowReaderFactory(new DefaultRowReaderFactory());
    node.setBatchTranslatorFactory(new DefaultBatchTranslatorFactory());
    node.setSelectTranslatorFactory(new DefaultSelectTranslatorFactory());
    domain.addNode(node);
}
Also used : DefaultRowReaderFactory(org.apache.cayenne.access.jdbc.reader.DefaultRowReaderFactory) SkipSchemaUpdateStrategy(org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy) DefaultSelectTranslatorFactory(org.apache.cayenne.access.translator.select.DefaultSelectTranslatorFactory) DataNode(org.apache.cayenne.access.DataNode) StringET1ExtendedType(org.apache.cayenne.testdo.extended_type.StringET1ExtendedType) Procedure(org.apache.cayenne.map.Procedure) DefaultBatchTranslatorFactory(org.apache.cayenne.access.translator.batch.DefaultBatchTranslatorFactory)

Aggregations

DefaultRowReaderFactory (org.apache.cayenne.access.jdbc.reader.DefaultRowReaderFactory)2 MockConnection (com.mockrunner.mock.jdbc.MockConnection)1 MockResultSet (com.mockrunner.mock.jdbc.MockResultSet)1 MockStatement (com.mockrunner.mock.jdbc.MockStatement)1 Connection (java.sql.Connection)1 Statement (java.sql.Statement)1 DataRow (org.apache.cayenne.DataRow)1 DataNode (org.apache.cayenne.access.DataNode)1 SkipSchemaUpdateStrategy (org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy)1 DefaultBatchTranslatorFactory (org.apache.cayenne.access.translator.batch.DefaultBatchTranslatorFactory)1 DefaultSelectTranslatorFactory (org.apache.cayenne.access.translator.select.DefaultSelectTranslatorFactory)1 ExtendedTypeMap (org.apache.cayenne.access.types.ExtendedTypeMap)1 DbAdapter (org.apache.cayenne.dba.DbAdapter)1 Procedure (org.apache.cayenne.map.Procedure)1 MockQueryMetadata (org.apache.cayenne.query.MockQueryMetadata)1 StringET1ExtendedType (org.apache.cayenne.testdo.extended_type.StringET1ExtendedType)1 Test (org.junit.Test)1