assertTrue(dsp.isManaged("ds-foo3"));
}
public void testGetDataSource() throws Exception
{
DataSourceProvider dsp = new DataSourceProviderImpl(null);
DataSource ds = dsp.getDataSource(DS_NAME);
assertNotNull(ds);
Connection con = ds.getConnection();
con.commit();
assertTrue(mds.con.committed);
con = ds.getConnection(null, null);
con.commit();
assertTrue(mds.con.committed);
MyTransactionService mts = new MyTransactionService();
mts.tm.setStatus(Status.STATUS_ACTIVE);
dsp = new DataSourceProviderImpl(null, mts);
ds = dsp.getDataSource(DS_NAME);
assertNotNull(ds);
con = ds.getConnection();
con.commit();
assertTrue(mds.con.committed);
con = ds.getConnection(null, null);
con.commit();
assertTrue(mds.con.committed);
mts.tm.setStatus(Status.STATUS_NO_TRANSACTION);
con = ds.getConnection();
con.commit();
assertTrue(mds.con.committed);
con = ds.getConnection(null, null);
con.commit();
assertTrue(mds.con.committed);
InitParams params = new InitParams();
ValueParam paramConf = new ValueParam();
paramConf.setName(DataSourceProviderImpl.PARAM_ALWAYS_MANAGED);
paramConf.setValue("true");
params.addParameter(paramConf);
dsp = new DataSourceProviderImpl(params, mts);
ds = dsp.getDataSource(DS_NAME);
assertNotNull(ds);
mts.tm.setStatus(Status.STATUS_ACTIVE);
con = ds.getConnection();
con.commit();
assertFalse(mds.con.committed);
con = ds.getConnection(null, null);
con.commit();
assertFalse(mds.con.committed);
mts.tm.setStatus(Status.STATUS_NO_TRANSACTION);
con = ds.getConnection();
con.commit();
assertTrue(mds.con.committed);
con = ds.getConnection(null, null);
con.commit();
assertTrue(mds.con.committed);
paramConf = new ValueParam();
paramConf.setName(DataSourceProviderImpl.PARAM_CHECK_TX);
paramConf.setValue("false");
params.addParameter(paramConf);
dsp = new DataSourceProviderImpl(params, mts);
ds = dsp.getDataSource(DS_NAME);
assertNotNull(ds);
mts.tm.setStatus(Status.STATUS_ACTIVE);
con = ds.getConnection();
con.commit();
assertFalse(mds.con.committed);