You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/04/27 17:21:30 UTC
svn commit: r1331467 - in
/camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint:
CamelBlueprintHelper.java CamelBlueprintTestSupport.java
Author: davsclaus
Date: Fri Apr 27 15:21:30 2012
New Revision: 1331467
URL: http://svn.apache.org/viewvc?rev=1331467&view=rev
Log:
CAMEL-5217: Allow to customize bundle filter. Thanks to Jean-Baptiste Defard 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=1331467&r1=1331466&r2=1331467&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 Fri Apr 27 15:21:30 2012
@@ -66,6 +66,7 @@ import static org.apache.camel.test.juni
public final class CamelBlueprintHelper {
public static final long DEFAULT_TIMEOUT = 30000;
+ public static final String BUNDLE_FILTER = "(Bundle-SymbolicName=*)";
private static final transient Logger LOG = LoggerFactory.getLogger(CamelBlueprintHelper.class);
private static final ClassResolver RESOLVER = new DefaultClassResolver();
@@ -73,6 +74,10 @@ public final class CamelBlueprintHelper
}
public static BundleContext createBundleContext(String name, String descriptors, boolean includeTestBundle) throws Exception {
+ return createBundleContext(name, descriptors, BUNDLE_FILTER, includeTestBundle);
+ }
+
+ public static BundleContext createBundleContext(String name, String descriptors, String bundleFilter, boolean includeTestBundle) throws Exception {
deleteDirectory("target/bundles");
createDirectory("target/bundles");
@@ -80,7 +85,7 @@ public final class CamelBlueprintHelper
System.setProperty("org.osgi.framework.storage", "target/bundles/" + System.currentTimeMillis());
// get the bundles
- List<BundleDescriptor> bundles = getBundleDescriptors();
+ List<BundleDescriptor> bundles = getBundleDescriptors(bundleFilter);
if (includeTestBundle) {
// add ourselves as a bundle
@@ -199,12 +204,13 @@ public final class CamelBlueprintHelper
/**
* Gets list of bundle descriptors.
+ * @param bundleFilter Filter expression for OSGI bundles.
*
* @return List pointers to OSGi bundles.
* @throws Exception If looking up the bundles fails.
*/
- private static List<BundleDescriptor> getBundleDescriptors() throws Exception {
- return new ClasspathScanner().scanForBundles("(Bundle-SymbolicName=*)");
+ private static List<BundleDescriptor> getBundleDescriptors(final String bundleFilter) throws Exception {
+ return new ClasspathScanner().scanForBundles(bundleFilter);
}
/**
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=1331467&r1=1331466&r2=1331467&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 Fri Apr 27 15:21:30 2012
@@ -32,7 +32,7 @@ public abstract class CamelBlueprintTest
@Before
@Override
public void setUp() throws Exception {
- bundleContext = CamelBlueprintHelper.createBundleContext(getClass().getSimpleName(), getBlueprintDescriptor(), true);
+ this.bundleContext = CamelBlueprintHelper.createBundleContext(getClass().getSimpleName(), getBlueprintDescriptor(), getBundleFilter(), true);
super.setUp();
}
@@ -57,6 +57,16 @@ public abstract class CamelBlueprintTest
return null;
}
+ /**
+ * Gets filter expression of bundle descriptors. Modify this method if you wish to change
+ * default behavior.
+ *
+ * @return filter expression for OSGi bundles.
+ */
+ protected String getBundleFilter() {
+ return CamelBlueprintHelper.BUNDLE_FILTER;
+ }
+
@Override
protected CamelContext createCamelContext() throws Exception {
return CamelBlueprintHelper.getOsgiService(bundleContext, CamelContext.class);