use of de.kalpatec.pojosr.framework.launch.PojoServiceRegistry in project ddf by codice.
the class CatalogComponentTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
LOGGER.debug("INSIDE createCamelContext");
CamelContext camelContext = super.createCamelContext();
// Configure PojoSR to be our mock OSGi Registry
PojoServiceRegistry reg = new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(new HashMap());
bundleContext = reg.getBundleContext();
// Since the Camel BlueprintComponentResolver does not execute outside
// of an OSGi container, we cannot
// rely on the CatalogComponentResolver to be used for resolving the
// CatalogComponent when Camel loads the route.
// Therefore, we Mock what the CatalogComponent's blueprint.xml file
// would have done by creating a
// CatalogComponent explicitly and adding it to the CamelContext used
// for this unit test.
catalogComponent = new CatalogComponent();
catalogComponent.setBundleContext(bundleContext);
camelContext.addComponent(CatalogComponent.NAME, catalogComponent);
return camelContext;
}
use of de.kalpatec.pojosr.framework.launch.PojoServiceRegistry in project aries by apache.
the class Helper method createBundleContext.
public static BundleContext createBundleContext(String bundleFilter, TinyBundle[] testBundles) throws Exception {
deleteDirectory("target/bundles");
createDirectory("target/bundles");
// ensure pojosr stores bundles in an unique target directory
System.setProperty("org.osgi.framework.storage", "target/bundles/" + System.currentTimeMillis());
// get the bundles
List<BundleDescriptor> bundles = getBundleDescriptors(bundleFilter);
// with pojosr because it does not support bundle hooks, so events are lost.
if (testBundles != null) {
for (TinyBundle bundle : testBundles) {
File tmp = File.createTempFile("test-", ".jar", new File("target/bundles/"));
tmp.delete();
bundles.add(0, getBundleDescriptor(tmp.getPath(), bundle));
}
}
if (LOG.isDebugEnabled()) {
for (int i = 0; i < bundles.size(); i++) {
BundleDescriptor desc = bundles.get(i);
LOG.debug("Bundle #{} -> {}", i, desc);
}
}
// setup pojosr to use our bundles
Map<String, List<BundleDescriptor>> config = new HashMap<String, List<BundleDescriptor>>();
config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles);
// create pojorsr osgi service registry
PojoServiceRegistry reg = new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(config);
return reg.getBundleContext();
}
use of de.kalpatec.pojosr.framework.launch.PojoServiceRegistry in project ddf by codice.
the class CatalogComponentFrameworkTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
// Since the Camel BlueprintComponentResolver does not execute outside
// of an OSGi container, we cannot
// rely on the CatalogComponentResolver to be used for resolving the
// CatalogComponent when Camel loads the route.
// Therefore, we Mock what the CatalogComponent's blueprint.xml file
// would have done by creating a
// CatalogComponent explicitly and adding it to the CamelContext used
// for this unit test.
// Configure PojoSR to be our mock OSGi Registry
final PojoServiceRegistry reg = new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(new HashMap());
final BundleContext bundleContext = reg.getBundleContext();
final CamelContext camelContext = super.createCamelContext();
final CatalogComponent catalogComponent = new CatalogComponent();
catalogComponent.setBundleContext(bundleContext);
catalogFramework = mock(CatalogFramework.class);
catalogComponent.setCatalogFramework(catalogFramework);
camelContext.addComponent(CatalogComponent.NAME, catalogComponent);
return camelContext;
}
Aggregations