String testName = resolveTestName();
TestRunnable runnable = testRunnables.get(testName);
+ long start = System.nanoTime();
if (timeout > -1) {
+ LOGGER.info("Running test {} with a timeout of {} seconds", testName, timeout); //$NON-NLS-1$
Timer timer = new Timer();
timer.schedule(new TimerTask() {
}, timeout*1000);
try {
runnable.run();
+ long end = System.nanoTime();
+ LOGGER.info("Completed test {} execution in {} seconds", testName, String.format("%.3f", (end-start)*1e-9)); //$NON-NLS-1$
} catch (Exception e) {
LOGGER.error("Failed to run test {} runnable {}", testName, runnable, e);
} finally {
timer.cancel();
}
} else {
+ LOGGER.info("Running test {} without timeout", testName); //$NON-NLS-1$
try {
runnable.run();
+ long end = System.nanoTime();
+ LOGGER.info("Completed test {} execution in {} seconds", testName, String.format("%.3f", (end-start)*1e-9)); //$NON-NLS-1$
} catch (Exception e) {
LOGGER.error("Failed to run test {} runnable {}", testName, runnable, e);
}
-package org.simantics.db.testing.cases;
/*******************************************************************************
* Copyright (c) 2007, 2010 Association for Decentralized Information Management
* in Industry THTH ry.
* Contributors:
* VTT Technical Research Centre of Finland - initial API and implementation
*******************************************************************************/
-
+package org.simantics.db.testing.cases;
import org.junit.After;
import org.junit.Before;
public class FreshDatabaseTest extends TestBase {
public void configure(TestSettings settings) {
-
}
@Before
import org.simantics.db.testing.impl.Configuration;
public class FreshWorkspaceTest extends TestBase {
-
+
public void configure(TestSettings settins) {
}
-
+
@Before
public void setUp() throws Exception {
-
TestBase.printStart(this);
configure(TestSettings.getInstanceUnsafe());
state = Tests.freshWorkspace(Configuration.get().coreDir, initialWorkspaceFiles);
super.setUp();
}
-
- @After
- public void tearDown() throws Exception {
-
- Tests.shutdown(state);
- super.tearDown();
- }
+
+ @After
+ public void tearDown() throws Exception {
+ Tests.shutdown(state);
+ super.tearDown();
+ }
+
}
static boolean printStart = true;
public static final ArrayList<String> initialWorkspaceFiles = FileUtils.createFileFilter(Platform.getLocation().toFile(), null);
public static void printStart(Object t) {
- if(printStart) LOGGER.info("Test is {}", t.getClass().getName());
+ if(printStart) LOGGER.info("Test class is {}", t.getClass().getName());
}
protected static void setPrintStart(boolean value) {
printStart = value;
}
public void resetDatabase(IProgressMonitor monitor) throws PlatformException {
+ // TODO: fix this to use Path APIs
File dbLocation = Platform.getLocation().append("db").toFile();
if(!dbLocation.exists()) return;
try { // Load driver
- Driver driver = Manager.getDriver("procore");
+ Driver driver = Manager.getDriver("acorn");
Management management = driver.getManagement(dbLocation.getAbsolutePath(), null);
management.delete();
} catch (DatabaseException e) {