use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class ContractTest method testOverlap.
/**
* Test if we can detect an overlap, and then if we can control the overlap
*
* @throws Exception
*/
public void testOverlap() throws Exception {
Jar bjar = getContractExporter("test", "2.5", "${exports}");
Builder a = newBuilder();
a.setTrace(true);
// 1x
a.addClasspath(bjar);
// 2x
a.addClasspath(bjar);
a.setProperty(Constants.CONTRACT, "*");
a.setImportPackage("org.osgi.service.cm,*");
a.setProperty("Export-Package", "test.refer");
Jar ajar = a.build();
assertTrue(a.check("Contracts \\[Contract \\[name=test;version=2.5.0;from=biz.aQute.bndlib.tests\\], Contract \\[name=test;version=2.5.0"));
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class ContractTest method testSimple.
public void testSimple() throws Exception {
Jar bjar = getContractExporter("test", "2.5", "${exports}");
Builder a = newBuilder();
a.setTrace(true);
a.addClasspath(bjar);
a.setProperty(Constants.CONTRACT, "*");
a.setImportPackage("org.osgi.service.cm,*");
a.setProperty("Export-Package", "test.refer");
Jar ajar = a.build();
assertTrue(a.check());
Domain domain = Domain.domain(ajar.getManifest());
Parameters rc = domain.getRequireCapability();
rc.remove("osgi.ee");
System.out.println(rc);
assertEquals(1, rc.size());
Packages ps = a.getImports();
assertTrue(ps.containsFQN("org.osgi.service.cm"));
Attrs attrs = ps.getByFQN("org.osgi.service.cm");
assertNotNull(attrs);
assertNull(attrs.getVersion());
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class ContractTest method testWarningVersion.
/**
* Test the warnings that we have no no version
*
* @throws Exception
*/
public void testWarningVersion() throws Exception {
Jar bjara = getContractExporter("abc", (String[]) null, "${exports}");
Builder a = newBuilder();
a.setTrace(true);
a.addClasspath(bjara);
a.setProperty(Constants.CONTRACT, "*");
a.setImportPackage("test.packageinfo,*");
a.setProperty("Export-Package", "test.refer");
Jar ajar = a.build();
assertTrue(a.check("Contract \\[name=abc;version=0.0.0;from=biz.aQute.bndlib.tests] does not declare a version"));
Domain domain = Domain.domain(ajar.getManifest());
Parameters p = domain.getRequireCapability();
p.remove("osgi.ee");
assertEquals(0, p.size());
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class ContractTest method testMultiple.
public void testMultiple() throws Exception {
Jar bjar = getContractExporter("abc", new String[] { "2.5", "2.6", "3.0", "3.1" }, "${exports}");
Builder a = newBuilder();
a.setTrace(true);
a.addClasspath(bjar);
a.setProperty(Constants.CONTRACT, "*");
a.setImportPackage("org.osgi.service.cm,*");
a.setProperty("Export-Package", "test.refer");
Jar ajar = a.build();
assertTrue(a.check());
Domain domain = Domain.domain(ajar.getManifest());
Parameters rc = domain.getRequireCapability();
rc.remove("osgi.ee");
System.out.println(rc);
assertEquals(1, rc.size());
assertNotNull(rc);
assertEquals(1, rc.size());
Attrs attrs = rc.get("osgi.contract");
assertEquals("(&(osgi.contract=abc)(version=3.1.0))", attrs.get("filter:"));
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BuilderTest method testIncludeResourceFromZipOneDirectory.
public static void testIncludeResourceFromZipOneDirectory() throws Exception {
Builder bmaker = new Builder();
try {
Properties p = new Properties();
p.put("Import-Package", "");
p.put("Include-Resource", "@jar/easymock.jar!/org/easymock/**");
bmaker.setProperties(p);
Jar jar = bmaker.build();
assertTrue(bmaker.check());
assertEquals(59, jar.getResources().size());
assertNotNull(jar.getResource("org/easymock/AbstractMatcher.class"));
} finally {
bmaker.close();
}
}
Aggregations