X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=tests%2Forg.simantics.db.tests%2Fsrc%2Forg%2Fsimantics%2Fdb%2Ftests%2Fapi%2Fstory%2FsessionGarbageCollection%2FCollectDuringWriteAndRead.java;fp=tests%2Forg.simantics.db.tests%2Fsrc%2Forg%2Fsimantics%2Fdb%2Ftests%2Fapi%2Fstory%2FsessionGarbageCollection%2FCollectDuringWriteAndRead.java;h=a15725d0b82716b0e34fb0736c7f700bbd47615e;hb=67fd62f9c742337ec80eef658192db198a0efaac;hp=0000000000000000000000000000000000000000;hpb=cde82ba81327d5515fdca362f7f4c70f5103ae80;p=simantics%2Fplatform.git diff --git a/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/story/sessionGarbageCollection/CollectDuringWriteAndRead.java b/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/story/sessionGarbageCollection/CollectDuringWriteAndRead.java new file mode 100644 index 000000000..a15725d0b --- /dev/null +++ b/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/story/sessionGarbageCollection/CollectDuringWriteAndRead.java @@ -0,0 +1,89 @@ +package org.simantics.db.tests.api.story.sessionGarbageCollection; + +import org.simantics.db.Resource; +import org.simantics.db.Session; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.WriteResultRequest; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.util.SessionGarbageCollection; +import org.simantics.db.testing.annotation.Fails; +import org.simantics.db.testing.base.CommandSequenceTest; +import org.simantics.db.testing.common.Command; +import org.simantics.db.testing.common.CommandSequenceEnvironment; +import org.simantics.db.testing.common.CommandSpec; +import org.simantics.db.testing.common.Kill; +import org.simantics.db.testing.common.Reconnect; + +/** + * @author Antti Villberg + */ +@Fails +public class CollectDuringWriteAndRead extends CommandSequenceTest { + + private final int SEQUENCE_SIZE = 300; + private final int LIST_SIZE = 500; + + private Resource root; + private int index; + + public Resource getRoot() { + return root; + } + + public int incrementAndGetIndex() { + return index++; + } + + public int getListSize() { + return LIST_SIZE; + } + + @Override + protected int getSequenceSize() { + return SEQUENCE_SIZE; + } + + @Override + protected CommandSpec[] getFactories() { + return new CommandSpec[] { + CommandSpec.make(AddList.class, 1.0), + CommandSpec.make(RemoveList.class, 1.0), + CommandSpec.make(AppendList.class, 0.5), + CommandSpec.make(Read.class, 0.1), + CommandSpec.make(AddListAndKill.class, 0.02), + CommandSpec.make(Reconnect.class, 0.02), + CommandSpec.make(Kill.class, 0.02) + }; + } + + protected Command[] beforeSequence(CommandSequenceEnvironment environment) throws Exception { + + return new Command[] { + + new Command() { + + @Override + public void run(CommandSequenceEnvironment environment) throws Exception { + + Session s = getSession(); + root = s.syncRequest(new WriteResultRequest() { + + @Override + public Resource perform(WriteGraph graph) throws DatabaseException { + return graph.newResource(); + } + + }); + for(int i=0;i<10;i++) new AddList().run(CollectDuringWriteAndRead.this); + SessionGarbageCollection.gc(null, s, true, null, 0, 0); + + } + + } + + }; + + + } + +}