use of aQute.bnd.osgi.Resource in project bnd by bndtools.
the class DSAnnotationTest method testVolatileFieldDynamic.
public void testVolatileFieldDynamic() throws Exception {
Builder b = new Builder();
b.setProperty(Constants.DSANNOTATIONS, "test.component.*VolatileField");
b.setProperty("Private-Package", "test.component");
b.addClasspath(new File("bin"));
Jar jar = b.build();
assertOk(b);
Attributes a = getAttr(jar);
checkRequires(a, "1.3.0", LogService.class.getName());
Resource r = jar.getResource("OSGI-INF/test.component.DSAnnotationTest$VolatileField.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");
// Test the defaults
xt.assertAttribute("test.component.DSAnnotationTest$VolatileField", "scr:component/implementation/@class");
xt.assertAttribute("log1", "scr:component/reference[1]/@name");
xt.assertAttribute(LogService.class.getName(), "scr:component/reference[1]/@interface");
xt.assertAttribute("dynamic", "scr:component/reference[1]/@policy");
xt.assertAttribute("log2", "scr:component/reference[2]/@name");
xt.assertAttribute(LogService.class.getName(), "scr:component/reference[2]/@interface");
xt.assertNoAttribute("scr:component/reference[2]/@policy");
}
use of aQute.bnd.osgi.Resource in project bnd by bndtools.
the class DSAnnotationTest method testReferenceType.
public void testReferenceType() throws Exception {
Builder b = new Builder();
b.setProperty(Constants.DSANNOTATIONS, "test.component.*RefType");
b.setProperty("Private-Package", "test.component");
b.addClasspath(new File("bin"));
Jar jar = b.build();
assertOk(b, 0, 0);
Attributes a = getAttr(jar);
checkRequires(a, null, Marker.class.getName(), GenericMarker.class.getName(), Object.class.getName());
Resource r = jar.getResource("OSGI-INF/test.component.DSAnnotationTest$RefType.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");
Collection<String> indices = new TreeSet<String>();
for (int i = 1; i < 16; i++) indices.add(Integer.toString(i));
this.indices.addAll(indices);
checkMarkerReference(xt, 1, Marker.class);
checkMarkerReference(xt, 2, Marker.class);
checkMarkerReference(xt, 3, Marker.class);
checkMarkerReference(xt, 4, Marker.class);
checkMarkerReference(xt, 5, GenericMarker.class);
checkMarkerReference(xt, 6, GenericMarker.class);
checkMarkerReference(xt, 7, GenericMarker.class);
checkMarkerReference(xt, 8, GenericMarker.class);
checkMarkerReference(xt, 9, GenericMarker.class);
checkMarkerReference(xt, 10, GenericMarker.class);
checkMarkerReference(xt, 11, GenericMarker.class);
checkMarkerReference(xt, 12, GenericMarker.class);
checkMarkerReference(xt, 13, GenericMarker.class);
checkMarkerReference(xt, 14, Object.class);
checkMarkerReference(xt, 15, Marker.class);
}
use of aQute.bnd.osgi.Resource in project bnd by bndtools.
the class DSAnnotationTest method testComponentReference.
public void testComponentReference() throws Exception {
Builder b = new Builder();
b.setProperty(Constants.DSANNOTATIONS, "test.component.*ComponentReference*");
b.setProperty(Constants.DSANNOTATIONS_OPTIONS, "version;minimum=1.0.0");
b.setProperty("Private-Package", "test.component");
b.addClasspath(new File("bin"));
Jar jar = b.build();
assertOk(b, 1, 0);
{
Resource r = jar.getResource("OSGI-INF/test.component.DSAnnotationTest$ComponentReferenceGood.xml");
System.err.println(Processor.join(jar.getResources().keySet(), "\n"));
assertNotNull(r);
r.write(System.err);
XmlTester xt = new XmlTester(r.openInputStream());
xt.assertAttribute(LogService.class.getName(), "component/reference[1]/@interface");
}
{
Resource r = jar.getResource("OSGI-INF/test.component.DSAnnotationTest$ComponentReferenceBad.xml");
System.err.println(Processor.join(jar.getResources().keySet(), "\n"));
assertNotNull(r);
r.write(System.err);
XmlTester xt = new XmlTester(r.openInputStream());
xt.assertCount(0, "component/reference");
}
}
use of aQute.bnd.osgi.Resource in project bnd by bndtools.
the class DSAnnotationTest method testPrefixCollisionExtraAttributesDefaultPrefix.
public void testPrefixCollisionExtraAttributesDefaultPrefix() throws Exception {
Builder b = new Builder();
b.setProperty(Constants.DSANNOTATIONS, "test.component.DSAnnotationTest$DefaultPrefixCollisionExtraAttributes*");
b.setProperty("Private-Package", "test.component");
b.addClasspath(new File("bin"));
Jar jar = b.build();
assertOk(b);
String name = DefaultPrefixCollisionExtraAttributes.class.getName();
Resource r = jar.getResource("OSGI-INF/" + name + ".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", "ns", "org.foo.extensions.v4", "ns1", "org.foo.extensions.v5");
// Test the defaults
xt.assertAttribute(name, "scr:component/implementation/@class");
// Default must be the implementation class
xt.assertAttribute(name, "scr:component/@name");
xt.assertCount(10, "scr:component/@*");
xt.assertAttribute("bar", "scr:component/@ns:stringAttr4");
xt.assertAttribute("A", "scr:component/@ns:fooAttr4");
xt.assertAttribute("true", "scr:component/@ns:booleanAttr4");
xt.assertAttribute("bar3", "scr:component/@ns1:stringAttr5");
xt.assertAttribute("B", "scr:component/@ns1:fooAttr5");
xt.assertAttribute("true", "scr:component/@ns1:booleanAttr5");
}
use of aQute.bnd.osgi.Resource in project bnd by bndtools.
the class DSAnnotationTest method testExtraAttributes10.
/**
* test that an extension attribute will ensure at least a 1.1 namespace, so
* the extension namespace is meaningful
*
* @throws Exception
*/
public void testExtraAttributes10() throws Exception {
Builder b = new Builder();
b.setProperty(Constants.DSANNOTATIONS, "test.component.DSAnnotationTest$ExtraAttributes*");
b.setProperty(Constants.DSANNOTATIONS_OPTIONS, "version;minimum=1.0.0");
b.setProperty("Private-Package", "test.component");
b.addClasspath(new File("bin"));
Jar jar = b.build();
assertOk(b);
String name = ExtraAttributes10.class.getName();
Resource r = jar.getResource("OSGI-INF/" + name + ".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.1.0", "foo", "org.foo.extensions.v1");
// This wll check that the spec namespace is 1.1
xt.assertAttribute(name, "scr:component/implementation/@class");
}
Aggregations