]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/clusterControl/CachedDirectPredicatesWithNoCluster.java
Added missing org.simantics.db.{tests,testing} plug-ins.
[simantics/platform.git] / tests / org.simantics.db.tests / src / org / simantics / db / tests / api / support / clusterControl / CachedDirectPredicatesWithNoCluster.java
diff --git a/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/clusterControl/CachedDirectPredicatesWithNoCluster.java b/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/clusterControl/CachedDirectPredicatesWithNoCluster.java
new file mode 100644 (file)
index 0000000..19091b5
--- /dev/null
@@ -0,0 +1,74 @@
+package org.simantics.db.tests.api.support.clusterControl;
+
+import org.junit.Test;
+import org.simantics.db.AsyncReadGraph;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Session;
+import org.simantics.db.common.procedure.adapter.AsyncProcedureAdapter;
+import org.simantics.db.common.procedure.adapter.ListenerAdapter;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.procedure.AsyncProcedure;
+import org.simantics.db.request.AsyncRead;
+import org.simantics.db.request.Read;
+import org.simantics.db.service.ClusterControl;
+import org.simantics.db.testing.base.ExistingDatabaseTest;
+import org.simantics.layer0.Layer0;
+
+public class CachedDirectPredicatesWithNoCluster extends ExistingDatabaseTest {
+    
+    @Test
+    public void test() throws DatabaseException {
+        
+        Session session = getSession();
+        
+        final Layer0 L0 = Layer0.getInstance(session);
+        
+        session.syncRequest(new Read<Boolean>() {
+
+            @Override
+            public Boolean perform(ReadGraph graph) throws DatabaseException {
+                Layer0 L0 = Layer0.getInstance(graph);
+                return graph.hasStatement(L0.Entity);
+            }
+            
+        }, new ListenerAdapter<Boolean>());
+        
+        ClusterControl support = getSession().getService(ClusterControl.class);
+        support.collectClusters(Integer.MAX_VALUE);
+        
+        session.syncRequest(new AsyncRead<Boolean>() {
+
+            @Override
+            public void perform(AsyncReadGraph graph, AsyncProcedure<Boolean> procedure) {
+                graph.forHasStatement(L0.Entity, procedure);
+            }
+            
+            @Override
+            public int threadHash() {
+                return hashCode();
+            }
+
+            @Override
+            public int getFlags() {
+                return 0;
+            }
+            
+        }, new AsyncProcedureAdapter<Boolean>() {
+
+            @Override
+            public void execute(AsyncReadGraph graph, Boolean result) {
+                if (DEBUG)
+                    System.err.println("exec: " + result);
+            }
+            
+            @Override
+            public void exception(AsyncReadGraph graph, Throwable t) {
+                if (DEBUG)
+                    System.err.println("exception: " + t);
+            }
+            
+        });
+
+    }
+    
+}