use of aQute.bnd.osgi.Analyzer in project bnd by bndtools.
the class AnalyzerTest method testMultilevelInheritance.
public static void testMultilevelInheritance() throws Exception {
try (Analyzer a = new Analyzer()) {
a.setJar(new File("bin"));
a.analyze();
String result = a._classes("cmd", "named", "*T?", "extends", "test.T0", "concrete");
System.err.println(result);
assertTrue(result.contains("test.T2"));
assertTrue(result.contains("test.T3"));
}
}
use of aQute.bnd.osgi.Analyzer in project bnd by bndtools.
the class AnalyzerTest method testExportForJar.
/**
* There was an export generated for a jar file.
*
* @throws Exception
*/
public static void testExportForJar() throws Exception {
try (Analyzer an = new Analyzer()) {
Jar jar = new Jar("dot");
jar.putResource("target/aopalliance.jar", new FileResource(IO.getFile("jar/asm.jar")));
an.setJar(jar);
an.setProperty("Export-Package", "target");
Manifest manifest = an.calcManifest();
assertTrue(an.check());
String exports = manifest.getMainAttributes().getValue(Analyzer.EXPORT_PACKAGE);
Parameters map = Analyzer.parseHeader(exports, null);
assertEquals(1, map.size());
assertEquals("target", map.keySet().iterator().next());
}
}
use of aQute.bnd.osgi.Analyzer in project bnd by bndtools.
the class AnalyzerTest method testClassQuery.
public static void testClassQuery() throws Exception {
try (Analyzer a = new Analyzer()) {
a.setJar(IO.getFile("jar/osgi.jar"));
a.analyze();
String result = a._classes("cmd", "named", "org.osgi.service.http.*", "abstract");
TreeSet<String> r = new TreeSet<String>(Processor.split(result));
assertEquals(new TreeSet<String>(Arrays.asList("org.osgi.service.http.HttpContext", "org.osgi.service.http.HttpService")), r);
}
}
use of aQute.bnd.osgi.Analyzer in project bnd by bndtools.
the class Target method testComponentReader.
public static void testComponentReader() throws Exception {
Analyzer analyzer = new Analyzer();
File f = IO.getFile("bin/test/AnnotationsTest$MyComponent.class");
Clazz c = new Clazz(analyzer, "test.AnnotationsTest.MyComponent", new FileResource(f));
@SuppressWarnings("restriction") Map<String, String> map = ComponentAnnotationReader.getDefinition(c);
System.err.println(map);
assertEquals("mycomp", map.get("name:"));
assertEquals("true", map.get("servicefactory:"));
assertEquals("activatex", map.get("activate:"));
assertEquals("deactivatex", map.get("deactivate:"));
assertEquals("modifiedx", map.get("modified:"));
assertEquals("org.osgi.service.log.LogService(abc=3)~", map.get("log/setLog"));
assertEquals("org.osgi.service.packageadmin.PackageAdmin", map.get("packageAdmin/setPackageAdmin"));
assertEquals("aprop= a prop ,aprop2= really dumb value ! ", map.get("properties:"));
}
use of aQute.bnd.osgi.Analyzer in project bnd by bndtools.
the class Target method testNestedAnnotations.
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void testNestedAnnotations() throws Exception {
try (Analyzer analyzer = new Analyzer()) {
TypeRef typeref = analyzer.getTypeRefFromFQN(ActualAnnotation.class.getName());
Map<String, Object> annMap = (Map) Collections.singletonMap("a", 5);
Annotation annotation = new Annotation(typeref, annMap, ElementType.FIELD, RetentionPolicy.RUNTIME);
Map<String, Object> properties = (Map) Collections.singletonMap("ann", annotation);
ConfigurableInterface a = Configurable.createConfigurable(ConfigurableInterface.class, properties);
assertNotNull(a);
assertNotNull(a.ann());
assertEquals(5, a.ann().a());
}
}
Aggregations