use of org.apache.cayenne.configuration.server.DbAdapterFactory in project cayenne by apache.
the class CayenneTask method getAdapter.
protected DbAdapter getAdapter(Injector injector, DataSource dataSource) throws Exception {
DbAdapterFactory adapterFactory = injector.getInstance(DbAdapterFactory.class);
DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
nodeDescriptor.setAdapterType(adapter);
return adapterFactory.createAdapter(nodeDescriptor, dataSource);
}
use of org.apache.cayenne.configuration.server.DbAdapterFactory in project cayenne by apache.
the class ToolsModuleTest method testDbApdater.
@Test
public void testDbApdater() throws Exception {
Logger log = mock(Logger.class);
Injector i = DIBootstrap.createInjector(new ToolsModule(log));
DbAdapterFactory factory = i.getInstance(DbAdapterFactory.class);
DataNodeDescriptor nodeDescriptor = mock(DataNodeDescriptor.class);
DataSource dataSource = mock(DataSource.class);
assertTrue(factory.createAdapter(nodeDescriptor, dataSource) instanceof AutoAdapter);
}
use of org.apache.cayenne.configuration.server.DbAdapterFactory 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