1 package org.simantics.db.tests.regression.bugs;
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;
30 public class Issue3288Test2 extends ExistingDatabaseTest {
32 public void test() throws DatabaseException {
33 getSession().syncRequest(new Read());
35 private static class Read extends ReadRequest {
37 public void run(ReadGraph graph) throws DatabaseException {
38 Layer0 l0 = Layer0.getInstance(graph);
39 Resource rl = graph.getRootLibrary();
40 Collection<Resource> rs = graph.getObjects(rl, l0.IsRelatedTo);
41 Set<Resource> done = new HashSet<Resource>();
42 Set<Resource> todo = new HashSet<Resource>();
45 while (!todo.isEmpty()) {
46 Resource r = todo.iterator().next();
49 Collection<Resource> rs2 = graph.getObjects(r, l0.IsRelatedTo);
50 for (Resource rr : rs2)
51 if (!done.contains(rr))
54 System.out.println("" + done.size());