use of aQute.bnd.test.XmlTester in project bnd by bndtools.
the class DSAnnotationTest method testFieldCollectionType.
public void testFieldCollectionType() throws Exception {
Builder b = new Builder();
b.setProperty(Constants.DSANNOTATIONS, "test.component.DSAnnotationTest*TestFieldCollectionType");
b.setProperty("Private-Package", "test.component");
b.addClasspath(new File("bin"));
Jar jar = b.build();
assertOk(b);
Attributes a = getAttr(jar);
checkProvides(a, SERIALIZABLE_RUNNABLE);
checkRequires(a, "1.3.0", LogService.class.getName());
Resource r = jar.getResource("OSGI-INF/" + TestFieldCollectionType.class.getName() + ".xml");
assertNotNull(r);
r.write(System.err);
XmlTester xt = new XmlTester(r.openInputStream(), "scr", "http://www.osgi.org/xmlns/scr/v1.3.0");
xt.assertNamespace("http://www.osgi.org/xmlns/scr/v1.3.0");
xt.assertAttribute("propsField", "scr:component/reference[1]/@name");
xt.assertAttribute(LogService.class.getName(), "scr:component/reference[1]/@interface");
xt.assertAttribute("propsField", "scr:component/reference[1]/@field");
xt.assertAttribute("properties", "scr:component/reference[1]/@field-collection-type");
xt.assertAttribute("serviceField", "scr:component/reference[2]/@name");
xt.assertAttribute(LogService.class.getName(), "scr:component/reference[2]/@interface");
xt.assertAttribute("serviceField", "scr:component/reference[2]/@field");
xt.assertAttribute("service", "scr:component/reference[2]/@field-collection-type");
xt.assertAttribute("soField", "scr:component/reference[3]/@name");
xt.assertAttribute(LogService.class.getName(), "scr:component/reference[3]/@interface");
xt.assertAttribute("soField", "scr:component/reference[3]/@field");
xt.assertAttribute("serviceobjects", "scr:component/reference[3]/@field-collection-type");
xt.assertAttribute("srField", "scr:component/reference[4]/@name");
xt.assertAttribute(LogService.class.getName(), "scr:component/reference[4]/@interface");
xt.assertAttribute("srField", "scr:component/reference[4]/@field");
xt.assertAttribute("reference", "scr:component/reference[4]/@field-collection-type");
xt.assertAttribute("tupleField", "scr:component/reference[5]/@name");
xt.assertAttribute(LogService.class.getName(), "scr:component/reference[5]/@interface");
xt.assertAttribute("tupleField", "scr:component/reference[5]/@field");
xt.assertAttribute("tuple", "scr:component/reference[5]/@field-collection-type");
}
use of aQute.bnd.test.XmlTester in project bnd by bndtools.
the class DSAnnotationTest method checkConfigurationPolicy.
void checkConfigurationPolicy(Jar jar, Class<?> clazz, String option) throws Exception, XPathExpressionException {
Resource r = jar.getResource("OSGI-INF/" + clazz.getName() + ".xml");
assertNotNull(r);
r.write(System.err);
XmlTester xt = new XmlTester(r.openInputStream(), "scr", "http://www.osgi.org/xmlns/scr/v1.1.0");
xt.assertNamespace("http://www.osgi.org/xmlns/scr/v1.1.0");
xt.assertAttribute(option, "scr:component/@configuration-policy");
}
use of aQute.bnd.test.XmlTester in project bnd by bndtools.
the class DSAnnotationTest method verifyDS11VeryBasic.
private void verifyDS11VeryBasic(Jar jar, Class<?> clazz) throws Exception, XPathExpressionException {
String className = clazz.getName();
Resource r = jar.getResource("OSGI-INF/" + className + ".xml");
System.err.println(Processor.join(jar.getResources().keySet(), "\n"));
assertNotNull(r);
r.write(System.err);
// #136
XmlTester xt = new XmlTester(r.openInputStream(), "scr", "http://www.osgi.org/xmlns/scr/v1.1.0");
// was
// http://www.osgi.org/xmlns/scr/1.1.0
// Test the defaults
xt.assertAttribute(className, "scr:component/implementation/@class");
// Default must be the implementation class
xt.assertAttribute(className, "scr:component/@name");
xt.assertAttribute("", "scr:component/@configuration-policy");
xt.assertAttribute("", "scr:component/@immediate");
xt.assertAttribute("", "scr:component/@enabled");
xt.assertAttribute("", "scr:component/@factory");
xt.assertAttribute("", "scr:component/service/@servicefactory");
xt.assertAttribute("", "scr:component/@configuration-pid");
xt.assertAttribute("activate", "scr:component/@activate");
xt.assertAttribute("deactivate", "scr:component/@deactivate");
xt.assertAttribute("", "scr:component/@modified");
xt.assertAttribute("0", "count(scr:component/properties)");
xt.assertAttribute("0", "count(scr:component/property)");
xt.assertAttribute("LogService", "scr:component/reference[1]/@name");
xt.assertAttribute("", "scr:component/reference[1]/@target");
xt.assertAttribute("setLogService", "scr:component/reference[1]/@bind");
xt.assertAttribute("unsetLogService", "scr:component/reference[1]/@unbind");
xt.assertAttribute("", "scr:component/reference[1]/@cardinality");
xt.assertAttribute("", "scr:component/reference[1]/@policy");
xt.assertAttribute("", "scr:component/reference[1]/@target");
xt.assertAttribute("", "scr:component/reference[1]/@policy-option");
}
use of aQute.bnd.test.XmlTester in project bnd by bndtools.
the class DSAnnotationTest method testMismatchedUnbind.
public void testMismatchedUnbind() throws Exception {
Builder b = new Builder();
b.setProperty(Constants.DSANNOTATIONS, "test.component.*MismatchedUnbind");
b.setProperty("Private-Package", "test.component");
b.addClasspath(new File("bin"));
Jar jar = b.build();
assertOk(b, 0, 8);
Attributes a = getAttr(jar);
checkRequires(a, null, LogService.class.getName());
Resource r = jar.getResource("OSGI-INF/test.component.DSAnnotationTest$MismatchedUnbind.xml");
System.err.println(Processor.join(jar.getResources().keySet(), "\n"));
assertNotNull(r);
r.write(System.err);
XmlTester xt = new XmlTester(r.openInputStream(), "scr", "http://www.osgi.org/xmlns/scr/v1.3.0");
xt.assertAttribute("LogService10", "scr:component/reference[1]/@name");
xt.assertAttribute(LogService.class.getName(), "scr:component/reference[1]/@interface");
xt.assertAttribute("setLogService10", "scr:component/reference[1]/@bind");
xt.assertNoAttribute("scr:component/reference[1]/@unbind");
xt.assertNoAttribute("scr:component/reference[1]/@updated");
xt.assertAttribute("LogService11", "scr:component/reference[2]/@name");
xt.assertAttribute(LogService.class.getName(), "scr:component/reference[2]/@interface");
xt.assertAttribute("setLogService11", "scr:component/reference[2]/@bind");
xt.assertNoAttribute("scr:component/reference[2]/@unbind");
xt.assertAttribute("LogService13", "scr:component/reference[3]/@name");
xt.assertAttribute(LogService.class.getName(), "scr:component/reference[3]/@interface");
xt.assertAttribute("setLogService13", "scr:component/reference[3]/@bind");
xt.assertNoAttribute("scr:component/reference[3]/@unbind");
}
use of aQute.bnd.test.XmlTester in project bnd by bndtools.
the class DSAnnotationTest method testBinds.
public void testBinds(String extender) throws Exception {
Builder b = new Builder();
b.setProperty(Constants.DSANNOTATIONS, "test.component.DSAnnotationTest*CheckBinds");
if (extender != null)
b.setProperty(Constants.DSANNOTATIONS_OPTIONS, "extender");
b.setProperty(Constants.DSANNOTATIONS_OPTIONS + ".min", "version;minimum=1.2.0");
b.setProperty("Private-Package", "test.component");
b.addClasspath(new File("bin"));
Jar jar = b.build();
assertOk(b);
Attributes a = getAttr(jar);
checkProvides(a);
checkRequires(a, extender, LogService.class.getName());
Resource r = jar.getResource("OSGI-INF/prototypes.xml");
assertNotNull(r);
r.write(System.err);
XmlTester xt = new XmlTester(r.openInputStream(), "scr", "http://www.osgi.org/xmlns/scr/v1.2.0");
xt.assertAttribute("LogService", "scr:component/reference[1]/@name");
xt.assertAttribute("bindLogService", "scr:component/reference[1]/@bind");
xt.assertAttribute("unbindLogService", "scr:component/reference[1]/@unbind");
xt.assertAttribute("updatedLogService", "scr:component/reference[1]/@updated");
}
Aggregations