use of org.infinispan.persistence.jdbc.common.configuration.SimpleConnectionFactoryConfiguration in project infinispan by infinispan.
the class SimpleConnectionFactory method start.
@Override
public void start(ConnectionFactoryConfiguration config, ClassLoader classLoader) throws PersistenceException {
SimpleConnectionFactoryConfiguration factoryConfiguration;
if (config instanceof SimpleConnectionFactoryConfiguration) {
factoryConfiguration = (SimpleConnectionFactoryConfiguration) config;
} else {
throw new PersistenceException("ConnectionFactoryConfiguration has to be an instance of " + "SimpleConnectionFactoryConfiguration.");
}
loadDriver(factoryConfiguration.driverClass(), classLoader);
this.connectionUrl = factoryConfiguration.connectionUrl();
this.userName = factoryConfiguration.username();
this.password = factoryConfiguration.password();
if (log.isTraceEnabled()) {
log.tracef("Starting connection %s", this);
}
}
use of org.infinispan.persistence.jdbc.common.configuration.SimpleConnectionFactoryConfiguration in project infinispan by infinispan.
the class TableManagerTest method createConnection.
@BeforeClass
public void createConnection() throws Exception {
JdbcStringBasedStoreConfigurationBuilder storeBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(false).persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class);
UnitTestDatabaseManager.setDialect(storeBuilder);
UnitTestDatabaseManager.buildTableManipulation(storeBuilder.table());
ConnectionFactoryConfiguration factoryConfiguration = UnitTestDatabaseManager.configureUniqueConnectionFactory(storeBuilder).create();
if (factoryConfiguration instanceof SimpleConnectionFactoryConfiguration) {
SimpleConnectionFactoryConfiguration simpleConfiguration = (SimpleConnectionFactoryConfiguration) factoryConfiguration;
connectionFactory = ConnectionFactory.getConnectionFactory(SimpleConnectionFactory.class);
connectionFactory.start(simpleConfiguration, connectionFactory.getClass().getClassLoader());
connection = connectionFactory.getConnection();
} else if (factoryConfiguration instanceof PooledConnectionFactoryConfiguration) {
PooledConnectionFactoryConfiguration pooledConfiguration = (PooledConnectionFactoryConfiguration) factoryConfiguration;
connectionFactory = ConnectionFactory.getConnectionFactory(PooledConnectionFactory.class);
connectionFactory.start(pooledConfiguration, connectionFactory.getClass().getClassLoader());
connection = connectionFactory.getConnection();
}
Cache<?, ?> cache = mock(Cache.class);
when(cache.getCacheConfiguration()).thenReturn(new ConfigurationBuilder().build());
JdbcStringBasedStoreConfiguration config = storeBuilder.create();
GlobalConfiguration globalConfiguration = mock(GlobalConfiguration.class);
when(globalConfiguration.classLoader()).thenReturn(getClass().getClassLoader());
ctx = new DummyInitializationContext(config, cache, new TestObjectStreamMarshaller(), null, null, null, globalConfiguration, null, null, null);
tableManager = TableManagerFactory.getManager(ctx, connectionFactory, config, "aName");
}
Aggregations