use of aQute.bnd.test.XmlTester in project bnd by bndtools.
the class SpecMetatypeTest method testAD.
public void testAD() throws Exception {
Builder b = new Builder();
b.addClasspath(new File("bin"));
b.setProperty("Export-Package", "test.metatype");
b.setProperty(Constants.METATYPE_ANNOTATIONS, TestAD.class.getName());
b.build();
Resource r = b.getJar().getResource("OSGI-INF/metatype/test.metatype.SpecMetatypeTest$TestAD.xml");
assertEquals(0, b.getErrors().size());
assertEquals(0, b.getWarnings().size());
System.err.println(b.getJar().getResources().keySet());
assertNotNull(r);
IO.copy(r.openInputStream(), System.err);
XmlTester xt = xmlTester12(r);
assertAD(xt, "noSettings", "No settings", null, null, null, 0, "String", null, null, null);
assertAD(xt, "withId", "id", null, null, null, 0, "String", null, null, null);
assertAD(xt, "withName", "name", null, null, null, 0, "String", null, null, null);
assertAD(xt, "withMax", "With max", null, "1", null, 0, "String", null, null, null);
assertAD(xt, "withMin", "With min", "-1", null, null, 0, "String", null, null, null);
assertAD(xt, "withC1", "With c1", null, null, null, 1, "String", null, null, null);
assertAD(xt, "withC0", "With c0", null, null, null, 0, "String", null, null, null);
assertAD(xt, "withC.1", "With c 1", null, null, null, -1, "String", null, null, null);
assertAD(xt, "withC.1ButArray", "With c 1 but array", null, null, null, -1, "String", null, null, null);
assertAD(xt, "withC1ButCollection", "With c1 but collection", null, null, null, 1, "String", null, null, null);
assertAD(xt, "withInt", "With int", null, null, null, 0, "String", null, null, null);
assertAD(xt, "withString", "With string", null, null, null, 0, "Integer", null, null, null);
assertAD(xt, "a", "A", null, null, null, 0, "String", "description_xxx\"xxx'xxx", null, null);
assertAD(xt, "valuesOnly", "Values only", null, null, null, 0, "String", null, new String[] { "a", "b" }, new String[] { "a", "b" });
assertAD(xt, "labelsAndValues", "Labels and values", null, null, null, 0, "String", null, new String[] { "a", "b" }, new String[] { "A", "B" });
}
use of aQute.bnd.test.XmlTester in project bnd by bndtools.
the class SpecMetatypeTest method xmlTester.
private XmlTester xmlTester(Resource r, MetatypeVersion version) throws Exception {
XmlTester xt = new XmlTester(r.openInputStream(), "metatype", version.getNamespace());
xt.assertNamespace(version.getNamespace());
return xt;
}
use of aQute.bnd.test.XmlTester in project bnd by bndtools.
the class SpecMetatypeTest method testEnum.
public void testEnum() throws Exception {
Builder b = new Builder();
b.addClasspath(new File("bin"));
b.setProperty("Export-Package", "test.metatype");
b.setProperty(Constants.METATYPE_ANNOTATIONS, Enums.class.getName() + "*");
b.build();
System.err.println(b.getErrors());
assertEquals(0, b.getErrors().size());
assertEquals(0, b.getWarnings().size());
Resource r = b.getJar().getResource("OSGI-INF/metatype/test.metatype.SpecMetatypeTest$Enums.xml");
IO.copy(r.openInputStream(), System.err);
XmlTester xt = xmlTester12(r);
assertAD(xt, "r", "R", optionLabels, optionValues);
assertAD(xt, "i", "I", optionLabels, optionValues);
assertAD(xt, "o", "O", optionLabels, optionValues);
}
use of aQute.bnd.test.XmlTester in project bnd by bndtools.
the class SpecMetatypeTest method testMappingExtensions.
public void testMappingExtensions() throws Exception {
MetatypeVersion version = MetatypeVersion.VERSION_1_2;
Builder b = new Builder();
b.addClasspath(new File("bin"));
b.setProperty("Export-Package", "test.metatype");
b.setProperty(Constants.METATYPE_ANNOTATIONS, MappingConfig.class.getName());
b.build();
Resource r = b.getJar().getResource("OSGI-INF/metatype/test.metatype.SpecMetatypeTest$MappingConfig.xml");
assertEquals(0, b.getErrors().size());
assertEquals("warnings: " + b.getWarnings(), 0, b.getWarnings().size());
System.err.println(b.getJar().getResources().keySet());
assertNotNull(r);
IO.copy(r.openInputStream(), System.err);
XmlTester xt = new XmlTester(r.openInputStream(), "metatype", version.getNamespace(), "foo", "org.foo.extensions.v1");
xt.assertNamespace(version.getNamespace());
xt.assertExactAttribute("test.metatype.SpecMetatypeTest$MappingConfig", "metatype:MetaData/OCD/@id");
xt.assertCount(5, "metatype:MetaData/OCD/@*");
xt.assertExactAttribute("A", "metatype:MetaData/OCD/@foo:first");
xt.assertExactAttribute("B", "metatype:MetaData/OCD/@foo:second");
xt.assertCount(6, "metatype:MetaData/OCD/AD[@id='property']/@*");
xt.assertExactAttribute("one", "metatype:MetaData/OCD/AD[@id='property']/@foo:first");
xt.assertExactAttribute("two", "metatype:MetaData/OCD/AD[@id='property']/@foo:second");
}
Aggregations