]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.testing/src/org/simantics/db/testing/base/WriteReadTest.java
Added missing org.simantics.db.{tests,testing} plug-ins.
[simantics/platform.git] / bundles / org.simantics.db.testing / src / org / simantics / db / testing / base / WriteReadTest.java
1 package org.simantics.db.testing.base;
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.Test;
16 import org.simantics.db.ReadGraph;
17 import org.simantics.db.Resource;
18 import org.simantics.db.Session;
19 import org.simantics.db.WriteGraph;
20 import org.simantics.db.common.request.ReadRequest;
21 import org.simantics.db.common.request.WriteRequest;
22 import org.simantics.db.exception.DatabaseException;
23
24 abstract public class WriteReadTest extends ExistingDatabaseTest {
25     protected Resource written;
26     @Test
27     public void test() throws Exception {
28         Session s = getSession();
29         s.syncRequest(new WriteRequest() {
30
31                 @Override
32                 public void perform(WriteGraph graph) throws DatabaseException {
33                         written = graph.newResource();
34                         write(graph);
35                 }
36
37         });
38         s.syncRequest(new ReadRequest() {
39
40                 @Override
41                 public void run(ReadGraph graph) throws DatabaseException {
42                         read(graph);
43                 }
44
45         });
46     }
47     protected void write(WriteGraph graph) throws DatabaseException {}
48     protected void read(ReadGraph graph) throws DatabaseException {}
49 }