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%2FObjectsWithNoClusterWithCachedRelationInfo.java;fp=tests%2Forg.simantics.db.tests%2Fsrc%2Forg%2Fsimantics%2Fdb%2Ftests%2Fapi%2Fsupport%2FclusterControl%2FObjectsWithNoClusterWithCachedRelationInfo.java;h=0596f765873630e4bfda2f322385b91aa94ec272;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/ObjectsWithNoClusterWithCachedRelationInfo.java b/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/clusterControl/ObjectsWithNoClusterWithCachedRelationInfo.java new file mode 100644 index 000000000..0596f7658 --- /dev/null +++ b/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/clusterControl/ObjectsWithNoClusterWithCachedRelationInfo.java @@ -0,0 +1,49 @@ +package org.simantics.db.tests.api.support.clusterControl; + +import org.junit.Test; +import org.simantics.db.Resource; +import org.simantics.db.Session; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.primitiverequest.PossibleObject; +import org.simantics.db.common.procedure.adapter.ListenerAdapter; +import org.simantics.db.common.request.WriteResultRequest; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.service.ClusterControl; +import org.simantics.db.testing.base.ExistingDatabaseTest; +import org.simantics.layer0.Layer0; + +public class ObjectsWithNoClusterWithCachedRelationInfo extends ExistingDatabaseTest { + + @Test + public void test() throws DatabaseException { + + Session session = getSession(); + + final Layer0 L0 = Layer0.getInstance(session); + + // Create resource in new cluster (not 1) + final Resource res = session.syncRequest(new WriteResultRequest() { + + @Override + public Resource perform(WriteGraph graph) throws DatabaseException { + + Resource res = graph.newResource(); + graph.claim(res, L0.HasName, L0.NameOf, res); + return res; + + } + + }); + + // Cache RelationInfo for HasName + session.syncRequest(new PossibleObject(L0.Entity, L0.HasName), new ListenerAdapter()); + + // Flush clusters + ClusterControl support = getSession().getService(ClusterControl.class); + support.collectClusters(Integer.MAX_VALUE); + + // Request objects for res, now relationinfo is in cache and res has no cluster + session.syncRequest(new PossibleObject(res, L0.HasName)); + + } +}