Author: davsclaus
Date: Tue Jun 19 13:16:43 2012
New Revision: 1351706
URL: http://svn.apache.org/viewvc?rev=1351706&view=rev
Log:
CAMEL-5380: Allow to provide TinyBunlder in createBundleContext. Thanks to
Achim for the patch.
Modified:
camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
Modified:
camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java?rev=1351706&r1=1351705&r2=1351706&view=diff
==============================================================================
---
camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
(original)
+++
camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
Tue Jun 19 13:16:43 2012
@@ -75,11 +75,22 @@ public final class CamelBlueprintHelper
}
public static BundleContext createBundleContext(String name, String
descriptors, boolean includeTestBundle) throws Exception {
- return createBundleContext(name, descriptors, BUNDLE_FILTER,
BUNDLE_VERSION, includeTestBundle);
+ return createBundleContext(name, descriptors, includeTestBundle,
BUNDLE_FILTER, BUNDLE_VERSION);
}
- public static BundleContext createBundleContext(String name, String
descriptors, String bundleFilter,
- String testBundleVersion,
boolean includeTestBundle) throws Exception {
+ public static BundleContext createBundleContext(String name, String
descriptors, boolean includeTestBundle,
+ String bundleFilter,
String testBundleVersion) throws Exception {
+ TinyBundle bundle = null;
+
+ if (includeTestBundle) {
+ // add ourselves as a bundle
+ bundle = createTestBundle(name, testBundleVersion, descriptors);
+ }
+
+ return createBundleContext(name, bundleFilter, bundle);
+ }
+
+ public static BundleContext createBundleContext(String name, String
bundleFilter, TinyBundle bundle) throws Exception {
deleteDirectory("target/bundles");
createDirectory("target/bundles");
@@ -89,9 +100,7 @@ public final class CamelBlueprintHelper
// get the bundles
List<BundleDescriptor> bundles = getBundleDescriptors(bundleFilter);
- if (includeTestBundle) {
- // add ourselves as a bundle
- TinyBundle bundle = createTestBundle(name, testBundleVersion,
descriptors);
+ if (bundle != null) {
String jarName = name.toLowerCase();
bundles.add(getBundleDescriptor("target/bundles/" + jarName +
".jar", bundle));
}
@@ -175,6 +184,19 @@ public final class CamelBlueprintHelper
}
}
+ protected static TinyBundle createTestBundle(String name, String version,
String descriptors) throws FileNotFoundException, MalformedURLException {
+ TinyBundle bundle = TinyBundles.newBundle();
+ for (URL url : getBlueprintDescriptors(descriptors)) {
+ LOG.info("Using Blueprint XML file: " + url.getFile());
+ bundle.add("OSGI-INF/blueprint/blueprint-" +
url.getFile().replace("/", "-"), url);
+ }
+ bundle.set("Manifest-Version", "2")
+ .set("Bundle-ManifestVersion", "2")
+ .set("Bundle-SymbolicName", name)
+ .set("Bundle-Version", version);
+ return bundle;
+ }
+
/**
* Explode the dictionary into a <code>,</code> delimited list of
<code>key=value</code> pairs.
*/
@@ -198,19 +220,6 @@ public final class CamelBlueprintHelper
return references == null ? new ArrayList<ServiceReference>(0) :
Arrays.asList(references);
}
- private static TinyBundle createTestBundle(String name, String version,
String descriptors) throws FileNotFoundException, MalformedURLException {
- TinyBundle bundle = TinyBundles.newBundle();
- for (URL url : getBlueprintDescriptors(descriptors)) {
- LOG.info("Using Blueprint XML file: " + url.getFile());
- bundle.add("OSGI-INF/blueprint/blueprint-" +
url.getFile().replace("/", "-"), url);
- }
- bundle.set("Manifest-Version", "2")
- .set("Bundle-ManifestVersion", "2")
- .set("Bundle-SymbolicName", name)
- .set("Bundle-Version", version);
- return bundle;
- }
-
/**
* Gets list of bundle descriptors.
* @param bundleFilter Filter expression for OSGI bundles.
Modified:
camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java?rev=1351706&r1=1351705&r2=1351706&view=diff
==============================================================================
---
camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
(original)
+++
camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
Tue Jun 19 13:16:43 2012
@@ -39,7 +39,7 @@ public abstract class CamelBlueprintTest
public void setUp() throws Exception {
String symbolicName = getClass().getSimpleName();
this.bundleContext =
CamelBlueprintHelper.createBundleContext(symbolicName, getBlueprintDescriptor(),
- getBundleFilter(), getBundleVersion(), true);
+ true, getBundleFilter(), getBundleVersion());
// must register override properties early in OSGi containers
Properties extra = useOverridePropertiesWithPropertiesComponent();