use of aQute.bnd.metatype.MetatypeVersion in project bnd by bndtools.
the class SpecMetatypeTest method testSimpleExtensions.
public void testSimpleExtensions() 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, SimpleConfig.class.getName());
b.build();
Resource r = b.getJar().getResource("OSGI-INF/metatype/test.metatype.SpecMetatypeTest$SimpleConfig.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$SimpleConfig", "metatype:MetaData/OCD/@id");
xt.assertCount(4, "metatype:MetaData/OCD/@*");
xt.assertExactAttribute("default", "metatype:MetaData/OCD/@foo:simple");
xt.assertCount(5, "metatype:MetaData/OCD/AD[@id='property']/@*");
xt.assertExactAttribute("value", "metatype:MetaData/OCD/AD[@id='property']/@foo:simple");
}
use of aQute.bnd.metatype.MetatypeVersion 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.metatype.MetatypeVersion 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