]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - tests/org.simantics.db.tests/src/org/simantics/db/tests/regression/bugs/Issue3288Test1.java
Added missing org.simantics.db.{tests,testing} plug-ins.
[simantics/platform.git] / tests / org.simantics.db.tests / src / org / simantics / db / tests / regression / bugs / Issue3288Test1.java
diff --git a/tests/org.simantics.db.tests/src/org/simantics/db/tests/regression/bugs/Issue3288Test1.java b/tests/org.simantics.db.tests/src/org/simantics/db/tests/regression/bugs/Issue3288Test1.java
new file mode 100644 (file)
index 0000000..057cd2b
--- /dev/null
@@ -0,0 +1,55 @@
+package org.simantics.db.tests.regression.bugs;
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+
+
+import org.junit.Test;
+import org.simantics.db.Resource;
+import org.simantics.db.VirtualGraph;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.request.UndoTraits;
+import org.simantics.db.request.Write;
+import org.simantics.db.testing.cases.FreshDatabaseTest;
+import org.simantics.layer0.Layer0;
+/**
+ * Meant to be run together wit Issue3288Test2.
+ * This test stops server in the middle of transaction.
+ * Issue3288Test2 can be used to visually check that recovery does at least something.
+ * At the moment both must be manually run with separate runs.  
+ */
+public class Issue3288Test1 extends FreshDatabaseTest {
+    @Test
+    public void test() throws DatabaseException {
+        getSession().syncRequest(new Modi());
+    }
+    private static class Modi implements Write {
+        @Override
+        public UndoTraits getUndoTraits() {
+            return null;
+        }
+        @Override
+        public VirtualGraph getProvider() {
+            return null;
+        }
+        @Override
+        public void perform(WriteGraph graph) throws DatabaseException {
+            Resource rl = graph.getRootLibrary();
+            Layer0 l0 = Layer0.getInstance(graph);
+            Resource r = graph.newResource();
+            graph.claim(rl, l0.ConsistsOf, r);
+            graph.flushCluster(rl);
+            System.setSecurityManager(null);
+            System.exit(666);
+        }
+    }
+}
\ No newline at end of file