1 package org.simantics.db.testing.common;
4 import java.io.IOException;
5 import java.util.Properties;
7 import org.eclipse.core.runtime.Platform;
8 import org.simantics.db.Driver;
9 import org.simantics.db.Driver.Management;
10 import org.simantics.db.Manager;
11 import org.simantics.db.ServerI;
12 import org.simantics.db.Session;
13 import org.simantics.db.exception.DatabaseException;
14 import org.simantics.db.indexing.DatabaseIndexing;
17 * ProCore specific test handler.
20 public class AcornTestHandler {
21 // private final TestSettings testSettings;
22 private final Driver driver;
23 private final File dbFolder;
25 AcornTestHandler(TestSettings testSettings, String dbFolderName) throws DatabaseException {
26 // this.testSettings = testSettings;
27 driver = Manager.getDriver("acorn");
29 throw new IllegalArgumentException("No driver found for acorn!");
30 if (null == dbFolderName)
31 dbFolder = Platform.getLocation().append("db").toFile();
33 dbFolder = new File(dbFolderName);
36 void initNew() throws DatabaseException {
37 Management m = getManagement();
45 void initIfNeccessary() throws DatabaseException {
46 Management m = getManagement();
53 private void deleteIndexes() throws DatabaseException {
55 DatabaseIndexing.deleteAllIndexes();
56 } catch (IOException e) {
57 throw new DatabaseException("Failed to delete all existing indexes", e);
61 public Session getSession() throws DatabaseException {
62 // Note that we normally user authentication agent for user
64 Properties props = new Properties();
65 props.setProperty("user", "Default User");
66 props.setProperty("password", "");
67 return driver.getSession(dbFolder.getAbsolutePath(), props);
70 public ServerI getServer() throws DatabaseException {
71 return driver.getServer(dbFolder.getAbsolutePath(), null);
74 public Management getManagement() throws DatabaseException {
75 return driver.getManagement(dbFolder.getAbsolutePath(), null);