1 package org.simantics.db.testing.impl;
2 /*******************************************************************************
3 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
11 * VTT Technical Research Centre of Finland - initial API and implementation
12 *******************************************************************************/
15 import java.util.Collection;
16 import java.util.HashSet;
19 import org.junit.Test;
20 import org.simantics.db.ReadGraph;
21 import org.simantics.db.Resource;
22 import org.simantics.db.common.request.ReadRequest;
23 import org.simantics.db.exception.DatabaseException;
24 import org.simantics.db.testing.base.ExistingDatabaseTest;
25 import org.simantics.layer0.Layer0;
26 public class TempTest extends ExistingDatabaseTest {
28 public void test() throws DatabaseException {
29 final Resource rl = getSession().getRootLibrary();
30 getSession().syncRequest(new ReadRequest() {
32 public void run(ReadGraph g) throws DatabaseException {
33 Layer0 b = Layer0.getInstance(g);
34 Collection<Resource> rs = g.getObjects(rl, b.IsRelatedTo);
35 Set<Resource> done = new HashSet<Resource>();
36 Set<Resource> todo = new HashSet<Resource>();
39 while (!todo.isEmpty()) {
40 Resource r = todo.iterator().next();
43 Collection<Resource> rs2 = g.getObjects(r, b.IsRelatedTo);
44 for (Resource rr : rs2)
45 if (!done.contains(rr))
48 System.out.println("" + done.size());
50 System.out.println("" + done.size());