1 package org.simantics.scl.osgi.internal;
3 import java.io.BufferedReader;
4 import java.io.InputStream;
5 import java.io.InputStreamReader;
8 import org.simantics.scl.compiler.commands.CommandSession;
9 import org.simantics.scl.compiler.commands.TestScriptExecutor;
10 import org.simantics.scl.compiler.testing.TestRunnable;
11 import org.simantics.scl.osgi.SCLOsgi;
12 import org.simantics.scl.runtime.SCLContext;
13 import org.simantics.scl.runtime.reporting.SCLReportingHandler;
15 public class BundleTestScriptRunnable implements TestRunnable {
17 private final String name;
18 private final URL url;
20 public BundleTestScriptRunnable(String name, URL url) {
26 public String getName() {
31 public void run() throws Exception {
32 InputStream stream = url.openStream();
33 BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
35 SCLContext context = SCLContext.getCurrent();
36 SCLReportingHandler printer = (SCLReportingHandler)context.get(SCLReportingHandler.REPORTING_HANDLER);
37 SCLReportingHandler handler;
38 if(printer instanceof SCLReportingHandler)
39 handler = (SCLReportingHandler)printer;
41 handler = SCLReportingHandler.DEFAULT;
44 CommandSession session = new CommandSession(SCLOsgi.MODULE_REPOSITORY, handler);
45 new TestScriptExecutor(session, reader, handler).execute();
52 public String toString() {
53 return getName() + " (" + url + ")";