use of org.apache.cayenne.dba.sybase.SybaseAdapter in project cayenne by apache.
the class DefaultDbAdapterFactoryTest method testCreatedAdapter_Custom.
@Test
public void testCreatedAdapter_Custom() throws Exception {
DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
nodeDescriptor.setAdapterType(SybaseAdapter.class.getName());
List<DbAdapterDetector> detectors = new ArrayList<DbAdapterDetector>();
Module testModule = binder -> {
ServerModule.contributeProperties(binder);
ServerModule.contributeDefaultTypes(binder);
ServerModule.contributeUserTypes(binder);
ServerModule.contributeTypeFactories(binder);
binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class);
binder.bind(ClassLoaderManager.class).to(DefaultClassLoaderManager.class);
binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
binder.bind(ResourceLocator.class).to(ClassLoaderResourceLocator.class);
binder.bind(Key.get(ResourceLocator.class, Constants.SERVER_RESOURCE_LOCATOR)).to(ClassLoaderResourceLocator.class);
binder.bind(RuntimeProperties.class).to(DefaultRuntimeProperties.class);
binder.bind(BatchTranslatorFactory.class).toInstance(mock(BatchTranslatorFactory.class));
ServerModule.contributeValueObjectTypes(binder);
binder.bind(ValueObjectTypeRegistry.class).to(DefaultValueObjectTypeRegistry.class);
};
Injector injector = DIBootstrap.createInjector(testModule);
DefaultDbAdapterFactory factory = new DefaultDbAdapterFactory(detectors);
injector.injectMembers(factory);
DbAdapter createdAdapter = factory.createAdapter(nodeDescriptor, new MockDataSource());
assertNotNull(createdAdapter);
assertTrue("Unexpected class: " + createdAdapter.getClass().getName(), createdAdapter instanceof SybaseAdapter);
}
Aggregations