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 java.util.HashSet;
17 import org.junit.Test;
18 import org.simantics.databoard.Bindings;
19 import org.simantics.db.ReadGraph;
20 import org.simantics.db.Resource;
21 import org.simantics.db.Session;
22 import org.simantics.db.common.primitiverequest.ForObjectSet;
23 import org.simantics.db.exception.DatabaseException;
24 import org.simantics.db.procedure.SyncSetListener;
25 import org.simantics.db.testing.base.ExistingDatabaseTest;
26 import org.simantics.layer0.Layer0;
28 public class SyncAsyncSyncTest8 extends ExistingDatabaseTest {
31 public void test() throws Exception {
33 Session session = getSession();
35 final Set<String> expected = new HashSet<String>();
37 session.syncRequest(new TestReadRequest() {
40 public void run(ReadGraph g) throws DatabaseException {
42 final Layer0 b = Layer0.getInstance(g);
44 g.syncRequest(new ForObjectSet(g.getRootLibrary(), b.InstanceOf, new SyncSetListener<Resource>() {
47 public void add(ReadGraph graph, Resource type) throws DatabaseException {
49 graph.syncRequest(new ForObjectSet(type, b.Inherits, new SyncSetListener<Resource>() {
52 public void add(ReadGraph graph, Resource result) throws DatabaseException {
54 expected.remove(graph.getRelatedValue(result, b.HasName, Bindings.STRING));
59 public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {
64 public void remove(ReadGraph graph, Resource result) throws DatabaseException {
69 public boolean isDisposed() {
78 public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {
83 public void remove(ReadGraph graph, Resource result) throws DatabaseException {
88 public boolean isDisposed() {
98 assert(expected.isEmpty());