Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore start option for fragment bundles. skip fragment bundles during '... #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.ops4j.pax.exam.options.ValueOption;
import org.ops4j.pax.exam.options.extra.CleanCachesOption;
import org.ops4j.pax.exam.options.extra.RepositoryOption;
import org.ops4j.pax.swissbox.core.BundleUtils;
import org.ops4j.pax.swissbox.tracker.ServiceLookup;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
Expand Down Expand Up @@ -310,11 +311,10 @@ private void installAndStartBundles(BundleContext context) throws BundleExceptio
int startLevel = getStartLevel(bundle);
BundleStartLevel sl = b.adapt(BundleStartLevel.class);
sl.setStartLevel(startLevel);
if (bundle.shouldStart()) {
if (bundle.shouldStart() && ! isFragment(b)) {
try {
b.start();
}
catch (BundleException e) {
} catch (BundleException e) {
throw new BundleException("Error starting bundle " + b.getSymbolicName() + ". " + e.getMessage(), e);
}
LOG.debug("+ Install (start@{}) {}", startLevel, bundle);
Expand Down Expand Up @@ -384,14 +384,13 @@ public void frameworkEvent(FrameworkEvent frameworkEvent) {
private void verifyThatBundlesAreResolved(List<Bundle> bundles) {
boolean hasUnresolvedBundles = false;
for (Bundle bundle : bundles) {
if (bundle.getState() == Bundle.INSTALLED) {
if (bundle.getState() == Bundle.INSTALLED && !isFragment(bundle)) {
LOG.error("Bundle [{}] is not resolved", bundle);
hasUnresolvedBundles = true;
}
}
ConfigurationManager cm = new ConfigurationManager();
boolean failOnUnresolved = Boolean.parseBoolean(cm.getProperty(EXAM_FAIL_ON_UNRESOLVED_KEY,
"false"));
boolean failOnUnresolved = Boolean.parseBoolean(cm.getProperty(EXAM_FAIL_ON_UNRESOLVED_KEY, "false"));
if (hasUnresolvedBundles && failOnUnresolved) {
throw new TestContainerException(
"There are unresolved bundles. See previous ERROR log messages for details.");
Expand Down Expand Up @@ -469,4 +468,8 @@ public synchronized void uninstallProbe() {
throw new TestContainerException(exc);
}
}

private boolean isFragment(Bundle bundle) {
return bundle.getHeaders().get(org.osgi.framework.Constants.FRAGMENT_HOST) != null;
}
}