// This is required because adding Properties to Categories requires a
// Schema Parser in SchemaFactory, even though we have validation off.
Environment.init("/com/volantis/mcs/ibm/ucp/ucp-config.xml");
// Use the in-memory hypersonic db - no background threads!
final HypersonicManager hypersonicMgr = new HypersonicManager(
HypersonicManager.IN_MEMORY_SOURCE);
hypersonicMgr.useCleanupWith(new Executor() {
public void execute() throws Exception {
// Create the database tables.
// todo: this should be refactored to be re-usable, see the
// to do comment in the class comment.
Connection connection = DriverManager.getConnection(
hypersonicMgr.getUrl(),
HypersonicManager.DEFAULT_USERNAME,
HypersonicManager.DEFAULT_PASSWORD);
Statement statement = connection.createStatement();
// Create the device patterns table
String sql = "CREATE TABLE VMDEVICE_PATTERNS ( " +
"PROJECT VARCHAR (255) NOT NULL," +
"NAME VARCHAR (20) NOT NULL," +
"PATTERN VARCHAR (255) NOT NULL," +
"REVISION NUMERIC (9) DEFAULT 0" +
" ) ";
statement.execute(sql);
statement.close();
statement = connection.createStatement();
// Create the device patterns table
sql = "CREATE TABLE VMPOLICY_VALUES ( " +
"PROJECT VARCHAR (255) NOT NULL," +
"NAME VARCHAR (20) NOT NULL," +
"POLICY VARCHAR (200) NOT NULL," +
"VALUE VARCHAR (1024)," +
"REVISION NUMERIC (9) DEFAULT 0" +
" ) ";
statement.execute(sql);
statement.close();
// Note: must leave connection open so that subsequent code
// can find the tables we just created.
final HashMap params = new HashMap();
params.put("repository-type", "jdbc");
// todo: all these values should come from the db manager class.
params.put("odbc-user", HypersonicManager.DEFAULT_USERNAME);
params.put("odbc-password", HypersonicManager.DEFAULT_PASSWORD);
params.put("odbc-source", hypersonicMgr.getSource());
params.put("odbc-vendor", "hypersonic");
// NOTE: our old style devices don't currently use default
// project but we need to provide it or the test fails...
params.put("project", "#DefaultProject");
// params.put("odbc-host", "not used");