1 package org.simantics.db.tests.api.support.clusterControl;
4 import org.simantics.db.AsyncReadGraph;
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.Session;
7 import org.simantics.db.common.procedure.adapter.AsyncProcedureAdapter;
8 import org.simantics.db.common.procedure.adapter.ListenerAdapter;
9 import org.simantics.db.exception.DatabaseException;
10 import org.simantics.db.procedure.AsyncProcedure;
11 import org.simantics.db.request.AsyncRead;
12 import org.simantics.db.request.Read;
13 import org.simantics.db.service.ClusterControl;
14 import org.simantics.db.testing.base.ExistingDatabaseTest;
15 import org.simantics.layer0.Layer0;
17 public class CachedDirectPredicatesWithNoCluster extends ExistingDatabaseTest {
20 public void test() throws DatabaseException {
22 Session session = getSession();
24 final Layer0 L0 = Layer0.getInstance(session);
26 session.syncRequest(new Read<Boolean>() {
29 public Boolean perform(ReadGraph graph) throws DatabaseException {
30 Layer0 L0 = Layer0.getInstance(graph);
31 return graph.hasStatement(L0.Entity);
34 }, new ListenerAdapter<Boolean>());
36 ClusterControl support = getSession().getService(ClusterControl.class);
37 support.collectClusters(Integer.MAX_VALUE);
39 session.syncRequest(new AsyncRead<Boolean>() {
42 public void perform(AsyncReadGraph graph, AsyncProcedure<Boolean> procedure) {
43 graph.forHasStatement(L0.Entity, procedure);
47 public int threadHash() {
52 public int getFlags() {
56 }, new AsyncProcedureAdapter<Boolean>() {
59 public void execute(AsyncReadGraph graph, Boolean result) {
61 System.err.println("exec: " + result);
65 public void exception(AsyncReadGraph graph, Throwable t) {
67 System.err.println("exception: " + t);