commit fbf6950f166374acfd0361165cee8678a4dceb87 Author: Cristiano Gaviao <cvgav...@gmail.com> AuthorDate: Tue, 11 Jun 2013 08:43:57 -0300 Commit: Cristiano Gaviao <cvgav...@gmail.com> CommitDate: Tue, 11 Jun 2013 08:43:57 -0300
improved message for non started test bundle error. diff --git a/jbehave-osgi-bundles/org.jbehave.osgi.core/src/main/java/org/jbehave/osgi/core/io/CodeLocationsOsgi.java b/jbehave-osgi-bundles/org.jbehave.osgi.core/src/main/java/org/jbehave/osgi/core/io/CodeLocationsOsgi.java index 5700e83..471134c 100644 --- a/jbehave-osgi-bundles/org.jbehave.osgi.core/src/main/java/org/jbehave/osgi/core/io/CodeLocationsOsgi.java +++ b/jbehave-osgi-bundles/org.jbehave.osgi.core/src/main/java/org/jbehave/osgi/core/io/CodeLocationsOsgi.java @@ -3,6 +3,7 @@ package org.jbehave.osgi.core.io; import java.io.File; import java.net.URL; +import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; /** @@ -24,9 +25,14 @@ public class CodeLocationsOsgi { public static URL codeLocationFromClass(Class<?> codeLocationClass) { File file = null; try { - - file = FrameworkUtil.getBundle( - codeLocationClass).getBundleContext().getDataFile(""); + BundleContext bc = FrameworkUtil.getBundle(codeLocationClass) + .getBundleContext(); + if (bc == null) + throw new RuntimeException( + "The bundle that contains the class " + + codeLocationClass + + " not started. You must set its Bundle-ActivationPolicy to lazy !"); + file = bc.getDataFile(""); return file.toURI().toURL(); } catch (Exception e) { throw new InvalidCodeLocation(file.getAbsolutePath(), e);