camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andre Piwoni <apiwo...@yahoo.com>
Subject Re: CamelBlueprintTestSupport Issues
Date Tue, 08 Oct 2013 05:53:14 GMT
Willem, thank you for reply. My point is that with CamelBlueprintTestSupport
that utilizes CamelBlueprintHelper I don't have much control over which
bundles are included.

Here's sample Maven project structure that creates bundle (not test bundle)
and contains test case that extends CamelBlueprintTestSupport:

ProjectA (bundle)
- /src/main/resources/OSGI-INF/blueprint/camel-context.xml
- /src/test/java/TestClassThatExtendsCamelBluePrintTestSupport.java

public class TestClassThatExtendsCamelBluePrintTestSupport extends
CamelBlueprintTestSupport {
    ...
    protected String getBlueprintDescriptor() {
        return "OSGI-INF/blueprint/camel-context.xml";
    }
    ...
}
When TestClassThatExtendsCamelBluePrintTestSupport  is executed
CamelBlueprintTestSupport calls CamelBlueprintHelper which includes test
bundle and ProjectA bundle.

public static BundleContext createBundleContext(String name, String
descriptors, boolean  includeTestBundle,String bundleFilter, String
testBundleVersion, String testBundleDirectives) throws Exception {
        TinyBundle bundle = null;

        if (includeTestBundle) { // ALWAYS SET TO TRUE BY
CamelBlueprintTestSupport 
            // add ourselves as a bundle
            bundle = createTestBundle(testBundleDirectives == null ? name :
name + ';' + testBundleDirectives, testBundleVersion, descriptors);
        }

        return createBundleContext(name, bundleFilter, bundle);
    }

Here's test bundle inclusion code from createTestBundle():

        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;

Here's ProjectA bundle inclusion that comes from scan within
createBundleContext():

for (Enumeration<URL> e =
getClass().getClassLoader().getResources("META-INF/MANIFEST.MF");e.hasMoreElements();)
{
   URL manifestURL = e.nextElement();
...
   bundles.add(new BundleDescriptor(getClass().getClassLoader(),
getParentURL(manifestURL), headers));
}

Above results in two bundles with OSGI-INF/blueprint/camel-context.xml and
I'm not sure how your suggestion would solve this problem? I want to run
test case but exclude ProjectA bundle.




--
View this message in context: http://camel.465427.n5.nabble.com/CamelBlueprintTestSupport-Issues-tp5741066p5741074.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message