Search in sources :

Example 1 with DataSourceFactory

use of org.apache.cayenne.configuration.server.DataSourceFactory in project cayenne by apache.

the class DefaultDbImportActionTest method buildDbImportAction.

private DefaultDbImportAction buildDbImportAction(FileProjectSaver projectSaver, DataMapLoader mapLoader, final DbLoader dbLoader) throws Exception {
    Logger log = mock(Logger.class);
    when(log.isDebugEnabled()).thenReturn(true);
    when(log.isInfoEnabled()).thenReturn(true);
    DbAdapter dbAdapter = mock(DbAdapter.class);
    DbAdapterFactory adapterFactory = mock(DbAdapterFactory.class);
    when(adapterFactory.createAdapter((DataNodeDescriptor) any(), (DataSource) any())).thenReturn(dbAdapter);
    DataSourceFactory dataSourceFactory = mock(DataSourceFactory.class);
    DataSource mock = mock(DataSource.class);
    when(dataSourceFactory.getDataSource((DataNodeDescriptor) any())).thenReturn(mock);
    MergerTokenFactoryProvider mergerTokenFactoryProvider = mock(MergerTokenFactoryProvider.class);
    when(mergerTokenFactoryProvider.get((DbAdapter) any())).thenReturn(new DefaultMergerTokenFactory());
    DataChannelDescriptorLoader dataChannelDescriptorLoader = mock(DataChannelDescriptorLoader.class);
    return new DefaultDbImportAction(log, projectSaver, dataSourceFactory, adapterFactory, mapLoader, mergerTokenFactoryProvider, dataChannelDescriptorLoader) {

        protected DbLoader createDbLoader(DbAdapter adapter, Connection connection, DbImportConfiguration config) {
            return dbLoader;
        }
    };
}
Also used : DbAdapterFactory(org.apache.cayenne.configuration.server.DbAdapterFactory) DataSourceFactory(org.apache.cayenne.configuration.server.DataSourceFactory) DbAdapter(org.apache.cayenne.dba.DbAdapter) DefaultMergerTokenFactory(org.apache.cayenne.dbsync.merge.factory.DefaultMergerTokenFactory) DataChannelDescriptorLoader(org.apache.cayenne.configuration.DataChannelDescriptorLoader) Connection(java.sql.Connection) Logger(org.slf4j.Logger) MergerTokenFactoryProvider(org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider) DataSource(javax.sql.DataSource)

Aggregations

Connection (java.sql.Connection)1 DataSource (javax.sql.DataSource)1 DataChannelDescriptorLoader (org.apache.cayenne.configuration.DataChannelDescriptorLoader)1 DataSourceFactory (org.apache.cayenne.configuration.server.DataSourceFactory)1 DbAdapterFactory (org.apache.cayenne.configuration.server.DbAdapterFactory)1 DbAdapter (org.apache.cayenne.dba.DbAdapter)1 DefaultMergerTokenFactory (org.apache.cayenne.dbsync.merge.factory.DefaultMergerTokenFactory)1 MergerTokenFactoryProvider (org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider)1 Logger (org.slf4j.Logger)1