// Reason: Missing Permission: (org.osgi.framework.PackagePermission org.osgi.framework export,import),
// Missing Constraint: Import-Package: org.osgi.framework; version="1.3.0"
System.setSecurityManager(null);
try {
OSGiTestRunner runner = new OSGiTestRunner();
runner.setFramework(frameworkName);
runner.setRepositoryDirectory(repository);
if (systemBundle != null) {
runner.setSystemBundle(systemBundle.getName(), systemBundle.getVersion());
}
if (runnerBundle != null) {
runner.setTestRunnerBundle(runnerBundle.getName(), runnerBundle.getVersion());
}
for (BundleDescriptor bundle : requiredBundles.getBundleDescriptors()) {
runner.addRequiredBundle(bundle.getName(), bundle.getVersion());
}
for (BundleDescriptor bundle : testBundles.getBundleDescriptors()) {
runner.addTestBundle(bundle.getName(), bundle.getVersion());
}
for (Parameter parameter : parameters.getParameters()) {
runner.addTestParameter(parameter.getName(), parameter.getValue());
}
try {
List<OSGiTestResult> results;
PrintStream oldOutStream = System.out;
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
PrintStream newOutStream = new PrintStream(outStream);
PrintStream oldErrStream = System.err;
ByteArrayOutputStream errStream = new ByteArrayOutputStream();
PrintStream newErrStream = new PrintStream(errStream);
String out;
String err;
try {
System.setErr(newErrStream);
results = runner.runTests();
} finally {
out = outStream.toString();
err = errStream.toString();
newOutStream.close();
System.setOut(oldOutStream);