]> gerrit.simantics Code Review - simantics/python.git/blobdiff - org.simantics.pythonlink/test/org/simantics/pythonlink/test/ScriptTestBase.java
Initial commit of Python Integration feature.
[simantics/python.git] / org.simantics.pythonlink / test / org / simantics / pythonlink / test / ScriptTestBase.java
diff --git a/org.simantics.pythonlink/test/org/simantics/pythonlink/test/ScriptTestBase.java b/org.simantics.pythonlink/test/org/simantics/pythonlink/test/ScriptTestBase.java
new file mode 100644 (file)
index 0000000..6328fec
--- /dev/null
@@ -0,0 +1,36 @@
+package org.simantics.pythonlink.test;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+
+import org.junit.Before;
+import org.simantics.scl.compiler.commands.CommandSession;
+import org.simantics.scl.compiler.commands.TestScriptExecutor;
+import org.simantics.scl.compiler.module.repository.ModuleRepository;
+import org.simantics.scl.compiler.source.repository.CompositeModuleSourceRepository;
+import org.simantics.scl.compiler.source.repository.SourceRepositories;
+import org.simantics.scl.osgi.SCLOsgi;
+import org.simantics.scl.osgi.internal.ServiceBasedModuleSourceRepository;
+
+public class ScriptTestBase {
+    
+    private final String path;
+    
+    public ScriptTestBase(String path) {
+        this.path = path;
+    }
+    
+    protected void test() throws Exception {
+        String testScriptName = Thread.currentThread().getStackTrace()[2].getMethodName();
+        String testPath = path + "/" + testScriptName + ".sts";
+
+        CommandSession session = new CommandSession(SCLOsgi.MODULE_REPOSITORY, null);
+        new TestScriptExecutor(session, 
+                new BufferedReader(
+                        new InputStreamReader(getClass().getResourceAsStream(testPath), Charset.forName("UTF-8"))),
+                        null)
+        .execute();
+    }
+    
+}