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;
17 public class RuntimeSTSTestRunner extends Runner {
19 private final String name;
20 private final String code;
21 private final Integer priority;
22 private CommandSession session;
24 public RuntimeSTSTestRunner(String name, String code, Integer priority) {
27 this.priority = priority;
30 public void setCommandSession(CommandSession session) {
31 this.session = session;
35 public Description getDescription() {
36 return Description.createTestDescription(RuntimeSTSTestRunner.class, name);
40 public void run(RunNotifier notifier) {
41 StringReader reade = new StringReader(code);
42 BufferedReader reader = new BufferedReader(reade);
44 SCLContext context = SCLContext.getCurrent();
45 SCLReportingHandler printer = (SCLReportingHandler)context.get(SCLReportingHandler.REPORTING_HANDLER);
46 SCLReportingHandler handler;
47 if(printer instanceof SCLReportingHandler)
48 handler = (SCLReportingHandler)printer;
50 handler = SCLReportingHandler.DEFAULT;
54 session = new CommandSession(SCLOsgi.MODULE_REPOSITORY, handler);
55 new TestScriptExecutor(session, reader, handler).execute();
56 } catch (IOException e) {
57 throw new RuntimeException(e);
61 } catch (IOException e) {
67 public String getName() {
71 public Integer getPriority() {