DefaultEquinoxInstallationFactory implements EquinoxInstallationFactory { protected String toOsgiBundles(Map<ArtifactKey, File> bundles, Map<String, BundleStartLevel> startLevel, BundleStartLevel defaultStartLevel) throws IOException { log.debug("Installation OSGI bundles:"); StringBuilder result = new StringBuilder(); for (Map.Entry<ArtifactKey, File> entry : bundles.entrySet()) { BundleStartLevel level = startLevel.get(entry.getKey().getId()); if (level != null && level.getLevel() == -1) { continue; } if (result.length() > 0) { result.append(","); } StringBuilder line = new StringBuilder(); line.append(appendAbsolutePath(entry.getValue())); if (level != null) { line.append('@'); if (level.getLevel() > 0) { line.append(level.getLevel()); } if (level.isAutoStart()) { if (line.charAt(line.length() - 1) == '@') { line.append("start"); } else { line.append(":start"); } } } else { if (defaultStartLevel.isAutoStart()) { line.append("@start"); } } log.debug("\t" + line); result.append(line.toString()); } return result.toString(); } DefaultEquinoxInstallationFactory();   DefaultEquinoxInstallationFactory(Logger log); @Override EquinoxInstallation createInstallation(EquinoxInstallationDescription description, File location);  }
@Test public void testExplicitlyConfiguredStartLevelAndAutoStart() throws IOException { instDesc.addBundleStartLevel(new BundleStartLevel("org.example.bundle1", 6, true)); List<String> config = splitAtComma( subject.toOsgiBundles(bundles, instDesc.getBundleStartLevel(), defaultLevel)); assertThat(config, hasItem("reference:file:absolute/path/to/bundle1@6:start")); }
@Test public void testDefaultStartLevelIsNotSet() throws Exception { List<String> config = splitAtComma( subject.toOsgiBundles(bundles, instDesc.getBundleStartLevel(), defaultLevel)); assertThat(config, hasItem("reference:file:absolute/path/to/bundle2")); }
@Test public void testDefaultAutoStartIsSet() throws Exception { defaultLevel = new BundleStartLevel(null, 7, true); List<String> config = splitAtComma( subject.toOsgiBundles(bundles, instDesc.getBundleStartLevel(), defaultLevel)); assertThat(config, hasItem("reference:file:absolute/path/to/bundle2@start")); }
@Test public void testExplicitlyConfiguredAutoStart() throws Exception { instDesc.addBundleStartLevel(new BundleStartLevel("org.example.bundle1", 0, true)); List<String> config = splitAtComma( subject.toOsgiBundles(bundles, instDesc.getBundleStartLevel(), defaultLevel)); assertThat(config, hasItem("reference:file:absolute/path/to/bundle1@start")); }
@Test public void testExplicitlyConfiguredStartLevel() throws IOException { instDesc.addBundleStartLevel(new BundleStartLevel("org.example.bundle1", 6, false)); List<String> config = splitAtComma( subject.toOsgiBundles(bundles, instDesc.getBundleStartLevel(), defaultLevel)); assertThat(config, hasItem("reference:file:absolute/path/to/bundle1@6")); }