if (internalConfigurationOptions != null && internalConfigurationOptions.length != 0) {
invokerConfiguration =
systemProperty(EXAM_INVOKER_PROPERTY).value(internalConfigurationOptions[0].getInvoker());
}
ExamSystem subsystem = system.fork(
options(
systemProperty(RMI_HOST_PROPERTY).value(registry.getHost()),
systemProperty(RMI_PORT_PROPERTY).value("" + registry.getPort()),
systemProperty(RMI_NAME_PROPERTY).value(name),
invokerConfiguration,
systemProperty(EXAM_INJECT_PROPERTY).value("true"),
editConfigurationFileExtend("etc/system.properties", "jline.shutdownhook", "true")
));
target = new RBCRemoteTarget(name, registry.getPort(), subsystem.getTimeout());
System.setProperty("java.protocol.handler.pkgs", "org.ops4j.pax.url");
URL sourceDistribution = new URL(framework.getFrameworkURL());
KeepRuntimeFolderOption[] keepRuntimeFolder = subsystem.getOptions(KeepRuntimeFolderOption.class);
if (keepRuntimeFolder != null && keepRuntimeFolder.length != 0) {
deleteRuntime = false;
}
targetFolder = retrieveFinalTargetFolder(subsystem);
extractKarafDistribution(sourceDistribution, targetFolder);
File javaHome = new File(System.getProperty("java.home"));
File karafBase = searchKarafBase(targetFolder);
File distributionInfo = new File(karafBase + "/etc/distribution.info");
File karafBin = new File(karafBase + "/bin");
File featuresXmlFile = new File(targetFolder + "/examfeatures.xml");
File karafHome = karafBase;
File deploy = new File(karafBase + "/deploy");
String karafData = karafHome + "/data";
framework = new InternalKarafDistributionConfigurationOption(framework, distributionInfo);
versionAdaptions = KarafManipulatorFactory.createManipulator(framework.getKarafVersion());
ArrayList<String> javaOpts = Lists.newArrayList();
appendVmSettingsFromSystem(javaOpts, subsystem);
String[] javaEndorsedDirs =
new String[]{ javaHome + "/jre/lib/endorsed", javaHome + "/lib/endorsed", karafHome + "/lib/endorsed" };
String[] javaExtDirs =
new String[]{ javaHome + "/jre/lib/ext", javaHome + "/lib/ext", javaHome + "/lib/ext" };
String[] karafOpts = new String[]{};
ArrayList<String> opts =
Lists.newArrayList("-Dkaraf.startLocalConsole=" + shouldLocalConsoleBeStarted(subsystem),
"-Dkaraf.startRemoteShell=" + shouldRemoteShellBeStarted(subsystem));
String[] classPath = buildKarafClasspath(karafHome);
String main = "org.apache.karaf.main.Main";
String options = "";
String[] environment = new String[]{};
String[] fileEndings = new String[]{ "jar", "war", "zip", "kar", "xml" };
updateLogProperties(karafHome, subsystem);
updateUserSetProperties(karafHome, subsystem);
copyBootClasspathLibraries(karafHome, subsystem);
setupExamProperties(karafHome, subsystem);
makeScriptsInBinExec(karafBin);
int startLevel = Constants.DEFAULT_START_LEVEL;
ExamBundlesStartLevel examBundlesStartLevel = system.getSingleOption(ExamBundlesStartLevel.class);
if (examBundlesStartLevel != null) {
startLevel = examBundlesStartLevel.getStartLevel();
}
ExamFeaturesFile examFeaturesFile;
if (framework.isUseDeployFolder()) {
copyReferencedArtifactsToDeployFolder(deploy, subsystem, fileEndings);
examFeaturesFile = ExamFeaturesFileFactory.createExamFeaturesFile("", startLevel);
} else {
StringBuilder extension = extractExtensionString(subsystem);
examFeaturesFile = ExamFeaturesFileFactory.createExamFeaturesFile(extension.toString(), startLevel);
}
examFeaturesFile.writeToFile(featuresXmlFile);
examFeaturesFile.adaptDistributionToStartExam(karafHome, featuresXmlFile);
long startedAt = System.currentTimeMillis();
runner.exec(environment, karafBase, javaHome.toString(), javaOpts.toArray(new String[]{}),
javaEndorsedDirs, javaExtDirs, karafHome.toString(), karafData, karafOpts,
opts.toArray(new String[]{}), classPath, main, options);
LOGGER.debug("Test Container started in " + (System.currentTimeMillis() - startedAt) + " millis");
LOGGER.info("Wait for test container to finish its initialization " + subsystem.getTimeout());
if (subsystem.getOptions(ServerModeOption.class).length == 0) {
waitForState(org.openengsb.labs.paxexam.karaf.container.internal.Constants.SYSTEM_BUNDLE,
Bundle.ACTIVE, subsystem.getTimeout());
}
else {
LOGGER
.info("System runs in Server Mode. Which means, no Test facility bundles available on target system.");
}