1 package org.simantics.tests.modelled.junit;
3 import java.io.BufferedReader;
4 import java.io.IOException;
5 import java.io.StringReader;
7 import org.junit.runner.Description;
8 import org.junit.runner.Runner;
9 import org.junit.runner.notification.RunNotifier;
10 import org.simantics.scl.compiler.commands.CommandSession;
11 import org.simantics.scl.compiler.commands.TestScriptExecutor;
12 import org.simantics.scl.osgi.SCLOsgi;
13 import org.simantics.scl.runtime.SCLContext;
14 import org.simantics.scl.runtime.reporting.SCLReportingHandler;
16 public class RuntimeSTSTestRunner extends Runner {
18 private final String name;
19 private final String code;
20 private final Integer priority;
21 private CommandSession session;
23 public RuntimeSTSTestRunner(String name, String code, Integer priority) {
26 this.priority = priority;
29 public void setCommandSession(CommandSession session) {
30 this.session = session;
34 public Description getDescription() {
35 return Description.createTestDescription(RuntimeSTSTestRunner.class, name);
39 public void run(RunNotifier notifier) {
40 StringReader reade = new StringReader(code);
41 BufferedReader reader = new BufferedReader(reade);
43 SCLContext context = SCLContext.getCurrent();
44 SCLReportingHandler printer = (SCLReportingHandler)context.get(SCLReportingHandler.REPORTING_HANDLER);
45 SCLReportingHandler handler;
46 if(printer instanceof SCLReportingHandler)
47 handler = (SCLReportingHandler)printer;
49 handler = SCLReportingHandler.DEFAULT;
53 session = new CommandSession(SCLOsgi.MODULE_REPOSITORY, handler);
54 new TestScriptExecutor(session, reader, handler).execute();
55 } catch (IOException e) {
56 throw new RuntimeException(e);
60 } catch (IOException e) {
66 public String getName() {
70 public Integer getPriority() {