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.ArrayList;
15 import java.util.concurrent.ConcurrentSkipListSet;
17 import org.junit.Test;
18 import org.simantics.db.ReadGraph;
19 import org.simantics.db.Resource;
20 import org.simantics.db.Session;
21 import org.simantics.db.exception.DatabaseException;
22 import org.simantics.db.procedure.SyncSetListener;
23 import org.simantics.db.testing.base.ExistingDatabaseTest;
24 import org.simantics.layer0.Layer0;
26 public class SyncAsyncSyncTest6 extends ExistingDatabaseTest {
29 public void test() throws Exception {
31 Session session = getSession();
33 final ConcurrentSkipListSet<String> names = new ConcurrentSkipListSet<String>();
34 final ArrayList<Resource> resources = new ArrayList<Resource>();
35 final Resource root = SyncAsyncSyncUtils.createNames(session, names, resources);
37 session.syncRequest(new TestReadRequest() {
40 public void run(ReadGraph graph) {
41 Layer0 b = Layer0.getInstance(graph);
42 graph.forObjectSet(root, b.ConsistsOf, new SyncSetListener<Resource>() {
45 public void add(ReadGraph graph, final Resource resource) throws DatabaseException {
46 Layer0 b = Layer0.getInstance(graph);
47 names.remove(graph.getRelatedValue(resource, b.HasName));
52 public void remove(ReadGraph graph, Resource result) throws DatabaseException {
56 public void exception(ReadGraph graph, Throwable t) {
60 public boolean isDisposed() {
69 assert(names.isEmpty());