X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=tests%2Forg.simantics.db.tests%2Fsrc%2Forg%2Fsimantics%2Fdb%2Ftests%2Fregression%2Fbugs%2FSimanticsBug1659Test1.java;h=1673c89f16f606335d211f39a2193811bd6290aa;hp=768ebf73a8256dbb5629bd0acc432a6139edfca8;hb=0d9b90834ce56b292c00b1a39850ed842c3e4d42;hpb=e5db6157fd8722c946613d4e46d7aaf6bfa92609 diff --git a/tests/org.simantics.db.tests/src/org/simantics/db/tests/regression/bugs/SimanticsBug1659Test1.java b/tests/org.simantics.db.tests/src/org/simantics/db/tests/regression/bugs/SimanticsBug1659Test1.java index 768ebf73a..1673c89f1 100644 --- a/tests/org.simantics.db.tests/src/org/simantics/db/tests/regression/bugs/SimanticsBug1659Test1.java +++ b/tests/org.simantics.db.tests/src/org/simantics/db/tests/regression/bugs/SimanticsBug1659Test1.java @@ -1,12 +1,13 @@ package org.simantics.db.tests.regression.bugs; import org.junit.Test; +import org.simantics.db.AsyncReadGraph; import org.simantics.db.ReadGraph; 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.request.ReadRequest; +import org.simantics.db.common.request.AsyncReadRequest; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.procedure.SyncListener; @@ -103,51 +104,55 @@ public class SimanticsBug1659Test1 extends ExistingDatabaseTest { } } } - class Query extends ReadRequest { + class Query extends AsyncReadRequest { @Override - public void run(ReadGraph g) throws DatabaseException { - Layer0 l0 = Layer0.getInstance(g); - for (Resource r : g.getObjects(testRoot, l0.ConsistsOf)) { - if (DEBUG) - System.out.println("Resource " + r); - for (Resource rr : g.getObjects(r, l0.ConsistsOf)) { -// if (DEBUG) -// System.out.println("Resource " + rr); - if (!g.isInstanceOf(rr, type)) - fail("Resource " + rr + " is not instance of type."); - if (!g.isInstanceOf(rr, l0.Entity)) - fail("Resource " + rr + " is not instance of Entity."); - if (USE_LISTENER) - g.forPossibleObject(rr, l0.InstanceOf, new SyncListener() { - - @Override - public void execute(ReadGraph graph, Resource resource) throws DatabaseException { - if (DEBUG_LISTENER) - System.out.println("change " + resource); - } - - @Override - public void exception(ReadGraph graph, Throwable t) - throws DatabaseException { - t.printStackTrace(); - fail("Listener got exception: " + t); - } - - @Override - public boolean isDisposed() { - if (DEBUG_LISTENER) - System.out.println("Asked if disposed."); - return true; - } - }); - if (USE_LISTENER2) { - g.forPossibleObject(rr, l0.InstanceOf, new Listener(loopCount, listenerCount)); - } - if (USE_LISTENER3) { - g.syncRequest(new PossibleObject(rr, l0.InstanceOf), new Listener(loopCount, listenerCount)); - } - } - } + public void run(AsyncReadGraph g) { + try { + Layer0 l0 = Layer0.getInstance(g); + for (Resource r : g.getObjects(testRoot, l0.ConsistsOf)) { + if (DEBUG) + System.out.println("Resource " + r); + for (Resource rr : g.getObjects(r, l0.ConsistsOf)) { + // if (DEBUG) + // System.out.println("Resource " + rr); + if (!g.isInstanceOf(rr, type)) + fail("Resource " + rr + " is not instance of type."); + if (!g.isInstanceOf(rr, l0.Entity)) + fail("Resource " + rr + " is not instance of Entity."); + if (USE_LISTENER) + g.forPossibleObject(rr, l0.InstanceOf, new SyncListener() { + + @Override + public void execute(ReadGraph graph, Resource resource) throws DatabaseException { + if (DEBUG_LISTENER) + System.out.println("change " + resource); + } + + @Override + public void exception(ReadGraph graph, Throwable t) + throws DatabaseException { + t.printStackTrace(); + fail("Listener got exception: " + t); + } + + @Override + public boolean isDisposed() { + if (DEBUG_LISTENER) + System.out.println("Asked if disposed."); + return true; + } + }); + if (USE_LISTENER2) { + g.forPossibleObject(rr, l0.InstanceOf, new Listener(loopCount, listenerCount)); + } + if (USE_LISTENER3) { + g.syncRequest(new PossibleObject(rr, l0.InstanceOf), new Listener(loopCount, listenerCount)); + } + } + } + } catch (DatabaseException e) { + e.printStackTrace(); + } } } class Listener implements SyncListener {