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;
16 import org.junit.Test;
17 import org.simantics.db.AsyncReadGraph;
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.impl.query.CacheEntry;
23 import org.simantics.db.impl.service.QueryDebug;
24 import org.simantics.db.procedure.AsyncMultiListener;
25 import org.simantics.db.request.Read;
26 import org.simantics.db.testing.base.SimpleBase;
27 import org.simantics.layer0.Layer0;
29 public class RequestParentTest6 extends SimpleBase {
32 public void test() throws Exception {
34 Session session = getSession();
36 QueryDebug debug = session.getService(QueryDebug.class);
38 class Request implements Read<Object> {
41 public Object perform(ReadGraph graph) throws DatabaseException {
47 final Request request = new Request();
49 session.syncRequest(new TestReadRequest() {
52 public void run(ReadGraph graph) throws Throwable {
53 Layer0 l0 = Layer0.getInstance(graph);
54 graph.forEachObject(rl, l0.InstanceOf, new AsyncMultiListener<Resource>() {
57 public void exception(AsyncReadGraph graph, Throwable t) {
61 public void execute(AsyncReadGraph graph, Resource result) {
62 graph.asyncRequest(request);
66 public boolean isDisposed() {
71 public void finished(AsyncReadGraph graph) {
80 Set<CacheEntry> parents = debug.getParents(request);
81 if(!parents.isEmpty())fail("Request2 should not have parents");