Search in sources :

Example 1 with DruidDataSourceFactory

use of com.alibaba.druid.pool.DruidDataSourceFactory in project druid by alibaba.

the class DruidDataSourceFactoryTest0 method test_factory_null.

public void test_factory_null() throws Exception {
    DruidDataSourceFactory factory = new DruidDataSourceFactory();
    Assert.assertNull(factory.getObjectInstance(null, null, null, null));
}
Also used : DruidDataSourceFactory(com.alibaba.druid.pool.DruidDataSourceFactory)

Example 2 with DruidDataSourceFactory

use of com.alibaba.druid.pool.DruidDataSourceFactory in project druid by alibaba.

the class DruidDataSourceFactoryTest0 method test_factory_null_1.

public void test_factory_null_1() throws Exception {
    DruidDataSourceFactory factory = new DruidDataSourceFactory();
    Assert.assertNull(factory.getObjectInstance(new Object(), null, null, null));
}
Also used : DruidDataSourceFactory(com.alibaba.druid.pool.DruidDataSourceFactory)

Example 3 with DruidDataSourceFactory

use of com.alibaba.druid.pool.DruidDataSourceFactory in project druid by alibaba.

the class DruidDataSourceFactoryTest method test_factory.

public void test_factory() throws Exception {
    DruidDataSourceFactory factory = new DruidDataSourceFactory();
    Reference ref = new Reference(DataSource.class.getName());
    ref.add(new StringRefAddr(DruidDataSourceFactory.PROP_REMOVEABANDONED, "true"));
    ref.add(new StringRefAddr(DruidDataSourceFactory.PROP_MAXACTIVE, "20"));
    Hashtable<String, String> env = new Hashtable<String, String>();
    dataSource = (DruidDataSource) factory.getObjectInstance(ref, null, null, env);
    Assert.assertTrue(dataSource.isRemoveAbandoned());
    Assert.assertEquals(20, dataSource.getMaxActive());
}
Also used : StringRefAddr(javax.naming.StringRefAddr) Reference(javax.naming.Reference) Hashtable(java.util.Hashtable) DruidDataSourceFactory(com.alibaba.druid.pool.DruidDataSourceFactory) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) DataSource(javax.sql.DataSource)

Example 4 with DruidDataSourceFactory

use of com.alibaba.druid.pool.DruidDataSourceFactory in project druid by alibaba.

the class DruidDataSourceFactoryTest method test_factory.

@SuppressWarnings("serial")
public void test_factory() throws Exception {
    DruidDataSourceFactory factory = new DruidDataSourceFactory();
    Assert.assertNull(factory.getObjectInstance(null, null, null, null));
    Assert.assertNull(factory.getObjectInstance(new Reference("javax.sql.Date"), null, null, null));
    Reference ref = new Reference("javax.sql.DataSource");
    ref.add(new RefAddr("user") {

        @Override
        public Object getContent() {
            return null;
        }
    });
    ref.add(new RefAddr("defaultReadOnly") {

        @Override
        public Object getContent() {
            return Boolean.TRUE;
        }
    });
    factory.getObjectInstance(ref, null, null, new Hashtable<Object, Object>());
}
Also used : RefAddr(javax.naming.RefAddr) Reference(javax.naming.Reference) DruidDataSourceFactory(com.alibaba.druid.pool.DruidDataSourceFactory)

Aggregations

DruidDataSourceFactory (com.alibaba.druid.pool.DruidDataSourceFactory)4 Reference (javax.naming.Reference)2 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)1 Hashtable (java.util.Hashtable)1 RefAddr (javax.naming.RefAddr)1 StringRefAddr (javax.naming.StringRefAddr)1 DataSource (javax.sql.DataSource)1