use of java.util.jar.Attributes in project bnd by bndtools.
the class DSAnnotationTest method testProperties.
public void testProperties() throws Exception {
Builder b = new Builder();
b.setProperty(Constants.DSANNOTATIONS, "test.component.*x");
b.setProperty("Private-Package", "test.component");
b.addClasspath(new File("bin"));
Jar jar = b.build();
if (!b.check("Cannot convert data blabla to type Integer", "Cannot convert data 3.0 to type Integer"))
fail();
Attributes a = getAttr(jar);
checkProvides(a);
checkRequires(a, null);
//
// Test all the defaults
//
Resource r = jar.getResource("OSGI-INF/test.component.DSAnnotationTest$PropertiesTestx.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");
xt.assertAttribute("1", "scr:component/property[@name='b']/@value");
xt.assertAttribute("", "scr:component/property[@name='a']/@value");
xt.assertAttribute("Byte", "scr:component/property[@name='byte']/@type");
xt.assertAttribute("Boolean", "scr:component/property[@name='boolean']/@type");
xt.assertAttribute("Character", "scr:component/property[@name='char']/@type");
xt.assertAttribute("Short", "scr:component/property[@name='short']/@type");
xt.assertAttribute("Integer", "scr:component/property[@name='integer']/@type");
xt.assertAttribute("Long", "scr:component/property[@name='long']/@type");
xt.assertAttribute("Float", "scr:component/property[@name='float']/@type");
xt.assertAttribute("Double", "scr:component/property[@name='double']/@type");
xt.assertAttribute("Integer", "scr:component/property[@name='̓̈́͆ͅ']/@type");
}
use of java.util.jar.Attributes in project bnd by bndtools.
the class DSAnnotationTest method testBasicFelix12.
public void testBasicFelix12() throws Exception {
Builder b = new Builder();
b.setProperty(Constants.DSANNOTATIONS, "test.component.*_basicFelix12");
b.setProperty("-ds-felix-extensions", "true");
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, null, LogService.class.getName());
// Test Felix12 activate gives Felix 1.2 namespace
checkDSFelix12(jar, "test.component.DSAnnotationTest$activate_basicFelix12");
// Test Felix12 deactivate gives Felix 1.2 namespace
checkDSFelix12(jar, "test.component.DSAnnotationTest$deactivate_basicFelix12");
// Test Felix12 modified gives Felix 1.2 namespace
checkDSFelix12(jar, "test.component.DSAnnotationTest$modified_basicFelix12");
// Test Felix12 bind gives Felix 1.2 namespace
checkDSFelix12(jar, "test.component.DSAnnotationTest$bind_basicFelix12");
// Test Felix12 bind gives Felix 1.2 namespace
checkDSFelix12(jar, "test.component.DSAnnotationTest$unbind_basicFelix12");
// Test Felix12 updated gives Felix 1.2 namespace
checkDSFelix12(jar, "test.component.DSAnnotationTest$updated_basicFelix12");
}
use of java.util.jar.Attributes 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 java.util.jar.Attributes 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 java.util.jar.Attributes in project bnd by bndtools.
the class DSAnnotationTest method testNoHeaderDups.
public void testNoHeaderDups() throws Exception {
Builder b = new Builder();
b.setProperty(Constants.DSANNOTATIONS, "test.component.DSAnnotationTest$DS13_*");
b.setProperty("Private-Package", "test.component");
b.setProperty("Provide-Capability", "osgi.service;objectClass:List<String>=\"java.io.Serializable,java.lang.Runnable\"");
b.setProperty("Require-Capability", "osgi.service;filter:=\"(objectClass=org.osgi.service.log.LogService)\";effective:=active");
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());
}
Aggregations