use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class VersionPolicyTest method testImportProvided.
/**
* Test import provide:.
*/
public static void testImportProvided() throws Exception {
Builder a = new Builder();
a.addClasspath(IO.getFile("jar/osgi.jar"));
a.addClasspath(new File("bin"));
a.setProperty("Private-Package", "test.refer");
a.setProperty("Import-Package", "org.osgi.service.event;provide:=true,*");
Jar jar = a.build();
Map<String, String> event = a.getImports().getByFQN("org.osgi.service.event");
assertEquals("[1.0,1.1)", event.get("version"));
Map<String, String> http = a.getImports().getByFQN("org.osgi.service.http");
assertEquals("[1.2,2)", http.get("version"));
Manifest m = jar.getManifest();
String imports = m.getMainAttributes().getValue(Constants.IMPORT_PACKAGE);
assertFalse(imports.contains(Constants.PROVIDE_DIRECTIVE));
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class VersionPolicyTest method testVersionPolicyImportedExportsDefaultPolicy.
/**
* Test if we can get the version from the source and apply the default
* policy.
*/
public static void testVersionPolicyImportedExportsDefaultPolicy() throws Exception {
Builder b = new Builder();
b.addClasspath(IO.getFile("jar/osgi.jar"));
b.addClasspath(new File("bin"));
b.setProperty("Export-Package", "org.osgi.service.event");
b.setProperty("Private-Package", "test.refer");
b.build();
String s = b.getImports().getByFQN("org.osgi.service.event").get("version");
assertEquals("[1.0,2)", s);
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class VersionPolicyTest method testHardcodedImports.
/**
* hardcoded imports
*/
public static void testHardcodedImports() throws Exception {
Builder b = new Builder();
b.addClasspath(IO.getFile("jar/osgi.jar"));
b.setProperty("-versionpolicy", "${range;[==,+)}");
b.setProperty("Private-Package", "org.objectweb.asm");
b.setProperty("Import-Package", "org.osgi.framework,org.objectweb.asm,abc;version=2.0.0,*");
b.build();
Manifest m = b.getJar().getManifest();
m.write(System.err);
String s = b.getImports().getByFQN("org.objectweb.asm").get("version");
assertNull(s);
s = b.getImports().getByFQN("abc").get("version");
assertEquals("2.0.0", s);
s = b.getImports().getByFQN("org.osgi.framework").get("version");
assertEquals("[1.3,2)", s);
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class VersionPolicyTest method testExportAnnotation.
/**
* Test export annotation.
*/
public static void testExportAnnotation() throws Exception {
Builder a = new Builder();
a.addClasspath(new File("bin"));
a.setProperty("build", "xyz");
a.setProperty("Export-Package", "test.versionpolicy.api");
a.build();
Map<String, String> attrs = a.getExports().getByFQN("test.versionpolicy.api");
assertEquals("1.2.0.xyz", attrs.get("version"));
assertEquals("PrivateImpl", attrs.get("exclude:"));
assertEquals("a", attrs.get("mandatory:"));
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class VersionPolicyTest method testProviderTypeR6.
/**
* Test if the implementation of "AnnotatedProviderInterface", which is
* annotated with OSGi R6 @ProviderType, causes import of the api package to
* use the provider version policy
*/
public static void testProviderTypeR6() throws Exception {
Builder b = new Builder();
b.addClasspath(new File("bin"));
b.setPrivatePackage("test.versionpolicy.implemented.osgi");
b.setProperty("build", "123");
Jar jar = b.build();
assertTrue(b.check());
Manifest m = jar.getManifest();
m.write(System.err);
Domain d = Domain.domain(m);
Parameters params = d.getImportPackage();
Attrs attrs = params.get("test.version.annotations.osgi");
assertNotNull(attrs);
assertEquals("[1.2,1.3)", attrs.get("version"));
}
Aggregations