use of aQute.bnd.osgi.Resource in project bnd by bndtools.
the class SpecMetatypeTest method testExtensions.
public void testExtensions() 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, TestExtensions.class.getName());
b.build();
Resource r = b.getJar().getResource("OSGI-INF/metatype/test.metatype.SpecMetatypeTest$TestExtensions.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$TestExtensions", "metatype:MetaData/OCD/@id");
xt.assertExactAttribute("simple", "metatype:MetaData/OCD/AD[@id='simple']/@id");
xt.assertExactAttribute("Simple", "metatype:MetaData/OCD/AD[@id='simple']/@name");
xt.assertExactAttribute("String", "metatype:MetaData/OCD/AD[@id='simple']/@type");
xt.assertExactAttribute("false", "metatype:MetaData/OCD/AD[@id='enabled']/@required");
xt.assertExactAttribute("true", "metatype:MetaData/OCD/AD[@id='enabled']/@default");
xt.assertExactAttribute(Integer.MAX_VALUE + "", "metatype:MetaData/OCD/AD[@id='notSoSimple']/@cardinality");
xt.assertCount(8, "metatype:MetaData/OCD/@*");
xt.assertExactAttribute("ocd", "metatype:MetaData/OCD/@foo:stringAttr");
xt.assertExactAttribute("A", "metatype:MetaData/OCD/@foo:fooAttr");
xt.assertExactAttribute("foo bar", "metatype:MetaData/OCD/@foo:stringArrayAttr");
xt.assertExactAttribute("1 2 3", "metatype:MetaData/OCD/@foo:intArrayAttr");
xt.assertExactAttribute("true", "metatype:MetaData/OCD/@foo:booleanAttr");
xt.assertCount(3, "metatype:MetaData/OCD/AD[@id='simple']/@*");
xt.assertCount(8, "metatype:MetaData/OCD/AD[@id='notSoSimple']/@*");
xt.assertExactAttribute("ad", "metatype:MetaData/OCD/AD[@id='notSoSimple']/@foo:stringAttr2");
xt.assertExactAttribute("B", "metatype:MetaData/OCD/AD[@id='notSoSimple']/@foo:fooAttr2");
xt.assertExactAttribute(String.class.getName(), "metatype:MetaData/OCD/AD[@id='notSoSimple']/@foo:classAttr2");
xt.assertExactAttribute("true", "metatype:MetaData/OCD/AD[@id='notSoSimple']/@foo:booleanAttr2");
xt.assertCount(4, "metatype:MetaData/OCD/AD[@id='stringCollection']/@*");
xt.assertCount(9, "metatype:MetaData/OCD/AD[@id='enabled']/@*");
xt.assertExactAttribute("ad2", "metatype:MetaData/OCD/AD[@id='enabled']/@foo:stringAttr2");
xt.assertExactAttribute("A", "metatype:MetaData/OCD/AD[@id='enabled']/@foo:fooAttr2");
xt.assertExactAttribute(Object.class.getName(), "metatype:MetaData/OCD/AD[@id='enabled']/@foo:classAttr2");
xt.assertExactAttribute("true", "metatype:MetaData/OCD/AD[@id='enabled']/@foo:booleanAttr2");
}
use of aQute.bnd.osgi.Resource in project bnd by bndtools.
the class SpecMetatypeTest method testEscapes.
public void testEscapes() throws Exception {
Builder b = new Builder();
b.addClasspath(new File("bin"));
b.setProperty("Export-Package", "test.metatype");
b.setProperty(Constants.METATYPE_ANNOTATIONS, Escapes.class.getName());
b.build();
Resource r = b.getJar().getResource("OSGI-INF/metatype/test.metatype.SpecMetatypeTest$Escapes.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, "escapes", "Escapes", null, null, "\\ \\,\\ \\\\,a\\,b,c\\,d,'apostrophe',\"quote\"&", 2147483647, "String", null, null, null);
}
use of aQute.bnd.osgi.Resource in project bnd by bndtools.
the class SpecMetatypeTest method testNaming14.
public void testNaming14() throws Exception {
Builder b = new Builder();
b.addClasspath(new File("bin"));
b.setProperty("Export-Package", "test.metatype");
b.setProperty(Constants.METATYPE_ANNOTATIONS, Naming14.class.getName());
b.build();
System.out.println(b.getErrors());
assertEquals(0, b.getErrors().size());
System.out.println(b.getWarnings());
assertEquals(0, b.getWarnings().size());
Resource r = b.getJar().getResource("OSGI-INF/metatype/test.metatype.SpecMetatypeTest$Naming14.xml");
IO.copy(r.openInputStream(), System.err);
XmlTester xt = xmlTester14(r);
assertAD(xt, "test.a-b", "A b", "foo");
assertAD(xt, "test.xa-b", "a-b", "foo");
assertAD(xt, "test.naming14", "Value", "foo");
}
use of aQute.bnd.osgi.Resource in project bnd by bndtools.
the class SpecMetatypeTest method testBndAnnoCompatible.
// cf issue 1130
public void testBndAnnoCompatible() throws Exception {
Builder b = new Builder();
b.addClasspath(new File("bin"));
b.setProperty("Export-Package", "test.metatype");
b.setProperty(Constants.METATYPE_ANNOTATIONS, C.class.getName());
b.build();
Resource r = b.getJar().getResource("OSGI-INF/metatype/test.metatype.SpecMetatypeTest$C.xml");
assertEquals(0, b.getErrors().size());
assertEquals(0, b.getWarnings().size());
assertNull(r);
}
use of aQute.bnd.osgi.Resource in project bnd by bndtools.
the class SpecMetatypeTest method testADWithInheritance.
public void testADWithInheritance() throws Exception {
Builder b = new Builder();
b.addClasspath(new File("bin"));
b.setProperty("Export-Package", "test.metatype");
b.setProperty(Constants.METATYPE_ANNOTATIONS, TestADWithInheritanceChild.class.getName().substring(0, TestADWithInheritanceChild.class.getName().length() - "Child".length()) + "*");
// b.setProperty("-metatypeannotations-inherit", "true");
b.build();
Resource r = b.getJar().getResource("OSGI-INF/metatype/test.metatype.SpecMetatypeTest$TestADWithInheritanceChild.xml");
System.err.println(b.getErrors());
assertEquals(0, b.getErrors().size());
System.err.println(b.getWarnings());
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, "fromChild", "From child", null, null, null, 0, "String", null, null, null);
assertAD(xt, "fromSuperOne", "From super one", null, null, null, 0, "String", null, null, null);
assertAD(xt, "fromSuperTwo", "From super two", null, null, null, 0, "String", null, null, null);
}
Aggregations