]> gerrit.simantics Code Review - simantics/python.git/blob - org.simantics.pythonlink/test/org/simantics/pythonlink/test/ScriptTestBase.java
Some fixes to Python integration.
[simantics/python.git] / org.simantics.pythonlink / test / org / simantics / pythonlink / test / ScriptTestBase.java
1 package org.simantics.pythonlink.test;
2
3 import java.io.BufferedReader;
4 import java.io.InputStreamReader;
5 import java.nio.charset.Charset;
6
7 import org.simantics.scl.compiler.commands.CommandSession;
8 import org.simantics.scl.compiler.commands.TestScriptExecutor;
9 import org.simantics.scl.osgi.SCLOsgi;
10
11 public class ScriptTestBase {
12     
13     private final String path;
14     
15     public ScriptTestBase(String path) {
16         this.path = path;
17     }
18     
19     protected void test() throws Exception {
20         String testScriptName = Thread.currentThread().getStackTrace()[2].getMethodName();
21         String testPath = path + "/" + testScriptName + ".sts";
22
23         CommandSession session = new CommandSession(SCLOsgi.MODULE_REPOSITORY, null);
24         new TestScriptExecutor(session, 
25                 new BufferedReader(
26                         new InputStreamReader(getClass().getResourceAsStream(testPath), Charset.forName("UTF-8"))),
27                         null)
28         .execute();
29     }
30     
31 }