use of org.example.tests.utils.WibbleAnalyzer in project bnd by bndtools.
the class TestOSGiServices method testWhiteboardAnalyzer.
// Test whiteboard registration of Resource Analyzers.
public void testWhiteboardAnalyzer() throws Exception {
ServiceRegistration<ResourceAnalyzer> reg = context.registerService(ResourceAnalyzer.class, new WibbleAnalyzer(), null);
ServiceReference<ResourceIndexer> ref = context.getServiceReference(ResourceIndexer.class);
ResourceIndexer indexer = context.getService(ref);
StringWriter writer = new StringWriter();
Map<String, String> config = new HashMap<String, String>();
config.put(ResourceIndexer.ROOT_URL, tempDir.getAbsoluteFile().toURI().toString());
indexer.indexFragment(Collections.singleton(copyToTempFile(tempDir, "testdata/01-bsn+version.jar")), writer, config);
assertEquals(readStream(TestOSGiServices.class.getResourceAsStream("/testdata/fragment-wibble.txt")), writer.toString().trim());
context.ungetService(ref);
reg.unregister();
}
use of org.example.tests.utils.WibbleAnalyzer in project bnd by bndtools.
the class TestOSGiServices method testWhiteboardAnalyzerWithFilter.
// Test whiteboard registration of Resource Analyzers, with resource filter
// property.
public void testWhiteboardAnalyzerWithFilter() throws Exception {
Dictionary<String, Object> analyzerProps = new Hashtable<String, Object>();
analyzerProps.put(ResourceAnalyzer.FILTER, "(location=*sion.jar)");
ServiceRegistration<ResourceAnalyzer> reg = context.registerService(ResourceAnalyzer.class, new WibbleAnalyzer(), analyzerProps);
ServiceReference<ResourceIndexer> ref = context.getServiceReference(ResourceIndexer.class);
ResourceIndexer indexer = context.getService(ref);
StringWriter writer = new StringWriter();
Set<File> files = new LinkedHashSet<File>();
files.add(copyToTempFile(tempDir, "testdata/01-bsn+version.jar"));
files.add(copyToTempFile(tempDir, "testdata/02-localization.jar"));
Map<String, String> config = new HashMap<String, String>();
config.put(ResourceIndexer.ROOT_URL, tempDir.getAbsoluteFile().toURI().toString());
indexer.indexFragment(files, writer, config);
assertEquals(readStream(TestOSGiServices.class.getResourceAsStream("/testdata/fragment-wibble-filtered.txt")), writer.toString().trim());
context.ungetService(ref);
reg.unregister();
}
Aggregations