X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=tests%2Forg.simantics.db.tests%2Fsrc%2Forg%2Fsimantics%2Fdb%2Ftests%2Fapi%2Fsupport%2FclusterControl%2FCachedDirectPredicatesWithNoCluster.java;fp=tests%2Forg.simantics.db.tests%2Fsrc%2Forg%2Fsimantics%2Fdb%2Ftests%2Fapi%2Fsupport%2FclusterControl%2FCachedDirectPredicatesWithNoCluster.java;h=19091b51862b5dcc552d70f80d8516d86aed8271;hb=67fd62f9c742337ec80eef658192db198a0efaac;hp=0000000000000000000000000000000000000000;hpb=cde82ba81327d5515fdca362f7f4c70f5103ae80;p=simantics%2Fplatform.git 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 index 000000000..19091b518 --- /dev/null +++ b/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/clusterControl/CachedDirectPredicatesWithNoCluster.java @@ -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() { + + @Override + public Boolean perform(ReadGraph graph) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + return graph.hasStatement(L0.Entity); + } + + }, new ListenerAdapter()); + + ClusterControl support = getSession().getService(ClusterControl.class); + support.collectClusters(Integer.MAX_VALUE); + + session.syncRequest(new AsyncRead() { + + @Override + public void perform(AsyncReadGraph graph, AsyncProcedure procedure) { + graph.forHasStatement(L0.Entity, procedure); + } + + @Override + public int threadHash() { + return hashCode(); + } + + @Override + public int getFlags() { + return 0; + } + + }, new AsyncProcedureAdapter() { + + @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); + } + + }); + + } + +}