]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.testing/src/org/simantics/db/testing/cases/FreshDatabaseTest.java
Clean up also indexes during DB unit test environment initialization
[simantics/platform.git] / bundles / org.simantics.db.testing / src / org / simantics / db / testing / cases / FreshDatabaseTest.java
1 package org.simantics.db.testing.cases;
2 /*******************************************************************************
3  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4  * in Industry THTH ry.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  *     VTT Technical Research Centre of Finland - initial API and implementation
12  *******************************************************************************/
13
14
15 import org.junit.After;
16 import org.junit.Before;
17 import org.simantics.SimanticsPlatform;
18 import org.simantics.db.Resource;
19 import org.simantics.db.Session;
20 import org.simantics.db.testing.common.DatabaseState;
21 import org.simantics.db.testing.common.TestBase;
22 import org.simantics.db.testing.common.TestSettings;
23 import org.simantics.db.testing.common.Tests;
24
25 public class FreshDatabaseTest extends TestBase {
26
27     public void configure(TestSettings settings) {
28
29     }
30
31     @Before
32     public void setUp() throws Exception {
33         TestBase.printStart(this);
34         TestSettings testSettings = TestSettings.getInstanceUnsafe();
35         configure(testSettings);
36         state = Tests.newSimanticsWorkspace(testSettings, null);
37         super.setUp();
38     }
39
40     @After
41     public void tearDown() throws Exception {
42         Tests.shutdown(state);
43         super.tearDown();
44     }
45
46     public Resource getProjectResource() {
47         return SimanticsPlatform.INSTANCE.projectResource;
48     }
49
50     protected Session getSession() {
51         return state.getSession();
52     }
53
54     public DatabaseState getState() {
55         return state;
56     }
57
58     public void reconnect() throws Exception {
59         setPrintStart(false);
60         tearDown();
61         setUp();
62         setPrintStart(true);
63     }
64 }