Hi All,
I have a test case where, in the setUp method, I create a hypersonic
database (random dbalias), run the table set up scripts, run my tests
(using dbunit) then, in the tearDown method I swap out the descriptor
and delete the database in preparation for the next test.
I'm having a problem where the JdbcConnectionDescriptor is successfully
replaced (I can see the one to the new dbalias being loaded), however
when I apply the scripts it tries to apply to the previous database (I'm
guessing it's pulling a connection from the pool that is still
associated with the old database?)...both JdbcConnectionDescriptor
objects are associated with the same jcdAlias. Code is below, I would
really appreciate if anyone has any thoughts?
Cheers
Adam
public synchronized void setUp() throws Exception{
log.debug("Creating descriptor.");
String tmpDir = System.getProperty("test.tmp.dir");
if(tmpDir == null) tmpDir = System.getProperty("tmp.dir");
if(tmpDir == null) {
tmpDir = System.getProperty("user.home") + File.separator +
".testing";
final File tmpDirFile = new File(tmpDir);
if(!tmpDirFile.exists()) tmpDirFile.mkdir();
}
descriptor = new JdbcConnectionDescriptor();
descriptor.setDefaultConnection(false);
descriptor.setJcdAlias("certificate-manager");
descriptor.setDbms("hsqldb");
descriptor.setJdbcLevel(2.0);
descriptor.setDriver("org.hsqldb.jdbcDriver");
descriptor.setProtocol("jdbc");
descriptor.setSubProtocol("hsqldb");
filePrefix = tmpDir + File.separator + "test" + rnd.nextInt();
log.debug("Test Database Prefix and Loc: " + filePrefix);
descriptor.setDbAlias("file:" + filePrefix);
descriptor.setUserName("sa");
descriptor.setPassWord("");
MetadataManager.getInstance().connectionRepository().addDescriptor(descriptor);
final IDatabaseConnection connection = getConnection();
final InputStream in =
Thread.currentThread().getContextClassLoader().getResourceAsStream(
"/com/infocomp/ssl/certificatemanager/scripts/hsqldb/database-schema.sql"
);
log.debug("Script input stream: " + in);
applyScript(
IOUtils.toString(in),
connection.getConnection()
);
}
public synchronized void tearDown(){
MetadataManager.getInstance().connectionRepository().removeDescriptor(descriptor);
releaseAllInstances();
if(log.isDebugEnabled()){
log.debug("Inspecting connection repository.");
final ConnectionRepository repository =
MetadataManager.getInstance().connectionRepository();
for(JdbcConnectionDescriptor descriptor :
(List<JdbcConnectionDescriptor>)repository.getAllDescriptor()){
log.debug("Active Descriptor: " +
descriptor.getJcdAlias() + " is connected to " +
descriptor.getDbAlias());
}
}
final File logFile = new File(filePrefix + ".log");
final File propertiesFile = new File(filePrefix +
".properties");
logFile.delete();
propertiesFile.delete();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]