use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BNDAnnotationTest method builder.
private Builder builder(String spec, int errors, int warnings) throws IOException, Exception, AssertionFailedError {
Builder b = new Builder();
b.setExceptions(true);
b.setClasspath(new File[] { new File("bin") });
b.setProperty("Service-Component", spec);
b.setProperty("Private-Package", "test.component");
b.setProperty("-dsannotations", "");
b.setProperty("-fixupmessages.bndannodeprecated", "Bnd DS annotations are deprecated");
b.build();
assertOk(b, errors, warnings);
return b;
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BNDAnnotationTest method testNoUnbindDynamic.
public void testNoUnbindDynamic() throws Exception {
Builder b = builder("*NoUnbindDynamic", 1, 0);
assertTrue(b.getErrors().get(0).endsWith("dynamic but has no unbind method."));
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BNDAnnotationTest method testExplicitUnbind.
public void testExplicitUnbind() throws Exception {
Builder b = builder("*ExplicitUnbind", 1, 0);
Document doc = doc(b, "explicitunbind");
assertEquals("setLog", xpath.evaluate("component/reference/@bind", doc));
assertEquals("killLog", xpath.evaluate("component/reference/@unbind", doc));
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BNDAnnotationTest method testMultipleArguments.
public void testMultipleArguments() throws Exception {
Builder b = builder("*.(MultipleArguments|ReferenceArgument)");
Document doc = doc(b, "mcomp");
assertAttribute(doc, "bindWithMap", "scr:component/reference/@bind");
assertAttribute(doc, "org.osgi.service.log.LogService", "scr:component/reference/@interface");
doc = doc(b, "rcomp");
assertAttribute(doc, "bindReference", "scr:component/reference/@bind");
assertAttribute(doc, "org.osgi.service.log.LogService", "scr:component/reference/@interface");
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BNDAnnotationTest method testConfig.
public void testConfig() throws Exception {
Builder b = builder("*MetatypeConfig*");
assertTrue(b.check());
System.err.println(b.getJar().getResources().keySet());
// Check component name
{
Resource cr = b.getJar().getResource("OSGI-INF/config.xml");
cr.write(System.err);
Document d = db.parse(cr.openInputStream());
assertEquals("config", xpath.evaluate("/scr:component/@name", d, XPathConstants.STRING));
}
// Check if config properly linked
{
Resource mr = b.getJar().getResource("OSGI-INF/metatype/config.xml");
mr.write(System.err);
Document d = db.parse(mr.openInputStream());
assertEquals("config", xpath.evaluate("//Designate/@factoryPid", d, XPathConstants.STRING));
assertEquals("config", xpath.evaluate("//Object/@ocdref", d, XPathConstants.STRING));
}
// Now with default name
{
Resource cr2 = b.getJar().getResource("OSGI-INF/test.component.BNDAnnotationTest$MetatypeConfig2.xml");
cr2.write(System.err);
Document d = db.parse(cr2.openInputStream());
assertEquals("test.component.BNDAnnotationTest$MetatypeConfig2", xpath.evaluate("//scr:component/@name", d, XPathConstants.STRING));
}
{
Resource mr2 = b.getJar().getResource("OSGI-INF/metatype/test.component.BNDAnnotationTest$MetatypeConfig2.xml");
mr2.write(System.err);
Document d = db.parse(mr2.openInputStream());
assertEquals("test.component.BNDAnnotationTest$MetatypeConfig2", xpath.evaluate("//Designate/@pid", d, XPathConstants.STRING));
assertEquals("test.component.BNDAnnotationTest$MetatypeConfig2", xpath.evaluate("//Object/@ocdref", d, XPathConstants.STRING));
}
}
Aggregations