use of aQute.bnd.osgi.Domain in project bnd by bndtools.
the class BuilderTest method testEEMacro2.
public static void testEEMacro2() throws Exception {
String[] packages = { "eclipse_1_1", "eclipse_1_2", "eclipse_1_3", "eclipse_1_4", "eclipse_1_5", "eclipse_1_6", "eclipse_1_7", "eclipse_jsr14", "sun_1_8" };
String[] ees = { "JRE-1.1", "J2SE-1.2", "J2SE-1.3", "J2SE-1.4", "J2SE-1.5", "JavaSE-1.6", "JavaSE-1.7", "J2SE-1.4", "JavaSE-1.8" };
String[] versions = { "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.4", "1.8" };
Pattern p = Pattern.compile("\\(&\\(osgi.ee=JavaSE\\)\\(version=(" + Version.VERSION_STRING + ")\\)\\)");
for (int i = 0; i < packages.length; i++) {
Builder b = new Builder();
try {
b.addClasspath(IO.getFile("compilerversions/compilerversions.jar"));
b.setPrivatePackage(packages[i]);
b.setBundleRequiredExecutionEnvironment("${ee}");
Jar jar = b.build();
assertTrue(b.check());
Domain domain = Domain.domain(jar.getManifest());
Parameters ee = domain.getBundleRequiredExecutionEnvironment();
System.err.println(ee);
assertEquals(ees[i], ee.toString());
//
// Check the requirements
//
Parameters een = domain.getRequireCapability();
assertFalse(een.isEmpty());
Attrs attrs = een.get("osgi.ee");
String filter = attrs.get("filter:");
Matcher m = p.matcher(filter);
assertTrue(m.matches());
assertEquals(versions[i], m.group(1));
} finally {
b.close();
}
}
}
use of aQute.bnd.osgi.Domain in project bnd by bndtools.
the class ContractTest method testSelect.
/**
* Test if we can select
*
* @throws Exception
*/
public void testSelect() throws Exception {
Jar bjara = getContractExporter("atest", "2.5", "${exports}");
Jar bjarb = getContractExporter("btest", "2.5", "${exports}");
Builder a = newBuilder();
a.setTrace(true);
// 1x
a.addClasspath(bjara);
// 2x
a.addClasspath(bjarb);
a.setProperty(Constants.CONTRACT, "atest;alpha=1");
a.setImportPackage("org.osgi.service.cm,*");
a.setProperty("Export-Package", "test.refer");
Jar ajar = a.build();
assertTrue(a.check());
ajar.getManifest().write(System.out);
Domain domain = Domain.domain(ajar.getManifest());
Parameters p = domain.getRequireCapability();
p.remove("osgi.ee");
assertNotNull(p);
assertEquals(1, p.size());
Attrs attrs = p.get("osgi.contract");
String alpha = attrs.get("alpha");
assertEquals("1", alpha);
assertEquals("(&(osgi.contract=atest)(version=2.5.0))", attrs.get("filter:"));
}
use of aQute.bnd.osgi.Domain in project bnd by bndtools.
the class ResourceTest method testImportExportServiceFromManifest.
public void testImportExportServiceFromManifest() throws Exception {
ResourceBuilder rb = new ResourceBuilder();
File f = IO.getFile("testresources/manifest/configadmin-1.8.8.mf");
Manifest m = new Manifest(new FileInputStream(f));
Domain d = Domain.domain(m);
rb.addManifest(d);
assertConfigAdminServices(rb.build());
}
use of aQute.bnd.osgi.Domain in project bnd by bndtools.
the class AnnotationHeadersTest method testDefaultAttrs.
/**
* Default values of annotation attributes not included for customized
* webresource annotations #976
* <p>
* When I add a customized webresource annotation to a type definition, the
* default attributes are not included in the Require-Capability header. For
* example with the Jsonrpc webresource annotation this leads to the
* following Require-Capability in the manifest:
* osgi.enroute.webresource;filter:=
* "(&(osgi.enroute.webresource=/osgi/enroute/jsonrpc)(&(version>=1.1.1)(!(version>=2.0.0))))".
* Only when I explicitly add resource={"jsonrpc.js"} this is reflected in
* the manifest: osgi.enroute.webresource;resource:List
* <String>="jsonrpc.js";filter:=
* "(&(osgi.enroute.webresource=/osgi/enroute/jsonrpc)(&(version>=1.1.1)(!(version>=2.0.0))))",
* although jsonrpc.js is set as default for the resource attribute.
*/
public void testDefaultAttrs() throws Exception {
try (Builder b = new Builder()) {
b.addClasspath(IO.getFile("bin"));
b.setPrivatePackage("test.annotationheaders.attrs.defaults");
b.build();
assertTrue(b.check());
b.getJar().getManifest().write(System.out);
Domain d = Domain.domain(b.getJar().getManifest());
Parameters rc = d.getRequireCapability();
assertNotNull(rc);
assertEquals(2, rc.size());
Attrs attrs = rc.get("default-attrs");
assertEquals("42", attrs.get("foo"));
Parameters pc = d.getProvideCapability();
assertNotNull(pc);
assertEquals(1, pc.size());
attrs = pc.get("default-attrs");
assertEquals("42", attrs.get("foo"));
}
}
use of aQute.bnd.osgi.Domain in project bnd by bndtools.
the class VersionPolicyTest method testProviderType.
/**
* Tests if the implementation of the EventAdmin (which is marked as a
* ProviderType) causes the import of the api package to use the provider
* version policy.
*/
public static void testProviderType() throws Exception {
Builder a = new Builder();
a.addClasspath(new File("bin"));
a.setPrivatePackage("test.versionpolicy.implemented");
a.setExportPackage("test.versionpolicy.api");
// what changed so this is
a.setImportPackage("test.versionpolicy.api");
// not automatically
// added?
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,1.3)", attrs.get("version"));
}
Aggregations