-package org.simantics.tests.modelled.junit;\r
-\r
-import java.io.BufferedReader;\r
-import java.io.IOException;\r
-import java.io.StringReader;\r
-\r
-import org.junit.runner.Description;\r
-import org.junit.runner.Runner;\r
-import org.junit.runner.notification.RunNotifier;\r
-import org.simantics.scl.compiler.commands.CommandSession;\r
-import org.simantics.scl.compiler.commands.TestScriptExecutor;\r
-import org.simantics.scl.osgi.SCLOsgi;\r
-import org.simantics.scl.runtime.SCLContext;\r
-import org.simantics.scl.runtime.reporting.SCLReportingHandler;\r
-\r
-public class RuntimeSTSTestRunner extends Runner {\r
- \r
- private final String name;\r
- private final String code;\r
- private final Integer priority;\r
- private CommandSession session;\r
-\r
- public RuntimeSTSTestRunner(String name, String code, Integer priority) {\r
- this.name = name;\r
- this.code = code;\r
- this.priority = priority;\r
- }\r
- \r
- public void setCommandSession(CommandSession session) {\r
- this.session = session;\r
- }\r
-\r
- @Override\r
- public Description getDescription() {\r
- return Description.createTestDescription(RuntimeSTSTestRunner.class, name);\r
- }\r
-\r
- @Override\r
- public void run(RunNotifier notifier) {\r
- StringReader reade = new StringReader(code);\r
- BufferedReader reader = new BufferedReader(reade);\r
- \r
- SCLContext context = SCLContext.getCurrent();\r
- SCLReportingHandler printer = (SCLReportingHandler)context.get(SCLReportingHandler.REPORTING_HANDLER);\r
- SCLReportingHandler handler;\r
- if(printer instanceof SCLReportingHandler)\r
- handler = (SCLReportingHandler)printer;\r
- else\r
- handler = SCLReportingHandler.DEFAULT;\r
- \r
- try {\r
- if (session == null)\r
- session = new CommandSession(SCLOsgi.MODULE_REPOSITORY, handler);\r
- new TestScriptExecutor(session, reader, handler).execute();\r
- } catch (IOException e) {\r
- throw new RuntimeException(e);\r
- } finally {\r
- try {\r
- reader.close();\r
- } catch (IOException e) {\r
- // Ignore\r
- }\r
- }\r
- }\r
-\r
- public Integer getPriority() {\r
- return priority;\r
- }\r
-\r
+package org.simantics.tests.modelled.junit;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+
+import org.junit.runner.Description;
+import org.junit.runner.Runner;
+import org.junit.runner.notification.RunNotifier;
+import org.simantics.scl.compiler.commands.CommandSession;
+import org.simantics.scl.compiler.commands.TestScriptExecutor;
+import org.simantics.scl.osgi.SCLOsgi;
+import org.simantics.scl.runtime.SCLContext;
+import org.simantics.scl.runtime.reporting.SCLReportingHandler;
+
+@Deprecated
+public class RuntimeSTSTestRunner extends Runner {
+
+ private final String name;
+ private final String code;
+ private final Integer priority;
+ private CommandSession session;
+
+ public RuntimeSTSTestRunner(String name, String code, Integer priority) {
+ this.name = name;
+ this.code = code;
+ this.priority = priority;
+ }
+
+ public void setCommandSession(CommandSession session) {
+ this.session = session;
+ }
+
+ @Override
+ public Description getDescription() {
+ return Description.createTestDescription(RuntimeSTSTestRunner.class, name);
+ }
+
+ @Override
+ public void run(RunNotifier notifier) {
+ StringReader reade = new StringReader(code);
+ BufferedReader reader = new BufferedReader(reade);
+
+ SCLContext context = SCLContext.getCurrent();
+ SCLReportingHandler printer = (SCLReportingHandler)context.get(SCLReportingHandler.REPORTING_HANDLER);
+ SCLReportingHandler handler;
+ if(printer instanceof SCLReportingHandler)
+ handler = (SCLReportingHandler)printer;
+ else
+ handler = SCLReportingHandler.DEFAULT;
+
+ try {
+ if (session == null)
+ session = new CommandSession(SCLOsgi.MODULE_REPOSITORY, handler);
+ new TestScriptExecutor(session, reader, handler).execute();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Integer getPriority() {
+ return priority;
+ }
+
}
\ No newline at end of file