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;
}
};
}
Aggregations