use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BNDAnnotationTest method testAnnotations.
public void testAnnotations() throws Exception {
Builder b = builder("*MyComponent");
Document doc = doc(b, "acomp");
print(doc, "");
assertAttribute(doc, "test.component.BNDAnnotationTest$MyComponent", "scr:component/implementation/@class");
assertAttribute(doc, "acomp", "scr:component/@name");
assertAttribute(doc, "abc", "scr:component/@factory");
assertAttribute(doc, "true", "scr:component/service/@servicefactory");
assertAttribute(doc, "activatex", "scr:component/@activate");
assertAttribute(doc, "modifiedx", "scr:component/@modified");
assertAttribute(doc, "deactivatex", "scr:component/@deactivate");
assertAttribute(doc, "org.osgi.service.log.LogService", "scr:component/service/provide/@interface");
assertAttribute(doc, "(abc=3)", "scr:component/reference/@target");
assertAttribute(doc, "setLog", "scr:component/reference/@bind");
assertAttribute(doc, "unsetLog", "scr:component/reference/@unbind");
assertAttribute(doc, "0..1", "scr:component/reference/@cardinality");
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BNDAnnotationTest method testActivateWithMultipleArguments.
public void testActivateWithMultipleArguments() throws Exception {
Builder b = builder("*.ActivateWithMultipleArguments");
Document doc = doc(b, "amcomp");
assertAttribute(doc, "whatever", "scr:component/@activate");
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class VersionPolicyTest method testImportMicroNotTruncated.
/**
* Check if we can set a specific version on the import that does not use a
* version policy.
*/
public static void testImportMicroNotTruncated() throws Exception {
Builder b = new Builder();
b.addClasspath(IO.getFile("jar/osgi.jar"));
b.setProperty("Import-Package", "org.osgi.service.event;version=${@}, org.osgi.service.log;version=\"${range;[==,=+)}\"");
b.build();
String s = b.getImports().getByFQN("org.osgi.service.event").get("version");
String l = b.getImports().getByFQN("org.osgi.service.log").get("version");
assertEquals("1.0.1", s);
assertEquals("[1.3,1.4)", l);
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class VersionPolicyTest method testDisableDefaultPackageVersion.
/**
* Test disable default package versions.
*/
public static void testDisableDefaultPackageVersion() throws Exception {
Builder a = new Builder();
a.addClasspath(new File("bin"));
a.setProperty("Bundle-Version", "1.2.3");
a.setProperty("Export-Package", "test.refer");
a.setProperty("-nodefaultversion", "true");
Jar jar = a.build();
Manifest m = jar.getManifest();
Parameters exports = Processor.parseHeader(m.getMainAttributes().getValue(Constants.EXPORT_PACKAGE), null);
Map<String, String> attrs = exports.get("test.refer");
assertNotNull(attrs);
assertNull(attrs.get("version"));
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class VersionPolicyTest method testConsumerType.
/**
* Tests if the implementation of the EventHandler (which is marked as a
* ConsumerType) causes the import of the api package to use the consumer
* version policy.
*/
public static void testConsumerType() throws Exception {
Builder a = new Builder();
a.addClasspath(new File("bin"));
a.setPrivatePackage("test.versionpolicy.uses");
a.setExportPackage("test.versionpolicy.api");
a.setProperty("build", "123");
Jar jar = a.build();
assertTrue(a.check());
Manifest m = jar.getManifest();
m.write(System.err);
Domain d = Domain.domain(m);
Parameters parameters = d.getImportPackage();
Attrs attrs = parameters.get("test.versionpolicy.api");
assertNotNull(attrs);
assertEquals("[1.2,2)", attrs.get("version"));
}
Aggregations