]> gerrit.simantics Code Review - simantics/platform.git/blob
19091b51862b5dcc552d70f80d8516d86aed8271
[simantics/platform.git] /
1 package org.simantics.db.tests.api.support.clusterControl;
2
3 import org.junit.Test;
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;
16
17 public class CachedDirectPredicatesWithNoCluster extends ExistingDatabaseTest {
18     
19     @Test
20     public void test() throws DatabaseException {
21         
22         Session session = getSession();
23         
24         final Layer0 L0 = Layer0.getInstance(session);
25         
26         session.syncRequest(new Read<Boolean>() {
27
28             @Override
29             public Boolean perform(ReadGraph graph) throws DatabaseException {
30                 Layer0 L0 = Layer0.getInstance(graph);
31                 return graph.hasStatement(L0.Entity);
32             }
33             
34         }, new ListenerAdapter<Boolean>());
35         
36         ClusterControl support = getSession().getService(ClusterControl.class);
37         support.collectClusters(Integer.MAX_VALUE);
38         
39         session.syncRequest(new AsyncRead<Boolean>() {
40
41             @Override
42             public void perform(AsyncReadGraph graph, AsyncProcedure<Boolean> procedure) {
43                 graph.forHasStatement(L0.Entity, procedure);
44             }
45             
46             @Override
47             public int threadHash() {
48                 return hashCode();
49             }
50
51             @Override
52             public int getFlags() {
53                 return 0;
54             }
55             
56         }, new AsyncProcedureAdapter<Boolean>() {
57
58             @Override
59             public void execute(AsyncReadGraph graph, Boolean result) {
60                 if (DEBUG)
61                     System.err.println("exec: " + result);
62             }
63             
64             @Override
65             public void exception(AsyncReadGraph graph, Throwable t) {
66                 if (DEBUG)
67                     System.err.println("exception: " + t);
68             }
69             
70         });
71
72     }
73     
74 }