1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.tests.api.request.misc;
14 import org.junit.Test;
15 import org.simantics.db.ReadGraph;
16 import org.simantics.db.Resource;
17 import org.simantics.db.Session;
18 import org.simantics.db.Statement;
19 import org.simantics.db.common.primitiverequest.PossibleStatement;
20 import org.simantics.db.exception.DatabaseException;
21 import org.simantics.db.procedure.SyncListener;
22 import org.simantics.db.testing.base.ExistingDatabaseTest;
23 import org.simantics.layer0.Layer0;
25 public class SyncAsyncSyncTest9 extends ExistingDatabaseTest {
28 public void test() throws Exception {
30 Session session = getSession();
32 session.syncRequest(new TestReadRequest() {
35 public void run(ReadGraph g) throws DatabaseException {
37 final Layer0 b = Layer0.getInstance(g);
39 g.forPossibleObject(g.getRootLibrary(), b.InstanceOf, new SyncListener<Resource>() {
42 public void execute(ReadGraph graph, Resource type) throws DatabaseException {
44 graph.asyncRequest(new PossibleStatement(type, b.InstanceOf), new SyncListener<Statement>() {
47 public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {
51 public void execute(ReadGraph graph, Statement result) throws DatabaseException {
55 public boolean isDisposed() {
61 // graph.syncRequest(new ForObjectSet(type, b.Inherits, new SyncSetListener<Resource>() {
64 // public void add(ReadGraph graph, Resource result) throws DatabaseException {
66 // System.out.println(GraphUtils.getReadableName(graph, result));
68 // graph.asyncRequest(new PossibleStatement(result, b.InstanceOf), new SyncListener<Statement>() {
71 // public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {
75 // public void execute(ReadGraph graph, Statement result) throws DatabaseException {
79 // public boolean isDisposed() {
88 // public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {
93 // public void remove(ReadGraph graph, Resource result) throws DatabaseException {
98 // public boolean isDisposed() {
107 public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {
108 throwable.printStackTrace();
113 public boolean isDisposed() {