]> gerrit.simantics Code Review - simantics/python.git/blob - 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
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.junit.Before;
8 import org.simantics.scl.compiler.commands.CommandSession;
9 import org.simantics.scl.compiler.commands.TestScriptExecutor;
10 import org.simantics.scl.compiler.module.repository.ModuleRepository;
11 import org.simantics.scl.compiler.source.repository.CompositeModuleSourceRepository;
12 import org.simantics.scl.compiler.source.repository.SourceRepositories;
13 import org.simantics.scl.osgi.SCLOsgi;
14 import org.simantics.scl.osgi.internal.ServiceBasedModuleSourceRepository;
15
16 public class ScriptTestBase {
17     
18     private final String path;
19     
20     public ScriptTestBase(String path) {
21         this.path = path;
22     }
23     
24     protected void test() throws Exception {
25         String testScriptName = Thread.currentThread().getStackTrace()[2].getMethodName();
26         String testPath = path + "/" + testScriptName + ".sts";
27
28         CommandSession session = new CommandSession(SCLOsgi.MODULE_REPOSITORY, null);
29         new TestScriptExecutor(session, 
30                 new BufferedReader(
31                         new InputStreamReader(getClass().getResourceAsStream(testPath), Charset.forName("UTF-8"))),
32                         null)
33         .execute();
34     }
35     
36 }