use of org.apache.derbyTesting.junit.TestConfiguration in project derby by apache.
the class PhaseChanger method setUp.
/**
* Set the phase and boot the database, creating it
* or upgrading it as required. The thread context
* class loader is changed to point to the old
* jar files if required for the phase.
*/
protected void setUp() throws SQLException {
UpgradeChange.phase.set(phase);
UpgradeChange.oldVersion.set(version);
TestConfiguration config = TestConfiguration.getCurrent();
trace = config.doTrace();
if (trace) {
String versStr = ((int[]) UpgradeChange.oldVersion.get())[0] + "." + ((int[]) UpgradeChange.oldVersion.get())[1] + "." + ((int[]) UpgradeChange.oldVersion.get())[2] + "." + ((int[]) UpgradeChange.oldVersion.get())[3];
BaseTestCase.traceit("Test upgrade from: " + versStr + ", phase: " + UpgradeChange.PHASES[phase]);
if (UpgradeChange.PHASES[phase].equals("UPGRADE")) {
BaseTestCase.traceit("Upgrade attributes = " + upgradeAttributes);
}
}
if (loader != null) {
previousLoader = Thread.currentThread().getContextClassLoader();
ClassLoaderTestSetup.setThreadLoader(loader);
}
DataSource ds = JDBCDataSource.getDataSource();
switch(phase) {
case UpgradeChange.PH_POST_HARD_UPGRADE:
// in a setup method.
return;
case UpgradeChange.PH_CREATE:
JDBCDataSource.setBeanProperty(ds, "createDatabase", "create");
break;
case UpgradeChange.PH_HARD_UPGRADE:
JDBCDataSource.setBeanProperty(ds, "connectionAttributes", upgradeAttributes);
break;
default:
break;
}
// Ensure the database exists or upgrade it.
ds.getConnection().close();
}
Aggregations