use of aQute.bnd.osgi.Clazz in project bnd by bndtools.
the class ClazzTest method testRecursiveAnnotation.
public void testRecursiveAnnotation() throws Exception {
File file = IO.getFile("bin/test/ClazzTest$RecursiveAnno.class");
try (Analyzer analyzer = new Analyzer()) {
Clazz clazz = new Clazz(analyzer, file.getPath(), new FileResource(file));
clazz.parseClassFile();
analyzer.getClassspace().put(clazz.getClassName(), clazz);
AnnotationReader.getDefinition(clazz, analyzer, EnumSet.noneOf(DSAnnotations.Options.class), new XMLAttributeFinder(analyzer), AnnotationReader.V1_3);
}
}
use of aQute.bnd.osgi.Clazz in project bnd by bndtools.
the class ClassParserTest method testGenericsSignature.
public static void testGenericsSignature() throws Exception {
Clazz c = new Clazz(a, "genericstest", new FileResource(IO.getFile("src/test/generics.clazz")));
c.parseClassFile();
assertTrue(c.getReferred().contains(a.getPackageRef("javax/swing/table")));
assertTrue(c.getReferred().contains(a.getPackageRef("javax/swing")));
}
use of aQute.bnd.osgi.Clazz in project bnd by bndtools.
the class ClassParserTest method testMissingPackage1.
public void testMissingPackage1() throws Exception {
InputStream in = getClass().getResourceAsStream("JobsService.clazz");
assertNotNull(in);
Clazz clazz = new Clazz(a, "test", null);
clazz.parseClassFile(in);
System.err.println(clazz.getReferred());
clazz.parseDescriptor("(IILcom/linkedin/member2/pub/profile/core/view/I18nPositionViews;)Lcom/linkedin/leo/cloud/overlap/api/OverlapQuery;", 0);
assertTrue(clazz.getReferred().contains(a.getPackageRef("com/linkedin/member2/pub/profile/core/view")));
}
use of aQute.bnd.osgi.Clazz in project bnd by bndtools.
the class ClassParserTest method testConstantValues.
/**
* Test the constant values
*
* @throws Exception
*/
public void testConstantValues() throws Exception {
final Map<String, Object> values = new HashMap<String, Object>();
Clazz c = new Clazz(a, "ConstantValues", new FileResource(IO.getFile(new File("").getAbsoluteFile(), "bin/test/ConstantValues.class")));
c.parseClassFileWithCollector(new ClassDataCollector() {
Clazz.FieldDef last;
@Override
public void field(Clazz.FieldDef referenced) {
last = referenced;
}
@Override
public void constant(Object value) {
values.put(last.getName(), value);
}
});
assertEquals(1, values.get("t"));
assertEquals(0, values.get("f"));
assertEquals((int) Byte.MAX_VALUE, values.get("bt"));
assertEquals((int) Short.MAX_VALUE, values.get("shrt"));
assertEquals((int) Character.MAX_VALUE, values.get("chr"));
assertEquals(Integer.MAX_VALUE, values.get("intgr"));
assertEquals(Long.MAX_VALUE, values.get("lng"));
assertEquals(Float.MAX_VALUE, values.get("flt"));
assertEquals(Double.MAX_VALUE, values.get("dbl"));
assertEquals("blabla", values.get("strng"));
// Classes are special
// assertEquals("java.lang.Object", ((Clazz.ClassConstant)
// values.get("clss")).getName());
}
use of aQute.bnd.osgi.Clazz in project bnd by bndtools.
the class ClassParserTest method testGenericsSignature3.
public void testGenericsSignature3() throws Exception {
Clazz c = new Clazz(a, "genericstest", null);
c.parseClassFile(getClass().getResourceAsStream("Generics.class"));
assertTrue(c.getReferred().contains(a.getPackageRef("test")));
assertTrue(c.getReferred().contains(a.getPackageRef("aQute/bnd/osgi")));
}
Aggregations